How should one implement a custom window color for a custom window?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How should one implement a custom window color for a custom window?

Eliot Miranda-2
Hi Marcel, Hi All,

    at one point I had implemented custom window colors for the VM simulator window thusly:

InterpreterPrimitives class>>initialize
"Initialize the window color.  This is probably Squeak-specific, so..."
[Preferences
setWindowColorFor: #cogVirtualMachineSimulatorWindowColor
to: (Color colorFrom: InterpreterPrimitives windowColorSpecification brightColor)]
on: Error
do: [:ex| Transcript show: 'Failed to set window color preference in ', thisContext method methodReference asString]

SimulatorMorphicModel class>>registerWindowColor
(Preferences windowColorFor: self name) = Color white
ifTrue: [ Preferences setWindowColorFor: self name to: (Color colorFrom: self windowColorSpecification brightColor) ].

This approach is now deprecated, causing the load script to protest.  But the deprecation message isn't helpful.  The setter setWindowColorFor:to: just says the method is deprecated, not suggesting any alternative.  The getter Preferences class>>#windowColorFor: just says 'Use Model >> #customWindowColor', but the method isn't implemented in any class.

Where's an example of the right way to do it?  Could the deprecation warnings be more informative?

thanks
_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|

Re: How should one implement a custom window color for a custom window?

marcel.taeumel
Hi Eliot,

just implement #defaultWindowColor in your model class. Unless overwritten bei the UI theme, that color will be used. See Model >> #windowColorToUse for reference. If you fancy, you can also overwrite #uniformWindowColor for your model class. :)

Sorry, #customWindowColor got renamed to #defaultWindowColor. I forgot to update that deprecation comment.

Best,
Marcel