[cairo] mixing native OSX widgets with a cairo canvas
Vladimir Vukicevic
vladimir at pobox.com
Thu Jan 17 14:27:56 PST 2008
On Jan 16, 2008, at 5:20 PM, Bobby Powers wrote:
> hello!
>
> I am starting to work on my pet project, and it requires people to
> be able to add text labels to different parts of a cairo canvas on
> MacOS X. I could just draw a text input box and flash a vertical
> line as a cursor, but I know that Firefox 3 mixes native widgets
> with a cairo canvas to lay out pages, and I was hoping to do the
> same. I've tried adding UI elements as subviews, but it didn't seem
> to work. Does anyone have any suggestions? I downloaded the source
> for the latest FF3 beta, but I must admit I was a little overwhelmed
> and couldn't find anything.
We basically grab the CGContext from the quartz surface, recreate the
cairo_t state, and then make HITheme calls to draw the widget bits.
Check out http://mxr.mozilla.org/seamonkey/source/widget/src/cocoa/nsNativeThemeCocoa.mm
-- specifically the nsNativeThemeCocoa::DrawWidgetBackground method
(called "draw background" because the background is the native part,
and then we draw things like text on top of it).
- Vlad
More information about the cairo
mailing list