[Q] Need recepie to change morphic look
Doug Way
dway at riskmetrics.com
Sun Mar 17 04:26:31 UTC 2002
Martin Drautzburg wrote:
> I am failing at something as simple as changing the color of Window
> Title bars. I believe it must somehow be possible so inspect a title
> bar and then "click my way backwards" until I find the right piece of
> code, i.e. the code that creates WindowTitle. I would be most grateful
> if someone could give me instructions on how to do this.
Ned already gave you the answer, but here's what you could have done to
track down the code for this:
Yes, you can inspect the title bar of a window by bringing up the
morphic halos on it (alt-click)... this is the right direction to go in.
If you alt-click once on the title bar of a Browser window (in
3.2gamma), for example, a halo appears around the whole window which
says "System Browser" at the bottom. If you click again, a smaller halo
appears around the title bar, which says "Alignment". If you click a
third time a smaller halo appears around a section of the title bar
called "Rectangle". (If you want, you can do fun stuff like tearing
apart the title bar by using the "Pick up" (black) halo to drag the
Alignment or Rectangle morph out of the window.)
Now, you can inspect any of these objects by clicking on the "Debug"
halo handle on the right (with the wrench). When the debug menu comes
up I usually choose "explore it" as the inspector, since the explorer
lets you dive down into the details of morphs more easily.
If you alt-click to the "Alignment" or "Rectangle" morph in the title
bar and explore that one, you'll notice that they have an instance
variable called "color". You can change the value of the color variable
in the explorer by executing a Smalltalk command in the lower pane of
the explorer. For example, try a do-it on "self color: Color red" and
you'd see part of the title bar turn red!
Also, when exploring the Alignment morph, you'll see the top line of the
explorer says something like "an AlignmentMorph(2140)". That's the
actual class name for this particular morph. You can then browse the
code for this class by selecting that line and choosing "browse
hierarchy" from the pop-up menu.
If you browse the source code for the AlignmentMorph and RectangleMorph
classes, you might eventually realize that these are dead-ends in terms
of figuring out where the code is that originally sets the title bar
color. These are just basic classes for grouping (aligning) morphs
together and drawing rectangle shapes.
What you really want is the morph for the whole window, the first halo
that came up, that was labeled "System Browser". In the explorer,
you'll see the class for this is SystemWindow. If you browse the
SystemWindow class, you'll see methods such as #addCloseBox,
#addExpandBox, etc. (which would appear to refer to the titlebar
widgets), so this is more promising.
SystemWindow is a fairly large class, though, so finding the right
method in there is a little tricky. You could start looking by hand
through all methods that have to do with initialization (starting with
#initialize), or with setting up the title bar (apparently called the
labelArea if you look through the methods).
If you didn't find it right away, you might try putting a breakpoint (a
"self halt") in one of the initialization methods that you know will be
executed when a window is opened. Then you could open a window and step
through the initialization code as it is being run. While stepping
through, you could watch the "submorphs" or "labelArea" instance
variables of the window to see when they are initialized, and if/when
they change color.
(Of course, there is a big problem with putting a "self halt" in window
initialization code, because when it tries to bring up the debugger
window, it will hit the halt again! Then you're in a bad state, and the
"Emergency Evaluator" comes up. What you'll really need to use is "self
doOnlyOnce: [self halt]" to make sure the halt only happens once. See
the "Emergency Evaluator" or "Debugger" swiki pages, or the page about
crashing/freezing on the Squeak FAQ, for more details on how to do this.)
> Also:
>
> Neither the MVC nor the morphic UI are currenlty "themable", right ?
> All alternative looks work by hacking the system as such, and cannot
> coexist, true ?
Mostly true. But someone did create a Themes/Skins package awhile ago
for Squeak (2.8 maybe?) which does let you do this. It was rather
large, though, so it probably wasn't really practical to incorporate in
the standard release. This package may or may not work with 3.2, I'm
not sure. Look on the Screenshots page of the swiki for it, or do a
search (for "theme" or "skin") on the swiki.
By the way, there is a Recipes page on the swiki, too, which would be
good to look at. Perhaps this message could be added as a recipe.
- Doug Way
dway at riskmetrics.com
More information about the Squeak-dev
mailing list
|