links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How can I change the color of a window?
Last updated at 4:23 pm UTC on 14 January 2006
Frank Shearar March 01, 2005 Question: Is it better form to override #defaultBackgroundColor or to "Preferences setWindowColorFor: Foo name to: someColor" in Foo class>>initialize?

In the latter case, we'd of course call "Preferences windowColorFor: self class name" in our Foo>>openWindowTypeOfMethod.

How to save a part bin Answer: You shouldn't override defaultBackgroundColor. And there's no reason to do a setWindowColorFor:to: if you put a #windowColorSpecification in the class side of the model class. In fact, doing a #setWindowColorFor:to: is rude, as it overrules the user's own window color settings.

In the case of a SystemWindow without a separate model, just make the model of the window itself, and then provide a #windowColorSpecification as above. The window opening (assuming you're opening a SystemWindow) will look up the window color itself. If you're getting a color for a non-SystemWindow, you would do it as you describe.

The default window color (that is, for things with a nil model or no windowColorSpecification in their model class), by the way, could stand to be something with a little more contrast.

Frank Shearar Question: I see that sending one of the #open__ messages calls #paneColor which, under some conditions (model notNil being the most important), will ask the model for its #defaultBackgroundColor. I can't see how it gets the window colour from the #windowColourSpecification though. MethodFinder gives me three senders: Finder class>windowColourSpecification just delegates to RefactoringBrowser classwindowColourSpecification, TestRunner classinitialize does The Rude Thing and calls Preferences classsetWindowColorFor:to: and Preferences classwindowColorTable just returns an Array containing implementors of #windowColorSpecification...Ned Konz Answer: Yes, and it's Preferences that keeps track of the colors, since you can change the window colors from the prefs panel.That's used to set up Preferences param #windowColors, which finally is used to answer windowColorFor:.