ImageEditView.st
changeset 2747 818a513a64c3
parent 2690 53bc9dc52ce4
child 2756 5a1646996277
equal deleted inserted replaced
2746:2c614cc1559c 2747:818a513a64c3
    12 
    12 
    13 "{ Package: 'stx:libwidg2' }"
    13 "{ Package: 'stx:libwidg2' }"
    14 
    14 
    15 ImageView subclass:#ImageEditView
    15 ImageView subclass:#ImageEditView
    16 	instanceVariableNames:'magnification imageReaderClass resourceClass resourceSelector
    16 	instanceVariableNames:'magnification imageReaderClass resourceClass resourceSelector
    17 		mouseKeyColorMode undoImages modified editMode lastPastePoint
    17 		mouseKeyColorMode undoImages modifiedHolder editMode
    18 		imageInfoHolder activityInfoHolder pickedColorHolder
    18 		lastPastePoint imageInfoHolder activityInfoHolder
    19 		drawingColors drawingPixels drawingColorHolders
    19 		pickedColorHolder drawingColors drawingPixels drawingColorHolders
    20 		drawingPixelHolders clickInfoCallBack'
    20 		drawingPixelHolders clickInfoCallBack'
    21 	classVariableNames:'Clipboard ClipboardMagnified LastMagnification
    21 	classVariableNames:'Clipboard ClipboardMagnified LastMagnification
    22 		GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass'
    22 		GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass'
    23 	poolDictionaries:''
    23 	poolDictionaries:''
    24 	category:'Views-Misc'
    24 	category:'Views-Misc'
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 documentation
    43 documentation
    44 "
    44 "
    45     The ImageEditView is a view class which can be used by applications
    45     An ImageEditView is a view which can be used by applications
    46     like the Image Editor for modifying or inspecting images.
    46     like the Image Editor for editing or inspecting (bitmap-) images.
    47 
    47 
    48     [see also:]
    48     [see also:]
    49 	ImageEditor Image
    49         ImageEditor Image
    50 
    50 
    51     [author:]
    51     [author:]
    52 	Thomas Zwick
    52         Thomas Zwick
    53 "
    53 "
    54 ! !
    54 ! !
    55 
    55 
    56 !ImageEditView class methodsFor:'initialization'!
    56 !ImageEditView class methodsFor:'initialization'!
    57 
    57 
   104 
   104 
   105     "Created: / 29.7.1998 / 18:49:39 / cg"
   105     "Created: / 29.7.1998 / 18:49:39 / cg"
   106 !
   106 !
   107 
   107 
   108 clearModified
   108 clearModified
   109         modified := false
   109         self modified:false
   110 !
   110 !
   111 
   111 
   112 clickInfoCallBack:aTwoArgBlock
   112 clickInfoCallBack:aTwoArgBlock
   113      clickInfoCallBack := aTwoArgBlock
   113      clickInfoCallBack := aTwoArgBlock
   114 
   114 
   161 	self invalidate.
   161 	self invalidate.
   162 	ClipboardMagnified := nil.
   162 	ClipboardMagnified := nil.
   163     ]
   163     ]
   164 
   164 
   165     "Modified: / 31.7.1998 / 02:38:47 / cg"
   165     "Modified: / 31.7.1998 / 02:38:47 / cg"
       
   166 !
       
   167 
       
   168 modified:aBoolean
       
   169     modifiedHolder value:aBoolean
       
   170 !
       
   171 
       
   172 modifiedHolder
       
   173     ^ modifiedHolder
   166 !
   174 !
   167 
   175 
   168 resourceClass
   176 resourceClass
   169 
   177 
   170     ^resourceClass
   178     ^resourceClass
   222 selectedColorIndex: aPixelIndex
   230 selectedColorIndex: aPixelIndex
   223     (drawingPixelHolders at:mouseKeyColorMode) value: aPixelIndex
   231     (drawingPixelHolders at:mouseKeyColorMode) value: aPixelIndex
   224 !
   232 !
   225 
   233 
   226 setModified
   234 setModified
   227         modified := true
   235         self modified:true
   228 !
   236 !
   229 
   237 
   230 undoImages
   238 undoImages
   231 
   239 
   232    ^undoImages
   240    ^undoImages
  1842 
  1850 
  1843     self enableMotionEvents.
  1851     self enableMotionEvents.
  1844 
  1852 
  1845     undoImages        := List new: MaxUndos.
  1853     undoImages        := List new: MaxUndos.
  1846     magnification     := LastMagnification ? (8@8).
  1854     magnification     := LastMagnification ? (8@8).
  1847     modified          := false.
  1855     modifiedHolder    := false asValue.
  1848     mouseKeyColorMode := 1.
  1856     mouseKeyColorMode := 1.
  1849     resourceClass     := resourceSelector := ''.
  1857     resourceClass     := resourceSelector := ''.
  1850     drawingColorHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
  1858     drawingColorHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
  1851     drawingPixelHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
  1859     drawingPixelHolders := Array with:(nil asValue) with:(nil asValue).   "/ left/right mouse colors
  1852     editMode          := #point.
  1860     editMode          := #point.
  2207 ! !
  2215 ! !
  2208 
  2216 
  2209 !ImageEditView methodsFor:'release'!
  2217 !ImageEditView methodsFor:'release'!
  2210 
  2218 
  2211 releasePasteDrawing
  2219 releasePasteDrawing
  2212 
       
  2213     self repairDamage.
  2220     self repairDamage.
  2214     (lastPastePoint notNil and: [ClipboardMagnified notNil]) 
  2221     (lastPastePoint notNil and: [ClipboardMagnified notNil]) 
  2215     ifTrue: 
  2222     ifTrue: [ 
  2216     [ 
       
  2217         self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardMagnified extent)). 
  2223         self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardMagnified extent)). 
  2218         "/ self repairDamage.
  2224         "/ self repairDamage.
  2219     ].
  2225     ].
  2220     lastPastePoint := ClipboardMagnified := nil
  2226     lastPastePoint := ClipboardMagnified := nil
  2221 !
  2227 !
  2222 
  2228 
  2223 releaseUndos
  2229 releaseUndos
  2224 
       
  2225     undoImages removeAll.
  2230     undoImages removeAll.
  2226     "/ cg: what a kludge - please change to use a valueHolder,
       
  2227 "/    masterApplication notNil ifTrue:[
       
  2228 "/        masterApplication valueOfCanUndo value: false.
       
  2229 "/    ].
       
  2230 
       
  2231     "Modified: / 31.7.1998 / 02:47:21 / cg"
       
  2232 ! !
  2231 ! !
  2233 
  2232 
  2234 !ImageEditView methodsFor:'testing'!
  2233 !ImageEditView methodsFor:'testing'!
  2235 
  2234 
  2236 checkModified
  2235 checkModified
  2237 
  2236     modifiedHolder value ifTrue:[
  2238     modified ifTrue:
       
  2239     [
       
  2240         ((YesNoBox title:(resources string:'Image was not saved. Exit anyway ?'))
  2237         ((YesNoBox title:(resources string:'Image was not saved. Exit anyway ?'))
  2241             noText:(resources string:'Cancel');
  2238             noText:(resources string:'Cancel');
  2242             yesText:(resources string:'Exit without Saving');
  2239             yesText:(resources string:'Exit without Saving');
  2243             showAtPointer;
  2240             showAtPointer;
  2244             accepted) ifFalse: [^false].
  2241             accepted
  2245         modified := false
  2242         ) ifFalse: [^false].
       
  2243 
       
  2244         self modified:false.
  2246     ].
  2245     ].
  2247     ^ true
  2246     ^ true
  2248 
  2247 
  2249     "Modified: / 29.7.1998 / 18:55:24 / cg"
  2248     "Modified: / 29.7.1998 / 18:55:24 / cg"
  2250 ! !
  2249 ! !
  2251 
  2250 
  2252 !ImageEditView class methodsFor:'documentation'!
  2251 !ImageEditView class methodsFor:'documentation'!
  2253 
  2252 
  2254 version
  2253 version
  2255     ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.195 2004-03-29 14:16:30 cg Exp $'
  2254     ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.196 2004-09-29 11:31:22 cg Exp $'
  2256 ! !
  2255 ! !
  2257 
  2256 
  2258 ImageEditView initialize!
  2257 ImageEditView initialize!