checking if text will fit

I would like to know at run-time if a certain string will fit into a
predefined rectangle of certain dimensions. For example, I have a string
"Hello" in font Arial and point size 12, and I want to know if this will fit
into a box of (let's say) 100x100 pixels. I've looked through the available
controls but I can't see which ones might be used to check for this kind of
"overflow".
Any suggestions would be very much appreciated!
David

David Resnick wrote:

I would like to know at run-time if a certain string will fit into a
predefined rectangle of certain dimensions. For example, I have a string
"Hello" in font Arial and point size 12, and I want to know if this will fit
into a box of (let's say) 100x100 pixels. I've looked through the available
controls but I can't see which ones might be used to check for this kind of
"overflow".

Create a DC, set it to use the font you want, and then call

  w, h = dc.GetTextExtent(text)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks a lot, just what I was looking for!

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Monday, April 11, 2005 22:01
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] checking if text will fit

David Resnick wrote:

I would like to know at run-time if a certain string will fit into a
predefined rectangle of certain dimensions. For example, I have a string
"Hello" in font Arial and point size 12, and I want to know if this will

fit

into a box of (let's say) 100x100 pixels. I've looked through the

available

controls but I can't see which ones might be used to check for this kind

of

"overflow".

Create a DC, set it to use the font you want, and then call

  w, h = dc.GetTextExtent(text)

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org