[futurebasic] Re: [FB] CoreGraphics

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2006 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Thu, 17 Aug 2006 19:57:58 +1200
SVANVOORST@... wrote:

> To my knowledge this demo has not been previously posted to the  
> List and was not included on the last CD.  It shows some of the  
> benefits of using core graphics.  Watch for line breaks.
>
> '------- Start of code -----
< snip >

Well, I had to watch for option-space characters -- chr$( 202 ) -- of  
which there were 100 to replace by ordinary spaces. No problem after  
that.

Great demo of CG transforms, Steve.
I notice that you draw text with CGContextShowTextAtPoint(), which  
lacks any formatting ability such as word-wrap and justification. An  
alternative way to obtain Quartz text is with DrawThemeTextBox().

'----------------------
dim as Rect r
window 1
text _sysFont, 24
SetRect( r, 10, 10, 100, 140 )
fn DrawThemeTextBox( fn CFSTR( "Quartz Text" ),  
_kThemeCurrentPortFont, ¬
_kThemeStateActive, _true, @r, _teJustLeft, 0 )
do
HandleEvents
until 0
'----------------------

In this simple example, the last parameter is 0, but it can be a  
CGContext. Here's FB's definition of DTTB:

toolbox fn DrawThemeTextBox( CFStringRef, ThemeFontID,  
ThemeDrawState, Boolean wrapToWidth, Rect *boundingBox, SInt16 just,  
ptr inContext ) = OSStatus // inContext can be 0

DrawThemeTextBox() might improve your demo by making it more text-savvy.

Robert P.