DialogBox.st
changeset 739 67e04c0c38a7
parent 735 2552463a8f34
child 742 d735741381f5
--- a/DialogBox.st	Fri May 31 21:39:25 1996 +0200
+++ b/DialogBox.st	Fri May 31 22:16:08 1996 +0200
@@ -2449,13 +2449,15 @@
     tabableElements isNil ifTrue:[
         tabableElements := OrderedCollection new
     ].
-    tabableElements add:aComponentOrSubcomponent.
-
-    (aComponentOrSubcomponent isInputField) ifTrue:[
-        self addToInputFieldGroup:aComponentOrSubcomponent
+    (tabableElements includesIdentical:aComponentOrSubcomponent) ifFalse:[
+        tabableElements add:aComponentOrSubcomponent.
+
+        (aComponentOrSubcomponent isInputField) ifTrue:[
+            self addToInputFieldGroup:aComponentOrSubcomponent
+        ].
     ].
 
-    "Modified: 27.4.1996 / 17:55:44 / cg"
+    "Modified: 31.5.1996 / 21:22:13 / cg"
 !
 
 makeTabable:aComponentOrSubcomponent before:anotherComponent
@@ -2467,6 +2469,8 @@
     tabableElements isNil ifTrue:[
         tabableElements := OrderedCollection new
     ].
+    tabableElements remove:aComponentOrSubcomponent ifAbsent:nil.
+
     anotherComponent isNil ifTrue:[
         tabableElements addFirst:aComponentOrSubcomponent
     ] ifFalse:[
@@ -2477,7 +2481,7 @@
         self addToInputFieldGroup:aComponentOrSubcomponent
     ].
 
-    "Modified: 27.4.1996 / 17:55:52 / cg"
+    "Modified: 31.5.1996 / 21:15:11 / cg"
 !
 
 okAction:aBlock
@@ -2838,8 +2842,21 @@
     inputFieldGroup add:aComponentOrSubcomponent.
     self delegate:(KeyboardForwarder to:inputFieldGroup condition:#noFocus).
 
+"/    inputFields isNil ifTrue:[
+"/        inputFields := OrderedCollection new.
+"/
+"/        "/ the very first field gets the focus initially
+"/
+"/        aComponentOrSubcomponent showCursor.
+"/        aComponentOrSubcomponent hasKeyboardFocus:true.
+"/    ] ifFalse:[
+"/        aComponentOrSubcomponent hideCursor.
+"/        aComponentOrSubcomponent hasKeyboardFocus:false.
+"/    ].
+"/    inputFields add:aComponentOrSubcomponent
+
     "Created: 9.2.1996 / 20:23:04 / cg"
-    "Modified: 27.4.1996 / 17:54:51 / cg"
+    "Modified: 31.5.1996 / 21:30:56 / cg"
 ! !
 
 !DialogBox methodsFor:'construction-buttons'!
@@ -3424,7 +3441,7 @@
     ].
     ^ aField
 
-    "Modified: 9.2.1996 / 20:47:28 / cg"
+    "Modified: 31.5.1996 / 21:22:29 / cg"
 !
 
 addInputFieldOn:aModel
@@ -4053,7 +4070,7 @@
     p resize; sizeFixed:true.
     labelString notNil ifTrue:[
         box := HorizontalPanelView new.
-        box borderWidth:0; horizontalLayout:#right. "/ #rightSpace.
+        box borderWidth:0; horizontalLayout:#rightSpace.
         box add:(l := Label label:labelString).
         l borderWidth:0.
         box add:p.
@@ -4063,7 +4080,7 @@
     self addComponent:box tabable:tabable tabbedComponent:p.
     ^ p
 
-    "Modified: 31.5.1996 / 10:13:31 / cg"
+    "Modified: 31.5.1996 / 21:25:17 / cg"
 !
 
 addPopUpListOn:aModel
@@ -4392,28 +4409,13 @@
      Equally space elements as returned from aBlock.
      Advance y."
 
-    |helper component|
-
-    helper := HorizontalPanelView new.
-
-    aCol do:[:el |
-        component := aBlock value:el.
-        component resize.
-        helper add:component.
-        tabable ifTrue:[self makeTabable:component]
-    ].    
-
-    helper resize.
-    self addComponent:helper.
-
-    width < helper preferredExtent x ifTrue:[
-        self width:helper preferredExtent x.
-        "/ Transcript show:'w now: '; showCR:helper preferredExtent x
-    ].
-    helper horizontalLayout:hLayout.
-    helper verticalLayout:#fit.
-    helper left:leftX asFloat;
-           right:rightX asFloat.
+    ^ self
+        addRow:aCol 
+        fromX:leftX toX:rightX 
+        collect:aBlock 
+        tabable:tabable 
+        horizontalLayout:hLayout
+        verticalLayout:#fit
 
     "
      |dialog|
@@ -4474,7 +4476,101 @@
     "
 
     "Created: 9.2.1996 / 22:24:31 / cg"
+    "Modified: 31.5.1996 / 20:46:00 / cg"
+!
+
+addRow:aCol fromX:leftX toX:rightX collect:aBlock tabable:tabable horizontalLayout:hLayout verticalLayout:vLayout
+    "add some elements in a horizontal row.
+     Equally space elements as returned from aBlock.
+     Advance y."
+
+    |helper component|
+
+    helper := HorizontalPanelView new.
+
+    aCol do:[:el |
+        component := aBlock value:el.
+        component resize.
+        helper add:component.
+        tabable ifTrue:[self makeTabable:component]
+    ].    
+
+    helper resize.
+    self addComponent:helper.
+
+    width < helper preferredExtent x ifTrue:[
+        self width:helper preferredExtent x.
+        "/ Transcript show:'w now: '; showCR:helper preferredExtent x
+    ].
+    hLayout notNil ifTrue:[
+        helper horizontalLayout:hLayout.
+    ].
+    vLayout notNil ifTrue:[
+        helper verticalLayout:vLayout.
+    ].
+    helper left:leftX asFloat;
+           right:rightX asFloat.
+
+    "
+     |dialog|
+
+     dialog := Dialog new.
+     dialog 
+        addRow:#('a' 'b' 'c' 'd')
+        fromX:0
+        toX:1
+        collect:[:label | Label label:label]
+        tabable:false
+        horizontalLayout:#fit.
+
+     dialog addOkButton.
+     dialog open.
+    "
+
+    "
+     |dialog|
+
+     dialog := Dialog new.
+     dialog 
+        addRow:#('one' 'two' 'three' 'four')
+        fromX:0
+        toX:1
+        collect:[:label | Button label:label]
+        tabable:false
+        horizontalLayout:#fit.
+
+     dialog addOkButton.
+     dialog open.
+    "
+
+    "
+     |dialog|
+
+     dialog := Dialog new.
+     dialog 
+        addRow:#('a1' 'b1' 'c1' 'd1')
+        fromX:0
+        toX:1 
+        collect:[:label | Label label:label].
+
+     dialog 
+        addRow:#('a2' 'b2' 'c2' 'd2')
+        fromX:0
+        toX:0.5 
+        collect:[:label | Label label:label].
+
+     dialog 
+        addRow:#('a3' 'b3' 'c3' 'd3')
+        fromX:0.5
+        toX:1 
+        collect:[:label | Label label:label].
+
+     dialog addOkButton.
+     dialog open.
+    "
+
     "Modified: 9.2.1996 / 22:28:14 / cg"
+    "Created: 31.5.1996 / 20:45:31 / cg"
 ! !
 
 !DialogBox methodsFor:'explicit focus control'!
@@ -4496,17 +4592,19 @@
     |fields buttons|
 
     tabableElements isNil ifTrue:[
-	fields := #()
+        fields := #()
     ] ifFalse:[
-	fields := tabableElements
+        fields := tabableElements
     ].
     buttonPanel notNil ifTrue:[
-	buttons := buttonPanel subViews.
-	buttons notNil ifTrue:[
-	    fields := fields , buttonPanel subViews
-	]
+        buttons := buttonPanel subViews.
+        buttons notNil ifTrue:[
+            fields := fields , buttonPanel subViews
+        ]
     ].
-    ^ fields
+    ^ fields select:[:aField | aField realized].
+
+    "Modified: 31.5.1996 / 22:05:58 / cg"
 !
 
 initialize
@@ -4795,6 +4893,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.80 1996-05-31 11:24:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.81 1996-05-31 20:16:08 cg Exp $'
 ! !
 DialogBox initialize!