CheckBox.st
changeset 56 aa651da467e2
parent 55 75c4a8031e66
child 58 2bdd35f8aef0
--- a/CheckBox.st	Tue May 09 03:58:26 1995 +0200
+++ b/CheckBox.st	Fri May 12 20:34:25 1995 +0200
@@ -24,7 +24,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.3 1995-05-09 01:57:57 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.4 1995-05-12 18:34:07 claus Exp $
 "
 !
 
@@ -49,7 +49,18 @@
      b open
 
 
-  changing colors (a demo only: it is no good style to fight the styleSheet):
+  no-op checkBox, disabled:
+
+     |b|
+
+     b := CheckBox new.
+     b label:'foo'.
+     b disable.
+     b open
+
+
+  changing colors 
+  (a demo only: it is no good style to fight the styleSheet):
 
      |panel b|
 
@@ -92,6 +103,7 @@
      b open.
      model inspect.
 
+
   with a model and different changeSelector
   (using a plug here, for demonstration only):
 
@@ -105,6 +117,42 @@
      b model:model; change:#changeCheck:.
      b open.
 
+
+  with models, one checkBox disabling the others:
+
+     |dialog translator enableChannel val1 val2 val3 eBox box1 box2 box3|
+
+     translator := Plug new.
+     translator respondTo:#enableDisable 
+		with:[enableChannel value
+			 ifTrue:[box1 enable.
+				 box2 enable.
+				 box3 enable.]
+			 ifFalse:[box1 disable.
+				  box2 disable.
+				  box3 disable.]].
+
+     enableChannel := true asValue.
+     enableChannel onChangeSend:#enableDisable to:translator.
+     val1 := true asValue.
+     val2 := false asValue.
+     val3 := true asValue.
+
+     dialog := Dialog new.
+     dialog addCheckBox:'enable' on:enableChannel.
+     dialog addVerticalSpace.
+     dialog leftIndent:30.
+     box1 := dialog addCheckBox:'value1' on:val1.
+     dialog addVerticalSpace.
+     box2 := dialog addCheckBox:'value2' on:val2.
+     dialog addVerticalSpace.
+     box3 := dialog addCheckBox:'value3' on:val3.
+     dialog addVerticalSpace.
+     dialog addOkButton.
+
+     dialog open.
+
+
   multiple checkBoxes on a single model (using different aspects)
 
      |top panel b model value1 value2 ok|
@@ -158,37 +206,64 @@
 
 ! !
 
-!CheckBox methodsFor:'accessing'!
+!CheckBox methodsFor:'accessing-mvc'!
 
-label:aString
-    labelView label:aString.
-    labelView forceResize.
-    mustRearrange := true.
+changeMessage:aChangeSelector
+    "forward to toggle"
+
+    toggleView changeMessage:aChangeSelector
 !
 
-font:aFont
-    labelView font:aFont.
-    labelView forceResize.
-    mustRearrange := true.
-!
+aspect:aspectSymbol
+    "forward to label & toggle"
 
-font
-    ^ labelView font
-!
-
-change:aChangeSelector
-    toggleView change:aChangeSelector
-!
-
-label
-    ^ labelView label
+    labelView aspect:aspectSymbol.
+    toggleView aspect:aspectSymbol
 !
 
 model:aModel
+    "forward to label & toggle"
+
     labelView model:aModel.
     toggleView model:aModel
+! !
+
+!CheckBox methodsFor:'accessing-behavior'!
+
+action:aBlock
+    "forward to toggle"
+
+    toggleView action:aBlock
 !
 
+enable
+    "forward to toggle & change labels color"
+
+    toggleView enable.
+    labelView foregroundColor:(toggleView foregroundColor).
+!
+
+disable
+    "forward to toggle & change labels color"
+
+    toggleView disable.
+    labelView foregroundColor:(toggleView disabledForegroundColor).
+!
+
+turnOff
+    "forward to toggle"
+
+    toggleView turnOff
+!
+
+turnOn
+    "forward to toggle"
+
+    toggleView turnOn
+! !
+
+!CheckBox methodsFor:'accessing'!
+
 labelView
     "return the labelView; allows manipulation of the
      labels attributes (colors etc.)"
@@ -201,43 +276,53 @@
      toggles attributes (colors etc.)"
 
     ^ toggleView
-!
+! !
+
+!CheckBox methodsFor:'accessing-look'!
 
-aspect:aspectSymbol
-    labelView aspect:aspectSymbol.
-    toggleView aspect:aspectSymbol
+label:aString
+    "forward to label & resize"
+
+    labelView label:aString.
+    labelView forceResize.
+    mustRearrange := true.
 !
 
-turnOn
-    toggleView turnOn
-!
+font:aFont
+    "forward to label & resize"
 
-action:aBlock
-    toggleView action:aBlock
+    labelView font:aFont.
+    labelView forceResize.
+    mustRearrange := true.
 !
 
-enable
-    toggleView enable
+font
+    "forward from label"
+
+    ^ labelView font
 !
 
-turnOff
-    toggleView turnOff
-!
+label
+    "forward from label"
+
+    ^ labelView label
+! !
+
+!CheckBox methodsFor:'private'!
 
 sendChangeMessageWith:aValue
-    toggleView sendChangeMessageWith:aValue
-!
+    "redefined to have mimic changes being sent from the toggle
+     instead of myself"
 
-disable
-    toggleView disable
+    toggleView sendChangeMessageWith:aValue
 ! !
 
 !CheckBox methodsFor:'initialization'!
 
 initialize
-    |panel|
+    super initialize.
 
-    super initialize.
+    borderWidth := 0.
 
     hLayout := #fixLeftSpace.
     vLayout := #center.
@@ -249,9 +334,11 @@
     labelView forceResize.
     labelView adjust:#left.
     self height:labelView preferedExtent y + ViewSpacing.
-"/    self delegate:(KeyboardForwarder toView:toggleView).
 
-    self controller:(toggleView controller view:toggleView).
+    "
+     all of my input goes to the toggle
+    "
+    self delegate:(KeyboardForwarder toView:toggleView).
 
     "
      |b|
@@ -261,4 +348,3 @@
      b open
     "
 ! !
-