checkin from browser
authorClaus Gittinger <cg@exept.de>
Tue, 25 Aug 1998 12:44:01 +0200
changeset 1096 6ab44a6939bf
parent 1095 44b55760239b
child 1097 8a2f6c5ad1a9
checkin from browser
MenuPanel.st
--- a/MenuPanel.st	Mon Aug 24 19:17:11 1998 +0200
+++ b/MenuPanel.st	Tue Aug 25 12:44:01 1998 +0200
@@ -1252,10 +1252,11 @@
         "/ horizontal - add x-extents; take max of y-extents
         y := 0.
 
-        self do:[:el||elY|
+        self do:[:el| |elY elPref|
             el isVisible ifTrue:[
-                x := x + el preferredExtentX.
-                elY := el preferredExtentY.
+                elPref := el preferredExtent.
+                x := x + elPref x.
+                elY := elPref y.
                 el isButton ifTrue:[
                     elY := elY + (2 * DefaultButtonItemSpace).
                     x := x + (2 * DefaultButtonItemSpace).
@@ -1286,7 +1287,7 @@
                         shCtKey := e
                     ].
                 ].
-                y := y + el preferredExtentY
+                y := y + el preferredExtent y
             ]
         ].
         x := x + hrzInset.
@@ -1886,10 +1887,10 @@
             e := self computeExtent.
 
             isVert ifTrue:[
-                items do:[:el|x := x + el preferredExtentY].
+                items do:[:el | x := x + el preferredExtent y].
                 y := e y.
             ] ifFalse:[
-                items do:[:el|x := x + el preferredExtentX].
+                items do:[:el|x := x + el preferredExtent x].
                 y := e x.
             ].
             x := x + (noItems + 1 * itemSpace).
@@ -1920,15 +1921,16 @@
     isVert ifTrue:[y := y + itemSpace]
           ifFalse:[x := x + itemSpace].
 
-    self keysAndValuesDo:[:anIndex :el||org corn|
+    self keysAndValuesDo:[:anIndex :el| |org corn elPref|
         el isVisible ifTrue:[
             el isButton ifTrue:[
                 org := Point x:(x+DefaultButtonItemSpace) y:(y+DefaultButtonItemSpace).
             ] ifFalse:[
                 org := Point x:x y:y.
             ].
+            elPref := el preferredExtent.
             isVert ifTrue:[
-                y := y + el preferredExtentY.
+                y := y + elPref y.
                 corn := (e x @ y).
                 el isButton ifTrue:[
                     corn := corn - (DefaultButtonItemSpace @ 0).
@@ -1939,7 +1941,7 @@
                 ].
                 y := y + itemSpace.
             ] ifFalse:[
-                x := x + el preferredExtentX.
+                x := x + elPref x.
                 el isButton ifTrue:[
                     x := x + DefaultButtonItemSpace.
                     corn := (x @ (e y - margin)).
@@ -3770,9 +3772,9 @@
     "gets height
     "
     layout isNil ifTrue:[
-        ^ self preferredExtentY
-    ].
-  ^ layout height
+        ^ self preferredExtent y
+    ].
+    ^ layout height
 !
 
 horizontalInset
@@ -3794,62 +3796,6 @@
     self redraw.
 !
 
-preferredExtentX
-    "compute my preferred extent x
-    "
-    |x s isVertical|
-
-    self isVisible ifFalse:[^ 0].
-
-    x := self horizontalInset * 2.
-    isVertical := menuPanel verticalLayout.
-
-    self isSeparator ifFalse:[
-        x := x + (rawLabel widthOn:menuPanel).
-
-        MenuView showAcceleratorKeys == true ifTrue:[
-            menuPanel isVerticalLayout ifTrue:[ "/ only for vertical menus ...
-                (s := self shortcutKeyAsString) notNil ifTrue:[
-                    x := x + LabelRightOffset + (s widthOn:menuPanel)
-                ].
-            ].
-        ].
-        (isVertical and:[self hasSubmenu or:[submenuChannel notNil]]) ifTrue:[
-            x := x + menuPanel subMenuIndicationWidth.
-
-            s notNil ifTrue:[x := x + ShortcutKeyOffset]
-                    ifFalse:[x := x + LabelRightOffset]
-        ].
-        ^ x
-    ].
-
-    isVertical ifFalse:[
-        ^ x max:(self class separatorSize:(self separatorType))
-    ].
-  ^ x
-
-    "Modified: / 8.8.1998 / 01:38:26 / cg"
-!
-
-preferredExtentY
-    "compute my preferred extent y
-    "
-    |y|
-
-    self isVisible ifFalse:[^ 0].
-
-    y := self verticalInset * 2.
-
-    self isSeparator ifFalse:[
-        ^ y + (rawLabel heightOn:menuPanel)
-    ].
-
-    menuPanel verticalLayout ifTrue:[
-        ^ y max:(self class separatorSize:(self separatorType))
-    ].
-  ^ y + (menuPanel font height)
-!
-
 verticalInset
 
     isButton ifTrue: [^menuPanel buttonPassiveLevel + VerticalButtonInset].
@@ -3859,10 +3805,11 @@
 width
     "gets width
     "
+
     layout isNil ifTrue:[
-        ^ self preferredExtentX
-    ].
-  ^ layout width
+        ^ self preferredExtent x
+    ].
+    ^ layout width
 ! !
 
 !MenuPanel::Item methodsFor:'building'!
@@ -4950,6 +4897,58 @@
     ]
 !
 
+preferredExtent
+    "compute my preferred extent
+    "
+    |x y s isVertical sepSize|
+
+    self isVisible ifFalse:[^ (0 @ 0) ].
+
+    x := self horizontalInset * 2.
+    y := self verticalInset * 2.
+
+    isVertical := menuPanel verticalLayout.
+
+    self isSeparator ifFalse:[
+        x := x + (rawLabel widthOn:menuPanel).
+        y := y + (rawLabel heightOn:menuPanel).
+
+        MenuView showAcceleratorKeys == true ifTrue:[
+            isVertical ifTrue:[ "/ only for vertical menus ...
+                (s := self shortcutKeyAsString) notNil ifTrue:[
+                    x := x + LabelRightOffset + (s widthOn:menuPanel)
+                ].
+            ].
+        ].
+        (isVertical and:[self hasSubmenu or:[submenuChannel notNil]]) ifTrue:[
+            x := x + menuPanel subMenuIndicationWidth.
+
+            s notNil ifTrue:[x := x + ShortcutKeyOffset]
+                    ifFalse:[x := x + LabelRightOffset]
+        ].
+    ] ifTrue:[
+
+        sepSize := (self class separatorSize:(self separatorType)).
+        isVertical ifFalse:[
+            x := x max:sepSize.
+            y := y + (menuPanel font height)
+        ] ifTrue:[
+            y := y max:sepSize
+        ].
+    ].
+
+    ^ (x @ y)
+
+    "Modified: / 8.8.1998 / 01:38:26 / cg"
+!
+
+preferredExtentX
+    "compute my preferred extent x
+    "
+    ^ self preferredExtent x
+
+!
+
 shortcutKeyAsString
     "converts shortcutKey to a text object
     "
@@ -5190,6 +5189,6 @@
 !MenuPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.118 1998-08-24 17:17:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.119 1998-08-25 10:44:01 cg Exp $'
 ! !
 MenuPanel initialize!