home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: sparky!uunet!psinntp!afs!greg
- From: greg@afs.com (Gregory H. Anderson)
- Subject: Re: Colored Button
- Message-ID: <1992Dec16.192424.6320@afs.com>
- Sender: greg@afs.com
- Reply-To: greg@afs.com
- References: <U3S9T0P@gwdu03.gwdg.de>
- Date: Wed, 16 Dec 1992 19:24:24 GMT
- Lines: 36
-
- 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
-