added resizeForLabel attribute
authorClaus Gittinger <cg@exept.de>
Wed, 10 May 2000 13:30:58 +0200
changeset 1769 68d65f17df56
parent 1768 04b330a75f75
child 1770 67d5517ba9df
added resizeForLabel attribute
CheckBox.st
--- a/CheckBox.st	Mon May 08 11:27:14 2000 +0200
+++ b/CheckBox.st	Wed May 10 13:30:58 2000 +0200
@@ -11,9 +11,12 @@
 "
 
 
+"{ Package: 'stx:libwidg2' }"
+
 HorizontalPanelView subclass:#CheckBox
 	instanceVariableNames:'toggleView labelView labelForegroundColor
-		disabledLabelForegroundColor foregroundChannel backgroundChannel'
+		disabledLabelForegroundColor foregroundChannel backgroundChannel
+		resizeForLabel'
 	classVariableNames:'DefaultLabelForegroundColor DefaultDisabledLabelForegroundColor
 		CheckToggleLeft'
 	poolDictionaries:''
@@ -412,9 +415,14 @@
 !
 
 labelChannel:aChannel
+    labelView labelChannel notNil ifTrue:[
+        labelView labelChannel removeDependent:self
+    ].
+    labelView labelChannel: aChannel.
+    aChannel notNil ifTrue:[
+        aChannel addDependent:self
+    ].
 
-    labelView labelChannel: aChannel
-   
 ! !
 
 !CheckBox methodsFor:'accessing-colors'!
@@ -523,11 +531,7 @@
     "set the logo; forward to label & resize"
 
     labelView label:aString.
-    labelView forceResize.
-    self layoutChanged.
-    self resize.
-
-    "Modified: 25.4.1996 / 16:33:14 / cg"
+    self resizeForChangedLabel.
 !
 
 labelForegroundColor
@@ -547,6 +551,14 @@
 
     "Created: 22.9.1995 / 15:44:14 / claus"
     "Modified: 25.4.1996 / 16:33:41 / cg"
+!
+
+resizeForLabel
+    ^ resizeForLabel ? false
+!
+
+resizeForLabel:aBoolean
+    resizeForLabel := aBoolean
 ! !
 
 !CheckBox methodsFor:'accessing-mvc'!
@@ -631,6 +643,20 @@
     self cursor:cursor.
     toggleView cursor:cursor.
 
+!
+
+update:something with:aParameter from:changedObject
+    changedObject == labelView ifTrue:[
+        something == #sizeOfView ifTrue:[
+            self resizeForChangedLabel.
+            ^ self
+        ]
+    ].
+"/    changedObject == labelView labelChannel ifTrue:[
+"/        self resizeForChangedLabel.
+"/        ^ self
+"/    ].
+    super update:something with:aParameter from:changedObject
 ! !
 
 !CheckBox methodsFor:'event handling'!
@@ -794,6 +820,15 @@
 
 !CheckBox methodsFor:'private'!
 
+resizeForChangedLabel
+    labelView forceResize.
+    resizeForLabel == true ifTrue:[
+        self extent:(self preferredExtent)
+    ].
+    self layoutChanged.
+    self resize.
+!
+
 sendChangeMessageWith:aValue
     "redefined to have mimic changes being sent from the toggle
      instead of myself"
@@ -841,5 +876,5 @@
 !CheckBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.65 2000-02-11 14:56:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.66 2000-05-10 11:30:58 cg Exp $'
 ! !