StandardSystemView.st
changeset 24 e810b1be068b
parent 21 7b3da079729d
child 46 7b331e9012fd
--- a/StandardSystemView.st	Sat Jan 08 18:12:58 1994 +0100
+++ b/StandardSystemView.st	Sat Jan 08 18:17:39 1994 +0100
@@ -11,7 +11,8 @@
 "
 
 View subclass:#StandardSystemView
-       instanceVariableNames:'label icon iconView minExtent maxExtent'
+       instanceVariableNames:'label icon iconView iconLabel
+                              minExtent maxExtent'
        classVariableNames:   ''
        poolDictionaries:''
        category:'Views-Basic'
@@ -25,7 +26,7 @@
 I represent topViews i.e. those views which have a title-label,
 an icon etc.
 
-$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.6 1993-12-20 17:29:01 claus Exp $
+$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.7 1994-01-08 17:16:02 claus Exp $
 written spring/summer 89 by claus
 '!
 
@@ -58,7 +59,7 @@
                  minExtent:minExtent
                  maxExtent:nil.
     newView model:aModel.
-    newView controller:(StandardSystemController new view:newView).
+    newView controller:(self defaultController new view:newView).
     ^ newView
 !
 
@@ -165,20 +166,57 @@
     ]
 !
 
+reinitialize
+    "this is called right after snapIn"
+
+    |myController|
+
+    "if I have already been reinited - return"
+    drawableId notNil ifTrue:[
+        ^ self
+    ].
+
+    myController := controller.
+    controller := nil.
+    self recreate.
+
+    "if I was mapped, do it again"
+    realized ifTrue:[
+        "if it was iconified, try to remap iconified"
+        shown ifFalse:[
+            device mapView:self id:drawableId iconified:true
+                       atX:left y:top width:width height:height
+        ] ifTrue:[
+            device mapView:self id:drawableId iconified:false
+                       atX:left y:top width:width height:height
+        ].
+
+        "and restart the window-group process"
+        windowGroup notNil ifTrue:[
+            windowGroup startup
+        ]
+    ].
+
+    "restore controller"
+    controller := myController
+!
+
 recreate
     "recreate the view after a snap-in"
 
-    icon notNil ifTrue:[
-        icon depth ~~ 1 ifTrue:[
-            icon := icon asMonochromeFormOn:device.
+    icon := self convertedIcon.
+    super recreate.
+    iconView notNil ifTrue:[
+        iconView create.
+        device setWindowIconWindow:iconView in:drawableId
+    ] ifFalse:[
+        (icon notNil and:[icon id notNil]) ifTrue:[
+            device setWindowIcon:icon in:drawableId
         ].
-        icon notNil ifTrue:[
-            icon := icon on:device.
-        ]
     ].
-    super recreate.
-    (icon notNil and:[icon id notNil]) ifTrue:[
-        device setWindowIcon:icon in:drawableId
+
+    iconLabel notNil ifTrue:[
+        device setIconName:iconLabel in:drawableId
     ]
 !
 
@@ -207,24 +245,43 @@
     ].
 ! !
 
+!StandardSystemView methodsFor:'private'!
+
+convertedIcon
+    "make certain, that the icon is a b&w bitmap;
+     do so by converting if appropriate.
+     Will add a device supportsDeepIcons and only convert when needed;
+     for now (since there are only Xdisplays) we always have to convert."
+
+    |deviceIcon|
+
+    icon isNil ifTrue:[^ nil].
+
+    icon depth ~~ 1 ifTrue:[
+        deviceIcon := icon asMonochromeFormOn:device.
+    ] ifFalse:[
+        deviceIcon := icon
+    ].
+    deviceIcon notNil ifTrue:[
+        deviceIcon := deviceIcon on:device
+    ].
+    ^ deviceIcon
+! !
+
 !StandardSystemView methodsFor:'realization'!
 
 create
     "create - make certain that icon is available"
 
-    icon notNil ifTrue:[
-        icon depth ~~ 1 ifTrue:[
-            icon := icon asMonochromeFormOn:device.
-        ].
-        icon notNil ifTrue:[
-            icon := icon on:device
-        ].
-    ].
+    icon := self convertedIcon.
     super create.
 
     iconView notNil ifTrue:[
         iconView create.
         device setWindowIconWindow:iconView in:drawableId
+    ].
+    iconLabel notNil ifTrue:[
+        device setIconName:iconLabel in:drawableId
     ]
 !
 
@@ -264,7 +321,24 @@
     ]
 !
 
+iconLabel
+    "return the name displayed in the icon"
+
+    ^ iconLabel
+!
+
+iconLabel:aString
+    "define the name to be displayed in the icon"
+
+    iconLabel := aString.
+    drawableId notNil ifTrue:[
+        device setIconName:aString in:drawableId
+    ]
+!
+
 name
+    "return the topViews label"
+
     ^ label
 !
 
@@ -277,31 +351,29 @@
 icon:aForm
     "define the form (bitmap) used as icon"
 
-    |invertedIcon|
+    |invertedIcon i|
 
     icon := aForm.
-
     icon notNil ifTrue:[
-        icon depth == 1 ifTrue:[
-            "icons assume 1s as black - invert icon if the device thinks different"
-            (device depth == 1 and:[device whitepixel ~~ 0]) ifTrue:[
-                icon := icon on:device.
-                invertedIcon := Form width:icon width height:icon height on:device.
-                invertedIcon function:#copyInverted.
-                invertedIcon copyFrom:icon x:0 y:0 toX:0 y:0 width:icon width height:icon height.
-                icon := invertedIcon
-            ]
-        ].
-
         drawableId notNil ifTrue:[
             icon depth ~~ 1 ifTrue:[
                 icon := icon asMonochromeFormOn:device.
             ].
-            icon := icon on:device.
-            icon notNil ifTrue:[
-                icon id notNil ifTrue:[
-                    device setWindowIcon:icon in:drawableId
+            "icons assume 1s as black - invert icon if the device thinks different"
+            (device depth == 1 and:[device whitepixel ~~ 0]) ifTrue:[
+                i := icon on:device.
+                i notNil ifTrue:[
+                    invertedIcon := Form width:icon width height:icon height on:device.
+                    invertedIcon function:#copy.
+                    invertedIcon foreground:Color noColor background:Color allColor.
+                    invertedIcon copyFrom:i x:0 y:0 toX:0 y:0 width:icon width height:icon height.
+                    i := invertedIcon.
                 ]
+            ] ifFalse:[
+                i := icon on:device.
+            ].
+            (i notNil and:[i id notNil]) ifTrue:[
+                device setWindowIcon:i in:drawableId
             ]
         ]
     ]
@@ -324,21 +396,19 @@
 !
 
 iconName:aString
-    "define the name to be displayed in the icon"
+    "this method will vanish soon ... - for backward compatibility"
 
-    drawableId notNil ifTrue:[
-        device setIconName:aString in:drawableId
-    ]
+    self iconLabel:aString
 !
 
 maximumSize:anExtent
-    "maxExtent: for ST-80 compatibility"
+    "same as maxExtent: for ST-80 compatibility"
 
     ^ self maxExtent:anExtent
 !
 
 minimumSize:anExtent
-    "minExtent: for ST-80 compatibility"
+    "same as minExtent: for ST-80 compatibility"
 
     ^ self minExtent:anExtent
 !