I'm working on an application framework (using Carbon) that draws
text via ATSU functions. Initially I drew text straight to the
screen without passing ATSU a CGContextRef via
ATSUSetlayoutControls, but the text would look terrible; bad
kerning, bad anti-aliasing... just ugly. I think this case is delt
with in the Apple documenatation here: http://developer.apple.com/documentation/Carbon/Conceptual/
ATSUI_Concepts/atsui_chap4/chapter_4_section_7.html
So I'm trying to fix that by having a global context like it says
and so far it's been really rough going. Firstly text only appears
on the first window and then I get no text on the 2nd window. Also
now all my text is drawn relitive to the window instead of relitive
to the control currently being painted. Heres how I create my
context (just once):
static CGContextRef GlobalContext = 0;
if (!GlobalContext)
{
CGrafPtr port;
GetPort(&port);
QDBeginCGContext(port, &GlobalContext);
}
Am I using the wrong method to get the port?
I'm leery about using GetPort these days. If you're using composited
windows (and you should be), you can get the port and the context
from the kEventControlDraw event when your handler is called.
Do I need to create a CGContextRef per window?
If you click the linked QDBeginCGContext on that page you'll see:
"QDBeginCGContext
Returns a Quartz 2D drawing environment associated with a graphics
port."
From QuickDraw.h:
* QDBeginCGContext()
*
* Summary:
* Allow CoreGraphics drawing in a CGrafPort
So I think that's a yes, you need a context per port. I could be
wrong since this isn't my area of expertise, but I think the part
about only having to call QDBeginCGContext once in your application
is wrong.
Is there some easy way to map output into the bounds of the control
(HIView) currently being drawn?
If you do your drawing in a kEventControlDraw handler then you can
get the context as a parameter from the event.
Larry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden