Re: Best way to customize Cocoa
Re: Best way to customize Cocoa
- Subject: Re: Best way to customize Cocoa
- From: Daniel Jalkut <email@hidden>
- Date: Tue, 14 Feb 2006 17:56:50 -0500
Dan:
On Feb 14, 2006, at 2:47 PM, Dan Koss wrote:
I'm looking at creating a custom UI similar to Logic Pro/Express
with colored window backing, different colored buttons, etc. and
possibly a skin-type functionality.
Is subclassing NSWindow the best way of achieving this, or is there
a better way? And if I subclass NSWindow, do I have to overload all
three init methods?
For the window background, all you have to do is call
"setBackgroundColor:" on the window.
For the colored buttons, etc., you'll probably want to subclass the
particular buttons you want. But since it sounds like you're going
for highly customized UI, it might be easier to start from scratch
and develop your own button subclass that draws everything yourself.
When you subclass something, you don't need to overload any init
methods, unless you're intercepting init method parameters of to the
subclass, or you need to initialize your own instance variables. In
any case, you can overload whichever init method you choose, as long
as you make sure it calls through to the corresponding super
initializer. If your goal is to just make sure you get a chance to
initialize your instance variables, you want to override the
designated initializer, because it's the only one that's guaranteed
to be called during initialization.
In the case of NSWindow, the designated initializer is
"initWithContentRect:styleMask:backing:defer:" - you'll see that this
is well documented in the NSWindow class documentation.
For more on initializers:
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaObjects/Articles/ObjectCreation.html
Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden