--- a/WinWorkstation.st Tue Mar 20 22:04:49 2007 +0100
+++ b/WinWorkstation.st Wed Apr 04 16:18:07 2007 +0200
@@ -9,14 +9,17 @@
other person. No title to or ownership of the software is
hereby transferred.
"
+'From Smalltalk/X, Version:5.3.5 on 04-04-2007 at 15:55:25' !
+
"{ Package: 'stx:libview' }"
DeviceWorkstation subclass:#WinWorkstation
instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
- eventTrace eventBuffer isWin95 isWinXP'
+ eventTrace eventBuffer isWin95 isWinXP
+ lastClipboardSequenceNumber'
classVariableNames:'BeepDuration NativeDialogs NativeWidgets NativeWidgetClassTable
StandardColorValues IgnoreSysColorChanges IgnoreFontChanges
- SystemColorValues ClipBoardObject'
+ SystemColorValues'
poolDictionaries:''
category:'Interface-Graphics'
!
@@ -8517,8 +8520,87 @@
!WinWorkstation methodsFor:'clipboard'!
+getClipboardObjectFor:drawableId
+ "answer an arbitrary object from the clipboard, or nil,
+ if there is no data that we are able to handle (decode)"
+
+ |currentSequenceNumber|
+
+ currentSequenceNumber := self getClipboardSequenceNumber.
+ lastClipboardSequenceNumber ~= currentSequenceNumber ifTrue:[
+ "copyBuffer is invalid, fill it from the windows clipboard.
+ Even if we could not decode the windows clipboard,
+ we intentionally set the copyBuffer to nil to get a consistent
+ behavior."
+ copyBuffer := self getClipboardData.
+ lastClipboardSequenceNumber := currentSequenceNumber.
+ ].
+ ^ copyBuffer
+!
+
+getClipboardText:selectionBufferSymbol for:drawableId
+ "get the contents of the clipboard and answer a String,
+ or nil, if there is no data that we can handle (decode)."
+
+ |currentSequenceNumber|
+
+ currentSequenceNumber := self getClipboardSequenceNumber.
+ lastClipboardSequenceNumber ~= currentSequenceNumber ifTrue:[
+ "copyBuffer is invalid, fill it from the windows clipboard.
+ Even if we could not decode the windows clipboard,
+ we intentionally set the copyBuffer to nil to get a consistent
+ behavior."
+ copyBuffer := self getClipboardData.
+ lastClipboardSequenceNumber := currentSequenceNumber.
+ ].
+ ^ self copyBufferAsString
+!
+
+setClipboardObject:something owner:drawableId
+ "store an arbitrary object into the clipboard.
+ Since we currently support only text, any other object
+ is stored only in our local copyBuffer and not made available
+ to other applications."
+
+ something isString ifTrue:[
+ self setClipboardText:something owner:drawableId.
+ ^ self
+ ].
+ something isStringCollection ifTrue:[
+ self setClipboardText:something asString owner:drawableId.
+ ^ self
+ ].
+
+ "copyBuffer is valid until the clipboard sequence number increases,
+ because new data has been put into the clipboard"
+ lastClipboardSequenceNumber := self getClipboardSequenceNumber.
+
+ "Created: / 13.7.1999 / 13:30:37 / cg"
+ "Modified: / 30.1.2000 / 11:59:41 / cg"
+!
+
+setClipboardText:something owner:drawableId
+ "store some text into the clipboard"
+
+ |result|
+
+ result := self setClipboardData:something asString string. "take care of StringCollections"
+
+ "as long as the sequence number doesn't change, our copyBuffer is valid"
+ lastClipboardSequenceNumber := self getClipboardSequenceNumber.
+ ^ result.
+
+
+ "Created: / 13.7.1999 / 13:36:43 / cg"
+ "Modified: / 30.1.2000 / 12:12:57 / cg"
+! !
+
+!WinWorkstation methodsFor:'clipboard-private'!
+
getClipboardData
- "caveat: for now, only Text is supported"
+ "get the contents of the windows clipboard.
+ Answer a string on success or nil otherwise.
+ Caveat: for now, only Text is supported"
%{
HANDLE hClip;
@@ -8641,36 +8723,41 @@
%}
!
-getClipboardObjectFor:drawableId
- ^ ClipBoardObject
-
- "Modified: / 30.1.2000 / 02:26:47 / cg"
-!
-
-getClipboardText:selectionBufferSymbol for:drawableId
- ^ self getCopyBuffer.
-!
-
-getCopyBuffer
- "return the copyBuffers contents."
-
- |clip|
-
- ClipBoardObject notNil ifTrue:[
- ^ ClipBoardObject
- ].
-
- (clip := (self getClipboardData)) notNil ifTrue:[
- ^ clip
- ].
- ^ copyBuffer
-
- "Created: / 13.7.1999 / 13:15:35 / cg"
- "Modified: / 30.1.2000 / 12:01:13 / cg"
+getClipboardOwner
+ "answer an handle telling us, who owns the clipboard."
+
+%{
+ HANDLE hWnd;
+
+ hWnd = GetClipboardOwner();
+ RETURN(__MKEXTERNALADDRESS(hWnd));
+%}
+
+ "
+ Screen current getClipboardOwner
+ "
+!
+
+getClipboardSequenceNumber
+ "answer the sequence number of the clioboard.
+ Each time, the keyboard is changed, the sequence number is incremented."
+
+%{
+ DWORD sequenceNumber;
+
+ sequenceNumber = GetClipboardSequenceNumber();
+ RETURN(__MKUINT(sequenceNumber));
+%}
+
+ "
+ Screen current getClipboardSequenceNumber
+ "
!
setClipboardData:aString
- "caveat: for now, only Text is supported"
+ "Set the contents of the windows clipboard.
+ Answer true, if the operation succeeded, false otherwise.
+ Caveat: for now, only Text is supported."
%{
HANDLE hClip;
@@ -8790,25 +8877,6 @@
}
%}.
self primitiveFailed.
-!
-
-setClipboardObject:something owner:drawableId
- something isString ifTrue:[
- self setClipboardText:something owner:drawableId.
- ^ self
- ].
- ClipBoardObject := something.
-
- "Created: / 13.7.1999 / 13:30:37 / cg"
- "Modified: / 30.1.2000 / 11:59:41 / cg"
-!
-
-setClipboardText:something owner:drawableId
- ClipBoardObject := nil.
- ^ self setClipboardData:something
-
- "Created: / 13.7.1999 / 13:36:43 / cg"
- "Modified: / 30.1.2000 / 12:12:57 / cg"
! !
!WinWorkstation methodsFor:'color stuff'!
@@ -16985,7 +17053,7 @@
!WinWorkstation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.341 2007-03-14 15:34:54 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.342 2007-04-04 14:18:07 stefan Exp $'
! !
WinWorkstation initialize!