DialogBox.st
changeset 381 49fc4e7d81b7
parent 374 39a735c9a1c7
child 414 1435ecc200a9
--- a/DialogBox.st	Thu Feb 22 21:27:08 1996 +0100
+++ b/DialogBox.st	Thu Feb 22 21:43:54 1996 +0100
@@ -2523,6 +2523,73 @@
     "Modified: 9.2.1996 / 21:36:16 / cg"
 !
 
+addListBoxOn:aModel
+    "add a selectionInListView to the box"
+
+    ^ self addListBoxOn:aModel withNumberOfLines:nil
+
+    "
+     |dialog model listView|
+
+     model := SelectionInList new.
+     model list:#('one' 'two' 'three' 'four').
+     model selectionIndex:2.
+
+     dialog := DialogBox new.
+     (dialog addTextLabel:'select any') adjust:#left.
+
+     listView := dialog addListBoxOn:model.
+
+     dialog addAbortButton; addOkButton.
+     dialog open.
+
+     dialog accepted ifTrue:[Transcript show:'selection is:'; showCr:model selection].
+    "
+
+    "Modified: 22.2.1996 / 15:40:54 / cg"
+!
+
+addListBoxOn:aModel withNumberOfLines:numLines
+    "add a selectionInListView to the box.
+     The list has numLines (if nonNil) number of lines shown."
+
+    |l scr h|
+
+    l := SelectionInListView new.
+    l model:aModel.
+    l doubleClickAction:[:name | self okPressed].
+    scr := ScrollableView forView:l.
+
+    numLines notNil ifTrue:[
+        h := l heightForLines:numLines.
+    ] ifFalse:[
+        h := l preferredExtent y
+    ].
+    self addComponent:scr withHeight:h.
+    ^ l
+
+    "
+     |dialog model listView|
+
+     model := SelectionInList new.
+     model list:#('one' 'two' 'three' 'four').
+     model selectionIndex:2.
+
+     dialog := DialogBox new.
+     (dialog addTextLabel:'select any') adjust:#left.
+
+     listView := dialog addListBoxOn:model withNumberOfLines:3.
+
+     dialog addAbortButton; addOkButton.
+     dialog open.
+
+     dialog accepted ifTrue:[Transcript show:'selection is:'; showCr:model selection].
+    "
+
+    "Created: 22.2.1996 / 15:40:07 / cg"
+    "Modified: 22.2.1996 / 15:41:25 / cg"
+!
+
 addOkButton
     "create an okButton - to be sent from redefined initialize
      methods in subclasses or when creating a box programmatically.
@@ -3429,5 +3496,5 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.45 1996-02-21 00:37:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.46 1996-02-22 20:43:54 cg Exp $'
 ! !