generic addLabelledField added
authorca
Sat, 20 Apr 1996 14:38:20 +0200
changeset 560 71479d7f20be
parent 559 3ff87e9447c6
child 561 ef45086071c6
generic addLabelledField added
DialogBox.st
--- a/DialogBox.st	Sat Apr 20 12:37:59 1996 +0200
+++ b/DialogBox.st	Sat Apr 20 14:38:20 1996 +0200
@@ -3016,6 +3016,76 @@
     "Modified: 9.2.1996 / 21:36:16 / cg"
 !
 
+addLabelledField:aView label:labelString adjust:labelAdjust tabable:tabable separateAtX:relativeX
+    "add a label and some view 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 max|
+
+    y := self yPosition.
+    lbl := Label label:labelString.
+    max := lbl preferredExtent y max:(aView preferredExtent y).
+
+    self addComponent:lbl indent:leftIndent withHeight:max.
+    lbl rightInset:0.
+    lbl width:relativeX; adjust:labelAdjust; borderWidth:0.
+
+    self yPosition:y.
+    self addComponent:aView tabable:tabable.
+    aView leftInset:ViewSpacing.
+    aView width:(1.0 - relativeX); left:relativeX.
+
+    aView isInputField ifTrue:[
+        self addToInputFieldGroup:aView
+    ].
+
+    ^ aView
+
+    "
+     |dialog model field|
+
+     model := '' asValue.
+
+     dialog := DialogBox new.
+
+     field := dialog 
+                addLabelledField:(EditField on:model) label:'input here:' 
+                adjust:#left 
+                tabable:true 
+                separateAtX:0.3.
+
+     dialog addAbortButton; addOkButton.
+     dialog open.
+     dialog accepted ifTrue:[Transcript showCr:model value].
+    "
+
+    "
+     |dialog model field|
+
+     model := SelectionInList new.
+     model list:#('foo' 'bar' 'baz').
+     model selectionIndex:2.
+
+     dialog := DialogBox new.
+
+     field := dialog 
+                addLabelledField:(PopUpList on:model) label:'select here:' 
+                adjust:#left 
+                tabable:true 
+                separateAtX:0.3.
+
+     dialog addAbortButton; addOkButton.
+     dialog open.
+     dialog accepted ifTrue:[Transcript showCr:model value].
+    "
+
+    "Created: 13.4.1996 / 13:41:31 / cg"
+    "Modified: 19.4.1996 / 17:39:46 / cg"
+!
+
 addLabelledInputField:labelString adjust:labelAdjust on:model tabable:tabable separateAtX: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.
@@ -3023,17 +3093,12 @@
      The inputField gets model as its model.
      Return the inputField."
 
-    |y lbl field|
-
-    y := self yPosition.
-    lbl := self addTextLabel:labelString.
-    lbl rightInset:0.
-    lbl width:relativeX; adjust:labelAdjust; borderWidth:0.
-    self yPosition:y.
-    field := self addInputFieldOn:model tabable:tabable.
-    field leftInset:0.
-    field width:(1.0 - relativeX); left:relativeX.
-    ^ field
+
+    ^ self 
+        addLabelledField:(EditField on:model) label:labelString 
+        adjust:labelAdjust
+        tabable:tabable 
+        separateAtX:relativeX.
 
     "
      |dialog model field|
@@ -4228,6 +4293,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.63 1996-04-19 17:02:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.64 1996-04-20 12:38:20 ca Exp $'
 ! !
 DialogBox initialize!