author | tz |
Mon, 31 Aug 1998 15:29:38 +0200 | |
changeset 1103 | 62fb33e2e17b |
parent 1084 | 87c661e6c333 |
child 1104 | a7101d656dab |
permissions | -rw-r--r-- |
636 | 1 |
" |
704 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
636 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
1 | 13 |
ImageView subclass:#ImageEditView |
1035 | 14 |
instanceVariableNames:'magnification selectColors imageReaderClass resourceClass |
15 |
resourceSelector mouseKeyColorMode undoImages modified |
|
16 |
masterApplication editMode lastPastePoint imageInfoHolder |
|
17 |
activityInfoHolder pickedColorHolder' |
|
18 |
classVariableNames:'Clipboard LastMagnification ClipboardMagnification |
|
19 |
GridMagnification MaxUndos' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Views-Misc' |
|
1 | 22 |
! |
23 |
||
636 | 24 |
!ImageEditView class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
704 | 28 |
COPYRIGHT (c) 1997 by eXept Software AG |
636 | 29 |
All Rights Reserved |
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
The ImageEditView is a view class which can be used by applications |
|
43 |
like the Image Editor for modifying or inspecting images. |
|
44 |
||
45 |
[see also:] |
|
46 |
ImageEditor Image |
|
47 |
||
48 |
[author:] |
|
49 |
Thomas Zwick |
|
50 |
" |
|
51 |
! ! |
|
353 | 52 |
|
7 | 53 |
!ImageEditView methodsFor:'accessing'! |
54 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
55 |
activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
56 |
"return the value of the instance variable 'activityInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
57 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
58 |
^ activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
59 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
60 |
"Created: / 29.7.1998 / 18:49:39 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
61 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
62 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
63 |
activityInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
64 |
"set the value of the instance variable 'activityInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
65 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
66 |
activityInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
67 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
68 |
"Created: / 29.7.1998 / 18:49:39 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
69 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
70 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
71 |
imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
72 |
"return the value of the instance variable 'imageInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
73 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
74 |
^ imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
75 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
76 |
"Created: / 29.7.1998 / 18:29:50 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
77 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
78 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
79 |
imageInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
80 |
"set the value of the instance variable 'imageInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
81 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
82 |
imageInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
83 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
84 |
"Created: / 29.7.1998 / 18:29:50 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
85 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
86 |
|
624 | 87 |
magnification |
88 |
||
89 |
^magnification |
|
90 |
||
255 | 91 |
! |
92 |
||
636 | 93 |
magnification: aPoint |
1037 | 94 |
|oldOrg| |
255 | 95 |
|
627 | 96 |
magnification ~= aPoint |
624 | 97 |
ifTrue: |
98 |
[ |
|
1037 | 99 |
oldOrg := self viewOrigin / magnification. |
627 | 100 |
magnification := aPoint asPoint. |
1037 | 101 |
|
102 |
self scrollTo:(oldOrg * magnification) rounded redraw:false. |
|
103 |
"/ self scrollToTopLeft. |
|
624 | 104 |
self contentsChanged. |
995 | 105 |
self invalidate. |
106 |
ClipboardMagnification := nil. |
|
686 | 107 |
] |
1037 | 108 |
|
109 |
"Modified: / 31.7.1998 / 02:38:47 / cg" |
|
624 | 110 |
! |
255 | 111 |
|
662 | 112 |
masterApplication |
113 |
||
114 |
^masterApplication |
|
115 |
! |
|
116 |
||
117 |
masterApplication: anApplicationModel |
|
118 |
||
119 |
masterApplication := anApplicationModel |
|
120 |
! |
|
121 |
||
627 | 122 |
resourceClass |
123 |
||
124 |
^resourceClass |
|
125 |
! |
|
126 |
||
127 |
resourceClass: aClassOrSymbol |
|
128 |
||
686 | 129 |
resourceClass := aClassOrSymbol isClass ifTrue: [aClassOrSymbol name] ifFalse: [aClassOrSymbol asSymbol] |
627 | 130 |
! |
131 |
||
132 |
resourceMessage |
|
133 |
||
134 |
^resourceClass, ' ', resourceSelector |
|
135 |
! |
|
136 |
||
636 | 137 |
resourceMessage: aString |
627 | 138 |
|
636 | 139 |
(aString isString and: [aString trimBlanks size > 0]) |
627 | 140 |
ifTrue: |
141 |
[ |
|
636 | 142 |
resourceClass := (aString readStream upTo: Character space) asSymbol. |
686 | 143 |
resourceSelector := (aString copy reverse readStream upTo: Character space) reverse asSymbol |
627 | 144 |
] |
145 |
ifFalse: |
|
146 |
[ |
|
147 |
^nil |
|
686 | 148 |
] |
627 | 149 |
|
150 |
||
151 |
! |
|
152 |
||
153 |
resourceSelector |
|
154 |
||
155 |
^resourceSelector |
|
156 |
! |
|
157 |
||
158 |
resourceSelector: aStringOrSymbol |
|
159 |
||
160 |
resourceSelector := aStringOrSymbol asSymbol |
|
161 |
! |
|
162 |
||
840 | 163 |
selectColors |
164 |
||
165 |
^selectColors |
|
166 |
! |
|
167 |
||
168 |
selectColors: anArrayTwoColors |
|
633 | 169 |
|
170 |
selectColors := anArrayTwoColors |
|
171 |
! |
|
172 |
||
627 | 173 |
selectedColor |
174 |
||
633 | 175 |
^selectColors at: mouseKeyColorMode |
627 | 176 |
! |
177 |
||
178 |
selectedColor: aColor |
|
179 |
||
180 |
selectColors at: mouseKeyColorMode put: aColor |
|
995 | 181 |
! |
182 |
||
183 |
undoImages |
|
184 |
||
185 |
^undoImages |
|
627 | 186 |
! ! |
187 |
||
188 |
!ImageEditView methodsFor:'drawing'! |
|
189 |
||
1036 | 190 |
drawFrame |
191 |
||
192 |
self paint:Color black. |
|
193 |
self lineWidth: (magnification x//3 min: 3). |
|
194 |
self displayRectangle: ((0@0) extent:(image extent * magnification) + 2). |
|
195 |
self lineWidth:1. |
|
196 |
! |
|
197 |
||
198 |
drawFramesIn: aRectangle |
|
199 |
||
200 |
magnification >= GridMagnification |
|
201 |
ifTrue: |
|
202 |
[ |
|
203 |
|origin lineStartingPoint lineEndingPoint oldColor| |
|
204 |
origin := aRectangle origin - 1. |
|
205 |
lineStartingPoint := origin + (0@magnification y). |
|
206 |
lineEndingPoint := lineStartingPoint + (aRectangle width@0). |
|
207 |
oldColor := self paint. |
|
208 |
self xoring: |
|
209 |
[ |
|
210 |
self displayLineFrom: lineStartingPoint to: lineEndingPoint. |
|
211 |
lineStartingPoint x to: lineStartingPoint x + aRectangle width - magnification x by: magnification x do: |
|
212 |
[:x| |
|
213 |
self displayLineFrom: x@(origin y) to: x@(origin y + magnification y) |
|
214 |
]. |
|
215 |
]. |
|
216 |
self paint: oldColor. |
|
217 |
] |
|
218 |
||
219 |
||
220 |
||
221 |
! |
|
222 |
||
662 | 223 |
fillFramedRectangle: aRectangle |
224 |
||
225 |
self fillRectangle: aRectangle. |
|
226 |
self drawFramesIn: aRectangle |
|
227 |
! |
|
228 |
||
627 | 229 |
redrawImageX:x y:y width:w height:h |
636 | 230 |
|
1037 | 231 |
|ih iw magX magY minX maxX minY maxY |
232 |
color lastColor lastY runW x0 xI yI maskColor mask |
|
233 |
sizeOfMaskPoint| |
|
627 | 234 |
|
1037 | 235 |
mask := image mask. |
627 | 236 |
ih := image height. |
237 |
iw := image width. |
|
662 | 238 |
magX := magnification x. |
239 |
magY := magnification y. |
|
627 | 240 |
|
662 | 241 |
minX := (x // magX - 1) max: 0. |
725 | 242 |
minX >= iw ifTrue:[minX := (iw - 1) max: 0]. |
662 | 243 |
minY := (y // magY - 1) max: 0. |
725 | 244 |
minY >= ih ifTrue:[minY := (ih - 1) max: 0]. |
662 | 245 |
maxX := (x + w) // magX + 1. |
627 | 246 |
maxX > iw ifTrue:[maxX := iw]. |
662 | 247 |
maxY := (y + h) // magY + 1. |
627 | 248 |
maxY > ih ifTrue:[maxY := ih]. |
249 |
||
250 |
lastY := -1. |
|
251 |
||
252 |
x0 := minX. |
|
253 |
runW := 0. |
|
254 |
maskColor := false. |
|
662 | 255 |
sizeOfMaskPoint := magnification//3. |
256 |
image colorsFromX: minX y: minY toX: maxX-1 y: maxY-1 do: |
|
627 | 257 |
[:xx :yy :color| |
633 | 258 |
yy ~~ lastY |
259 |
ifTrue: |
|
627 | 260 |
[ |
633 | 261 |
runW ~~ 0 |
262 |
ifTrue: |
|
627 | 263 |
[ |
264 |
|origin| |
|
662 | 265 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
266 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
|
627 | 267 |
maskColor ifTrue: |
268 |
[ |
|
662 | 269 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
627 | 270 |
]. |
271 |
runW := 0. |
|
272 |
]. |
|
273 |
x0 := xx. |
|
274 |
lastY := yy. |
|
275 |
]. |
|
624 | 276 |
|
662 | 277 |
color ~~ lastColor |
633 | 278 |
ifTrue: |
627 | 279 |
[ |
633 | 280 |
runW ~~ 0 |
281 |
ifTrue: |
|
627 | 282 |
[ |
283 |
|origin| |
|
662 | 284 |
origin := (x0 * magX + margin)@(yy * magY + margin). |
285 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
|
627 | 286 |
maskColor ifTrue: |
287 |
[ |
|
662 | 288 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
627 | 289 |
]. |
290 |
runW := 0. |
|
291 |
]. |
|
292 |
||
662 | 293 |
self paint: (lastColor := color). |
1037 | 294 |
mask notNil ifTrue: |
627 | 295 |
[ |
296 |
maskColor := false. |
|
1037 | 297 |
(mask colorAtX:xx y:yy) = Color black ifTrue: |
627 | 298 |
[ |
662 | 299 |
self paint: (lastColor := self viewBackground). |
627 | 300 |
maskColor := true. |
301 |
]. |
|
662 | 302 |
lastColor := nil. |
627 | 303 |
]. |
304 |
runW := 0. |
|
305 |
x0 := xx. |
|
306 |
]. |
|
662 | 307 |
runW := runW + magX |
627 | 308 |
]. |
309 |
runW ~~ 0 ifTrue: |
|
310 |
[ |
|
311 |
|origin| |
|
662 | 312 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
313 |
self fillFramedRectangle: (origin extent: runW@magY). |
|
627 | 314 |
maskColor ifTrue: |
315 |
[ |
|
662 | 316 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
627 | 317 |
]. |
318 |
runW := 0. |
|
319 |
]. |
|
1037 | 320 |
|
321 |
"Modified: / 31.7.1998 / 02:33:42 / cg" |
|
627 | 322 |
! |
323 |
||
324 |
redrawX:x y:y width:w height:h |
|
636 | 325 |
|
627 | 326 |
|ih iw xI yI| |
327 |
||
1037 | 328 |
image isNil ifTrue:[^self]. |
662 | 329 |
|
1037 | 330 |
magnification = (1@1) ifTrue: [ |
331 |
^ super redrawX:x y:y width:w height:h |
|
332 |
]. |
|
627 | 333 |
|
662 | 334 |
self clippingRectangle: (x@y extent: w@h). |
627 | 335 |
|
336 |
self redrawImageX:x y:y width:w height:h. |
|
337 |
||
338 |
"/ right of image ? |
|
339 |
adjust == #center ifTrue: |
|
340 |
[ |
|
633 | 341 |
xI := (width - ih) // 2 - margin. |
342 |
yI := (height - iw) // 2 - margin. |
|
627 | 343 |
] |
344 |
ifFalse: |
|
345 |
[ |
|
346 |
xI := yI := margin |
|
347 |
]. |
|
348 |
(x + w - 1) > (xI + (magnification x * image width)) ifTrue: |
|
349 |
[ |
|
350 |
self clearRectangleX:(xI + (magnification x * image width)) |
|
351 |
y:y |
|
352 |
width:(x + w - (magnification x * image width) - xI) |
|
353 |
height:h |
|
354 |
]. |
|
355 |
(y + h - 1) > (yI + (magnification y * image height)) ifTrue: |
|
356 |
[ |
|
357 |
self clearRectangleX:margin |
|
358 |
y:(yI + (magnification y * image height)) |
|
359 |
width:w |
|
360 |
height:(y + h - (magnification y * image height) - yI) |
|
361 |
]. |
|
362 |
self drawFrame. |
|
363 |
self clippingRectangle: nil. |
|
1037 | 364 |
|
365 |
"Modified: / 31.7.1998 / 02:22:45 / cg" |
|
627 | 366 |
! ! |
367 |
||
368 |
!ImageEditView methodsFor:'edit modes'! |
|
369 |
||
370 |
editMode |
|
371 |
||
737 | 372 |
^editMode ? (editMode := 'point') |
627 | 373 |
! |
374 |
||
375 |
editMode:aMode |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
376 |
"this is concatenated with 'At:' to form the click- |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
377 |
operation. I.e. any of 'point', 'box', 'filledBox' ..." |
627 | 378 |
|
737 | 379 |
editMode := aMode |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
380 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
381 |
"Modified: / 29.7.1998 / 18:36:30 / cg" |
627 | 382 |
! |
383 |
||
384 |
mouseKeyColorMode |
|
385 |
||
386 |
^mouseKeyColorMode printString |
|
387 |
! |
|
388 |
||
389 |
mouseKeyColorMode:aMode |
|
390 |
||
391 |
mouseKeyColorMode := aMode asInteger |
|
392 |
! ! |
|
393 |
||
394 |
!ImageEditView methodsFor:'event handling'! |
|
395 |
||
396 |
buttonMotion:state x:x y:y |
|
632 | 397 |
self drawCursorAt: x@y. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
398 |
state ~~ 0 ifTrue: [ |
995 | 399 |
(self selectedColor notNil and: [(self imageContainsPoint: x@y) and: [editMode = 'point']]) |
686 | 400 |
ifTrue: [^self pointAt: x@y] |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
401 |
] ifFalse:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
402 |
(editMode = 'paste' or:[editMode = 'pasteUnder']) ifTrue: [ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
403 |
(self selectedColor notNil and: [self imageContainsPastePoint: x@y]) |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
404 |
ifTrue: [self drawPasteRectangleAt: x@y] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
405 |
ifFalse: [self cursor:Cursor stop. self releasePasteDrawing] |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
406 |
] |
686 | 407 |
] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
408 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
409 |
"Modified: / 21.8.1998 / 20:16:01 / cg" |
624 | 410 |
! |
255 | 411 |
|
627 | 412 |
buttonPress:button x:x y:y |
413 |
||
632 | 414 |
self drawCursorAt: x@y. |
995 | 415 |
(self selectedColor notNil and: [self imageContainsPoint: x@y]) |
627 | 416 |
ifTrue: |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
417 |
[ |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
418 |
|mouseButtonColorToolBar clr| |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
419 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
420 |
self sensor shiftDown ifTrue:[ |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
421 |
pickedColorHolder notNil ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
422 |
"/ select the color under the cursor, place it into the |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
423 |
"/ pickedColorHolder/ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
424 |
clr := image colorAt:((x@y)//magnification). |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
425 |
pickedColorHolder value:clr |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
426 |
]. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
427 |
] ifFalse:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
428 |
"/ cg: what a kludge - please change to use a valueHolder, |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
429 |
"/ which gets the information ... |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
430 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
431 |
mouseKeyColorMode := button. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
432 |
mouseButtonColorToolBar := masterApplication builder componentAt: #MouseButtonColorToolBar. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
433 |
self makeUndo. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
434 |
masterApplication valueOfCanUndo value: true. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
435 |
(mouseButtonColorToolBar itemAt: mouseKeyColorMode) toggleIndication. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
436 |
mouseButtonColorToolBar do: [:i| i updateIndicators]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
437 |
self perform: (editMode, 'At:') asSymbol with: x@y |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
438 |
] |
686 | 439 |
] |
995 | 440 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
441 |
"Modified: / 29.7.1998 / 18:39:05 / cg" |
632 | 442 |
! |
443 |
||
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
444 |
buttonRelease:button x:x y:y |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
445 |
|
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
446 |
self drawCursorAt: x@y. |
995 | 447 |
(self selectedColor notNil and: [self imageContainsPoint: x@y]) |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
448 |
ifTrue: |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
449 |
[ |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
450 |
image restored. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
451 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
452 |
"/ cg: what a kludge - please change to use a valueHolder, |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
453 |
"/ which gets the information ... |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
454 |
masterApplication imagePreView invalidate |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
455 |
] |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
456 |
! |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
457 |
|
686 | 458 |
pointerLeave:state |
459 |
||
688 | 460 |
super pointerLeave: state. |
686 | 461 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
462 |
self updateImageInfo: self imageInfoString. |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
463 |
self cursor:Cursor normal. |
995 | 464 |
|
1013 | 465 |
(editMode = 'paste' or:[editMode = 'pasteUnder']) ifTrue: [self releasePasteDrawing] |
995 | 466 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
467 |
"Modified: / 29.7.1998 / 18:27:42 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
468 |
! ! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
469 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
470 |
!ImageEditView methodsFor:'image - dragging & info'! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
471 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
472 |
dragRectangleStartingAt: aPoint emphasis: emphasis |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
473 |
"drag a rectangle (filled or unfilled)" |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
474 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
475 |
|currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
476 |
mp lastMp p whichQuarter scrollX scrollY| |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
477 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
478 |
firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
479 |
magnification >= GridMagnification ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
480 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
481 |
[device anyButtonPressed] whileTrue: [ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
482 |
mp := self sensor mousePoint. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
483 |
mp = lastMp ifTrue:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
484 |
Delay waitForSeconds:0.05 |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
485 |
] ifFalse:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
486 |
lastMp := mp. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
487 |
mp := device translatePoint:mp from:device rootView id to:self id. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
488 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
489 |
scrollX := 0. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
490 |
mp x > width ifTrue:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
491 |
scrollX := mp x - width. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
492 |
] ifFalse:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
493 |
mp x < 0 ifTrue:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
494 |
scrollX := mp x. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
495 |
] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
496 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
497 |
scrollY := 0. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
498 |
mp y > height ifTrue:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
499 |
scrollY := mp y - height. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
500 |
] ifFalse:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
501 |
mp y < 0 ifTrue:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
502 |
scrollY := mp y. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
503 |
] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
504 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
505 |
(scrollX + scrollY) ~~ 0 ifTrue:[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
506 |
self scrollTo:(self viewOrigin + (scrollX @ scrollY)). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
507 |
lastMp := nil. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
508 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
509 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
510 |
currentPoint := (0@0) max: (image extent * magnification min: (p := self translation negated + mp)). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
511 |
currentPoint := currentPoint//magnification*magnification. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
512 |
currentExtent := (firstPoint - currentPoint) abs. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
513 |
whichQuarter := (firstPoint x - currentPoint x) > 0 |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
514 |
ifTrue: [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
515 |
ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
516 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
517 |
self drawCursorAt: p withLabel: |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
518 |
((firstPoint//magnification - whichQuarter + 1) printString, |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
519 |
' to: ', |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
520 |
(currentPoint//magnification + whichQuarter) printString), |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
521 |
' (extent: ', |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
522 |
(currentExtent//magnification) printString, ')'. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
523 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
524 |
currentPoint ~= lastCurrentPoint ifTrue: |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
525 |
[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
526 |
emphasis = #inverseFilledBox |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
527 |
ifTrue: |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
528 |
[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
529 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
530 |
self xoring: [self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection)] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
531 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
532 |
emphasis = #box |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
533 |
ifTrue: |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
534 |
[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
535 |
|origin extent lineWidthY lineWidthX| |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
536 |
origin := (firstPoint min: lastCurrentPoint) - 1. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
537 |
extent := (firstPoint - lastCurrentPoint) abs + 2. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
538 |
lineWidthY := extent y min: (magnification y + 2). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
539 |
lineWidthX := extent x min: (magnification x + 2). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
540 |
self redraw: (origin extent: (extent x@lineWidthY)). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
541 |
self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
542 |
self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
543 |
self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
544 |
self selectedColor ~= Color noColor |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
545 |
ifTrue: [self paint: self selectedColor] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
546 |
ifFalse: [self paint: self viewBackground]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
547 |
origin := (firstPoint min: currentPoint) + margin. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
548 |
extent := currentExtent - gridCorrection. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
549 |
lineWidthY := extent y min: magnification y. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
550 |
lineWidthX := extent x min: magnification x. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
551 |
(lineWidthY > 0 and: [lineWidthX > 0]) |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
552 |
ifTrue: |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
553 |
[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
554 |
self fillRectangle: (origin extent: (extent x@lineWidthY)). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
555 |
self fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
556 |
self fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
557 |
self fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
558 |
] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
559 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
560 |
emphasis = #filledBox |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
561 |
ifTrue: |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
562 |
[ |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
563 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
564 |
self selectedColor ~= Color noColor |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
565 |
ifTrue: [self paint: self selectedColor] |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
566 |
ifFalse: [self paint: self viewBackground]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
567 |
self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection). |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
568 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
569 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
570 |
lastCurrentPoint := currentPoint. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
571 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
572 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
573 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
574 |
^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
575 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
576 |
"Created: / 21.8.1998 / 20:17:07 / cg" |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
577 |
"Modified: / 21.8.1998 / 20:34:42 / cg" |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
578 |
! |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
579 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
580 |
drawCursorAt: aPoint |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
581 |
|clr| |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
582 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
583 |
image isNil ifTrue: [ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
584 |
self updateImageInfo: self imageInfoString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
585 |
self cursor:Cursor stop. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
586 |
^ self |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
587 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
588 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
589 |
(aPoint x < (image width * magnification) |
1060 | 590 |
and:[aPoint y < (image height * magnification) |
591 |
and:[aPoint x >= 0 |
|
592 |
and:[aPoint y >= 0]]]) |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
593 |
ifFalse:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
594 |
self updateImageInfo: self imageInfoString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
595 |
self cursor:Cursor stop. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
596 |
] ifTrue: [ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
597 |
clr := image colorAt:aPoint//magnification. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
598 |
self updateImageInfo: (aPoint//magnification) printString |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
599 |
, ' (red:' |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
600 |
, clr redByte printString |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
601 |
, ' green:' , clr greenByte printString |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
602 |
, ' blue:' , clr blueByte printString |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
603 |
, ')'. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
604 |
self cursor:Cursor crossHair |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
605 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
606 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
607 |
"Modified: / 29.7.1998 / 18:26:01 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
608 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
609 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
610 |
drawCursorAt: aPoint withLabel: aLabel |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
611 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
612 |
((0@0 extent: image extent * magnification) containsPoint: aPoint) |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
613 |
ifFalse:[self cursor:Cursor stop] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
614 |
ifTrue: [self cursor:Cursor crossHair]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
615 |
self updateImageInfo: aLabel. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
616 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
617 |
"Modified: / 29.7.1998 / 18:26:04 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
618 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
619 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
620 |
updateActivity: something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
621 |
|msg| |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
622 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
623 |
msg := something printString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
624 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
625 |
"/ cg: new code: |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
626 |
activityInfoHolder notNil ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
627 |
activityInfoHolder value:msg. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
628 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
629 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
630 |
"Modified: / 29.7.1998 / 18:41:47 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
631 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
632 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
633 |
updateImageInfo: something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
634 |
|msg coordLabel| |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
635 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
636 |
msg := something printString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
637 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
638 |
"/ cg: new code: |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
639 |
imageInfoHolder notNil ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
640 |
msg ~= imageInfoHolder value ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
641 |
imageInfoHolder value:msg. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
642 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
643 |
^ self |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
644 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
645 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
646 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
647 |
"/ "/ which gets the coordinate ... |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
648 |
"/ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
649 |
"/ (masterApplication respondsTo: #coordLabel) |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
650 |
"/ ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
651 |
"/ coordLabel := masterApplication coordLabel. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
652 |
"/ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
653 |
"/ coordLabel label ~= msg |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
654 |
"/ ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
655 |
"/ coordLabel label: msg. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
656 |
"/ "/ coordLabel redraw |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
657 |
"/ ] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
658 |
"/ ] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
659 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
660 |
"Modified: / 29.7.1998 / 19:00:21 / cg" |
627 | 661 |
! ! |
662 |
||
636 | 663 |
!ImageEditView methodsFor:'image editing'! |
627 | 664 |
|
665 |
boxAt: aPoint |
|
666 |
||
662 | 667 |
|choosedBox imageBox| |
1103 | 668 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
662 | 669 |
image rectangle: (imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification)) withColor: self selectedColor. |
632 | 670 |
image restored. |
662 | 671 |
self redraw: (choosedBox expandedBy: 1). |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
672 |
|
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
673 |
"/ cg: what a kludge - please change to use a valueHolder, |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
674 |
"/ which gets the information ... |
724 | 675 |
masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
676 | 676 |
modified := true |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
677 |
|
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
678 |
"Modified: / 31.7.1998 / 02:46:02 / cg" |
632 | 679 |
! |
680 |
||
1002 | 681 |
changeGridMagnification |
682 |
||
683 |
|box newGridMagnification| |
|
684 |
box := EnterBox new. |
|
685 |
box title:'Grid Magnification:'. |
|
686 |
box okText:'OK'. |
|
687 |
box abortText:'Cancel'. |
|
688 |
box initialText:GridMagnification x printString. |
|
689 |
box showAtPointer. |
|
690 |
(box accepted and: [(newGridMagnification := Number readFromString: box contents onError:[2]) notNil]) |
|
691 |
ifTrue: |
|
692 |
[ |
|
693 |
GridMagnification := (99 min: (2 max: newGridMagnification)) asPoint. |
|
694 |
self invalidate |
|
695 |
] |
|
696 |
! |
|
697 |
||
632 | 698 |
copyAt: aPoint |
699 |
||
700 |
|choosedBox| |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
701 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
702 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
995 | 703 |
ClipboardMagnification := nil. |
632 | 704 |
Clipboard := image subImageIn: (choosedBox origin//magnification extent: (choosedBox extent//magnification)). |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
705 |
self redraw: (choosedBox expandedBy: 1) |
632 | 706 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
707 |
"Modified: / 21.8.1998 / 20:16:41 / cg" |
632 | 708 |
! |
709 |
||
1035 | 710 |
drawPasteRectangleAt: aPoint |
711 |
||
712 |
|currentPoint gridCorrection extent| |
|
713 |
||
714 |
magnification >= GridMagnification ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
|
715 |
currentPoint := aPoint//magnification*magnification + margin. |
|
716 |
||
717 |
currentPoint ~= lastPastePoint |
|
718 |
ifTrue: |
|
719 |
[ |
|
720 |
ClipboardMagnification isNil ifTrue: [ClipboardMagnification := (Clipboard magnifiedBy: magnification) onDevice: device]. |
|
721 |
||
722 |
extent := ClipboardMagnification extent. |
|
723 |
||
724 |
currentPoint := currentPoint - self viewOrigin. |
|
725 |
||
726 |
self redraw: ((lastPastePoint ? currentPoint) extent: extent). |
|
727 |
||
728 |
(extent x > 200 or: [extent y > 200]) |
|
729 |
ifTrue: |
|
730 |
[ |
|
731 |
self xoring: [self fillRectangle: (currentPoint extent: extent)] |
|
732 |
] |
|
733 |
ifFalse: |
|
734 |
[ |
|
735 |
self displayDeviceForm: ClipboardMagnification x: currentPoint x y: currentPoint y |
|
736 |
] |
|
737 |
]. |
|
738 |
lastPastePoint := currentPoint. |
|
739 |
||
740 |
"Modified: / 29.7.1998 / 02:18:11 / cg" |
|
741 |
! |
|
742 |
||
632 | 743 |
fillAt: aPoint |
627 | 744 |
|
1047 | 745 |
windowGroup withExecuteCursorDo: |
632 | 746 |
[ |
747 |
|filledPoints| |
|
1002 | 748 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
749 |
self updateActivity:'Flood filling - press CTRL-y to abort ...'. |
632 | 750 |
[ |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
751 |
filledPoints := image floodFillAt: aPoint//magnification withColor: self selectedColor. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
752 |
image restored. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
753 |
|
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
754 |
"/ animation effect ... |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
755 |
filledPoints size < 300 |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
756 |
ifTrue: |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
757 |
[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
758 |
filledPoints do: [:p| self redraw: ((p * magnification extent: magnification) expandedBy: 1)] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
759 |
] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
760 |
ifFalse: |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
761 |
[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
762 |
self invalidate |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
763 |
]. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
764 |
"/ cg: what a kludge - please change to use a valueHolder, |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
765 |
"/ which gets the information ... |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
766 |
masterApplication imagePreView invalidate. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
767 |
modified := true |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
768 |
] valueOnUnwindDo:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
769 |
self updateActivity:'Flood fill aborted.' |
632 | 770 |
]. |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
771 |
self updateActivity:'' |
632 | 772 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
773 |
|
1047 | 774 |
"Modified: / 31.7.1998 / 20:12:45 / cg" |
632 | 775 |
! |
776 |
||
777 |
filledBoxAt: aPoint |
|
778 |
||
662 | 779 |
|choosedBox imageBox| |
1103 | 780 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
662 | 781 |
image fillRectangle: (imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification)) withColor: self selectedColor. |
632 | 782 |
image restored. |
662 | 783 |
self redraw: (choosedBox expandedBy: 1). |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
784 |
"/ cg: what a kludge - please change to use a valueHolder, |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
785 |
"/ which gets the information ... |
724 | 786 |
masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
686 | 787 |
modified := true |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
788 |
|
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
789 |
"Modified: / 31.7.1998 / 02:46:20 / cg" |
632 | 790 |
! |
791 |
||
636 | 792 |
flipHorizontal |
793 |
||
995 | 794 |
self makeUndo. |
725 | 795 |
self image: image copy flipHorizontal |
636 | 796 |
|
797 |
! |
|
798 |
||
799 |
flipVertical |
|
800 |
||
995 | 801 |
self makeUndo. |
725 | 802 |
self image: image copy flipVertical |
636 | 803 |
|
804 |
! |
|
805 |
||
806 |
magnifyImage |
|
807 |
||
808 |
|box newSize| |
|
809 |
box := EnterBox new. |
|
810 |
box title:'Image new size:'. |
|
811 |
box okText:'OK'. |
|
812 |
box abortText:'Cancel'. |
|
813 |
box initialText:image extent printString. |
|
814 |
box showAtPointer. |
|
815 |
(box accepted and: [(newSize := Object readFromString: box contents onError:nil) notNil]) |
|
816 |
ifTrue: |
|
817 |
[ |
|
995 | 818 |
self makeUndo. |
636 | 819 |
self image: (image magnifiedBy: newSize/image extent) |
686 | 820 |
] |
636 | 821 |
! |
822 |
||
823 |
negativeImage |
|
824 |
||
995 | 825 |
self makeUndo. |
725 | 826 |
self image: image copy negative |
636 | 827 |
! |
828 |
||
829 |
pasteAt: aPoint |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
830 |
"paste the image in the clipboard at aPoint" |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
831 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
832 |
self pasteAt:aPoint modeUnder:false. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
833 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
834 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
835 |
pasteAt: aPoint modeUnder:modeUnder |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
836 |
"paste the image in the clipboard at aPoint" |
636 | 837 |
|
995 | 838 |
ClipboardMagnification isNil ifTrue: [^self]. |
839 |
||
636 | 840 |
Object errorSignal handle: |
841 |
[:ex| |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
842 |
ex signal == Image unrepresentableColorSignal ifFalse:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
843 |
ex reject |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
844 |
]. |
995 | 845 |
self undo. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
846 |
self warn: 'Paste failed!!\Increasing the images depth might help.' withCRs. |
636 | 847 |
] |
848 |
do: |
|
849 |
[ |
|
1047 | 850 |
windowGroup withExecuteCursorDo:[ |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
851 |
|choosedBox imagePoint imgX imgY copiedImage imageBox presentClr newColorMap| |
995 | 852 |
|
853 |
||
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
854 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
855 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
856 |
imagePoint := choosedBox origin//magnification. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
857 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
858 |
copiedImage := Clipboard copy. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
859 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
860 |
copiedImage usedValues do:[:pixel | |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
861 |
|pastedColor oldColorMap| |
995 | 862 |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
863 |
pastedColor := (copiedImage colorMap at: pixel+1). |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
864 |
oldColorMap := image colorMap. |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
865 |
|
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
866 |
(oldColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
867 |
ifTrue: |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
868 |
[ |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
869 |
oldColorMap size < (1 bitShift:image depth) ifTrue:[ |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
870 |
"/ add to colormap |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
871 |
newColorMap isNil ifTrue:[ |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
872 |
newColorMap := oldColorMap asOrderedCollection. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
873 |
]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
874 |
newColorMap add:pastedColor. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
875 |
"/ Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
876 |
] ifFalse:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
877 |
"/ Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
878 |
copiedImage colorMap at: pixel+1 put: Color black |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
879 |
] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
880 |
] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
881 |
]. |
995 | 882 |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
883 |
newColorMap notNil ifTrue:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
884 |
image colorMap:(Colormap fromColors:newColorMap). |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
885 |
]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
886 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
887 |
copiedImage := image class fromImage: copiedImage. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
888 |
(newColorMap isNil and:[modeUnder not]) ifTrue:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
889 |
image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
890 |
] ifFalse:[ |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
891 |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
892 |
imgX := imagePoint x. |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
893 |
imgY := imagePoint y. |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
894 |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
895 |
0 to:copiedImage height-1 do:[:y | |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
896 |
0 to:copiedImage width-1 do:[:x | |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
897 |
|wasMasked newMasked dstX dstY oldColor| |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
898 |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
899 |
dstX := imgX + x. |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
900 |
dstY := imgY + y. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
901 |
wasMasked := (image maskAtX:dstX y:dstY) == 0. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
902 |
newMasked := (copiedImage maskAtX:x y:y) == 0. |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
903 |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
904 |
"/ with modeUnder, |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
905 |
"/ only replace, if its either unmasked, |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
906 |
"/ or the current drawing color. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
907 |
(modeUnder not |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
908 |
or:[wasMasked |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
909 |
or:[(oldColor := image colorAtX:dstX y:dstY) = (selectColors at:1)]]) |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
910 |
ifTrue:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
911 |
image |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
912 |
colorAtX:dstX |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
913 |
y:dstY |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
914 |
put:(copiedImage colorAtX:x y:y). |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
915 |
(wasMasked and:[newMasked not]) ifTrue:[ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
916 |
image mask pixelAtX:dstX y:dstY put:1 |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
917 |
]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
918 |
] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
919 |
] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
920 |
]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
921 |
]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
922 |
image restored. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
923 |
self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1). |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
924 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
925 |
modified := true |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
926 |
] |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
927 |
] |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
928 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
929 |
"Modified: / 21.8.1998 / 20:16:50 / cg" |
636 | 930 |
! |
931 |
||
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
932 |
pasteUnderAt: aPoint |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
933 |
"pasteUnder the image in the clipboard at aPoint. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
934 |
In this mode, only pixels which are not equal to |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
935 |
the current color or masked are pasted." |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
936 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
937 |
self pasteAt:aPoint modeUnder:true. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
938 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
939 |
|
636 | 940 |
pointAt: aPoint |
941 |
||
662 | 942 |
|imagePoint imageBox| |
636 | 943 |
imagePoint := aPoint//magnification. |
944 |
image atImageAndMask: imagePoint put: self selectedColor. |
|
662 | 945 |
self redraw: (imageBox := (imagePoint * magnification extent: magnification) expandedBy: 1). |
796 | 946 |
modified := true. |
947 |
||
636 | 948 |
! |
949 |
||
950 |
resizeImage |
|
951 |
||
952 |
|box newSize| |
|
953 |
box := EnterBox new. |
|
954 |
box title:'Image new size:'. |
|
955 |
box okText:'OK'. |
|
956 |
box abortText:'Cancel'. |
|
957 |
box initialText:image extent printString. |
|
958 |
box showAtPointer. |
|
959 |
(box accepted and: [(newSize := Object readFromString: box contents onError:nil) notNil]) |
|
960 |
ifTrue: |
|
961 |
[ |
|
962 |
|newImage| |
|
963 |
newImage := image class width: newSize x height: newSize y depth: image depth. |
|
964 |
newImage photometric:image photometric. |
|
965 |
newImage colorMap:image colorMap copy. |
|
966 |
newImage bits: (ByteArray new: newImage bytesPerRow * newSize y). |
|
967 |
||
968 |
image mask notNil |
|
969 |
ifTrue: |
|
970 |
[ |
|
971 |
|newMaskImage| |
|
972 |
newMaskImage := Depth1Image width: newSize x height: newSize y. |
|
973 |
newMaskImage photometric: image mask photometric. |
|
974 |
newMaskImage colorMap: image mask colorMap copy. |
|
975 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y). |
|
976 |
newImage mask: newMaskImage |
|
977 |
]. |
|
978 |
||
979 |
newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y). |
|
995 | 980 |
self makeUndo. |
827 | 981 |
self image: newImage. |
686 | 982 |
] |
636 | 983 |
! |
984 |
||
985 |
rotateImage |
|
986 |
||
987 |
|box rotation| |
|
988 |
box := EnterBox new. |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
989 |
box title:'Rotate by (degrees, clockwise):'. |
636 | 990 |
box okText:'OK'. |
991 |
box abortText:'Cancel'. |
|
992 |
box initialText: '0'. |
|
993 |
box showAtPointer. |
|
994 |
(box accepted and: [(rotation := Object readFromString: box contents onError:nil) notNil]) |
|
995 |
ifTrue: |
|
996 |
[ Object errorSignal handle: |
|
997 |
[:ex| |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
998 |
self warn: 'Image rotation failed!!\' withCRs, 'Increaing the image depth could help.' |
636 | 999 |
] |
1000 |
do: |
|
1001 |
[ |
|
995 | 1002 |
self makeUndo. |
636 | 1003 |
self image: (image hardRotated: rotation) |
1004 |
] |
|
686 | 1005 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1006 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1007 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
636 | 1008 |
! |
1009 |
||
1010 |
undo |
|
1011 |
||
995 | 1012 |
undoImages notEmpty |
636 | 1013 |
ifTrue: |
725 | 1014 |
[ |
1047 | 1015 |
windowGroup withExecuteCursorDo:[ |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1016 |
modified := false. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1017 |
self image: undoImages removeLast. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1018 |
"/ cg: what a kludge - please change to use a valueHolder, |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1019 |
masterApplication notNil ifTrue:[ |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1020 |
masterApplication listOfColors contents: image colorMap. |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1021 |
masterApplication findColorMapMode. |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1022 |
undoImages isEmpty ifTrue: [masterApplication valueOfCanUndo value: false]. |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1023 |
]. |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1024 |
"/ cg: not needed - image: already does it. |
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1025 |
"/ self invalidate |
688 | 1026 |
] |
636 | 1027 |
] |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1028 |
|
1047 | 1029 |
"Modified: / 31.7.1998 / 20:12:58 / cg" |
627 | 1030 |
! ! |
1031 |
||
1032 |
!ImageEditView methodsFor:'image setting'! |
|
1033 |
||
1034 |
image:anImage |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1035 |
|retVal| |
627 | 1036 |
|
688 | 1037 |
anImage isImage |
627 | 1038 |
ifTrue: |
725 | 1039 |
[ |
688 | 1040 |
(image isNil or: [self checkModified]) |
1041 |
ifTrue: |
|
1042 |
[ |
|
827 | 1043 |
|fileName| |
796 | 1044 |
masterApplication notNil |
1045 |
ifTrue: |
|
1046 |
[ |
|
995 | 1047 |
undoImages notEmpty ifTrue: [masterApplication valueOfCanUndo value: true]. |
796 | 1048 |
masterApplication imagePreView image: anImage |
1049 |
]. |
|
827 | 1050 |
image notNil |
1051 |
ifTrue: |
|
1052 |
[ |
|
1053 |
fileName := image fileName. |
|
1054 |
anImage fileName isNil ifTrue: [anImage fileName: fileName]. |
|
1055 |
]. |
|
688 | 1056 |
super image: anImage. |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1057 |
retVal := self. |
688 | 1058 |
]. |
674 | 1059 |
] |
1060 |
ifFalse: |
|
1061 |
[ |
|
1062 |
super image: nil. |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1063 |
]. |
1025
4470f3ad349f
update the image label, when a new image is assigned.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1064 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1065 |
self updateImageInfo: self imageInfoString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1066 |
^ retVal |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1067 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1068 |
"Modified: / 29.7.1998 / 18:27:31 / cg" |
627 | 1069 |
! |
1070 |
||
1071 |
loadFromFile: aFileName |
|
624 | 1072 |
|
676 | 1073 |
aFileName isNil ifTrue: [^nil]. |
624 | 1074 |
Object errorSignal handle: |
1075 |
[:exeption| |
|
674 | 1076 |
modified := false. |
632 | 1077 |
self warn: exeption errorString. |
624 | 1078 |
^nil |
1079 |
] |
|
1080 |
do: |
|
676 | 1081 |
[ |
1082 |
|imageFromFile| |
|
1083 |
(imageFromFile := Image fromFile: aFileName) notNil |
|
632 | 1084 |
ifTrue: |
1085 |
[ |
|
995 | 1086 |
self releaseUndos. |
676 | 1087 |
self image: imageFromFile. |
632 | 1088 |
imageReaderClass := ImageReader allSubclasses |
1089 |
detect: [:cls| cls isValidImageFile: aFileName] |
|
1090 |
ifNone: [self error: 'Unknown image file format!!'] |
|
1091 |
] |
|
1092 |
ifFalse: |
|
1093 |
[ |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1094 |
self error: 'Not an image file (or unrecognized format) !!' |
632 | 1095 |
] |
676 | 1096 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1097 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1098 |
"Modified: / 29.7.1998 / 18:09:13 / cg" |
624 | 1099 |
! |
255 | 1100 |
|
633 | 1101 |
loadFromMessage: aMessage |
1102 |
||
1103 |
(self resourceMessage: aMessage) isNil |
|
1104 |
ifTrue: |
|
1105 |
[ |
|
1106 |
^nil |
|
1107 |
]. |
|
624 | 1108 |
|
633 | 1109 |
^self loadfromClass: resourceClass andSelector: resourceSelector |
1110 |
||
1111 |
||
1112 |
! |
|
1113 |
||
1114 |
loadfromClass: aClassOrSymbol andSelector: aStringOrSymbol |
|
1115 |
||
678 | 1116 |
|aClass| |
1117 |
||
627 | 1118 |
imageReaderClass := nil. |
1119 |
self resourceClass: aClassOrSymbol. |
|
1120 |
self resourceSelector: aStringOrSymbol. |
|
678 | 1121 |
|
1122 |
((aClass := Smalltalk at: resourceClass) isClass and: |
|
1123 |
[aClass class implements: resourceSelector]) |
|
624 | 1124 |
ifTrue: |
1125 |
[ |
|
995 | 1126 |
self releaseUndos. |
627 | 1127 |
^self image: (aClass perform: resourceSelector) copy |
674 | 1128 |
] |
1129 |
ifFalse: |
|
1130 |
[ |
|
1131 |
modified := false. |
|
1132 |
^nil |
|
1133 |
] |
|
1134 |
||
161 | 1135 |
! ! |
1136 |
||
1 | 1137 |
!ImageEditView methodsFor:'initialization'! |
1138 |
||
161 | 1139 |
initialize |
624 | 1140 |
|
161 | 1141 |
super initialize. |
627 | 1142 |
|
686 | 1143 |
self enableMotionEvents. |
995 | 1144 |
|
1036 | 1145 |
GridMagnification := GridMagnification ? (8@8). |
995 | 1146 |
MaxUndos := MaxUndos ? 3. |
1147 |
undoImages := OrderedCollection new: MaxUndos. |
|
1003 | 1148 |
magnification := LastMagnification ? GridMagnification. |
995 | 1149 |
modified := false. |
627 | 1150 |
mouseKeyColorMode := 1. |
995 | 1151 |
resourceClass := resourceSelector := ''. |
1152 |
selectColors := Array with: nil with: nil. |
|
1036 | 1153 |
|
1154 |
"Modified: / 31.7.1998 / 02:15:14 / cg" |
|
1 | 1155 |
! ! |
1156 |
||
636 | 1157 |
!ImageEditView methodsFor:'printing & storing'! |
1 | 1158 |
|
724 | 1159 |
loadFromClass |
404 | 1160 |
|
676 | 1161 |
^self loadFromMessage: |
636 | 1162 |
(ResourceSelectionBrowser |
662 | 1163 |
request: 'Load Image From Class' |
724 | 1164 |
onSuperclass: nil |
636 | 1165 |
andClass: self resourceClass |
1166 |
andSelector: self resourceSelector |
|
1167 |
withResourceTypes: #(image fileImage)) |
|
1168 |
||
477 | 1169 |
|
161 | 1170 |
! |
1171 |
||
995 | 1172 |
makeUndo |
1173 |
||
1174 |
image notNil |
|
1175 |
ifTrue: |
|
1176 |
[ |
|
1177 |
MaxUndos <= undoImages size |
|
1178 |
ifTrue: [undoImages contents: (undoImages copyFrom: 2 to: MaxUndos)]. |
|
1179 |
undoImages add: image copy |
|
1180 |
] |
|
1181 |
! |
|
1182 |
||
627 | 1183 |
|
624 | 1184 |
|
686 | 1185 |
image notNil |
1186 |
ifTrue: |
|
636 | 1187 |
[ |
686 | 1188 |
|stream| |
1189 |
Printer supportsPostscript ifFalse: |
|
1190 |
[ |
|
1191 |
^self warn:'No postscript printer detected!!' |
|
1192 |
]. |
|
1193 |
stream := Printer newNative. |
|
1194 |
stream isNil ifTrue: |
|
1195 |
[ |
|
1196 |
^self warn:'Cannot open printer stream!!' |
|
1197 |
]. |
|
1198 |
self withWaitCursorDo: |
|
1199 |
[ |
|
1200 |
|psgc| |
|
823 | 1201 |
psgc := PSGraphicsContext on:stream. |
686 | 1202 |
psgc displayForm: (image magnifiedBy: magnification) x:0 y:0. |
1203 |
psgc close |
|
1204 |
] |
|
398
7b7255a4db0d
show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
362
diff
changeset
|
1205 |
] |
624 | 1206 |
! |
1207 |
||
1208 |
save |
|
1209 |
||
632 | 1210 |
self saveImageOrMask: #image. |
1211 |
||
624 | 1212 |
! |
1213 |
||
297 | 1214 |
saveAs |
1215 |
||
627 | 1216 |
self saveImageFileAs |
297 | 1217 |
! |
1218 |
||
627 | 1219 |
saveImageFileAs |
1220 |
||
633 | 1221 |
self saveImageFileAs: |
1222 |
(FileSelectionBrowser |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1223 |
request: 'Save Image To File' |
827 | 1224 |
fileName: self image fileName |
1225 |
withFileFilters: FileSelectionBrowser saveImageFileNameFilters) |
|
627 | 1226 |
! |
297 | 1227 |
|
627 | 1228 |
saveImageFileAs: aFileName |
297 | 1229 |
|
633 | 1230 |
aFileName isNil ifTrue: [^nil]. |
636 | 1231 |
image notNil |
627 | 1232 |
ifTrue: |
1233 |
[ |
|
1234 |
image fileName: aFileName. |
|
632 | 1235 |
self saveImageOrMask: #image |
1236 |
] |
|
1237 |
ifFalse: |
|
1238 |
[ |
|
633 | 1239 |
self warn: 'No image or file name for saving detected!!' |
632 | 1240 |
] |
1241 |
! |
|
1242 |
||
1243 |
saveImageMaskFileAs |
|
1244 |
||
633 | 1245 |
self saveImageMaskFileAs: |
636 | 1246 |
(FileSelectionBrowser |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1247 |
request: 'Save Image Mask To File' |
827 | 1248 |
fileName: self image fileName |
1249 |
withFileFilters: FileSelectionBrowser saveImageFileNameFilters) |
|
632 | 1250 |
! |
1251 |
||
1252 |
saveImageMaskFileAs: aFileName |
|
1253 |
||
633 | 1254 |
aFileName isNil ifTrue: [^nil]. |
632 | 1255 |
(image notNil and: [image mask notNil]) |
1256 |
ifTrue: |
|
1257 |
[ |
|
1258 |
image mask fileName: aFileName. |
|
1259 |
self saveImageOrMask: #mask |
|
627 | 1260 |
] |
1261 |
ifFalse: |
|
1262 |
[ |
|
632 | 1263 |
self warn: 'No image or image mask detected!!' |
627 | 1264 |
] |
628 | 1265 |
! |
1266 |
||
632 | 1267 |
saveImageOrMask: what |
628 | 1268 |
|
632 | 1269 |
Object errorSignal handle: |
1270 |
[:ex| |
|
1271 |
self warn: ex errorString. |
|
1272 |
^nil |
|
1273 |
] |
|
1274 |
do: |
|
1275 |
[ |
|
1276 |
|fileName| |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1277 |
|
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1278 |
windowGroup withCursor:Cursor write do:[ |
632 | 1279 |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1280 |
image isNil ifTrue: [^self error: 'No image to save!!']. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1281 |
what = #image |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1282 |
ifTrue: |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1283 |
[ |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1284 |
image fileName isNil ifTrue: [^self error: 'No file name for image detected!!']. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1285 |
fileName := image fileName asFilename |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1286 |
]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1287 |
what = #mask |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1288 |
ifTrue: |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1289 |
[ |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1290 |
image mask isNil ifTrue: [^self error: 'No image mask to save!!']. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1291 |
image mask fileName isNil ifTrue: [^self error: 'No file name for image mask detected!!']. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1292 |
fileName := image mask fileName asFilename |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1293 |
]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1294 |
fileName name size = 0 ifTrue: [^self error: 'No file name detected!!']. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1295 |
(fileName suffix = 'tiff') | (fileName suffix = 'tif') ifTrue: [imageReaderClass := TIFFReader]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1296 |
fileName suffix = 'xpm' ifTrue: [imageReaderClass := XPMReader]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1297 |
fileName suffix = 'xbm' ifTrue: [imageReaderClass := XBMReader]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1298 |
fileName suffix = 'gif' ifTrue: [imageReaderClass := GIFReader]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1299 |
(fileName suffix = 'jpg') | (fileName suffix = 'jpeg') ifTrue: [imageReaderClass := JPEGReader]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1300 |
imageReaderClass isNil ifTrue: [imageReaderClass := XPMReader. image fileName: image fileName, '.xpm']. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1301 |
what = #image ifTrue: [image saveOn: image fileName using: imageReaderClass. modified := false]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1302 |
what = #mask ifTrue: [image mask saveOn: image mask fileName using: imageReaderClass]. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1303 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1304 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1305 |
|
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1306 |
"Modified: / 28.7.1998 / 21:57:14 / cg" |
633 | 1307 |
! |
1308 |
||
1309 |
saveMethod |
|
1310 |
||
1311 |
Object errorSignal handle: |
|
1312 |
[:ex| |
|
1313 |
self warn: ex errorString. |
|
1314 |
^nil |
|
1315 |
] |
|
1316 |
do: |
|
1317 |
[ |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1318 |
|category imageStoreStream cls sel mthd imageKey| |
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1319 |
|
1050 | 1320 |
windowGroup withExecuteCursorDo:[ |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1321 |
(self resourceSelector trimBlanks size = 0) | (cls := Smalltalk at: self resourceClass) isClass not |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1322 |
ifTrue: [^self saveMethodAs]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1323 |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1324 |
self image storeOn: (imageStoreStream := WriteStream on: ''). |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1325 |
sel := self resourceSelector. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1326 |
|
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1327 |
"/ if that method already exists, do not overwrite the category |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1328 |
category := 'image specs'. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1329 |
(mthd := cls class compiledMethodAt:sel) notNil ifTrue:[ |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1330 |
category := mthd category. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1331 |
]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1332 |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1333 |
imageKey := (cls name, ' ', sel) asSymbol. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1334 |
Icon constantNamed: imageKey put:nil. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1335 |
ByteCodeCompiler |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1336 |
compile: ((sel, |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1337 |
'\', (ResourceSpecEditor codeGenerationCommentForClass: ImageEditor), |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1338 |
'\\' , |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1339 |
' "\', |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1340 |
' self ' , self resourceSelector , ' inspect\', |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1341 |
' ImageEditor openOnClass:self andSelector:#', self resourceSelector, |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1342 |
'\ "', |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1343 |
'\\', |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1344 |
' <resource: #image>', |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1345 |
'\\', |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1346 |
' ^Icon\') withCRs, |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1347 |
' constantNamed:#''', imageKey, '''\' withCRs, |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1348 |
' ifAbsentPut:[', imageStoreStream contents, ']') |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1349 |
forClass: cls class inCategory: category. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1350 |
modified := false. |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1351 |
] |
633 | 1352 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1353 |
|
1047 | 1354 |
"Modified: / 31.7.1998 / 20:12:54 / cg" |
633 | 1355 |
! |
1356 |
||
1357 |
saveMethodAs |
|
1358 |
||
636 | 1359 |
(self resourceMessage: |
1360 |
(ResourceSelectionBrowser |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1361 |
request: 'Save Image In Class' |
693 | 1362 |
onSuperclass: #Object |
636 | 1363 |
andClass: self resourceClass |
1364 |
andSelector: self resourceSelector |
|
1365 |
withResourceTypes: #(image fileImage))) notNil |
|
633 | 1366 |
ifTrue: |
674 | 1367 |
[ |
633 | 1368 |
^self saveMethod |
674 | 1369 |
]. |
633 | 1370 |
^nil |
1 | 1371 |
! ! |
1372 |
||
161 | 1373 |
!ImageEditView methodsFor:'queries'! |
5 | 1374 |
|
161 | 1375 |
heightOfContents |
1376 |
||
686 | 1377 |
image isNil ifTrue:[^0]. |
1378 |
^(image height * magnification y) rounded |
|
5 | 1379 |
! |
1380 |
||
995 | 1381 |
imageContainsPastePoint: aPoint |
1382 |
||
1383 |
^image notNil and: |
|
1384 |
[Clipboard notNil and: |
|
1385 |
[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]] |
|
1386 |
! |
|
1387 |
||
627 | 1388 |
imageContainsPoint: aPoint |
632 | 1389 |
|
1390 |
^image notNil and: |
|
1391 |
[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))] |
|
627 | 1392 |
! |
1393 |
||
783 | 1394 |
imageInfoString |
1395 |
||
1396 |
|imageInfoString usedColors| |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1397 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1398 |
image isNil ifTrue: [imageInfoString := 'No image loaded.'] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1399 |
ifFalse: [ |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1400 |
image colorMap isNil ifTrue: [usedColors := '?'] ifFalse: [usedColors := image usedColors size]. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1401 |
imageInfoString := image width printString, 'x' |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1402 |
, image height printString, 'x' |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1403 |
, (2 raisedTo: image depth) printString |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1404 |
, (image mask notNil ifTrue: [' (mask + '] ifFalse: ['(']) |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1405 |
, usedColors printString |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1406 |
, ' used colors)']. |
783 | 1407 |
|
1408 |
^imageInfoString |
|
1409 |
! |
|
1410 |
||
161 | 1411 |
widthOfContents |
5 | 1412 |
|
686 | 1413 |
image isNil ifTrue:[^0]. |
1414 |
^(image width * magnification x) rounded |
|
5 | 1415 |
! ! |
1416 |
||
627 | 1417 |
!ImageEditView methodsFor:'release'! |
1418 |
||
1419 |
destroy |
|
1420 |
||
996 | 1421 |
ClipboardMagnification := Clipboard := nil. |
1003 | 1422 |
LastMagnification := magnification. |
686 | 1423 |
|
1424 |
super destroy |
|
627 | 1425 |
|
995 | 1426 |
! |
1427 |
||
1428 |
releasePasteDrawing |
|
1429 |
||
1430 |
(lastPastePoint notNil and: [ClipboardMagnification notNil]) |
|
1431 |
ifTrue: |
|
1432 |
[ |
|
1433 |
self redraw: (lastPastePoint extent: (ClipboardMagnification extent)). |
|
1434 |
]. |
|
1435 |
lastPastePoint := ClipboardMagnification := nil |
|
1436 |
! |
|
1437 |
||
1438 |
releaseUndos |
|
1439 |
||
1440 |
undoImages removeAll. |
|
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1441 |
"/ cg: what a kludge - please change to use a valueHolder, |
995 | 1442 |
masterApplication valueOfCanUndo value: false. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1443 |
|
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1444 |
"Modified: / 31.7.1998 / 02:47:21 / cg" |
627 | 1445 |
! ! |
1446 |
||
632 | 1447 |
!ImageEditView methodsFor:'testing'! |
1448 |
||
1449 |
checkModified |
|
1450 |
||
1451 |
modified |
|
1452 |
ifTrue: |
|
1453 |
[ |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1454 |
((YesNoBox title:(resources string:'Image was modified !!')) |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1455 |
noText:(resources string:'Cancel'); |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1456 |
yesText:(resources string:'Forget it and proceed'); |
632 | 1457 |
showAtPointer; |
1458 |
accepted) ifFalse: [^false]. |
|
1459 |
modified := false |
|
1460 |
]. |
|
1461 |
^true |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1462 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1463 |
"Modified: / 29.7.1998 / 18:55:24 / cg" |
632 | 1464 |
! ! |
1465 |
||
255 | 1466 |
!ImageEditView class methodsFor:'documentation'! |
161 | 1467 |
|
1468 |
version |
|
1103 | 1469 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.101 1998-08-31 13:29:38 tz Exp $' |
161 | 1470 |
! ! |