added new windowStyle: #undecorated.
authorClaus Gittinger <cg@exept.de>
Tue, 09 Mar 2004 15:29:32 +0100
changeset 4079 8a66b0c94337
parent 4078 467a07009140
child 4080 8f7e8d597552
added new windowStyle: #undecorated.
TopView.st
--- a/TopView.st	Mon Mar 08 19:11:44 2004 +0100
+++ b/TopView.st	Tue Mar 09 15:29:32 2004 +0100
@@ -15,7 +15,10 @@
 View subclass:#TopView
 	instanceVariableNames:'type iconified keyboardProcessor'
 	classVariableNames:'TakeFocusWhenMapped ForceModalBoxesToOpenAtCenter
-		ForceModalBoxesToOpenAtPointer'
+		ForceModalBoxesToOpenAtPointer MasterSlaveMask BitMaster BitSlave
+		BitPartner WindowTypeMask BitDialog BitPopUp BitUndecorated
+		TypeMaster TypeSlave TypePartner TypeDialog TypePopUp
+		TypeUndecorated'
 	poolDictionaries:''
 	category:'Views-Basic'
 !
@@ -45,11 +48,14 @@
     topViews are typically instances of StandardSystemView.
 
     [instance variables:]
-	type		<Symbol>	one of #normal, #master, #slave or #partner
-					for modeless views
-					(#master, #slave or #partner link multiple views 
-					into a windowManagers windowGroup -> de-iconification) 
-					#dialog for modal views; #popup for popup views.
+        type            <Integer>       encodes master/slave relationship:
+                                            #normal, #master, #slave or #partner
+                                        for modeless views
+                                        (the #master-, #slave- or #partner-type links multiple views 
+                                         into a windowManagers windowGroup -> for de-iconification)
+
+                                        encodes window type:
+                                            #normal, #dialog, #popup, #undecorated 
 
     [see also:]
         StandardSystemView PopUpView DialogBox 
@@ -58,6 +64,115 @@
     [author:]
         Claus Gittinger
 "
+!
+
+examples
+"
+  Notice, the following examples only demonstrate the windos style (not its modal behavior).
+  the style is controlled by the systems windowManager, and might even be ignored by some.
+  (for example, the dialog- and normal styles often look the same).
+
+  The bahavior is controlled by ST/X, and controlled by the open vs. openModeless vs. openModal message.
+
+  Modeless:
+    regular style:
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v extent:200@200.
+        v open
+                                                            [exEnd]
+
+    dialog:
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v beDialogView.
+        v extent:200@200.
+        v open
+                                                            [exEnd]
+
+    popUp (always on top):
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v bePopUpView.
+        v extent:200@200.
+        v open
+                                                            [exEnd]
+
+    undecorated (looks loke popUp, but is not always on top):
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v beUndecorated.
+        v extent:200@200.
+        v open
+                                                            [exEnd]
+
+  Modal:
+    regular style:
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v extent:200@200.
+        v openModal
+                                                            [exEnd]
+
+    dialog:
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v beDialogView.
+        v extent:200@200.
+        v openModal
+                                                            [exEnd]
+
+    popUp (always on top):
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v bePopUpView.
+        v extent:200@200.
+        v openModal
+                                                            [exEnd]
+
+    undecorated (looks loke popUp, but is not always on top):
+                                                            [exBegin]
+        |v|
+
+        v := TopView new.
+        v beUndecorated.
+        v extent:200@200.
+        v openModal
+                                                            [exEnd]
+
+"
+! !
+
+!TopView class methodsFor:'class initialization'!
+
+initialize
+    MasterSlaveMask := 16r0F.
+    TypeMaster      := 16r01.
+    TypeSlave       := 16r02.
+    TypePartner     := 16r03.
+
+    WindowTypeMask  := 16rF0.
+    TypeDialog      := 16r10.
+    TypePopUp       := 16r20.
+    TypeUndecorated := 16r30.
+
+    "
+     self initialize
+    "
 ! !
 
 !TopView class methodsFor:'defaults'!
@@ -156,6 +271,14 @@
 
 !TopView methodsFor:'accessing-behavior'!
 
+beDialogView
+    type isInteger ifTrue:[
+        type := (type bitClear:WindowTypeMask) bitOr:TypeDialog.
+        ^ self.
+    ].
+    type := #dialog 
+!
+
 beIndependent
     "make this an independent view; i.e. remove any master/slave or partner
      attribute (this is the default).
@@ -170,6 +293,10 @@
      and also de/iconify together with their master(s).
      (i.e. they follow their master(s))."
 
+    type isInteger ifTrue:[
+        type := (type bitClear:MasterSlaveMask) bitOr:TypeMaster.
+        ^ self.
+    ].
     type := #master
 
     "
@@ -183,6 +310,10 @@
     "make this a partner-view. Each partner-view will automatically 
      close other partner views (within the same windowGroup) when closed."
 
+    type isInteger ifTrue:[
+        type := (type bitClear:MasterSlaveMask) bitOr:TypePartner.
+        ^ self.
+    ].
     type := #partner 
 
     "
@@ -204,11 +335,23 @@
     "Modified: 25.5.1996 / 11:44:48 / cg"
 !
 
+bePopUpView
+    type isInteger ifTrue:[
+        type := (type bitClear:WindowTypeMask) bitOr:TypePopUp.
+        ^ self.
+    ].
+    type := #popup 
+!
+
 beSlave
     "make this a slave-view. It will be closed automatically,
      whenever any master of the windowgroup is closed.
      See also: #bePartner"
 
+    type isInteger ifTrue:[
+        type := (type bitClear:MasterSlaveMask) bitOr:TypeSlave.
+        ^ self.
+    ].
     type := #slave 
 
     "
@@ -231,6 +374,14 @@
     "Modified: 25.5.1996 / 11:45:30 / cg"
 !
 
+beUndecorated
+    type isInteger ifTrue:[
+        type := (type bitClear:WindowTypeMask) bitOr:TypeUndecorated.
+        ^ self.
+    ].
+    type := nil
+!
+
 focusSequence:aCollectionOfSubcomponents
     "define the sequence for stepping through my components."
 
@@ -382,7 +533,7 @@
     screenCenter := device center.
     left := screenCenter x - (width // 2).
     top := screenCenter y - (height // 2).
-    type := #normal
+    type := 0
 !
 
 postRealize
@@ -471,9 +622,22 @@
     "Modified: 4.4.1997 / 14:44:39 / cg"
 !
 
+isDialogView
+    "return true if this is a dialog view"
+
+    type isInteger ifTrue:[
+        ^ (type bitAnd:WindowTypeMask) == TypeDialog
+    ].
+    ^ type == #dialog
+!
+
 isMaster
     "return true, if this is a masterView"
 
+    type isInteger ifTrue:[
+        ^ (type bitAnd:MasterSlaveMask) == TypeMaster
+    ].
+
     ^ type == #master
 !
 
@@ -487,13 +651,19 @@
 isPartner
     "return true, if this is a partnerView"
 
+    type isInteger ifTrue:[
+        ^ (type bitAnd:MasterSlaveMask) == TypePartner
+    ].
     ^ type == #partner
 !
 
 isPopUpView
-    "return true, since I want to come up without decoration 
-     and popUp to top immediately."
+    "return true if I am a popup view.
+     (i.e. I want to come up without decoration and popUp to top immediately)"
 
+    type isInteger ifTrue:[
+        ^ (type bitAnd:WindowTypeMask) == TypePopUp
+    ].
     ^ type == #popup
 
     "Created: 28.2.1997 / 22:12:30 / cg"
@@ -503,6 +673,9 @@
 isSlave
     "return true, if this is a slaveView"
 
+    type isInteger ifTrue:[
+        ^ (type bitAnd:MasterSlaveMask) == TypeSlave
+    ].
     ^ type == #slave
 !
 
@@ -514,6 +687,15 @@
     "Created: 22.3.1997 / 14:45:55 / cg"
 !
 
+isUndecoratedView
+    "return true if I am an undecorated view."
+
+    type isInteger ifTrue:[
+        ^ (type bitAnd:WindowTypeMask) == TypeUndecorated
+    ].
+    ^ false
+!
+
 preferredExtent
     "return my preferred extent - this is the minimum size I would like to have.
      The default here is the classes default extent,
@@ -530,13 +712,6 @@
     "Modified: 19.7.1996 / 20:45:41 / cg"
 !
 
-type
-    "return the views type. This is one of #normal,
-     #master, #slave or #partner."
-
-    ^ type
-!
-
 widthIncludingBorder
     "return the views overall-width"
 
@@ -547,6 +722,22 @@
     "for compatibility with applicationModels ... return the receiver"
 
     ^ self
+!
+
+windowStyle
+    "return a symbol describing my style (one of: #dialog, #popUp, #undecorated or #normal)
+     (used by the device as a decoration hint)"
+
+    |t|
+
+    type isInteger ifTrue:[
+        t := type bitAnd:WindowTypeMask.
+        t == TypeUndecorated ifTrue:[^ #undecorated].
+        t == TypeDialog ifTrue:[^ #dialog].
+        t == TypePopUp ifTrue:[^ #popUp].
+        ^ #normal
+    ].
+    ^ super windowStyle
 ! !
 
 !TopView methodsFor:'show & hide'!
@@ -785,13 +976,13 @@
         "/
         "/ if I am a master or partner, send to all slaves
         "/
-        (type == #master or:[type == #partner]) ifTrue:[
+        (self isMaster or:[self isPartner]) ifTrue:[
             aWindowGroup slavesDo:[:v | v perform:aSelector].
         ].
         "/
         "/ if I am a partner, send to all partners
         "/
-        type == #partner ifTrue:[
+        self isPartner ifTrue:[
             aWindowGroup partnersDo:[:v | v ~~ self ifTrue:[v perform:aSelector]].
         ].
     ].
@@ -825,5 +1016,7 @@
 !TopView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.84 2004-02-24 10:31:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.85 2004-03-09 14:29:32 cg Exp $'
 ! !
+
+TopView initialize!