*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Fri, 24 Oct 2008 16:02:55 +0200
changeset 3746 9592829bf5b3
parent 3745 2c027dc31a7d
child 3747 0812d143fc65
*** empty log message ***
RadioButton.st
--- a/RadioButton.st	Fri Oct 24 15:36:24 2008 +0200
+++ b/RadioButton.st	Fri Oct 24 16:02:55 2008 +0200
@@ -12,14 +12,17 @@
 "{ Package: 'stx:libwidg' }"
 
 Toggle subclass:#RadioButton
-	instanceVariableNames:'buttonStyle buttonOnLevel buttonOffLevel buttonOffImage
-		buttonOnImage'
+	instanceVariableNames:'buttonStyle buttonOnLevel buttonOffLevel offImage onImage
+		buttonOffImage buttonOnImage disabledOnImage disabledOffImage
+		enteredOnImage enteredOffImage'
 	classVariableNames:'DefaultButtonStyle DefaultActiveLevel DefaultPassiveLevel
 		DefaultForegroundColor DefaultBackgroundColor
 		DefaultActiveForegroundColor DefaultActiveBackgroundColor
 		MotifCheckBotForm MotifCheckTopForm MotifCheckInnerForm
 		Round3DCheckBotForm Round3DCheckTopForm Round3DCheckInnerForm
-		RoundHalfLightForm RoundOffForm RoundOnForm'
+		RoundHalfLightForm RoundOffForm RoundOnForm PassiveForm
+		ActiveForm EnteredPassiveForm EnteredActiveForm
+		DisabledActiveForm DisabledPassiveForm'
 	poolDictionaries:''
 	category:'Views-Interactors'
 !
@@ -150,6 +153,66 @@
 
 !RadioButton class methodsFor:'defaults'!
 
+activeForm
+    ActiveForm isNil ifTrue:[
+        self updateStyleCache.
+    ].
+    ^ ActiveForm
+
+    "
+     ActiveForm := nil. 
+     self updateStyleCache
+    "
+!
+
+disabledActiveForm
+    DisabledActiveForm isNil ifTrue:[
+        self updateStyleCache.
+    ].
+    ^ DisabledActiveForm
+
+    "
+     DisabledActiveForm := nil. 
+     self updateStyleCache
+    "
+!
+
+disabledPassiveForm
+    DisabledPassiveForm isNil ifTrue:[
+        self updateStyleCache.
+    ].
+    ^ DisabledPassiveForm
+
+    "
+     DisabledPassiveForm := nil. 
+     self updateStyleCache
+    "
+!
+
+enteredActiveForm
+    EnteredActiveForm isNil ifTrue:[
+        self updateStyleCache.
+    ].
+    ^ EnteredActiveForm
+
+    "
+     EnteredActiveForm := nil. 
+     self updateStyleCache
+    "
+!
+
+enteredPassiveForm
+    EnteredPassiveForm isNil ifTrue:[
+        self updateStyleCache.
+    ].
+    ^ EnteredPassiveForm
+
+    "
+     EnteredPassiveForm := nil. 
+     self updateStyleCache
+    "
+!
+
 motifCheckBotForm
     MotifCheckBotForm isNil ifTrue:[
         MotifCheckBotForm := Form 
@@ -237,6 +300,18 @@
     "Modified: / 30.7.1998 / 21:28:45 / cg"
 !
 
+passiveForm
+    PassiveForm isNil ifTrue:[
+        self updateStyleCache.
+    ].
+    ^ PassiveForm
+
+    "
+     PassiveForm := nil. 
+     self updateStyleCache
+    "
+!
+
 round3DCheckBotForm
     Round3DCheckBotForm isNil ifTrue:[
         Round3DCheckBotForm := Form 
@@ -466,15 +541,19 @@
                        #'radioButton.passiveLevel'
                        #'radioButton.activeImageFile'
                        #'radioButton.activeImage'
+                       #'radioButton.enteredActiveImageFile'
+                       #'radioButton.enteredActiveImage'
                        #'radioButton.passiveImageFile'
                        #'radioButton.passiveImage'
+                       #'radioButton.enteredPassiveImageFile'
+                       #'radioButton.enteredPassiveImage'
                        #'radioButton.foregroundColor'
                        #'radioButton.backgroundColor'
                        #'radioButton.activeForegroundColor'
                        #'radioButton.activeBackgroundColor'
                       )>
 
-    |l f|
+    |l fetchImage|
 
     DefaultFont := StyleSheet fontAt:'label.font'.                   
     DefaultButtonStyle := StyleSheet at:#'radioButton.style'.
@@ -491,39 +570,78 @@
     DefaultActiveBackgroundColor := StyleSheet at:#'radioButton.activeBackgroundColor'.
 
     RoundOnForm := RoundOffForm := nil.
+    ActiveForm := EnteredActiveForm := nil.
+    PassiveForm := EnteredPassiveForm := nil.
 
-    f := StyleSheet at:#'radioButton.activeImageFile'.
-    f notNil ifTrue:[
-        f := Smalltalk imageFromFileNamed:f forClass:self.
-    ] ifFalse:[
-        f := StyleSheet at:#'radioButton.activeImage'.
-    ].
-    f isNil ifTrue:[
-        RoundOffForm := StyleSheet isWindowsXPStyle
-                            ifTrue:[ self radioOnIcon_xp ]
-                            ifFalse:[ self radioOnIcon_w95 ]
-    ].
-    f notNil ifTrue:[
-        "/ RoundOnForm := self roundOnForm_old.
-        RoundOnForm := f onDevice:Display
-    ].
+    fetchImage := 
+        [:fileNameKey :imageKey :defaultW95 :defaultXP :defaultVista |
+            |f|
+
+            f := StyleSheet at:imageKey.
+            f notNil 
+                ifTrue:[ 
+                    f := f value ]
+                ifFalse:[
+                    f := StyleSheet at:fileNameKey.
+                    f notNil 
+                        ifTrue:[
+                            f := Smalltalk imageFromFileNamed:f forClass:self.]
+                        ifFalse:[
+                            f := (StyleSheet isWindowsVistaStyle)
+                                ifTrue:defaultVista
+                                ifFalse:[
+                                    StyleSheet isWindowsXPStyle
+                                        ifTrue:defaultXP
+                                        ifFalse:defaultW95].
+                        ]
+                ].
+            f notNil ifTrue:[
+                f := f onDevice:Display
+            ].
+            f
+        ].
 
-    f := StyleSheet at:#'radioButton.passiveImageFile'.
-    f notNil ifTrue:[
-        f := Smalltalk imageFromFileNamed:f forClass:self.
-    ] ifFalse:[
-        f := StyleSheet at:#'radioButton.passiveImage'.
-    ].
-    f isNil ifTrue:[
-        "/ RoundOffForm := self roundOffForm_old.
-        RoundOffForm := StyleSheet isWindowsXPStyle
-                            ifTrue:[ self radioOffIcon_xp ]
-                            ifFalse:[ self radioOffIcon_w95 ]
-    ].
+    ActiveForm := RoundOnForm := fetchImage 
+            value:#'radioButton.activeImageFile'
+            value:#'radioButton.activeImage'
+            value:[ self radioOnIcon_w95 ]
+            value:[ self radioOnIcon_xp ]
+            value:[ self radioOnIcon_vista ].
+
+    PassiveForm := RoundOffForm := fetchImage 
+            value:#'radioButton.passiveImageFile'
+            value:#'radioButton.passiveImage'
+            value:[ self radioOffIcon_w95 ]
+            value:[ self radioOffIcon_xp ]
+            value:[ self radioOffIcon_vista ].
+
+    EnteredActiveForm := fetchImage 
+            value:#'radioButton.enteredActiveImageFile'
+            value:#'radioButton.enteredActiveImage'
+            value:[ self radioOnEnteredIcon_w95 ]
+            value:[ self radioOnEnteredIcon_xp ]
+            value:[ self radioOnEnteredIcon_vista ].
 
-    f notNil ifTrue:[
-        RoundOffForm := f onDevice:Display
-    ].
+    EnteredPassiveForm := fetchImage 
+            value:#'radioButton.enteredPassiveImageFile'
+            value:#'radioButton.enteredPassiveImage'
+            value:[ self radioOffEnteredIcon_w95 ]
+            value:[ self radioOffEnteredIcon_xp ]
+            value:[ self radioOffEnteredIcon_vista ].
+
+    DisabledActiveForm := fetchImage 
+            value:#'radioButton.disabledActiveImageFile'
+            value:#'radioButton.disabledActiveImage'
+            value:[ self radioOnDisabledIcon_w95 ]
+            value:[ self radioOnDisabledIcon_xp ]
+            value:[ self radioOnDisabledIcon_vista ].
+
+    DisabledPassiveForm := fetchImage 
+            value:#'radioButton.disabledPassiveImageFile'
+            value:#'radioButton.disabledPassiveImage'
+            value:[ self radioOffDisabledIcon_w95 ]
+            value:[ self radioOffDisabledIcon_xp ]
+            value:[ self radioOffDisabledIcon_vista ].
 
     "
      self updateStyleCache
@@ -534,6 +652,34 @@
 
 !RadioButton class methodsFor:'image specs'!
 
+radioOffDisabledIcon_vista
+    ^ VistaToolbarIconLibrary radioOff12x12Icon
+!
+
+radioOffDisabledIcon_w95
+    ^ self radioOffIcon_w95
+!
+
+radioOffDisabledIcon_xp
+    ^ self radioOffIcon_xp
+!
+
+radioOffEnteredIcon_vista
+    ^ VistaToolbarIconLibrary radioOffEntered12x12Icon
+!
+
+radioOffEnteredIcon_w95
+    ^ self radioOffIcon_w95
+!
+
+radioOffEnteredIcon_xp
+    ^ self radioOffIcon_xp
+!
+
+radioOffIcon_vista
+    ^ VistaToolbarIconLibrary radioOff12x12Icon
+!
+
 radioOffIcon_w95
     "This resource specification was automatically generated
      by the ImageEditor of ST/X."
@@ -578,6 +724,34 @@
 G (%E1$\C@4+@PLHHB\UDQ$\C@4+@PLHA0$ED1,&C@4+@PLHA0P[H"0KJB$+@PLHA0PNB20,KA([E!!<*H@$[B20,KB0,HQT''G (R@"0,K@@a') ; colorMapFromArray:#[224 224 219 247 247 246 221 226 229 249 249 248 188 204 217 164 183 198 222 228 229 253 253 252 251 251 250 112 145 175 90 128 159 180 195 206 241 241 239 243 243 241 96 133 166 100 134 161 166 181 191 104 137 166 164 182 198 222 227 229 229 229 226 164 183 197 110 143 172 232 232 229 85 122 154 236 236 233 179 195 206 33 85 130 239 239 236 218 220 218 36 87 131 185 200 213 188 203 216 222 226 229 222 227 228 167 183 193 226 226 222 171 186 198 178 193 205 90 128 160 91 129 161 181 196 208 242 244 245 245 245 244 0 0 0]; mask:((ImageMask new) width: 13; height: 13; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'G<@?8G?0??#?>O?8??#?>O?8??!!?<C? G<@b') ; yourself); yourself]
 !
 
+radioOnDisabledIcon_vista
+    ^ VistaToolbarIconLibrary radioOn12x12Icon
+!
+
+radioOnDisabledIcon_w95
+    ^ self radioOnIcon_w95
+!
+
+radioOnDisabledIcon_xp
+    ^ self radioOnIcon_xp
+!
+
+radioOnEnteredIcon_vista
+    ^ VistaToolbarIconLibrary radioOnEntered12x12Icon
+!
+
+radioOnEnteredIcon_w95
+    ^ self radioOnIcon_w95
+!
+
+radioOnEnteredIcon_xp
+    ^ self radioOnIcon_xp
+!
+
+radioOnIcon_vista
+    ^ VistaToolbarIconLibrary radioOn12x12Icon
+!
+
 radioOnIcon_w95
     "This resource specification was automatically generated
      by the ImageEditor of ST/X."
@@ -668,14 +842,32 @@
 drawToggleImage
     "drawing of the radio image is done here."
 
-    |x y clrTop clrBot imgTop imgBot imgInside imgH imgOn threeD lvl
-     isActive|
+    |x y img clrTop clrBot imgTop imgBot imgInside imgH imgOn threeD lvl
+     isActive isEntered isEnabled|
 
     buttonStyle isNil ifTrue:[
         ^ super drawToggleImage
     ].
 
     isActive := controller pressed.
+    isEnabled := controller enabled.
+    isEnabled ifFalse:[
+        img := isActive ifTrue: disabledOnImage ifFalse: disabledOffImage.
+    ] ifTrue:[
+        isEntered := controller entered.
+        isEntered ifTrue:[        
+            img := isActive ifTrue: enteredOnImage ifFalse: enteredOffImage.
+        ] ifFalse:[
+            img := isActive ifTrue: onImage ifFalse: offImage.
+        ]
+    ].
+
+    img notNil ifTrue:[
+        x := hSpace + margin.
+        y := (height - img height) // 2.
+        self displayForm:img x:x y:y.
+        ^ self.
+    ].
 
     threeD := true.
     buttonStyle == #motif ifTrue:[
@@ -827,13 +1019,20 @@
         buttonStyle == #image ifTrue:[
             buttonOnImage := self class roundOnForm onDevice:device.
             buttonOffImage := self class roundOffForm onDevice:device.
+
+            onImage := self class activeForm onDevice:device.
+            offImage := self class passiveForm onDevice:device.
+            disabledOnImage := self class disabledActiveForm onDevice:device.
+            disabledOffImage := self class disabledPassiveForm onDevice:device.
+            enteredOnImage := self class enteredActiveForm onDevice:device.
+            enteredOffImage := self class enteredPassiveForm onDevice:device.
         ]
     ] ifFalse:[
         buttonStyle == #round2D ifTrue:[
             activeFgColor := fgColor.
             activeBgColor := bgColor.
         ]
-    ]
+    ].
 
     "Modified: / 28.4.1999 / 14:05:35 / cg"
 ! !
@@ -886,5 +1085,5 @@
 !RadioButton class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/RadioButton.st,v 1.43 2008-10-13 07:18:21 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/RadioButton.st,v 1.44 2008-10-24 14:02:55 cg Exp $'
 ! !