Re: Mutable NSColor?
Re: Mutable NSColor?
- Subject: Re: Mutable NSColor?
- From: rsharp <email@hidden>
- Date: Mon, 24 Sep 2001 08:04:47 -0500 (CDT)
On Mon, 24 Sep 2001, Rob Rix wrote:
>
Does anybody have a mutable NSColor subclass they'd be willing to share? I
>
need to be able to set a color instance's red, green, blue, and alpha
>
components, but I don't seem to be able to do that with NSColor as it is,
>
and I don't have the slightest clue how I would go about making a mutable
>
subclass of my own.
If you only need to ever work with ARGB components, then perhaps a simple
helper class would be better than trying to subclass. Your helper class
would simply maintain an NSColor* data member:
@interface MutableARGB : NSObject
{
NSColor* _myColor;
}
/* Following accessors just call thru to the NSColor ones */
- (float) redComponent;
- (float) greenComponent;
- (float) blueComponent;
- (float) alpha;
/* Rest of interface... */
- (void) setRedComponent: (float)red;
etc.
You then just simply maintain the single NSColor object.
There are disadvantages with this approach though...namely that you cant
pass such objects in place of NSColor. I'm not too keen on classes
posing as others, but I think that requires subclassing?
HTH,
Rick Sharp
Instant Interactive(tm)