[futurebasic] RE: [FB] Static text control line count

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2004 : Group Archive : Group : All Groups

From: "Edwards, Waverly" <Waverly.Edwards@...>
Date: Tue, 20 Apr 2004 09:19:24 -0400
I dont know if I can help you with the number of lines but the resizing should still work.
Change the inWrapToWidth paramater to true.  Pay special attention to how you setup the ioBounds so that you can get the correct height -- as I've gotten tripped up.  Once you have an accurate height if you still want to get the number of lines (assumning a monofont field) divide the field height by the font height.  ...nLines works but sometime its off by one and I've never been able to get that just right.




Tells you the height, width, and baseline for a string.

OSStatus GetThemeTextDimensions (
   CFStringRef inString,
   ThemeFontID inFontID,
   ThemeDrawState inState,
   Boolean inWrapToWidth,
   Point * ioBounds,
   SInt16 * outBaseline
Parameter Descriptions
A CFStringRef containing the unicode characters you wish to measure. You must not pass in a CFStringRef that was allocated with any of the "NoCopy" CFString creation functions, as mentioned in the description of the DrawThemeTextBox function.

The ThemeFontID describing the font you'd like to measure the text with. See "Theme Font IDs" for the values you can use here.

The ThemeDrawState which matches the state you will ultimately render the string with. Drawing state may affect text measurement, so you should be sure the value you pass to GetThemeTextDimensions matches the value you will eventually use for drawing. See "Theme Drawing States" for the values you can use here.

A Boolean indicating whether you want the measurements based on wrapping the text to a specific width. If you pass true, you must specify the desired width in ioBounds->h.

On output, ioBounds->v contains the height of the text. If you pass false in the inWrapToWidth parameter, ioBounds->h will contain the width of the text on output. If you pass true in inWrapToWidth, ioBounds->h must (on input) contain the desired width for wrapping; on output, ioBounds->h contains the same value you specified on input.

On output, outBaseline contains the offset (in QuickDraw space) from the bottom edge of the last line of text to the baseline of the first line of text. outBaseline will generally be a negative value.

function result
A result code. See "Appearance Manager Result Codes".

-----Original Message-----
From: Bernie Wylde [mailto:bernie.w@...]
Sent: Monday, April 19, 2004 5:57 PM
To: fblist
Subject: Re: [FB] Static text control line count

On 19 Apr 2004, at 17:26, Edwards, Waverly wrote:

> use getthemetextdimension.
> <snip>


Your code works well for counting lines that end with <cr> and I 
suspect it returns a more accurate text width value than fn 
StringWidth. However, for my SizeToFit option, I need to count the 
number of lines if the text has wrapped.

The following gives me the value I'm after for the edit text control 
but not for static text control:
txtH = button(cRef, _FBgetControlTEHandle)
txtLines = txtH..teNLines%

Thanks for your reply