*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Tue, 30 Oct 2007 19:53:14 +0100
changeset 4812 195b0d3192ba
parent 4811 9b04f5e8a01b
child 4813 f03cd0880bd9
*** empty log message ***
StandardSystemView.st
--- a/StandardSystemView.st	Tue Oct 30 16:54:44 2007 +0100
+++ b/StandardSystemView.st	Tue Oct 30 19:53:14 2007 +0100
@@ -807,17 +807,17 @@
     iconValue := icon value.
     iconValue notNil ifTrue:[
         drawableId notNil ifTrue:[
-            i := device convertedIcon:iconValue.
+            i := self convertedIcon:iconValue.
             (i notNil and:[i id notNil]) ifTrue:[
                 (m := iconValue mask) notNil ifTrue:[
-                    m := device convertedIconMask:m.
+                    m := self convertedIconMask:m.
                 ].
                 device setWindowIcon:i mask:m in:drawableId
             ]
         ]
     ]
 
-    "Modified: / 30-10-2007 / 16:39:15 / cg"
+    "Modified: / 30-10-2007 / 19:52:12 / cg"
 !
 
 iconLabel
@@ -1224,9 +1224,9 @@
      this means converting it to a format (typically: monochrome) which
      the device supports. Return a compatible version of the icon."
 
-    ^ device convertedIcon:icon
+    ^ self convertedIcon:icon
 
-    "Modified: / 30-10-2007 / 16:39:55 / cg"
+    "Modified: / 30-10-2007 / 19:51:58 / cg"
 !
 
 convertedIcon:iconArg
@@ -1234,9 +1234,60 @@
      this means converting it to a format (typically: monochrome) which
      the device supports. Return a compatible version of the icon."
 
-    ^ device convertedIcon:iconArg
+    |deviceIcon d toMono toDeep icon|
+
+    icon := iconArg value.
+    icon isNil ifTrue:[^ nil].
+
+    toMono := toDeep := false.
 
-    "Modified: / 30-10-2007 / 16:37:31 / cg"
+    d := icon depth.
+    device supportsDeepIcons ifFalse:[
+        (d ~~ 1 or:[icon isImage]) ifTrue:[
+            "
+             dither to monochrome
+            "
+            toMono := true.
+        ]
+    ] ifTrue:[
+        d == 1 ifTrue:[
+            icon colorMap notNil ifTrue:[
+                icon isImage ifFalse:[
+                    toMono := true.
+                ] ifTrue:[
+                    toDeep := true.
+                ]
+            ]
+        ] ifFalse:[
+            d ~~ device depth ifTrue:[
+                icon isImage ifFalse:[
+                    toMono := true.
+                ] ifTrue:[
+                    toDeep := true.
+                ]
+            ]
+        ]
+    ].
+
+    deviceIcon := icon.
+    toMono ifTrue:[
+        deviceIcon := icon asMonochromeFormOn:device.
+    ].
+    toDeep ifTrue:[
+        deviceIcon := (Image implementorForDepth:device depth)
+                        fromImage:icon.
+    ].
+
+    deviceIcon notNil ifTrue:[
+        "
+         get device pixmap (i.e. allocate colors & resource)
+        "
+        deviceIcon := deviceIcon onDevice:device
+    ].
+    ^ deviceIcon
+
+    "Created: / 10-06-1996 / 19:41:31 / cg"
+    "Modified: / 30-10-2007 / 19:51:41 / cg"
 !
 
 convertedIconMask:aMask
@@ -1245,9 +1296,14 @@
      mask - future versions may add alpha channel masks, if the device supports
      them ..."
 
-    ^ device convertedIconMask:aMask
+    device supportsIconMasks ifFalse:[^ nil].
 
-    "Modified: / 30-10-2007 / 16:38:58 / cg"
+    aMask depth ~~ 1 ifTrue:[
+        ^ aMask asMonochromeFormOn:device
+    ].
+    ^ aMask
+
+    "Modified: / 30-10-2007 / 19:51:50 / cg"
 !
 
 setWindowGroupFromApplication
@@ -1413,9 +1469,9 @@
 
     icon notNil ifTrue:[
         iconValue := icon value.
-        icn := device convertedIcon:iconValue.
+        icn := self convertedIcon:iconValue.
         (icnMask := iconValue mask) notNil ifTrue:[
-            icnMask := device convertedIconMask:icnMask
+            icnMask := self convertedIconMask:icnMask
         ].
         deviceIcon := icn.
     ].
@@ -1487,7 +1543,7 @@
     self setWindowClass:('Stx.', windowClassNameString) name:"name"'bla'.
 
     "Modified: / 14-06-1996 / 17:14:25 / stefan"
-    "Modified: / 30-10-2007 / 16:39:30 / cg"
+    "Modified: / 30-10-2007 / 19:52:15 / cg"
 !
 
 postRealize
@@ -1528,7 +1584,7 @@
         iconView setRealized:true.
     ] ifFalse:[
         icon notNil ifTrue:[
-            self icon:(device convertedIcon:icon).
+            self icon:(self convertedIcon:icon).
         ].
     ].
 
@@ -1536,13 +1592,13 @@
         device setIconName:iconLabel in:drawableId
     ]
 
-    "Modified: / 30-10-2007 / 16:39:42 / cg"
+    "Modified: / 30-10-2007 / 19:52:25 / cg"
 ! !
 
 !StandardSystemView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.174 2007-10-30 15:41:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.175 2007-10-30 18:53:14 cg Exp $'
 ! !
 
 StandardSystemView initialize!