On 13.04.2009, at 22:30, Frederik Slijkerman wrote:
Currently I'm porting a custom slider control that needs to draw parts
of the its interface, like the slider bar and the knob, in the OS style. The code that I currently have draws this to a temporary bitmap to avoid flicker on Windows and I'd like to keep it like this as much as possible
to avoid forking the code too much.

If you can, get the codebase changed in some way that you can get rid of the Windows code that isn't needed on the Mac, e.g. by adding additional abstractions. It'll hurt much less in the long run.

It looks like NSSliderCell will be able to draw the necessary parts, but the documentation says that you need to call lockFocus on the view that
you want to draw to first. But I would like to draw in a CGContextRef
that I have which draws into a bitmap. Now I'm wondering what lockFocus
on NSView does exactly. Does it just activate a graphics context that
works on this view?


That's what it basically does, so yes, this should work. That said, many cells expect to be hosted inside a view, and I'm not sure they'll work as well in any other graphics context. The main reason for cells to exist is not to draw outside views, but rather to support things like NSTableView, NSMatrix etc., where you draw several cells in a single view for efficiency reasons.

Another option than a bitmap context (which is a rather low-level way to go about things) would be to just use an NSImage.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to