SimpleView.st
changeset 5494 c02b3c579300
parent 5456 0df0f5ce9d91
child 5529 1723e8c112f3
--- a/SimpleView.st	Thu Nov 05 18:50:34 2009 +0100
+++ b/SimpleView.st	Fri Nov 06 17:45:25 2009 +0100
@@ -10129,7 +10129,7 @@
     "Modified: / 9.7.1998 / 01:20:57 / cg"
 !
 
-openModal:aBlock inGroup:mainGroup
+openModal:aBlock inGroup:aWindowGroup
     "create a new windowgroup, but start processing in the current process -
      actually suspending event processing for the main group.
      Stay in this modal loop while aBlock evaluates to true AND the receiver is
@@ -10138,143 +10138,140 @@
      This makes any interaction with the current window impossible -
      however, other views (in other windowgroups) still work."
 
-    |tops mainView mainViewID previousGroup |
+    |tops mainView mainViewID previousGroup mainGroup|
 
     self isPopUpView ifFalse:[
-	"/ the following allows for knowledgable programmers to suppress dialog boxes,
-	"/ or to patch common controls right before opening...
-	(Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:self) == #abort ifTrue:[
-	    ^ self
-	].
-
-	mainGroup notNil ifTrue:[
-	    (tops := mainGroup topViews) notNil ifTrue:[
-		tops notEmpty ifTrue:[
-		    mainView := tops detect:[:v| v shown] ifNone:nil.
-		    mainView notNil ifTrue:[
-			mainViewID := mainView id.
-		    ]
-		]
-	    ].
-	].
-
-	mainView notNil ifTrue:[
-	    mainView activate; setForegroundWindow.
-	].
-
-	ModalBox usingTransientViews ifTrue:[
-	    "make view only transient, if there is a visible topView.
-	     If none of them is visible, we do want an icon for ourself"
-
-	    mainViewID isNil ifTrue:[
-		self origin:(device center - (self extent//2))
-	    ].
-
-	    drawableId isNil ifTrue:[self create].
-	    mainView notNil ifTrue:[
-		device setTransient:drawableId for:mainViewID.
-	    ].
-	].
+        "/ the following allows for knowledgable programmers to suppress dialog boxes,
+        "/ or to patch common controls right before opening...
+        (Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:self) == #abort ifTrue:[
+            ^ self
+        ].
+
+        aWindowGroup notNil ifTrue:[
+            (tops := aWindowGroup topViews) notEmptyOrNil ifTrue:[
+                mainView := tops detect:[:v| v shown] ifNone:nil.
+                mainView notNil ifTrue:[
+                    mainViewID := mainView id.
+                ]
+            ].
+        ].
+
+        mainView notNil ifTrue:[
+            mainView activate; setForegroundWindow.
+        ].
+
+        ModalBox usingTransientViews ifTrue:[
+            "make view only transient, if there is a visible topView.
+             If none of them is visible, we do want an icon for ourself"
+
+            mainViewID isNil ifTrue:[
+                self origin:(device center - (self extent//2))
+            ].
+
+            drawableId isNil ifTrue:[self create].
+            mainView notNil ifTrue:[
+                device setTransient:drawableId for:mainViewID.
+            ].
+        ].
     ].
 
     self raise.
 
     Processor activeProcessIsSystemProcess ifTrue:[
-	"
-	 put myself into the modal group, let it handle events for
-	 me as well. This is only a half way solution, since the view
-	 is not modal at all ... however, the only situation
-	 where this happens is with modal boxes popped while in a
-	 modal browser. You will forgive me for that inconvenience.
-	"
-	windowGroup := mainGroup.
-	mainGroup notNil ifTrue:[mainGroup addTopView:self].
-	self realize
+        "
+         put myself into the modal group, let it handle events for
+         me as well. This is only a half way solution, since the view
+         is not modal at all ... however, the only situation
+         where this happens is with modal boxes popped while in a
+         modal browser. You will forgive me for that inconvenience.
+        "
+        windowGroup := aWindowGroup.
+        aWindowGroup notNil ifTrue:[aWindowGroup addTopView:self].
+        self realize
     ] ifFalse:[
-	previousGroup := WindowGroup activeGroup.
-
-	"
-	 show a stop-cursor in the main group
-	"
-	mainGroup notNil ifTrue:[
-	    self isPopUpView ifFalse:[
-		mainGroup showCursor:(Cursor stop).
-		(previousGroup notNil and:[previousGroup ~~ mainGroup]) ifTrue:[
-		    previousGroup showCursor:(Cursor stop).
-		].
-	    ]
-	].
-
-	"
-	 create a new window group and put myself into it
-	"
-	windowGroup := self windowGroupClass new.
-	windowGroup addTopView:self.
-	windowGroup setPreviousGroup:previousGroup.
-
-	superView notNil ifTrue:[
-	    "/
-	    "/ special: this is a modal subview,
-	    "/ prevent the view from reassigning its windowGroup when realized
-	    "/ (subviews normally place themself into the superviews group)
-	    "/
-	    windowGroup isForModalSubview:true.
-	].
-
-	"
-	 go dispatch events in this new group
-	 (thus current windowgroup is blocked from interaction)
-	"
-	AbortOperationRequest handle:[:ex |
-	    AbortOperationRequest handle:[:ex2 |
-		"/ an aborted hide (user confirmation ?)
-		self breakPoint:#cg.
-		ex proceed
-	    ] do:[
-		self hide.
-		self realized ifTrue:[
-		    "/ self halt. "/ hide handled and closeRequest not wanted:
-		    ex proceed
-		].
-"/                ex return
-	    ].
-	    ex return.
-	] do:[
-	    [
-		[
-		    windowGroup startupModal:[realized and:aBlock] forGroup:mainGroup
-		] ifCurtailed:[
-		    self hide.
-		]
-	    ] ensure:[
-		mainGroup notNil ifTrue:[
-		    mainGroup graphicsDevice sync.  "thats a round trip - make sure that all drawing has been processed"
-		    "/ ensure that eventListener runs here ...
-		    Delay waitForSeconds:0.05.
-		    mainGroup processExposeEvents.
-
-		    ReturnFocusWhenClosingModalBoxes ifTrue:[
-			"
-			 return the input focus to the previously active group's top.
-			 This helps with windowmanagers which need an explicit click
-			 on the view for the focus.
-			"
-			tops := mainGroup topViews.
-			(tops notEmptyOrNil) ifTrue:[
-			    tops first getKeyboardFocus
-			].
-		    ].
-
-		    "
-		     restore cursors in the main group
-		    "
-		    mainGroup restoreCursors.
-		    (previousGroup notNil and:[previousGroup ~~ mainGroup]) ifTrue:[
-			previousGroup restoreCursors.
-		    ].
-		]
-	    ]
-	].
+        previousGroup := WindowGroup activeGroup.
+
+        "
+         show a stop-cursor in the suspended window groups
+        "
+        (aWindowGroup notNil and:[self isPopUpView not]) ifTrue:[
+            mainGroup := aWindowGroup mainGroup.
+            mainGroup showCursor:(Cursor stop).
+            previousGroup ~~ mainGroup ifTrue:[
+                previousGroup showCursor:(Cursor stop).
+            ].    
+        ].
+
+        "
+         create a new window group and put myself into it
+        "
+        windowGroup := self windowGroupClass new.
+        windowGroup addTopView:self.
+        windowGroup setPreviousGroup:previousGroup.
+
+        superView notNil ifTrue:[
+            "/
+            "/ special: this is a modal subview,
+            "/ prevent the view from reassigning its windowGroup when realized
+            "/ (subviews normaly place themself into the superviews group)
+            "/
+            windowGroup isForModalSubview:true.
+        ].
+
+        "
+         go dispatch events in this new group
+         (thus current windowgroup is blocked from interaction)
+        "
+        AbortOperationRequest handle:[:ex |
+            AbortOperationRequest handle:[:ex2 |
+                "/ an aborted hide (user confirmation ?)
+                self breakPoint:#cg.
+                ex proceed
+            ] do:[
+                self hide.
+                self realized ifTrue:[
+                    "/ self halt. "/ hide handled and closeRequest not wanted:
+                    ex proceed
+                ].
+            ].
+        ] do:[
+            [
+                [
+                    windowGroup startupModal:[realized and:aBlock] forGroup:aWindowGroup
+                ] ifCurtailed:[
+                    self hide.
+                ]
+            ] ensure:[
+                aWindowGroup notNil ifTrue:[
+                    aWindowGroup graphicsDevice sync.  "thats a round trip - make sure that all drawing has been processed"
+                    "/ ensure that eventListener runs here ...
+                    Delay waitForSeconds:0.05.
+                    aWindowGroup processExposeEvents.
+
+                    ReturnFocusWhenClosingModalBoxes ifTrue:[
+                        "
+                         return the input focus to the previously active group's top.
+                         This helps with windowmanagers which need an explicit click
+                         on the view for the focus.
+                        "
+                        tops := aWindowGroup topViews.
+                        (tops notEmptyOrNil) ifTrue:[
+                            tops first getKeyboardFocus
+                        ].
+                    ].
+
+                    "
+                     restore cursors in the changed groups
+                    "
+                    mainGroup notNil ifTrue:[
+                        mainGroup restoreCursors.
+                        previousGroup ~~ mainGroup ifTrue:[
+                            previousGroup restoreCursors.
+                        ].    
+                    ].
+                ]
+            ]
+        ].
     ]
 
     "Created: / 10-12-1995 / 14:06:14 / cg"
@@ -10563,11 +10560,11 @@
 !SimpleView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.649 2009-11-04 11:23:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.650 2009-11-06 16:45:25 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.649 2009-11-04 11:23:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.650 2009-11-06 16:45:25 stefan Exp $'
 ! !
 
 SimpleView initialize!