SimpleView.st
changeset 7618 50ccaeb61be1
parent 7617 3bcc92c94b66
child 7622 c75552e285e5
--- a/SimpleView.st	Thu Oct 13 02:15:49 2016 +0200
+++ b/SimpleView.st	Thu Oct 13 16:40:12 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -11227,7 +11229,7 @@
     "Modified: / 9.7.1998 / 01:20:57 / cg"
 !
 
-openModal:aBlock inGroup:aWindowGroup
+openModal:aBlock inGroup:activeWindowGroup
     "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
@@ -11241,9 +11243,9 @@
     StandardSystemView cancelAutoRaise.
 
     isPopup := self isPopUpView.
-    aWindowGroup notNil ifTrue:[
-	mainGroup := aWindowGroup mainGroup.
-	mainView := mainGroup mainView.
+    activeWindowGroup notNil ifTrue:[
+        mainGroup := activeWindowGroup mainGroup.
+        mainView := mainGroup mainView.
     ].
 
     "/ set the windowgroup BEFORE sending the aboutToOpen notification
@@ -11251,161 +11253,161 @@
     "/ this allows for the handler to enqueue an event,
     "/ or to add event hooks.
     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 := aWindowGroup.
-	aWindowGroup notNil ifTrue:[aWindowGroup addTopView:self].
+        "
+         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 := activeWindowGroup.
+        activeWindowGroup notNil ifTrue:[activeWindowGroup addTopView:self].
     ] ifFalse:[
-	previousGroup := WindowGroup activeGroup.
+        previousGroup := activeWindowGroup.
     ].
 
     windowGroup isNil ifTrue:[
-	"/ create a new window group put myself into it
-	windowGroup := self windowGroupClass new.
-	windowGroup
-	    addTopView:self;
-	    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.
-	].
+        "/ create a new window group put myself into it
+        windowGroup := self windowGroupClass new.
+        windowGroup
+            addTopView:self;
+            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.
+        ].
     ].
 
     makeTransient := true.
     transientFor := mainView.
     isPopup 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
-	].
-	windowGroup isNil ifTrue:[
-	    "/ the aboutToOpenBoxNotificationSignal handler destroyed me (although it should proceed with #abort)!!
-	    "/ Transcript showCR:(self class name,': box opening suppressed by aboutToOpenBoxNotificationSignal handler').
-	    ^ self.
-	].
-
-	"/ the following allows for hooks to add a bell sound or other whenever a dialog opens
-	device modalWindowListenersDo:[:listener | listener aboutToOpenWindow:self].
-
-	"/ the following raises the corresponding mainview, so the dialog shows above
-	"/ any currently covered view. However, be careful if being debugged, or if this dialog
-	"/ is opened by an already open dialog.
-	(mainView isNil or:[mainView windowGroup isInModalLoop]) ifTrue:[
-	    (previousGroup notNil and:[previousGroup isModal]) ifTrue:[
-		transientFor := previousGroup mainView.
-	    ].
-	].
-
-	transientFor notNil ifTrue:[
-	    (transientFor windowGroup isInModalLoop
-		or:[ transientFor windowGroup isDebugged
-		or:[ WindowGroup activeGroup isDebugged
-	    ]]) ifFalse:[
-		self tracePoint:#cg message:'activate'.
-		self debuggingCodeFor:#cg is:[ Transcript showCR:transientFor; showCR:transientFor windowGroup. ].
-		transientFor activate; setForegroundWindow.
+        "/ 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
+        ].
+        windowGroup isNil ifTrue:[
+            "/ the aboutToOpenBoxNotificationSignal handler destroyed me (although it should proceed with #abort)!!
+            "/ Transcript showCR:(self class name,': box opening suppressed by aboutToOpenBoxNotificationSignal handler').
+            ^ self.
+        ].
+
+        "/ the following allows for hooks to add a bell sound or other whenever a dialog opens
+        device modalWindowListenersDo:[:listener | listener aboutToOpenWindow:self].
+
+        "/ the following raises the corresponding mainview, so the dialog shows above
+        "/ any currently covered view. However, be careful if being debugged, or if this dialog
+        "/ is opened by an already open dialog.
+        (mainView isNil or:[mainView windowGroup isInModalLoop]) ifTrue:[
+            (previousGroup notNil and:[previousGroup isModal]) ifTrue:[
+                transientFor := previousGroup mainView.
+            ].
+        ].
+
+        transientFor notNil ifTrue:[
+            (transientFor windowGroup isInModalLoop
+                or:[ transientFor windowGroup isDebugged
+                or:[ activeWindowGroup isDebugged
+            ]]) ifFalse:[
+                self tracePoint:#cg message:'activate'.
+                self debuggingCodeFor:#cg is:[ Transcript showCR:transientFor; showCR:transientFor windowGroup. ].
+                transientFor activate; setForegroundWindow.
 "/            ] ifTrue:[
 "/                makeTransient := false.
-	    ]
-	].
+            ]
+        ].
     ].
     "/ makeTransient ifTrue:[
-	transientFor notNil ifTrue:[
-	    "set the transient property.
-	     This is currently used for X, to tell the Window Manager
-	     That this view should be always on top of the mainView"
-	    self drawableId isNil ifTrue:[self create].
-	    device setTransient:self drawableId for:transientFor id.
-	].
+        transientFor notNil ifTrue:[
+            "set the transient property.
+             This is currently used for X, to tell the Window Manager
+             That this view should be always on top of the mainView"
+            self drawableId isNil ifTrue:[self create].
+            device setTransient:self drawableId for:transientFor id.
+        ].
     "/ ].
 
     self raise.
 
     Processor activeProcessIsSystemProcess ifTrue:[
-	self realize
+        self realize
     ] ifFalse:[
-	"
-	 show a stop-cursor in the suspended window groups
-	"
-	(mainGroup notNil and:[isPopup not]) ifTrue:[
-	    mainGroup showCursor:(Cursor stop).
-	    previousGroup ~~ mainGroup ifTrue:[
-		previousGroup showCursor:(Cursor stop).
-	    ].
-	    cursorChanged := true.
-	].
-
-	"
-	 go dispatch events in this new group
-	 (thus current windowgroup is blocked from interaction)
-	"
-	AbortOperationRequest handle:[:ex |
-	    "/ the dialog/popup is aborted - hide it. Care for another abort during the hide.
-	    AbortOperationRequest handle:[:ex2 |
-		"/ an aborted hide (possibly due to a cancelled user confirmation or similar)
-		self breakPoint:#cg.
-		ex exit.
-	    ] do:[
-		self hide.
-		realized ifTrue:[
-		    "/ self halt. "/ hide handled and closeRequest not wanted:
-		    ex exit.
-		].
-	    ].
-	] do:[
-	    [
-		[
-		    windowGroup startupModal:[realized and:aBlock] forGroup:aWindowGroup
-		] ifCurtailed:[
-		    self hide.
-		]
-	    ] ensure:[
-		aWindowGroup notNil ifTrue:[
-		    aWindowGroup graphicsDevice sync.  "that's a round trip - make sure that all drawing has been processed"
-		    "/ ensure that eventListener runs here ...
-		    Delay waitForMilliseconds:50.
-		    aWindowGroup processExposeEvents.
-
-		    (self isPopUpView or:[ReturnFocusWhenClosingModalBoxes]) ifTrue:[
-			"
-			 return the input focus to the previously active group's top.
-			 This helps with window managers which need an explicit click
-			 on the view for the focus.
-			 Only do this, if the previous group is still having the focus.
-			 (i.e. no other view was opened in the meantime)
-			"
-			aWindowGroup graphicsDevice focusView isNil ifTrue:[
-			    tops := aWindowGroup topViews.
-			    (tops notEmptyOrNil) ifTrue:[
-				tops first getKeyboardFocus
-			    ].
-			].
-		    ].
-
-		    "
-		     restore cursors in the changed groups
-		    "
-		    cursorChanged notNil ifTrue:[
-			mainGroup restoreCursors.
-			previousGroup ~~ mainGroup ifTrue:[
-			    previousGroup restoreCursors.
-			].
-		    ].
-		].
-		Dialog boxClosedNotificationSignal raiseRequestWith:self.
-	    ]
-	].
+        "
+         show a stop-cursor in the suspended window groups
+        "
+        (mainGroup notNil and:[isPopup not]) ifTrue:[
+            mainGroup showCursor:(Cursor stop).
+            previousGroup ~~ mainGroup ifTrue:[
+                previousGroup showCursor:(Cursor stop).
+            ].
+            cursorChanged := true.
+        ].
+
+        "
+         go dispatch events in this new group
+         (thus current windowgroup is blocked from interaction)
+        "
+        AbortOperationRequest handle:[:ex |
+            "/ the dialog/popup is aborted - hide it. Care for another abort during the hide.
+            AbortOperationRequest handle:[:ex2 |
+                "/ an aborted hide (possibly due to a cancelled user confirmation or similar)
+                self breakPoint:#cg.
+                ex exit.
+            ] do:[
+                self hide.
+                realized ifTrue:[
+                    "/ self halt. "/ hide handled and closeRequest not wanted:
+                    ex exit.
+                ].
+            ].
+        ] do:[
+            [
+                [
+                    windowGroup startupModal:[realized and:aBlock] forGroup:activeWindowGroup
+                ] ifCurtailed:[
+                    self hide.
+                ]
+            ] ensure:[
+                activeWindowGroup notNil ifTrue:[
+                    activeWindowGroup graphicsDevice sync.  "that's a round trip - make sure that all drawing has been processed"
+                    "/ ensure that eventListener runs here ...
+                    Delay waitForMilliseconds:50.
+                    activeWindowGroup processExposeEvents.
+
+                    (self isPopUpView or:[ReturnFocusWhenClosingModalBoxes]) ifTrue:[
+                        "
+                         return the input focus to the previously active group's top.
+                         This helps with window managers which need an explicit click
+                         on the view for the focus.
+                         Only do this, if the previous group is still having the focus.
+                         (i.e. no other view was opened in the meantime)
+                        "
+                        activeWindowGroup graphicsDevice focusView isNil ifTrue:[
+                            tops := activeWindowGroup topViews.
+                            (tops notEmptyOrNil) ifTrue:[
+                                tops first getKeyboardFocus
+                            ].
+                        ].
+                    ].
+
+                    "
+                     restore cursors in the changed groups
+                    "
+                    cursorChanged notNil ifTrue:[
+                        mainGroup restoreCursors.
+                        previousGroup ~~ mainGroup ifTrue:[
+                            previousGroup restoreCursors.
+                        ].
+                    ].
+                ].
+                Dialog boxClosedNotificationSignal raiseRequestWith:self.
+            ]
+        ].
     ]
 
     "Created: / 10-12-1995 / 14:06:14 / cg"