Label.st
changeset 110 eb59f6e31e84
parent 105 3d064ba4a0cc
child 113 fdd18cfff57e
--- a/Label.st	Mon Mar 20 12:52:08 1995 +0100
+++ b/Label.st	Sat Mar 25 23:21:46 1995 +0100
@@ -14,7 +14,7 @@
 
 View subclass:#Label
 	 instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust
-                hSpace vSpace bgColor fgColor fixSize'
+		hSpace vSpace bgColor fgColor fixSize'
 	 classVariableNames:'DefaultFont DefaultForegroundColor DefaultBackgroundColor'
 	 poolDictionaries:''
 	 category:'Views-Layout'
@@ -24,7 +24,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/Label.st,v 1.18 1995-03-18 05:14:54 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Label.st,v 1.19 1995-03-25 22:20:37 claus Exp $
 '!
 
 !Label class methodsFor:'documentation'!
@@ -45,7 +45,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/Label.st,v 1.18 1995-03-18 05:14:54 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Label.st,v 1.19 1995-03-25 22:20:37 claus Exp $
 "
 !
 
@@ -334,9 +334,9 @@
     prevPosition := labelOriginX.
     self computeLabelOrigin
     shown ifTrue:[
-        labelOriginX ~~ prevPosition ifTrue:[
-            self redraw
-        ]
+	labelOriginX ~~ prevPosition ifTrue:[
+	    self redraw
+	]
     ]
 ! !
 
@@ -482,6 +482,10 @@
     super realize.
     fgColor := fgColor on:device.
     bgColor := bgColor on:device.
+    (model notNil 
+    and:[aspectSymbol notNil]) ifTrue:[
+	self getLabelFromModel.
+    ]
 !
 
 initialize
@@ -578,6 +582,15 @@
 
 !Label methodsFor:'private'!
 
+getLabelFromModel
+    "ask my model for the label to show"
+
+    (model notNil 
+    and:[aspectSymbol notNil]) ifTrue:[
+	self label:(model perform: aspectSymbol) printString.
+    ].
+!
+
 newLayout
     "recompute position/size after a change
      - helper for form:/font: etc."
@@ -671,6 +684,17 @@
     textWidth := font widthOf:logo.
     labelWidth := textWidth + (hSpace * 2) .
     labelHeight := textHeight + (vSpace * 2)
+! !
+
+!Label methodsFor:'resizing'!
+
+forceResize
+    "resize myself to make text fit into myself."
+
+    logo notNil ifTrue:[
+	self extent:self preferedExtent.
+	self computeLabelOrigin
+    ]
 !
 
 resize
@@ -678,15 +702,14 @@
      but only do so, if I have not been given a relative extent
      or an extend computation block."
 
-    |extra|
-
-    logo notNil ifTrue:[
-	(relativeExtent isNil and:[extentRule isNil]) ifTrue:[
-	    (relativeCorner isNil and:[cornerRule isNil]) ifTrue:[
-		extra := margin * 2.
-		self extent:(labelWidth + extra) @ (labelHeight + extra)
-	    ].
-	].
+    (logo notNil 
+    and:[fixSize not
+    and:[relativeExtent isNil
+    and:[extentRule isNil
+    and:[relativeCorner isNil 
+    and:[cornerRule isNil]]]]]) ifTrue:[
+	self forceResize
+    ] ifFalse:[
 	self computeLabelOrigin
     ]
 ! !
@@ -698,9 +721,7 @@
 
     (aspectSymbol notNil
     and:[something == aspectSymbol]) ifTrue:[
-	model notNil ifTrue:[
-	    self label:(model perform: aspectSymbol) printString.
-	].
+	self getLabelFromModel.
 	^ self.
     ].
     super update:something