CheckBox.st
changeset 44 97c1c943bef6
child 49 4dd0f5c3353e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CheckBox.st	Sun Mar 26 22:16:44 1995 +0200
@@ -0,0 +1,176 @@
+"
+ COPYRIGHT (c) 1995 by Claus Gittinger
+              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
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+'From Smalltalk/X, Version:2.10.5 on 26-mar-1995 at 6:58:58 am'!
+
+HorizontalPanelView subclass:#CheckBox
+	 instanceVariableNames:'toggleView labelView'
+	 classVariableNames:''
+	 poolDictionaries:''
+	 category:'Views-Interactors'
+!
+
+!CheckBox class methodsFor:'documentation'!
+
+version
+"
+$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.1 1995-03-26 20:16:44 claus Exp $
+"
+!
+
+documentation
+"
+    CheckBox has been added somwehat in a hurry 
+    - obviously, much more protocol is needed.
+
+    For now, set actions etc. via sends to the components,
+    labelView and toggleView.
+"
+!
+
+examples
+"
+  no-op checkBox:
+
+     |b|
+
+     b := CheckBox new.
+     b label:'foo'.
+     b open
+
+
+  changing colors (a demo only: it is no good style to fight the styleSheet):
+
+     |panel b|
+
+     panel := VerticalPanelView new.
+
+     b := CheckBox in:panel.
+     b label:'foo'.
+
+     b := CheckBox in:panel.
+     b label:'bar'.
+     b labelView foregroundColor:Color red.
+
+     b := CheckBox in:panel.
+     b label:'baz'.
+     b toggleView activeForegroundColor:Color blue.
+
+     panel open
+
+
+  using action-blocks:
+
+     |b model|
+
+     model := Plug new.
+     model respondTo:#changeCheck: with:[:arg | Transcript showCr:'change to ' , arg printString].
+
+     b := CheckBox new.
+     b label:'check'.
+     b toggleView pressAction:[Transcript showCr:'on'].
+     b toggleView releaseAction:[Transcript showCr:'off'].
+     b open.
+
+
+  with a model (using a plug here, for demonstration only):
+
+     |b model|
+
+     model := Plug new.
+     model respondTo:#changeCheck: with:[:arg | Transcript showCr:'change to ' , arg printString].
+
+     b := CheckBox new.
+     b label:'check'.
+     b model:model; change:#changeCheck:.
+     b open.
+
+"
+!
+
+copyright
+"
+ COPYRIGHT (c) 1995 by Claus Gittinger
+              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
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+! !
+
+!CheckBox methodsFor:'accessing'!
+
+label:aString
+    labelView label:aString.
+    labelView forceResize.
+!
+
+model:aModel
+    labelView model:aModel.
+    toggleView model:aModel
+!
+
+change:aChangeSelector
+    toggleView change:aChangeSelector
+!
+
+label
+    ^ labelView label
+!
+
+labelView
+    ^ labelView
+!
+
+toggleView
+    ^ toggleView
+!
+
+aspect:aspectSymbol
+    labelView aspect:aspectSymbol.
+    toggleView aspect:aspectSymbol
+
+! !
+
+!CheckBox methodsFor:'initialization'!
+
+initialize
+    |panel|
+
+    super initialize.
+
+    hLayout := #leftSpace.
+    vLayout := #center.
+
+    toggleView := CheckToggle in:self.
+
+    labelView := Label in:self.
+    labelView label:'check'.
+    labelView forceResize.
+    labelView adjust:#left.
+    self height:labelView preferedExtent y + ViewSpacing.
+
+    "
+     |b|
+
+     b := CheckBox new.
+     b label:'foo'.
+     b open
+    "
+! !
+