Definitive guide to sizing and positioning Morphs?
Bob Arning
arning at charm.net
Fri Oct 29 15:01:37 UTC 1999
On Thu, 28 Oct 1999 23:37:34 -0700 "John Tobler" <squeakie at visto.com> wrote:
>Can some kind soul please point me to a useful reference
>for understanding how to control nested morph sizing and
>placement (particularly for AlignmentMorph and subclasses
>based upon it)?
>
>Example problems:
>
> 1. Construct a resizable box that will contain
> several other morphs. Place a morphic "color
> bar" across the top such that its height is
> always 10% of the total height of the containing
> box.
>
> 2. Construct a resizable box containing two
> "row" morphs. The top row is to contain
> three buttons (morphs) labelled "left,"
> "middle," and "right" -- one flush left,
> one centered, and one flush right.
John,
Examples follow.
Cheers,
Bob
============================================
'From Squeak 2.5 of August 6, 1999 on 29 October 1999 at 10:56:34 am'!
"Change Set: BobForJT
Date: 29 October 1999
Author: Bob Arning
Answers to two questions by John Tobler"!
Object subclass: #Bob1
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Bob-Bob'!
AlignmentMorph subclass: #PercentageOfParentMorph
instanceVariableNames: 'heightPercent widthPercent '
classVariableNames: ''
poolDictionaries: ''
category: 'Bob-Bob'!
!Bob1 commentStamp: 'RAA 10/29/1999 10:55' prior: 0!
On Thu, 28 Oct 1999 23:37:34 -0700 "John Tobler" <squeakie at visto.com> wrote:
>Can some kind soul please point me to a useful reference
>for understanding how to control nested morph sizing and
>placement (particularly for AlignmentMorph and subclasses
>based upon it)?
>
>Example problems:
>
> 1. Construct a resizable box that will contain
> several other morphs. Place a morphic "color
> bar" across the top such that its height is
> always 10% of the total height of the containing
> box.
Evaluate (Bob1 new test1)
> 2. Construct a resizable box containing two
> "row" morphs. The top row is to contain
> three buttons (morphs) labelled "left,"
> "middle," and "right" -- one flush left,
> one centered, and one flush right.
Evaluate (Bob1 new test2)
!
]style[(533 14 251 14 2)f1,f1cblue;,f1,f1cblue;,f1!
!Bob1 methodsFor: 'as yet unclassified' stamp: 'RAA 10/29/1999 10:49'!
test1
"
Wherein we create a morph one of whose submorphs is contrained (vertically in this case) to s percentage of its parent's size.
Bob1 new test1
"
| outer row |
outer _ AlignmentMorph newColumn extent: 300 at 100.
outer addMorphBack: (
(row _ PercentageOfParentMorph newRow
color: Color black;
heightPercent: 0.1;
vResizing: #shrinkWrap)
).
3 timesRepeat: [
outer addMorphBack: (
(row _ AlignmentMorph newRow color: Color transparent"; minCellSize: 30")
).
4 timesRepeat: [
row
addMorphBack: (
AlignmentMorph newColumn
color: Color random
)
].
].
outer openInWorld.
! !
!Bob1 methodsFor: 'as yet unclassified' stamp: 'RAA 10/29/1999 10:51'!
test2
"
Wherein we create a row of buttons, one flush left, one centered and one flush right
Bob1 new test2
"
| outer |
outer _ AlignmentMorph newColumn extent: 300 at 100.
outer addMorphBack: (
(AlignmentMorph newRow color: Color lightRed; vResizing: #shrinkWrap)
addMorphBack: (
AlignmentMorph newColumn
color: Color transparent;
centering: #topLeft;
addMorphBack: (
SimpleButtonMorph new label: 'Left'
)
);
addMorphBack: (
AlignmentMorph newColumn
color: Color transparent;
centering: #center;
addMorphBack: (
SimpleButtonMorph new label: 'Center'
)
);
addMorphBack: (
AlignmentMorph newColumn
color: Color transparent;
centering: #bottomRight;
addMorphBack: (
SimpleButtonMorph new label: 'Right'
)
)
).
outer addMorphBack: (
AlignmentMorph newRow color: Color lightBlue
).
outer openInWorld.
! !
!PercentageOfParentMorph methodsFor: 'as yet unclassified' stamp: 'RAA 10/29/1999 10:45'!
heightPercent: aFloat
heightPercent _ aFloat! !
!PercentageOfParentMorph methodsFor: 'as yet unclassified' stamp: 'RAA 10/29/1999 10:44'!
minHeight
heightPercent ifNil: [^super minHeight].
^(owner height * heightPercent) asInteger! !
"Postscript:
"
StringHolder new
textContents: Bob1 comment;
openLabel: '2 morphic examples'!
More information about the Squeak-dev
mailing list
|