Thanks for the code sample. That works for drawing unrotated text, but
I can't get it to work with my rotated CGContext. The suggestion was
to rotate the CGContext and then use RB's Drawstring function. Below
is my routine. The CGContextShowTextAtPoint command draws rotated
text, but no matter where I put the graphics_DrawString command that
you provided I can't get it to draw into the rotated CGContext. My
guess would be that I'm not getting the CGContext of theRB Graphic
object properly. But the CGContextShowTextAtPoint command works.



void SKSDrawRotatedTextfunc(REALgraphics context, REALstring text, int
Rotation, int x, int y)
{

        CGFloat rr,gg,bb;
        Rect r;
        unsigned long FontColor;
        REALstring fontName;
        float fontSize;
        CGAffineTransform myTextTransform;
        GrafPtr newPort;
        CGContextRef myContext;
        
        //Get RS Graphic properties
        REALGetPropValue((REALobject)context, "ForeColor", &FontColor);
        REALGetPropValue((REALobject)context, "TextFont", &fontName);
        REALGetPropValue((REALobject)context, "TextSize", &fontSize);
        
        rr = (FontColor >> 16)/255.0;
        gg = ((FontColor >> 8) & 0xff)/255.0;
        bb = (FontColor & 0xff)/255.0;
        
        //Setup for Quartz
        REALSelectGraphics(context);
        GetPort(&newPort);
        GetPortBounds(newPort, &r);
        QDBeginCGContext(newPort, &myContext);
        
        //Setup and rotate CGContext
        CGContextSelectFont (myContext, REALCString(fontName),fontSize,
kCGEncodingMacRoman);
    CGContextSetRGBFillColor(myContext,  rr, gg, bb, 1);
    CGContextSetRGBStrokeColor (myContext, rr, gg, bb, 1);
    myTextTransform =
CGAffineTransformMakeRotation(degreesToRadian(Rotation));
    CGContextSetTextMatrix (myContext, myTextTransform);
                
    //draw text
        CGContextShowTextAtPoint(myContext, x, r.bottom - y,
REALCString(text) , strlen(REALCString(text))); //draws rotated text,
but doesn't work with all fonts and is missing bold/underline/etc.
        graphics_DrawString(context, text, x, y+ 50, 1000, false);  //draws 
nothing
        
        //clean up
        QDEndCGContext(newPort, &myContext);
        
        graphics_DrawString(context, text, x, y+ 150, 1000, false);  //draws
unrotated text
}



On Wed, Dec 8, 2010 at 4:24 PM, Alfred Van Hoek <[email protected]> wrote:
>
> On Dec 8, 2010, at 2:44 PM, Real Basic wrote:
>
>> I did, or at least I thought I did. But then I get "Invalid use of
>> incomplete type 'struct REALobjectStruct'. But I have since gotten
>> over that hurdle.
>>
>> Everything now compiles, but I have no idea how to use it. The sample
>> code looks like this:
>>
>> void (*fpConnect)( REALobject ) = NULL;
>> fpConnect = (void (*)( REALobject ))REALLoadObjectMethod( obj, "Connect()" );
>> if (fpConnect)        fpConnect( obj );
>>
>> and my code looks like this:
>>
>> void (*fpConnect)(REALobject) = NULL;
>>       fpConnect = (void
>> (*)(REALobject))REALLoadObjectMethod((REALobjectStruct*)context,"DrawString(str
>> as string, x as integer, y as integer)");
>>       if (fpConnect) fpConnect((REALobjectStruct*)context);
>>
>> How do I use my text and x,y values in conjunction with my fpConnect
>> object? The "connect" sample doesn't show how to pass values in.
>>
>> --Seth
>>
>
> void graphics_DrawString(REALgraphics graphics, REALstring s, int x, int y, 
> int width, Boolean condense)
> {
>        static void (*_fp)(REALgraphics, REALstring, int, int, int, Boolean) = 
> nil;
>        if (!_fp)
>                _fp = (void(*)(REALgraphics, REALstring, int, int, int, 
> Boolean))REALLoadObjectMethod((REALobject)graphics,"DrawString(s as string, x 
> as integer, y as Integer, w as integer, c as boolean)");
>        if (_fp)
>                _fp(graphics, s,x,y,width,condense);
> }
>
>
> Always lookup the signature in the language reference. If the signature is 
> incorrect then the function pointer _fp will always be NULL. The signature of 
> the graphics.DrawString is:
>
> "DrawString(s as string, x as integer, y as Integer, w as integer, c as 
> boolean)"
>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to