DisplaySurface.st
changeset 8259 9328dbbffcb9
parent 8257 94cdb2927cb3
child 8349 1a56a0337599
--- a/DisplaySurface.st	Thu Jan 18 17:02:13 2018 +0100
+++ b/DisplaySurface.st	Thu Jan 18 17:17:05 2018 +0100
@@ -1,6 +1,6 @@
 "
  COPYRIGHT (c) 1992 by Claus Gittinger
-	      All Rights Reserved
+              All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -14,11 +14,11 @@
 "{ NameSpace: Smalltalk }"
 
 GraphicsMedium subclass:#DisplaySurface
-	instanceVariableNames:'viewBackground cursor eventMask moreAttributes renderer uuid
-		backed flags delegate updateRegion'
-	classVariableNames:'GotExposeFlagMask SaveUnderFlagMask'
-	poolDictionaries:''
-	category:'Graphics-Support'
+        instanceVariableNames:'viewBackground cursor eventMask moreAttributes renderer uuid
+                backed flags delegate updateRegion'
+        classVariableNames:'GotExposeFlagMask SaveUnderFlagMask'
+        poolDictionaries:''
+        category:'Graphics-Support'
 !
 
 !DisplaySurface class methodsFor:'documentation'!
@@ -26,7 +26,7 @@
 copyright
 "
  COPYRIGHT (c) 1992 by Claus Gittinger
-	      All Rights Reserved
+              All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -106,22 +106,22 @@
      newTop newBottom newLeft newRight|
 
     updateRegion isNil ifTrue:[
-	updateRegion := OrderedCollection with:newRectangle.
-	^ true
+        updateRegion := OrderedCollection with:newRectangle.
+        ^ true
     ].
     (updateRegion contains:[:oldRectangle | (newRectangle isContainedIn:oldRectangle)]) ifTrue:[
-	^ false.
+        ^ false.
     ].
 
     numRect := updateRegion size.
     numRect > 20 ifTrue:[
-	closure := updateRegion
-			inject:newRectangle
-			into:[:boundsSoFar :thisRectangle |
-				boundsSoFar quickMerge:thisRectangle
-			     ].
-	updateRegion := OrderedCollection with:closure.
-	^ true
+        closure := updateRegion
+                        inject:newRectangle
+                        into:[:boundsSoFar :thisRectangle |
+                                boundsSoFar quickMerge:thisRectangle
+                             ].
+        updateRegion := OrderedCollection with:closure.
+        ^ true
     ].
 
     lastRect := updateRegion at:numRect.
@@ -135,24 +135,24 @@
     newRight := newRectangle right.
 
     lastTop = newTop ifTrue:[
-	lastBottom = newBottom ifTrue:[
-	    lastLeft <= newLeft ifTrue:[
-		lastRight >= newLeft ifTrue:[
-		    updateRegion at:numRect put:(lastRect copy right:newRight).
-		    ^ false "/ true
-		]
-	    ]
-	].
+        lastBottom = newBottom ifTrue:[
+            lastLeft <= newLeft ifTrue:[
+                lastRight >= newLeft ifTrue:[
+                    updateRegion at:numRect put:(lastRect copy right:newRight).
+                    ^ false "/ true
+                ]
+            ]
+        ].
     ].
     lastLeft = newLeft ifTrue:[
-	lastRight = newRight ifTrue:[
-	    lastTop <= newTop ifTrue:[
-		lastBottom >= newTop ifTrue:[
-		    updateRegion at:numRect put:(lastRect copy bottom:newBottom).
-		    ^ false "/ true
-		]
-	    ]
-	].
+        lastRight = newRight ifTrue:[
+            lastTop <= newTop ifTrue:[
+                lastBottom >= newTop ifTrue:[
+                    updateRegion at:numRect put:(lastRect copy bottom:newBottom).
+                    ^ false "/ true
+                ]
+            ]
+        ].
     ].
 
     updateRegion add:newRectangle.
@@ -513,9 +513,9 @@
 
     id := cursor id.
     id isNil ifTrue:[
-	'DisplaySurface [warning]: nil cursorId ignored; shape=' errorPrint.
-	cursor shape errorPrintCR.
-	^ self.
+        'DisplaySurface [warning]: nil cursorId ignored; shape=' errorPrint.
+        cursor shape errorPrintCR.
+        ^ self.
     ].
     gc setCursorId:id .
 !
@@ -576,19 +576,19 @@
     |ret|
 
     cursor == aCursor ifTrue:[
-	^ aBlock value
+        ^ aBlock value
     ].
 
     self
-	withCursor:aCursor do:[
-	    |timeToExecute remainingShowTime|
-
-	    timeToExecute := Time millisecondsToRun:[ ret := aBlock value].
-	    remainingShowTime := UserPreferences current waitCursorVisibleTime - timeToExecute.
-	    remainingShowTime > 0 ifTrue:[
-		Delay waitForMilliseconds:remainingShowTime.
-	    ].
-	].
+        withCursor:aCursor do:[
+            |timeToExecute remainingShowTime|
+
+            timeToExecute := Time millisecondsToRun:[ ret := aBlock value].
+            remainingShowTime := UserPreferences current waitCursorVisibleTime - timeToExecute.
+            remainingShowTime > 0 ifTrue:[
+                Delay waitForMilliseconds:remainingShowTime.
+            ].
+        ].
     ^ ret.
 
     "Modified (comment): / 12-09-2011 / 12:14:29 / cg"
@@ -723,8 +723,8 @@
      how may true/false, but also #always, #whenMapped or #never."
 
     how ~~ backed ifTrue:[
-	backed := how.
-	super backingStore:how.
+        backed := how.
+        super backingStore:how.
     ]
 !
 
@@ -818,9 +818,9 @@
      - used for temporary views (i.e. PopUps and ModalBoxes)"
 
     aBoolean ifTrue:[
-	flags := flags bitOr:SaveUnderFlagMask.
+        flags := flags bitOr:SaveUnderFlagMask.
     ] ifFalse:[
-	flags := flags bitClear:SaveUnderFlagMask.
+        flags := flags bitClear:SaveUnderFlagMask.
     ].
     gc saveUnder:aBoolean.
 !
@@ -998,9 +998,9 @@
     |oldMenu|
 
     (oldMenu := self getMiddleButtonMenu) notNil ifTrue:[
-	oldMenu isArray ifFalse:[
-	    oldMenu destroy
-	]
+        oldMenu isArray ifFalse:[
+            oldMenu destroy
+        ]
     ].
     self setMiddleButtonMenu:aMenu
 
@@ -1364,7 +1364,7 @@
 
     windowGroup := self windowGroup.
     windowGroup notNil ifTrue:[
-	windowGroup sensor compressMotionEvents:aBoolean.
+        windowGroup sensor compressMotionEvents:aBoolean.
     ].
 !
 
@@ -1409,7 +1409,7 @@
 
     eventMask := eventMask bitAnd:(self graphicsDevice eventMaskFor:anEventSymbol) bitInvert.
     self drawableId notNil ifTrue:[
-	self graphicsDevice setEventMask:eventMask in:self drawableId
+        self graphicsDevice setEventMask:eventMask in:self drawableId
     ]
 !
 
@@ -1470,7 +1470,7 @@
 
     eventMask := (eventMask ? 0) bitOr:(self graphicsDevice eventMaskFor:anEventSymbol).
     self drawableId notNil ifTrue:[
-	self graphicsDevice setEventMask:eventMask in:self drawableId
+        self graphicsDevice setEventMask:eventMask in:self drawableId
     ]
 !
 
@@ -1518,9 +1518,9 @@
     "dispatch an event"
 
     ^ self
-	dispatchEvent:event
-	withFocusOn:nil
-	delegate:true
+        dispatchEvent:event
+        withFocusOn:nil
+        delegate:true
 
     "Modified: / 20.5.1998 / 23:01:15 / cg"
 !
@@ -1530,11 +1530,11 @@
 
     "/ XXXX: TO BE ELIMINATED
     ^ self
-	dispatchEvent:nil
-	type:type
-	arguments:arguments
-	withFocusOn:nil
-	delegate:true
+        dispatchEvent:nil
+        type:type
+        arguments:arguments
+        withFocusOn:nil
+        delegate:true
 
     "Modified: / 20.5.1998 / 22:50:31 / cg"
 !
@@ -1788,9 +1788,9 @@
     "dispatch the event"
 
     ^ self
-	dispatchEvent:event
-	withFocusOn:focusViewOrNil
-	delegate:true
+        dispatchEvent:event
+        withFocusOn:focusViewOrNil
+        delegate:true
 
     "Modified: / 20.5.1998 / 23:01:15 / cg"
 !
@@ -1799,11 +1799,11 @@
     "dispatch the event"
 
     ^ self
-	dispatchEvent:event
-	type:event type
-	arguments:(event arguments)
-	withFocusOn:focusViewOrNil
-	delegate:doDelegate
+        dispatchEvent:event
+        type:event type
+        arguments:(event arguments)
+        withFocusOn:focusViewOrNil
+        delegate:doDelegate
 
     "Modified: / 20.5.1998 / 23:01:15 / cg"
 ! !
@@ -1856,9 +1856,9 @@
 
 buttonRelease:button x:x y:y
     (button == 2) ifTrue:[
-	UserPreferences current showRightButtonMenuOnRelease ifTrue:[
-	    self activateMenu.
-	].
+        UserPreferences current showRightButtonMenuOnRelease ifTrue:[
+            self activateMenu.
+        ].
     ].
 !
 
@@ -1921,10 +1921,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	].
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ].
     ].
     self buttonMotion:state x:lx y:ly
 
@@ -1949,10 +1949,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	].
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ].
     ].
     self buttonMultiPress:butt x:lx y:ly
 
@@ -1977,10 +1977,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	].
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ].
     ].
     self buttonPress:butt x:lx y:ly
 
@@ -2005,10 +2005,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	].
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ].
     ].
     self buttonRelease:butt x:lx y:ly
 
@@ -2033,10 +2033,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	].
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ].
     ].
     self buttonShiftPress:butt x:lx y:ly
 
@@ -2063,10 +2063,10 @@
     lh := h.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx := currentTransformation applyInverseToX:lx.
-	ly := currentTransformation applyInverseToY:ly.
-	lw := currentTransformation applyInverseScaleX:lw.
-	lh := currentTransformation applyInverseScaleY:lh.
+        lx := currentTransformation applyInverseToX:lx.
+        ly := currentTransformation applyInverseToY:ly.
+        lw := currentTransformation applyInverseScaleX:lw.
+        lh := currentTransformation applyInverseScaleY:lh.
     ].
     self exposeX:lx y:ly width:lw height:lh
 
@@ -2093,10 +2093,10 @@
     lh := h.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx := currentTransformation applyInverseToX:lx.
-	ly := currentTransformation applyInverseToY:ly.
-	lw := currentTransformation applyInverseScaleX:lw.
-	lh := currentTransformation applyInverseScaleY:lh.
+        lx := currentTransformation applyInverseToX:lx.
+        ly := currentTransformation applyInverseToY:ly.
+        lw := currentTransformation applyInverseScaleX:lw.
+        lh := currentTransformation applyInverseScaleY:lh.
     ].
     self graphicsExposeX:lx y:ly width:lw height:lh final:final
 
@@ -2121,10 +2121,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	]
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ]
     ].
     self keyPress:key x:lx y:ly
 
@@ -2149,10 +2149,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	]
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ]
     ].
     self keyRelease:key x:lx y:ly
 
@@ -2177,10 +2177,10 @@
     ly := y.
     currentTransformation := gc transformation.
     currentTransformation notNil ifTrue:[
-	lx notNil ifTrue:[
-	    lx := currentTransformation applyInverseToX:lx.
-	    ly := currentTransformation applyInverseToY:ly.
-	]
+        lx notNil ifTrue:[
+            lx := currentTransformation applyInverseToX:lx.
+            ly := currentTransformation applyInverseToY:ly.
+        ]
     ].
     self pointerEnter:state x:lx y:ly
 
@@ -2225,20 +2225,20 @@
     |action rest restKey keyCommands|
 
     (keyCommands := self keyCommands) notNil ifTrue:[
-	action := keyCommands at:key ifAbsent:[nil].
-	action value
+        action := keyCommands at:key ifAbsent:[nil].
+        action value
     ].
 
     key isSymbol ifTrue:[
-	(key startsWith:'Basic') ifTrue:[
-	    "/ an unhandled BasicFoo key;
-	    "/ retry as Foo
-	    rest := key withoutPrefix:'Basic'.
-	    restKey := rest asSymbolIfInterned.
-	    restKey notNil ifTrue:[
-		self keyPress:restKey x:x y:y
-	    ]
-	].
+        (key startsWith:'Basic') ifTrue:[
+            "/ an unhandled BasicFoo key;
+            "/ retry as Foo
+            rest := key withoutPrefix:'Basic'.
+            restKey := rest asSymbolIfInterned.
+            restKey notNil ifTrue:[
+                self keyPress:restKey x:x y:y
+            ]
+        ].
     ].
 
     "Modified: 6.11.1996 / 17:51:15 / cg"
@@ -2248,12 +2248,12 @@
     "default action is to do nothing"
 
     key isSymbol ifTrue:[
-	(key startsWith:#Basic) ifTrue:[
-	    "/ an unhandled BasicFoo key;
-	    "/ retry as Foo
-
-	    self keyRelease:(key copyFrom:#Basic size) asSymbol x:x y:y
-	].
+        (key startsWith:#Basic) ifTrue:[
+            "/ an unhandled BasicFoo key;
+            "/ retry as Foo
+
+            self keyRelease:(key copyFrom:#Basic size) asSymbol x:x y:y
+        ].
     ].
 
     ^ self
@@ -2408,7 +2408,7 @@
 
 prepareForReinit
     gc notNil ifTrue:[
-	gc prepareForReinit.
+        gc prepareForReinit.
     ].
 !
 
@@ -2450,7 +2450,7 @@
     |keyCommands|
 
     (keyCommands := self keyCommands) isNil ifTrue:[
-	self keyCommands:(keyCommands := IdentityDictionary new).
+        self keyCommands:(keyCommands := IdentityDictionary new).
     ].
     keyCommands at:aKey put:aBlock
 !
@@ -2467,7 +2467,7 @@
     |keyCommands|
 
     (keyCommands := self keyCommands) notNil ifTrue:[
-	keyCommands removeKey:aKey ifAbsent:nil
+        keyCommands removeKey:aKey ifAbsent:nil
     ]
 ! !
 
@@ -2502,7 +2502,7 @@
 
     windowGroup := self windowGroup.
     windowGroup notNil ifTrue:[
-	(windowGroup sensor hasExposeEventFor:self) ifTrue:[^ true].
+        (windowGroup sensor hasExposeEventFor:self) ifTrue:[^ true].
     ].
     ^ device eventPending:#expose for:gc drawableId
 
@@ -2615,7 +2615,11 @@
 !
 
 beepInEditor
-    "output an audible beep or bell on my screen device"
+    "output an audible beep or bell on my screen device, if enabled.
+
+     Beep to wakeup the user after some error/not found condition in an editor.
+     Use this ONLY to beep in response to a bad user operation (not system failure beeps).
+     Can be disabled via the settings if too annoying"
 
     device beepInEditor