[Q] fullBounds and Bounds in Morphic

Bob Arning arning at charm.net
Thu Dec 30 00:34:23 UTC 1999


On Wed, 29 Dec 1999 13:24:32 -0800 "Andrew P. Black" <black at cse.ogi.edu> wrote:
>I'm still not very happy with my initialExtent method, though.
>
>!AccessorPreferences methodsFor: 'displaying' stamp: 'apb 12/29/1999 11:35'!
>initialExtent
>
>	^ 340 @ ((rows min: 12) * 19 + 35)! !
>
>Too many magic numbers!  The rows min: 12 calculation is intended to 
>leave room for at most 11 instance variables and the header; more 
>than that and the user uses the scrollbar.  But I would like to be 
>able to ask the scrollpane what the width of its submorphs are, and 
>what the height of the window frame is, rather than putting in 340 
>and 35.  I couldn't even get the height of a row by asking it (I got 
>40 as the answer); the magic number 19 came from the explorer.

If the scrollPane actually has some contents, you can resort to the (admittedly ugly) 

	scrollPane scroller firstSubmorph height "or width"
>
>I would have thought that shrinkwrap would do something like what I want.
>

Well, it does, but only for AlignmentMorphs. The problem here is that there are a couple of other classes that have different ideas: ScrollPane expects to be given a extent and then show whatever can be shown in that area while SystemWindow expects to start at some size (resizable by the user) and divide its space up porportionally. You could fix the first by defining a subclass of ScrollPane that expanded in size (up to some limit) as items were added and then acted like the present ScrollPane. The second problem (important only after the first is fixed) could be dealt with by creating a SystemWindow-ish thing that is really an AlignmentMorph and thus able to #shrinkWrap. Or you could define a subclass of SystemWindow that chose its initial extent from its subpanes rather than from the model.

>
>So, if I understand this right, fullBounds is the space that I want 
>to occupy on the screen, or more generally in the enclosing morph. My 
>fullBounds might be
>	(1) the same as my bounds (often)
>	(2) bigger than my bounds, if some submorphs extend beyond
>             my bounds.
>	(3) smaller than bounds (never?)
>
>When I'm asked for my fullBounds, I would normally ask all of my 
>submorphs what their fullBounds are, and answer the smallest 
>enclosing rectangle.  But if, for example, I'm a vertical scrollPane, 
>I might give a smaller (in height) answer, because I can scroll to 
>make the cropped morphs visible.

 Yup. You can think of fullbounds as the outer limit on a) what parts of the screen might need to be redrawn if you were changed/removed and b) where you or your submorphs might conceivably be interested in mouse clicks.

>If this is right, it seems that bounds should be private.  I might, 
>or might not, use my bounds in calculating my fullBounds, but no 
>other object should ask for my bounds.

Well, we could probably argue for privacy for all sorts of things, but sometimes the expedient access (e.g. allowing one morph to reposition/resize other morphs) seems to be worth the price.

>Please correct me where I'm wrong!

No, I think you've got it.

Cheers,
Bob





More information about the Squeak-dev mailing list