Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by mzeller
Mon, 14 Dec 1992 05:53
Colored Button
Author: mzeller
Date: Mon, 14 Dec 1992 05:53
Date: Mon, 14 Dec 1992 05:53
17 lines
937 bytes
937 bytes
Hi, I'd like to have a colored button - I don't want to use a TIFF Icon for it. Best solution would be a Category for the Button Class like -setColor. If thats not possible, a Subclass of the ButtonClass - ColoredButton with the same method would be nice. Did anybody write code for this? If not, whats the easiest way to implement it? (I guess you have to overwrite the drawSelf method for the Button class) Thanks for your help - Meinrad -- ** Meinrad Zeller - Foehrenweg 1 - 3400 Goettingen - Germany ** ** email: mzeller@namu01.gwdg.de Phone: +49-551-300095 **
Re: Colored Button
Author: Gregory H. Anderson
Date: Wed, 16 Dec 1992 19:24
Date: Wed, 16 Dec 1992 19:24
36 lines
2445 bytes
2445 bytes
Mail to the referenced address bounced, so pardon my bandwidth for posting the answer here. It's short and sweet, and maybe you'll learn something you didn't know about Buttons and ButtonCells anyway. 8^) In article <U3S9T0P@gwdu03.gwdg.de> mzeller@gwdg.de writes: > I'd like to have a colored button - I don't want to use a TIFF Icon for it. This is harder than you realize. You would have to subclass ButtonCell, not Button, because that's where the actual drawing gets done. In fact, the -setXxxColor methods in the View classes, like TextField, are actually cover methods for the underlying Cells. To get what you want, you would need to add an instance variable for the color(s) and subclass the -read: and -:write methods to store it. You would need to add set/return methods for the color(s) in the ButtonCell and Button classes. You'd probably want a custom IB inspector with a color well, so you wouldn't be forced to set the colors programatically. Here's the really difficult part. You would need to completely replace the -drawInside: method of ButtonCell, using your color(s) as the foreground and/or background fill color(s). The ButtonCell draw code is complicated. There are numerous combinations of text/icon placements, on/off states (which may have different icons and/or text), highlighting, etc. You'd have to get it all exactly right if you wanted the perfect substitute for a ButtonCell. That would take some patience and iterative testing. Plus, you'd have to be prepared to enhance its capabilities as new releases of the AppKit appear. I know a lot (not all) about how to do it, but I wouldn't want to replace ButtonCell's draw code from scratch on a deadline. I think the best solution is to lobby NeXT for this behavior in a future release. -- Gregory H. Anderson | Thus spake the master programmer: Master Programmer / Manager | "Let the programmers be many and Anderson Financial Systems | the managers few; then all will be greg@afs.com (Nextmail OK) | productive." -- Tao of Programming
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads