PseudoV.st
changeset 89 ea2bf46eb669
parent 85 32687feafcc1
child 93 92f1ec8b419e
--- a/PseudoV.st	Mon Feb 06 01:30:10 1995 +0100
+++ b/PseudoV.st	Mon Feb 06 01:38:04 1995 +0100
@@ -26,7 +26,7 @@
 COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/Attic/PseudoV.st,v 1.21 1994-11-22 23:09:18 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/PseudoV.st,v 1.22 1995-02-06 00:37:41 claus Exp $
 '!
 
 !PseudoView class methodsFor:'documentation'!
@@ -47,7 +47,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/Attic/PseudoV.st,v 1.21 1994-11-22 23:09:18 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/PseudoV.st,v 1.22 1995-02-06 00:37:41 claus Exp $
 "
 !
 
@@ -128,9 +128,6 @@
 	viewBackground := viewBackground on:device
     ].
     super recreate.
-"/    viewBackground isColor ifTrue:[
-"/        viewBackground := viewBackground on:device
-"/    ].
     cursor := cursor on:device.
     exposePending := false
 !
@@ -202,7 +199,10 @@
 !
 
 viewBackground:something
-    "set the viewBackground to something, a color, image or form"
+    "set the viewBackground to something, a color, image or form.
+     The viewBackground is the color or pattern with which exposed
+     regions are filled - do not confuse this with the drawing background
+     color, which is used with opaque drawing."
 
     viewBackground ~~ something ifTrue:[
 	viewBackground := something.
@@ -518,6 +518,12 @@
     ^ false
 !
 
+getKeyboardFocus
+    "tell the Display to assign keyboard focus to the receiver"
+
+    device setInputFocusTo:drawableId.
+!
+
 eventMask
     "return a (numeric) mask of allowed events -
      this is X-specific and will be removed / replaced by symbolic values)"
@@ -607,8 +613,11 @@
     self paint:viewBackground.
 
     viewBackground isColor ifFalse:[
-"/        self setMaskOriginX:0 y:0
-	self setMaskOriginX:self viewOrigin x negated y:self viewOrigin y negated
+	gcId notNil ifTrue:[
+	    device setMaskOriginX:self viewOrigin x rounded negated
+				y:self viewOrigin y rounded negated
+			       in:gcId
+	].
     ].
     "
      fill in device coordinates - not logical coordinates
@@ -628,8 +637,11 @@
     self paint:viewBackground.
 
     viewBackground isColor ifFalse:[
-"/        self setMaskOriginX:0 y:0
-	self setMaskOriginX:self viewOrigin x negated y:self viewOrigin y negated
+	gcId notNil ifTrue:[
+	    device setMaskOriginX:self viewOrigin x rounded negated
+				y:self viewOrigin y rounded negated
+			       in:gcId
+	].
     ].
     self fillRectangleX:x y:y width:w height:h.
     self paint:oldPaint
@@ -832,12 +844,18 @@
 
 !PseudoView methodsFor:'queries'!
 
+isView
+    "return true, if the receiver is a view"
+
+    ^ true
+!
+
 exposeEventPending
-    "return true, if an expose event is pending.
-     Dont use it, since it does not honor the windowGroup, but
-     goes directly to the device instead.
-     Actually, its a historical leftover"
+    "return true, if an expose event is pending."
 
+    |sensor|
+
+    ((sensor := self sensor) notNil and:[sensor hasDamageFor:self]) ifTrue:[^ true].
     ^ device eventPending:#expose for:drawableId
 !
 
@@ -861,6 +879,139 @@
     ^ device eventPending:#buttonRelease for:drawableId
 ! !
 
+!PseudoView methodsFor:'selection handling '!
+
+selectionClear
+    "someone else has the selection"
+
+    Smalltalk at:#CopyBuffer put:nil.
+!
+
+getSelection
+    "return the object selection - either the local one, or the displays
+     selection buffer."
+
+    |sel|
+
+    sel := Smalltalk at:#CopyBuffer.
+    sel isNil ifTrue:[
+	sel := device getSelectionFor:drawableId.
+	sel isNil ifTrue:[^ nil].
+    ].
+    ^ sel
+!
+
+getTextSelection
+    "return the text selection - either the local one, or the displays
+     selection buffer."
+
+    |sel|
+
+    sel := Smalltalk at:#CopyBuffer.
+    sel isNil ifTrue:[
+	sel := device getTextSelectionFor:drawableId.
+	sel isNil ifTrue:[^ nil].
+    ].
+    ^ sel
+!
+
+setTextSelection:something
+    "set the text selection - both the local one, and tell the display
+     that we have changed it."
+
+    |s|
+
+    Smalltalk at:#CopyBuffer put:something.
+    s := something.
+    s isString ifFalse:[
+	s := s asStringFrom:1 to:(s size) 
+		       compressTabs:false 
+		       withCR:false
+    ].
+    (device setTextSelection:s owner:drawableId) ifFalse:[
+	'selection failed' errorPrintNL
+    ]
+!
+
+setSelection:something
+    "set the object selection - both the local one, and tell the display
+     that we have changed it."
+
+    |s|
+
+    Smalltalk at:#CopyBuffer put:something.
+    (device setSelection:something owner:drawableId) ifFalse:[
+	'selection failed' errorPrintNL
+    ]
+!
+
+selectionRequest:propertyID target:targetID selection:selectionID from:windowID
+    "someone asks for our selection"
+
+    |o s stream|
+
+    o := Smalltalk at:#CopyBuffer.
+    targetID == (device atomIDOf:'STRING') ifTrue:[
+	s := o.
+	o isString ifFalse:[
+	    o isNil ifTrue:[
+		s := ''
+	    ] ifFalse:[
+		(o isMemberOf:Text) ifTrue:[
+		    s := o asStringFrom:1 to:(o size) 
+			   compressTabs:false 
+				 withCR:false
+		] ifFalse:[
+		    s := o storeString
+		]
+	    ]
+	].
+	device 
+	    sendSelection:s 
+	    property:propertyID 
+	    target:targetID 
+	    to:windowID
+    ] ifFalse:[
+	stream := WriteStream on:(ByteArray new:200).
+	o storeBinaryOn:stream.
+	device 
+	    sendSelection:(stream contents) 
+	    property:propertyID 
+	    target:(device atomIDOf:'ST_OBJECT' create:true) 
+	    to:windowID
+    ]
+!
+
+selectionNotify:propertyID target:targetID selection:selectionID from:windowID
+    "this is sent from the server as a reply to a request for a
+     selection. The view should be prepared to paste the received
+     string (it asked for it so that should not be a problem)"
+
+    |s|
+
+    targetID == (device atomIDOf:'STRING') ifTrue:[
+	"
+	 a returned string
+	"
+	s := device getTextProperty:propertyID from:windowID.
+	s notNil ifTrue:[
+	    (s endsWith:Character cr) ifTrue:[
+		self paste:(s asText copyWith:'')
+	    ] ifFalse:[
+		self paste:s
+	    ]
+	]
+    ] ifFalse:[
+	"
+	 a returned object
+	"
+	s := device getObjectProperty:propertyID from:windowID.
+	s notNil ifTrue:[
+	    self paste:s
+	]
+    ]
+! !
+
 !PseudoView methodsFor:'event handling'!
 
 catchExpose
@@ -1195,7 +1346,7 @@
 
 readBinaryContentsFrom: stream manager: manager
     "tell the newly restored View to recreate itself.
-     Bug: restored view seems to loose its position."
+     Bug: restored view seems to loose its position (if its not an StdSysView)."
 
     super readBinaryContentsFrom: stream manager: manager.