#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Mon, 09 Oct 2017 09:17:06 +0200
changeset 5618 fd26b56cfc91
parent 5616 4ff2c28c261c
child 5619 657eee4bfe48
#REFACTORING by cg class: ImageEditView class definition added: #clipBoardImage comment/format in: #buttonPress:x:y: #destroy #drawPasteRectangleAt: #imageContainsPastePoint: changed: #buttonMotion:x:y: #clipBoard #magnification: #pasteAt:mode: #releasePasteDrawing class: ImageEditView class comment/format in: #copyImageToClipboard:
ImageEditView.st
--- a/ImageEditView.st	Thu Oct 05 13:56:32 2017 +0200
+++ b/ImageEditView.st	Mon Oct 09 09:17:06 2017 +0200
@@ -22,12 +22,13 @@
 		penWidth sprayProcess sprayPosition spraySpot drawingAlpha
 		floodFillMaxHueError floodFillMaxLightError
 		userAllowedToChangeDrawingColor'
-	classVariableNames:'Clipboard ClipboardMagnified LastMagnification
-		GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass
-		EditModePoint EditModeBox EditModeFilledBox EditModeFill
-		EditModeCopy EditModePasteUnder EditModePaste
-		EditModePasteWithMask EditModeSpecialOperation EditModeSpray
-		EditModeCircle EditModeSmooth EditModeFilledCircle
+	classVariableNames:'Clipboard ClipboardMagnified ClipboardImage
+		ClipboardImageMagnified LastMagnification GridMagnificationLimit
+		MaxUndos LastSaveDirectory LastSaveClass EditModePoint
+		EditModeBox EditModeFilledBox EditModeFill EditModeCopy
+		EditModePasteUnder EditModePaste EditModePasteWithMask
+		EditModeSpecialOperation EditModeSpray EditModeCircle
+		EditModeSmooth EditModeFilledCircle
 		EditModeSpecialOperationCropSubImage EditModeMaskOutsideRect
 		EditModeMaskOutsideCircle'
 	poolDictionaries:''
@@ -158,8 +159,10 @@
 !ImageEditView class methodsFor:'helpers'!
 
 copyImageToClipboard:copiedImage
-    ClipboardMagnified := nil.
-    Clipboard := copiedImage.
+    ClipboardImageMagnified := nil.
+    ClipboardImage := copiedImage.
+
+    "Modified: / 08-10-2017 / 08:55:10 / cg"
 ! !
 
 !ImageEditView class methodsFor:'resources'!
@@ -203,7 +206,26 @@
     clipboardObject isImage ifTrue:[
         ^ clipboardObject
     ].
-    ^ Clipboard.
+    ^ ClipboardImage.
+
+    "Modified: / 08-10-2017 / 08:52:27 / cg"
+!
+
+clipBoardImage
+    "if there is one in the clobal clipboard, 
+     return that (an thus support copy-paste from another smalltalk application).
+     Otherwise return the local clipboardImage from a classVar to support copy-paste 
+     within this smalltalk session."
+     
+    |clipboardObject|
+    
+    clipboardObject := self getClipboardObject.
+    clipboardObject isImage ifTrue:[
+        ^ clipboardObject
+    ].
+    ^ ClipboardImage.
+
+    "Created: / 08-10-2017 / 08:55:59 / cg"
 !
 
 drawingAlpha
@@ -361,17 +383,17 @@
     magnification ~= aPoint
     ifTrue:
     [
-	oldOrg := self viewOrigin / magnification.
-	magnification := aPoint asPoint.
-
-	self scrollTo:(oldOrg * magnification) rounded redraw:false.        
+        oldOrg := self viewOrigin / magnification.
+        magnification := aPoint asPoint.
+
+        self scrollTo:(oldOrg * magnification) rounded redraw:false.        
 "/        self scrollToTopLeft.
-	self contentsChanged.
-	self invalidate.
-	ClipboardMagnified := nil.
+        self contentsChanged.
+        self invalidate.
+        ClipboardImageMagnified := nil.
     ]
 
-    "Modified: / 31.7.1998 / 02:38:47 / cg"
+    "Modified: / 08-10-2017 / 08:54:54 / cg"
 !
 
 modified
@@ -588,10 +610,10 @@
     self repairDamage.
 
     currentPoint ~= lastPastePoint ifTrue:[              
-        ClipboardMagnified isNil ifTrue:[
-            ClipboardMagnified := (Clipboard magnifiedBy: magnification) onDevice:device
+        ClipboardImageMagnified isNil ifTrue:[
+            ClipboardImageMagnified := (ClipboardImage magnifiedBy: magnification) onDevice:device
         ].   
-        extent := ClipboardMagnified extent.
+        extent := ClipboardImageMagnified extent.
 
         "/ currentPoint := currentPoint - self viewOrigin.
 
@@ -603,8 +625,8 @@
                 self fillRectangle: (currentPoint extent: extent)
             ]   
         ] ifFalse:[
-            ClipboardMagnified notNil ifTrue:[
-                self displayDeviceForm: ClipboardMagnified 
+            ClipboardImageMagnified notNil ifTrue:[
+                self displayDeviceForm: ClipboardImageMagnified 
                                      x: currentPoint x - self viewOrigin x 
                                      y: currentPoint y - self viewOrigin y.
             ].
@@ -615,7 +637,7 @@
     ]. 
     lastPastePoint := currentPoint.
 
-    "Modified: / 20-11-2007 / 17:17:14 / cg"
+    "Modified: / 08-10-2017 / 08:54:49 / cg"
 !
 
 fillFramedRectangle: aRectangle
@@ -935,11 +957,11 @@
     self drawCursorAt:p.
     
     "/ if in pastemode, highlight the affected rectangle (image to be pasted is in ClipBoard)
-    self inPasteMode ifTrue: [
+    (self inPasteMode and:[ ClipboardImage notNil ]) ifTrue: [
         "/ with shift, paste is offset by pasted image's size
         "/ (i.e. click-point will be corner of pasted rectangle)
         self sensor shiftDown ifTrue:[
-            p := p - Clipboard extent
+            p := p - ClipboardImage extent
         ].
         (self imageContainsPastePoint:p) ifTrue:[
             (self sensor hasButtonMotionEventFor:self) ifFalse:[
@@ -951,7 +973,7 @@
         ]
     ]
 
-    "Modified (format): / 16-02-2017 / 16:59:13 / cg"
+    "Modified: / 08-10-2017 / 09:00:00 / cg"
 !
 
 buttonPress:button x:x y:y
@@ -961,9 +983,9 @@
 
     "/ with shift, paste is offset by pasted image's size
     "/ (i.e. click-point will be corner of pasted rectangle)
-    self inPasteMode ifTrue:[
+    (self inPasteMode and:[ ClipboardImage notNil ]) ifTrue:[
         self sensor shiftDown ifTrue:[
-            p := p - Clipboard extent
+            p := p - ClipboardImage extent
         ]
     ].
     
@@ -1015,7 +1037,7 @@
         ]
     ]
 
-    "Modified: / 17-02-2017 / 16:25:29 / cg"
+    "Modified: / 08-10-2017 / 09:00:24 / cg"
 !
 
 buttonRelease:button x:x y:y
@@ -1820,7 +1842,7 @@
 
             imagePoint := choosenBox origin//magnification.
 
-            copiedImage := Clipboard copy.
+            copiedImage := ClipboardImage copy.
             copiedImage isNil ifTrue:[^ self].
             
             true "/ image photometric == #palette 
@@ -1886,7 +1908,7 @@
                             ]
                         ].
                         image restored.
-                        self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1).
+                        self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1).
                         self setModified.
                         ^ self.
                     ].
@@ -1944,7 +1966,7 @@
                             ]
                         ].
                         image restored.
-                        self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1).
+                        self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1).
                         self setModified.
                         ^ self.
                     ].
@@ -2003,14 +2025,13 @@
                 ].
             ].
             image restored.
-            self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1).
+            self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1).
 "/            masterApplication imagePreView redraw: (imageBox expandedBy: 1).
             self setModified.
         ]
    ]
 
-    "Modified: / 03-02-2017 / 17:10:05 / cg"
-    "Modified (comment): / 16-02-2017 / 11:13:59 / cg"
+    "Modified: / 08-10-2017 / 08:53:48 / cg"
 !
 
 shiftImageHorizontal:shiftH vertical:shiftV
@@ -3368,10 +3389,12 @@
 !ImageEditView methodsFor:'initialization & release'!
 
 destroy
-    ClipboardMagnified := Clipboard := nil.
+    ClipboardImageMagnified := ClipboardImage := nil.
     LastMagnification      := magnification.
 
     super destroy
+
+    "Modified: / 08-10-2017 / 08:54:36 / cg"
 !
 
 initialize
@@ -3859,10 +3882,13 @@
 !
 
 imageContainsPastePoint: aPoint
-
-    ^image notNil and: 
-	[Clipboard notNil and:
-	[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]]
+    ^image notNil 
+    and: [ ClipboardImage notNil 
+    and: [ (0@0 corner:(image extent) "- 1" - ClipboardImage extent) 
+                containsPoint: (((aPoint - margin + 1) / magnification) floor)
+    ]]
+
+    "Modified (format): / 08-10-2017 / 08:53:18 / cg"
 !
 
 imageContainsPoint: aPoint
@@ -3881,12 +3907,14 @@
 
 releasePasteDrawing
     self repairDamage.
-    (lastPastePoint notNil and: [ClipboardMagnified notNil]) 
+    (lastPastePoint notNil and: [ClipboardImageMagnified notNil]) 
     ifTrue: [ 
-        self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardMagnified extent)). 
+        self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardImageMagnified extent)). 
         "/ self repairDamage.
     ].
-    lastPastePoint := ClipboardMagnified := nil
+    lastPastePoint := ClipboardImageMagnified := nil
+
+    "Modified: / 08-10-2017 / 08:55:06 / cg"
 !
 
 releaseUndos