SystemWindow Q's

Lex Spoon lex at cc.gatech.edu
Sat Nov 18 18:23:34 UTC 2000


"montgomery f. tidwell" <mtidwell at practicalmatters.com> wrote:
> Howdy,
> 
>    in SystemWindow the title bar appears to be created by:
> 
>    stripes _ Array with: (RectangleMorph newBounds: bounds)
>                    with: (RectangleMorph newBounds: bounds).
>    self addMorph: (stripes first borderWidth: 1).
>    self addMorph: (stripes second borderWidth: 2).
> 
> Q1a) where is bounds coming from?
> Q1b) what sets the height of the stripes to only a few pixels
>      (the height of the title bar)?

For the first, "bounds" is an instance variable of Morph.  For the
second, check out "inst var refs" of "stripes" -- there are five
references in my image, and the one in #extent: looks like it answers
your question.  This makes sense, because when you resize a system
window, the system window should resize all of its submorphs as well.
"inst var refs" is in the browser window that lists classes. 

Incidentally, you can alse use "explain" on any variable you see in a
chunk of code, and "explain" will provide a chunk of code to let you
browse all references to the variable.


> 
> Q2) is extent called any time that the window needs to be
>     (re)drawn?

Extent is called whenever the window is resized, even if it is resized
by something like bounds:.  It doesn't get called just for a redraw.

The Morphic protocol should really all be documented somewhere.  In the
meantime, the definition of each method in Morph is usually helpful. 
Uh, wait, extent: doesn't have a comment.  Well, most of Morphic's core
methods *do* have a comment.... :)


> 
> Q3) if i add [see below] to SystemWindow>>initialize it adds a
>     text area that takes up the entire window (minus the title
>     bar). how does it know (1) not to go over the title bar?
>     (2) to use the entire window?
> 
>         textMorph _ PluggableTextMorph on: self text: nil accept: nil.
>         self addMorph: textMorph frame: (0 at 0 extent: 1 at 1).
> 
> 


When you use addMorph:frame: (another key method without a comment!),
SystemWindow will automatically resize everything to fit in the main
area of the window.   SystemWindow is smart enough not to resize
submorphs over its own title bar, though you are free to implement an
alternative.



-Lex





More information about the Squeak-dev mailing list