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: CGContextTranslateCTM Question



On Sunday, Aug 17, 2003, at 15:24 Europe/Rome, John Cebasek wrote:

If I don't do a CGContextTranslateCTM() when drawing, the splitters are drawn upside down and the sections of my window appear to be the correct proportions. Just the wrong way around.

Have you tried flipping the matrix with CGContextScaleCTM(context, 1.0f, -1.0f) ?
Note, however, that this won't alter the origin -- only the orientation.

If I do a CGContextTranslateCTM(x, 0.0f, splitRect.Height()) for the vertical and CGContextTranslateCTM(x, splitRect.Width(), -1.0f) for the horizontal, things are not drawn properly. The vertical splitter is in the wrong position, and the horizontal is no where to be seen.

Hmm, the second translation doesn't seem right...

What you want to do is offset the context matrix such that its origin is in the top-left corner of your SplitView *and* swap its orientation such that it's in standard coordinates (positive Y axis going down). You could try something like this:

HIRect frame = Frame();
CGContextSaveGState(context);
CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
CGContextScaleCTM(context, 1.0f, -1.0f);
// Perform your drawing here.
CGContextRestoreGState(context);

I've no idea whether this is the correct sequence for non-compositing mode.
Note that this assumes that your SplitView frame is in window coordinates -- embedded directly in the root control. If that's not the case, you can use Bounds() instead of Frame() and use HIViewConvertPoint to find the bounds origin in window coordinates (from your SplitView to the root control).

HTH,
Dario
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >CGContextTranslateCTM Question (From: John Cebasek <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.