Can I color an NSImage programmatically?
Can I color an NSImage programmatically?
- Subject: Can I color an NSImage programmatically?
- From: desktoast music productions <email@hidden>
- Date: Mon, 03 Apr 2006 19:24:46 +0200
Hello again,
My app is ready and running. Nevertheless I still got this special problem.
I tried to figure it out for the last three days but still found no clue. My
English rather sucks but I¹ll try to be as precise as I can:
My Apps main Window shows records (members) from an NSMutableArray in an
NSTableView. You can sort them, change some of their attributes, create new
ones or delete some there. To edit a record, just double-click its row to
open it in a window of its own. There you can change the records values in
more detail.
One of these record attributes is called memberGroup, which is merely an
integer stating which group a person (member) belongs to. It is changed via
a popUpbutton¹s menu. To reflect the group more visually, I included a
colored banner in the Records EditWindow. This banner changes its color
according to the member¹s group. (I used an empty NSTextView and an NSArry
containing 4 NSColor objects. E.g. If the group-Popup-Button is set to the
button¹s menuItem with index 2, the background color of my (banner)textview
is set to the color object at the same index of my Colors Array. So far,
this all works fine and seamless.
What I want to do now is to visually reflect the group of a selected record
in my table view as well.
I started out with just a column titled ³Group² with the groups number (its
integer value) in it. Works fine, looks bad. So I changed the dataCell of
the Column to an NSImageCell and added a new Value (NSImage *groupIndicator)
to my record class.
The easiest way from here, I believe, would be to add an array with 4 small
images, which are set the same way as the color of my subwindow¹s banner:
changing a record¹s group to 1 (menuItem index 1) would set my
groupIndicator¹s value to the image at Index 1 of my tinyImagesArray.
But I got one more nice feature built in my app so far: the 3 colors used
in my Subwindow¹s banner are not fixed. The user can choose his own group
colors via color picker in the preference window.
So, here¹s my question at last: How can I best create an NSImage (speaking
of a colored dot of max. 12 x 12 pixels)and set its color programmatically
to match the group color chosen by the user and finally I show it in my
TableViews groupIndicator-Column?
Any suggestions?
As always thankful,
Peter, austria
--
peter schwaiger
desktoast music productions
http://www.autlawmusic.com
_______________________________________________
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