MenuPanel.st
changeset 2337 7f384db88273
parent 2332 7e98cc0c92b7
child 2339 4dd599296b9f
--- a/MenuPanel.st	Mon Oct 28 11:17:59 2002 +0100
+++ b/MenuPanel.st	Tue Oct 29 10:42:26 2002 +0100
@@ -21,7 +21,7 @@
 		scrollActivity rightArrowShadow rightArrow fgColor verticalLayout
 		showSeparatingLines showGroupDivider implicitGrabView
 		lastPointerView openDelayedMenuBlock preferredWidth application
-		originator'
+		originator centerItems'
 	classVariableNames:'InitialSelectionQuerySignal Images LigthenedImages'
 	poolDictionaries:''
 	category:'Views-Menus'
@@ -440,13 +440,14 @@
     "
      self iconRadioGroupDisabledOn inspect
      ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOn
+     Icon flushCachedIcons
     "
 
     <resource: #image>
 
     ^Icon
-	constantNamed:#'MenuPanel iconRadioGroupDisabledOn'
-	ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DY@Z(AH@@+AI@@FLR@@@#D @@H1H@@BLRP@A#AX@@#@Z$A(0A** 0@C@C0@@O?@@') ; colorMapFromArray:#[0 0 0 85 85 85 170 170 170 255 255 255]; mask:((Depth1Image new) width: 15; height: 15; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'A<@_<C?8_?1??O?:??+?>/?:??)?=G?4O< HL@_@') ; yourself); yourself]
+        constantNamed:#'MenuPanel class iconRadioGroupDisabledOn'
+        ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DYUZ(AIUU+AIUUVLRUUU#D%UUX1IUUVLRUUU#AYUU#@Z%U(0A** 0@C@C0@@O?@@') ; colorMapFromArray:#[0 0 0 85 85 85 170 170 170 255 255 255]; mask:((Depth1Image new) width: 15; height: 15; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'A<@_<C?8_?1??O?:??+?>/?:??)?=G?4O< HL@_@') ; yourself); yourself]
 !
 
 iconRadioGroupOff
@@ -1676,6 +1677,14 @@
     ^ styleSheet at:#'menuPanel.buttonPassiveLevel'
 !
 
+centerItems
+    ^ centerItems ? false
+!
+
+centerItems:aBoolean
+    centerItems := aBoolean
+!
+
 fitFirstPanel
     "gets true if the first panel in the menu hierarchy must be fit 
      to the extent of its superView
@@ -6038,6 +6047,10 @@
     ].
 
     x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset.
+    (menuPanel centerItems 
+    and:[drawObject isImage]) ifTrue:[
+        x := x + (layout width - menuPanel buttonPassiveLevel - HorizontalButtonInset - 1 - drawObject width // 2).
+    ].
 
     isSelected ifFalse:[
         "check whether button should be drawn selected; indicator or radio button"
@@ -6216,27 +6229,27 @@
     menuPanel paint:fg.
 
     y := layout top + (layout height - rawLabelExtent y // 2) + yOffset.
-
+"/  menuPanel centerItems ifTrue:[self halt].
     aLabel isArray ifFalse:[
-	aLabel isImageOrForm ifFalse:[
-	    y := y + fontAscent.
-	].
-	aLabel displayOn:menuPanel x:x y:y.
+        aLabel isImageOrForm ifFalse:[
+            y := y + fontAscent.
+        ].
+        aLabel displayOn:menuPanel x:x y:y.
     ] ifTrue:[
-	aLabel do:[:el|
-	    el notNil ifTrue:[
-		el isImageOrForm ifFalse:[
-		    y0 := y + fontAscent
-		] ifTrue:[
-		    y0 := y
-		].
-		x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2).
-		el displayOn:menuPanel x:x0 y:y0.
-		y := y + 1 + (el heightOn:menuPanel)
-	    ] ifFalse:[
-		y := y + 3   "/ see #label:
-	    ]
-	].
+        aLabel do:[:el|
+            el notNil ifTrue:[
+                el isImageOrForm ifFalse:[
+                    y0 := y + fontAscent
+                ] ifTrue:[
+                    y0 := y
+                ].
+                x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2).
+                el displayOn:menuPanel x:x0 y:y0.
+                y := y + 1 + (el heightOn:menuPanel)
+            ] ifFalse:[
+                y := y + 3   "/ see #label:
+            ]
+        ].
     ].
     menuPanel setFont:mfont
 !
@@ -7324,7 +7337,7 @@
 !MenuPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.341 2002-10-26 15:51:56 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.342 2002-10-29 09:42:26 cg Exp $'
 ! !
 
 MenuPanel initialize!