On Tue, 28 Dec 1999 22:59:08 -0800 "Andrew P. Black" apb@cse.ogi.edu wrote:
I'm trying to build a control panel. The Morphic containment hierarchy looks like the following (extracted by playing with an explorer)
aSystemWindow (fullBounds = 263@340 corner: 863@712) aScrollPane (fullBounds = 264@357 corner: 863@711) aTransformMorph (fullBounds 267@345 corner: 849@697) anAlignmentMorph (fullBounds 0@0 corner: 320@61)
and the AllignmentMorphs contains more stuff which looks as I expect. What I don't expect is that the enclosing objects (ATransformMorph and outwards) have bounds that are so much bigger than the enclosed AlignmentMorph. I don't give any of these objects explicit sizes, and I would expect them to re-size around the AllignmentMorph that they contain.
[snip]
What am I doing wrong? As the comment indicates, I stole a lot of this from Preferences class, where it seems to work just fine.
The driving force here is the SystemWindow which has been told to be a certain size and adjusts its suppanes (the ScrollPane) accordingly. How it got told (and something you didn't copy from Preferences) is via #initialExtent. If you add: ========= !AccessorPreferences methodsFor: 'as yet unclassified' stamp: 'RAA 12/29/1999 07:18'! initialExtent
^330@200! ! ========= then you will get more of the behavior you expect.
If there is anything written on how bounds and fullBounds interact, I would appreciate a pointer.
I'm not sure what you mean by interact, but the simple difference is this: - bounds is the rectangle enclosing a morph - fullBounds is generally the rectangle enclosing the morph PLUS all its submorphs. Some morphs (those related to scrolling, e.g.) apply clipping and ignore anything outside their own bounds so they will implement this a bit differently. Hope this is what you were asking.
Cheers, Bob
!AccessorPreferences methodsFor: 'as yet unclassified' stamp: 'RAA 12/29/1999 07:18'! initialExtent
^330@200! !
then you will get more of the behavior you expect.
Ah! Thank you, thank you!
My new changeset is at
http://www.cse.ogi.edu/cse504/programs/AccessorCodeGen.st and I have stripped out some of STP's code that wasn't being used. This now seems to work, and I humbly submit it as an useful extension to the browser.
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.
I would have thought that shrinkwrap would do something like what I want.
Oh, and in MVC, it still makes a much too large window. Despite using the same initialExtent ...
If there is anything written on how bounds and fullBounds interact, I would appreciate a pointer.
I'm not sure what you mean by interact, but the simple difference is this:
- bounds is the rectangle enclosing a morph
- fullBounds is generally the rectangle enclosing the morph PLUS all
its submorphs. Some morphs (those related to scrolling, e.g.) apply clipping and ignore anything outside their own bounds so they will implement this a bit differently. Hope this is what you were asking.
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.
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.
Please correct me where I'm wrong!
Andrew
squeak-dev@lists.squeakfoundation.org