class definition
authorClaus Gittinger <cg@exept.de>
Tue, 03 May 2011 12:28:30 +0200
changeset 4041 2d635ff57406
parent 4040 408aada39551
child 4042 c67a4227f0e3
class definition added: #readOnly #readOnly: changed:6 methods
ImageEditView.st
--- a/ImageEditView.st	Wed Apr 20 12:45:04 2011 +0200
+++ b/ImageEditView.st	Tue May 03 12:28:30 2011 +0200
@@ -12,9 +12,9 @@
 "{ Package: 'stx:libwidg2' }"
 
 ImageView subclass:#ImageEditView
-	instanceVariableNames:'magnification imageReaderClass resourceClass resourceSelector
-		mouseKeyColorMode undoImages modifiedHolder editMode
-		lastPastePoint imageInfoHolder activityInfoHolder
+	instanceVariableNames:'readOnly magnification imageReaderClass resourceClass
+		resourceSelector mouseKeyColorMode undoImages modifiedHolder
+		editMode lastPastePoint imageInfoHolder activityInfoHolder
 		pickedColorHolder drawingColors drawingPixels drawingColorHolders
 		drawingPixelHolders clickInfoCallBack penWidth sprayProcess
 		sprayPosition spraySpot drawingAlpha'
@@ -289,6 +289,14 @@
     "Created: / 01-11-2007 / 23:34:56 / cg"
 !
 
+readOnly
+    ^ readOnly
+!
+
+readOnly:something
+    readOnly := something.
+!
+
 removelastUndo
     undoImages removeLast
 !
@@ -716,6 +724,7 @@
     (x < 0 or:[y < 0]) ifTrue:[
         ^ self
     ].
+    readOnly ifTrue:[^ self].
 
     p := x@y.
 
@@ -750,7 +759,7 @@
             ifFalse: [self cursor:Cursor stop. self releasePasteDrawing]
     ]
 
-    "Modified: / 20-11-2007 / 17:17:41 / cg"
+    "Modified: / 03-05-2011 / 12:26:54 / cg"
 !
 
 buttonPress:button x:x y:y
@@ -786,32 +795,34 @@
             masked ifTrue:[self selectedColorIndex:nil].
             self changed:#selectedColor with:clr.
         ] ifFalse:[
-            mouseKeyColorMode := button.
-            self makeUndo.
-
-            clickInfoCallBack notNil ifTrue:[
-                "/ still a kludge, but less ugly ...
-                clickInfoCallBack value:button value:p
-            ].
-            "/ editMode is something like #point, #rectangle etc.
-            [
-                self perform: (editMode, 'At:') asSymbol with:p
-            ] on:Error 
-            do:[:ex | 
-                (Dialog confirm:('Error during operation: ', ex description,'\\Debug ?') withCRs )
-                ifTrue:[
-                    ex reject
+            readOnly ifFalse:[
+                mouseKeyColorMode := button.
+                self makeUndo.
+
+                clickInfoCallBack notNil ifTrue:[
+                    "/ still a kludge, but less ugly ...
+                    clickInfoCallBack value:button value:p
+                ].
+                "/ editMode is something like #point, #rectangle etc.
+                [
+                    self perform: (editMode, 'At:') asSymbol with:p
+                ] on:Error do:[:ex | 
+                    (Dialog confirm:('Error during operation: ', ex description,'\\Debug ?') withCRs )
+                    ifTrue:[
+                        ex reject
+                    ].
                 ].
             ].
         ]
     ]
 
-    "Modified: / 20-11-2007 / 17:22:49 / cg"
+    "Modified: / 03-05-2011 / 12:26:06 / cg"
 !
 
 buttonRelease:button x:x y:y
 
     self drawCursorAt: x@y.
+    readOnly ifTrue:[^ self].
 
     ("self selectedColor notNil" true and: [self imageContainsPoint: x@y])
     ifTrue: [
@@ -829,7 +840,7 @@
         self changed:#subImageIn with:(image bounds).
     ]
 
-    "Modified: / 10.2.2000 / 23:41:41 / cg"
+    "Modified: / 03-05-2011 / 12:26:31 / cg"
 !
 
 inPasteMode
@@ -2146,6 +2157,7 @@
 drawCursorAt:aPoint
     |imgPoint|
 
+    readOnly ifTrue:[^ self].
     image isNil ifTrue: [
         self updateImageInfo: self imageInfoString. 
         self cursor:Cursor stop.
@@ -2163,17 +2175,18 @@
         self cursor:Cursor crossHair
     ].
 
-    "Modified: / 29.7.1998 / 18:26:01 / cg"
+    "Modified: / 03-05-2011 / 12:27:52 / cg"
 !
 
 drawCursorAt: aPoint withLabel: aLabel
+    readOnly ifTrue:[^ self].
 
     ((0@0 extent: image extent * magnification) containsPoint: aPoint)
-	 ifFalse:[self cursor:Cursor stop]
-	 ifTrue: [self cursor:Cursor crossHair].
+         ifTrue: [self cursor:Cursor crossHair]
+         ifFalse:[self cursor:Cursor stop].
      self updateImageInfo: aLabel.
 
-    "Modified: / 29.7.1998 / 18:26:04 / cg"
+    "Modified: / 03-05-2011 / 12:28:15 / cg"
 !
 
 updateActivity: something
@@ -2243,6 +2256,8 @@
 initialize
     super initialize.
 
+    readOnly := false.
+
     self enableMotionEvents.
 
     undoImages        := List new: MaxUndos.
@@ -2254,6 +2269,8 @@
     drawingColorHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
     drawingPixelHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
     self editMode:EditModePoint.
+
+    "Modified: / 03-05-2011 / 12:24:28 / cg"
 ! !
 
 !ImageEditView methodsFor:'loading & saving'!
@@ -2722,11 +2739,11 @@
 !ImageEditView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.246 2011-04-07 07:35:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.247 2011-05-03 10:28:30 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.246 2011-04-07 07:35:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.247 2011-05-03 10:28:30 cg Exp $'
 ! !
 
 ImageEditView initialize!