Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text drawing using Quartz in an PowerPlant LPane - how to invert y axis?




On 13 May 2005, at 22:46, William Hollingworth wrote:

I'm trying to draw some text in in a custom PowerPlant LPane using Quartz.

I have the text drawing OK, but am having problems because the y axis is
reversed when using Quartz so the location is incorrect.


My text is drawn correctly in the x position, but y seems bizarre. Y is
inverted (which I know from the Quartz docs), but also the offset seems very
strange. Y=0 does not seem to be the bottom of my LPane, or even the LPane's
owner window but rather some location about 80 pixels below the bottom edge
of my LPane.


I read the note in the Apple docs about how to invert the Y axis:

Code that transforms the Quartz origin to be at the upper-left
 CGContextSaveGState (myContext);
CGContextTranslateCTM (myContext, 0, myOrigin.y + myPortHeight);
CGContextScaleCTM (myContext, 1.0f, -1.0f);
// Your drawing code here.
CGContextRestoreGState (myContext);

I'm not sure what values get and use for myOrigin.y and myPortHeight.

You don't say how you're getting the context - whether it's from a draw event or one you've created yourself, but what you need to do is set the origin according to where your LPane is relative to the port origin. If you';re in your LPane::DrawSelf method, then the QD port will be set up correctly for your pane, but a Quartz context you create from that port won't be. You can call SyncCGContextOriginWithPort, but that's deprecated. Alternatively, you can use GetPortBounds to get the origin and set the CGContext accordingly. myPortHeight is just the height of your LPane. Using Quartz from PowerPlant is a bit of a shaky process (speaking from experience here) because PowerPlant does so much messing around with clip regions and origins to give you the illusion that you have a personal for for your pane and to work round problems with the control manager.


Jerry

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden
References: 
 >Text drawing using Quartz in an PowerPlant LPane - how to invert y axis? (From: William Hollingworth <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.