Hello, I'm trying to achieve a simple layout, only that I keep failing. Since I don't understand table-layout I tried to bypass it by calling extent: on my submorphs, but ... it does not work very properly.
I put two buttons in a Morph, two buttons in another Morph and then put the two morphs together into a third morph. I'd prefer to live with only one holder Morph as it would make things tidier.
I also don't understand how I can convince all Buttons to have the same width and height (I see that "justified" does that, but of course ONLY if I can live with one holder morph only).
So, basically, what I need to know is: how do I tell the table layout how many rows and columns I want?
niko
Niko Schwarz puso en su mail :
From a old code, this read the attached file and produce the attached pict.
!GreetingMorph methodsFor: 'initialization' stamp: 'edc 9/28/2004 07:37'! chooseColor | buttons b max maxX x y cuenta | ColoresCrayon ifEmpty: [self class readColoresCrayonFromFile]. buttons := OrderedCollection new. paleta := PasteUpMorph new. paleta layoutPolicy: nil. paleta hResizing: #rigid. paleta vResizing: #rigid. paleta borderWidth: 2. paleta borderColor: Color black. paleta color: Color white. . maxX := 0.
x := 0. y := 0. cuenta := 0.
ColoresCrayon keysAndValuesDo: [ :name :rgb| b := (SimpleButtonMorph new label: name;
color: rgb ; target: self; actionSelector: #backColor:;
arguments: (Array with: rgb) ). buttons add: b].
b := (SimpleButtonMorph new label: 'Enough Fun ?'; color: Color white; target: self; actionSelector: #killFrontDialog). buttons add: b. "Compute the max width" max := 0. buttons do: [:each | max := each width max: max]. "Set all widths to the max value" buttons do: [:each | each width: max].
buttons reverseDo: [:each | each position: x@y. paleta addMorph: each. cuenta < 7 ifTrue: [x := x + each width. cuenta := cuenta + 1] ifFalse: [y := y + each height. x > maxX ifTrue: [maxX := x]. x := 0. cuenta := 0. ]]. maxX := maxX + 10 . y := y + 10. paleta extent: maxX @ y. paleta position: 30@30 . paleta becomeLikeAHolder. paleta openInWorld. [done] whileFalse: [ World doOneCycle]
I left readColoresCrayonFromFile as exercise or you could grab
Morphic-Greeting.003.pr ( Squeaklets folder) And you could amaze friends and foes sending Squeak made cards with picts and music.
From ftp://elpelotero@201-212-99-13.cab.prima.net.ar/ password: elpelotero (on approximate 09:00 to 23:00 GMT, dig and take what you like, at your own risk)
Cheers
Edgar
squeak-dev@lists.squeakfoundation.org