--- a/CheckBox.st Sun Apr 30 15:40:33 1995 +0200
+++ b/CheckBox.st Wed May 03 02:43:15 1995 +0200
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -24,7 +24,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.1 1995-03-26 20:16:44 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.2 1995-05-03 00:42:20 claus Exp $
"
!
@@ -71,19 +71,29 @@
using action-blocks:
- |b model|
-
- model := Plug new.
- model respondTo:#changeCheck: with:[:arg | Transcript showCr:'change to ' , arg printString].
+ |b|
b := CheckBox new.
b label:'check'.
- b toggleView pressAction:[Transcript showCr:'on'].
- b toggleView releaseAction:[Transcript showCr:'off'].
+ b action:[:value | Transcript show:'set to: '; showCr:value].
b open.
- with a model (using a plug here, for demonstration only):
+ with a model (default ST-80 behavior, sending #value: to the model):
+ (see changing value in the inspector)
+
+ |b model|
+
+ model := ValueHolder newBoolean.
+
+ b := CheckBox new.
+ b label:'check'.
+ b model:model.
+ b open.
+ model inspect.
+
+ with a model and different changeSelector
+ (using a plug here, for demonstration only):
|b model|
@@ -95,13 +105,48 @@
b model:model; change:#changeCheck:.
b open.
+ multiple checkBoxes on a single model (using different aspects)
+
+ |top panel b model value1 value2 ok|
+
+ value1 := true.
+ value2 := false.
+ model := Plug new.
+ model respondTo:#value1 with:[value1].
+ model respondTo:#value1: with:[:val | value1 := val].
+ model respondTo:#value2 with:[value2].
+ model respondTo:#value2: with:[:val | value2 := val].
+
+ top := DialogBox new.
+ top extent:200@300.
+
+ panel := VerticalPanelView new.
+
+ b := CheckBox in:panel.
+ b label:'check1'.
+ b model:model; aspect:#value1; change:#value1:.
+
+ b := CheckBox in:panel.
+ b label:'check2'.
+ b model:model; aspect:#value2; change:#value2:.
+
+ top addComponent:panel.
+ top addAbortButton; addOkButton.
+ top okAction:[ok := true].
+ ok := false.
+ top openModal.
+
+ ok ifTrue:[
+ Transcript show:'value1: '; showCr:model value1.
+ Transcript show:'value2: '; showCr:model value2.
+ ]
"
!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -115,14 +160,20 @@
!CheckBox methodsFor:'accessing'!
+font:aFont
+ labelView font:aFont.
+ labelView forceResize.
+ mustRearrange := true.
+!
+
+font
+ ^ labelView font
+!
+
label:aString
labelView label:aString.
labelView forceResize.
-!
-
-model:aModel
- labelView model:aModel.
- toggleView model:aModel
+ mustRearrange := true.
!
change:aChangeSelector
@@ -134,17 +185,39 @@
!
labelView
+ "return the labelView; allows manipulation of the
+ labels attributes (colors etc.)"
+
^ labelView
!
toggleView
+ "return the toggleView; allows manipulation of the
+ toggles attributes (colors etc.)"
+
^ toggleView
!
+model:aModel
+ labelView model:aModel.
+ toggleView model:aModel
+!
+
aspect:aspectSymbol
labelView aspect:aspectSymbol.
toggleView aspect:aspectSymbol
+!
+action:aBlock
+ toggleView action:aBlock
+!
+
+enable
+ toggleView enable
+!
+
+disable
+ toggleView disable
! !
!CheckBox methodsFor:'initialization'!
@@ -154,7 +227,7 @@
super initialize.
- hLayout := #leftSpace.
+ hLayout := #fixLeftSpace.
vLayout := #center.
toggleView := CheckToggle in:self.