added #addLabelledInputField... method
authorClaus Gittinger <cg@exept.de>
Sat, 13 Apr 1996 13:40:12 +0200
changeset 534 26871bcd9473
parent 533 49c086c33d4f
child 535 84282b53f2a7
added #addLabelledInputField... method
DialogBox.st
--- a/DialogBox.st	Sat Apr 13 13:18:16 1996 +0200
+++ b/DialogBox.st	Sat Apr 13 13:40:12 1996 +0200
@@ -2719,6 +2719,79 @@
     "Modified: 9.2.1996 / 21:36:16 / cg"
 !
 
+addLabelledInputField:labelString adjust:labelAdjust on:model tabable:tabable x:relativeX
+    "add a label and an inputField side-by-side.
+     The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
+     The labels string is defined by labelString and adjusted according to labelAdjust.
+     The inputField gets model as its model.
+     Return the inputField."
+
+    |y lbl field|
+
+    y := self yPosition.
+    lbl := self addTextLabel:labelString.
+    lbl width:relativeX; adjust:labelAdjust; borderWidth:0.
+    self yPosition:y.
+    field := self addInputFieldOn:model tabable:tabable.
+    field width:(1.0 - relativeX); left:relativeX.
+    ^ field
+
+    "
+     |dialog model field|
+
+     model := '' asValue.
+
+     dialog := DialogBox new.
+
+     field := dialog 
+                addLabelledInputField:'enter a string' 
+                adjust:#left 
+                on:model 
+                tabable:true 
+                x:0.3.
+
+     dialog addAbortButton; addOkButton.
+     dialog open.
+     dialog accepted ifTrue:[Transcript showCr:model value].
+    "
+
+    "
+     |dialog model1 model2 field|
+
+     model1 := '' asValue.
+     model2 := '' asValue.
+
+     dialog := DialogBox new.
+
+     dialog addTextLabel:'a two-input box'.
+     dialog addHorizontalLine.
+
+     field := dialog 
+                addLabelledInputField:'string1:' 
+                adjust:#right 
+                on:model1 
+                tabable:true 
+                x:0.4.
+
+     field := dialog 
+                addLabelledInputField:'string2:' 
+                adjust:#right 
+                on:model2 
+                tabable:true 
+                x:0.4.
+
+     dialog addAbortButton; addOkButton.
+     dialog open.
+     dialog accepted ifTrue:[
+        Transcript showCr:model1 value.
+        Transcript showCr:model2 value.
+     ].
+    "
+
+    "Created: 13.4.1996 / 13:36:39 / cg"
+    "Modified: 13.4.1996 / 13:38:37 / cg"
+!
+
 addListBoxOn:aModel
     "add a selectionInListView to the box"
 
@@ -3809,6 +3882,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.55 1996-04-10 06:17:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.56 1996-04-13 11:40:12 cg Exp $'
 ! !
 DialogBox initialize!