[Q][Morphic][presentation] Bullet list morph

Hannes Hirzel hirzel at spw.unizh.ch
Mon Mar 4 21:40:44 UTC 2002


Hi all

I made a script in a workspace based on
'How to lay out submorphs' 
http://minnow.cc.gatech.edu/squeak/2141

which produces a bullet list morph. A list which can be edited
for beeing used in a slide in a presentation.

My questions:

1) How can I better position the bullet points? (some inset to the right
   and a bit lower)

2) Which properties do I have to set that the TextMorphs inside the list
   resize properly when I resize the outmost RectangleMorph with the
   yellow handle (at the moment resizing is not possible at all)


This is one of the morphs I'd like to put into a parts bin flap as 
described in another thread.


Hannes Hirzel





"-----------------------------------------------------------------"
"The code - put it into a Workspace - select all and do-it        "
"-----------------------------------------------------------------"
 

r := RectangleMorph new.
r color: Color blue twiceLighter.
r position: 10 at 10.
r extent: 150 at 200.
r name: 'background2'.
r openInWorld.

"OK, now set up our background so that we can put something inside"

r layoutPolicy: TableLayout new. "lay out contents as a table"
r listDirection: #topToBottom. "how we want to place the contents"
r listCentering: #topLeft. "start list at the top"
r wrapCentering: #topLeft. 


r addMorphBack: ((TTSampleStringMorph new
initializeToStandAlone; string: 'Change to title'; color: Color
white) openInWorld).

item1 _ Morph new.
item1 layoutPolicy: TableLayout new.
item1 cellPositioning: #topLeft. 
item1 cellInset: 4.
item1 color: Color blue twiceLighter twiceLighter.
item1 listDirection: #leftToRight.
item1 addMorph: (EllipseMorph new extent: 10 @ 10; color: Color
blue; borderWidth: 0 ).
item1 hResizing: #shrinkWrap.
item1 vResizing: #shrinkWrap.



t1 := TextMorph new.
t1 beAllFont: ((TextStyle default fontOfSize: 36) emphasized: 1).
t1 contentsWrapped: 'First list item - aTextMorph'.
t1 autoFit: true.
t1 width: 400.
item1 addMorphBack: t1.
r addMorphBack: item1.



"Now lets add a second item..."

item2 _ Morph new.
item2 layoutPolicy: TableLayout new.
item2 cellPositioning: #topLeft. 
item2 cellInset: 4.
item2 color: Color blue twiceLighter twiceLighter.
item2 listDirection: #leftToRight.
item2 addMorph: (EllipseMorph new extent: 10 @ 10; color: Color green
twiceDarker; borderWidth: 0).
item2 hResizing: #shrinkWrap.
item2 vResizing: #shrinkWrap.


t2 := TextMorph new.
t2 extent: 400 @ 100.
t2 beAllFont: ((TextStyle default fontOfSize: 36) emphasized: 1).
"t2 borderWidth: 1."
t2 color: Color blue twiceDarker.
t2 contentsWrapped: 'Second list item - text is editable; click and add
text. The box will grow'.
item2 addMorphBack: t2. 
r addMorphBack: item2.

"and a button bar ..."


bbar _ Morph new.
bbar layoutPolicy: TableLayout new.
bbar cellPositioning: #topLeft. 
bbar cellInset: 4.
bbar color: Color blue twiceLighter.
bbar listDirection: #leftToRight.
bbar hResizing: #shrinkWrap.
bbar vResizing: #shrinkWrap.

b := SimpleButtonMorph new.
b color: Color yellow;
label: 'remove button bar'; 
target: bbar;
actionSelector: #delete; 
setBalloonText: 'click to remove the button bar'.
bbar addMorph: b.
r addMorph: bbar.


block _ [ :r2 |
 item _ Morph new.
 item layoutPolicy: TableLayout new.
 item cellPositioning: #topLeft. 
 item cellInset: 4.
 item color: Color blue twiceLighter twiceLighter.
 item listDirection: #leftToRight.
 item addMorph: (EllipseMorph new extent: 10 @ 10; color: Color
blue; borderWidth: 0 ).
 item hResizing: #shrinkWrap.
 item vResizing: #shrinkWrap.



t := TextMorph new.
t beAllFont: ((TextStyle default fontOfSize: 36) emphasized: 1).
t contentsWrapped: 'A list item - aTextMorph'.
t autoFit: true.
t width: 400.
item addMorphBack: t.
r2 addMorphBack: item.
].

b := SimpleButtonMorph new.
b color: Color yellow;
label: 'add other item';
setBalloonText: 'click to add another bullet list item'.
bbar addMorph: b.
b target: block.
b actionSelector: #value:.
b arguments: (Array with: b owner owner).
r addMorph: bbar.


b := SimpleButtonMorph new.
b color: Color yellow;
label: 'X';
setBalloonText: 'click to delete bullet list completely'.
bbar addMorph: b.
b target: r.
b actionSelector: #delete.
r addMorph: bbar.


r cellInset: 3 at 5. "controls distance between content elements"


r hResizing: #shrinkWrap. "try it and see!"
r layoutInset: 4 at 8. "that was a bit too cramped"
r vResizing: #shrinkWrap. "Now we are done"







More information about the Squeak-dev mailing list