400
|
1 |
"
|
767
|
2 |
COPYRIGHT (c) 1997-1998 by eXept Software AG
|
400
|
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
|
405
|
7 |
inclusion of the above copyright notice. This software may not
|
400
|
8 |
be provided or otherwise made available to, or used by, any
|
405
|
9 |
other person. No title to or ownership of the software is
|
400
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
ToolApplicationModel subclass:#ImageEditor
|
|
14 |
instanceVariableNames:'colorMapMode selectedColorIndex postOpenAction'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
617
|
17 |
category:'Interface-UIPainter'
|
400
|
18 |
!
|
|
19 |
|
|
20 |
!ImageEditor class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
767
|
24 |
COPYRIGHT (c) 1997-1998 by eXept Software AG
|
400
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
405
|
29 |
inclusion of the above copyright notice. This software may not
|
400
|
30 |
be provided or otherwise made available to, or used by, any
|
405
|
31 |
other person. No title to or ownership of the software is
|
400
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
737
|
38 |
Image Editor allows you to create, design, modify or just inspect images.
|
400
|
39 |
|
|
40 |
[start with:]
|
|
41 |
ImageEditor open
|
|
42 |
ImageEditor openOnClass:ImageEditor andSelector:#newImageIcon
|
|
43 |
|
|
44 |
[see also:]
|
|
45 |
ImageEditView Image
|
|
46 |
|
|
47 |
[author:]
|
544
|
48 |
Thomas Zwick, eXept Software AG
|
400
|
49 |
"
|
|
50 |
! !
|
|
51 |
|
|
52 |
!ImageEditor class methodsFor:'instance creation'!
|
|
53 |
|
|
54 |
openModalOnClass: aClass andSelector: aSelector
|
767
|
55 |
"opens modal the Image Editor on aClass and aSelector"
|
|
56 |
"
|
|
57 |
self openModalOnClass: self andSelector: #leftMouseKeyIcon
|
|
58 |
"
|
400
|
59 |
|
767
|
60 |
|imageEditor imageEditView className resourceClassName resourceSelector|
|
|
61 |
|
400
|
62 |
imageEditor := self new.
|
767
|
63 |
|
400
|
64 |
aClass isClass ifTrue: [className := aClass name].
|
767
|
65 |
aClass isString ifTrue:[className := aClass].
|
400
|
66 |
|
688
|
67 |
imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector].
|
400
|
68 |
imageEditor openModal.
|
|
69 |
|
688
|
70 |
resourceClassName := imageEditView resourceClass.
|
767
|
71 |
resourceSelector := imageEditView resourceSelector.
|
415
|
72 |
|
815
|
73 |
((className asString ~= resourceClassName)
|
|
74 |
or:[aSelector asString ~= resourceSelector])
|
415
|
75 |
ifTrue: [^resourceClassName, ' ', resourceSelector]
|
|
76 |
ifFalse:[^nil]
|
400
|
77 |
!
|
|
78 |
|
|
79 |
openOnClass: aClass andSelector: aSelector
|
767
|
80 |
"opens the Image Editor on aClass and aSelector"
|
|
81 |
"
|
|
82 |
self openOnClass: self andSelector: #leftMouseKeyIcon
|
|
83 |
"
|
400
|
84 |
|
|
85 |
^self open loadFromMessage: aClass name, ' ', aSelector
|
|
86 |
!
|
|
87 |
|
767
|
88 |
openOnFile: aFileName
|
|
89 |
"opens the Image Editor on aFileName"
|
|
90 |
"
|
|
91 |
self openOnFile: 'bitmaps/SmalltalkX.xbm'
|
|
92 |
"
|
400
|
93 |
|
767
|
94 |
^self open loadFromFile: aFileName
|
400
|
95 |
!
|
|
96 |
|
767
|
97 |
openOnImage: anImage
|
|
98 |
"opens the Image Editor on anImage"
|
|
99 |
"
|
|
100 |
self openOnImage: self stxIcon
|
|
101 |
"
|
400
|
102 |
|
767
|
103 |
^self open loadFromImage: anImage
|
400
|
104 |
! !
|
|
105 |
|
|
106 |
!ImageEditor class methodsFor:'accessing'!
|
|
107 |
|
|
108 |
listOfColorMaps
|
767
|
109 |
"returns the list of default color maps for a new image"
|
400
|
110 |
|
|
111 |
|colorMap|
|
|
112 |
(colorMap := OrderedCollection new)
|
|
113 |
add: Color black;
|
|
114 |
add: Color white;
|
|
115 |
add: Color red;
|
|
116 |
add: Color green;
|
|
117 |
add: Color blue;
|
|
118 |
add: Color cyan;
|
|
119 |
add: Color yellow;
|
|
120 |
add: Color magenta;
|
|
121 |
add: (Color red: 50 green: 0 blue: 0);
|
|
122 |
add: (Color red: 0 green: 50 blue: 0);
|
|
123 |
add: (Color red: 0 green: 0 blue: 50);
|
|
124 |
add: (Color red: 0 green: 50 blue: 50);
|
|
125 |
add: (Color red: 50 green: 50 blue: 0);
|
|
126 |
add: (Color red: 50 green: 0 blue: 50);
|
|
127 |
add: Color gray;
|
|
128 |
add: Color lightGray.
|
|
129 |
0 to: 5 do:
|
|
130 |
[:r|
|
|
131 |
0 to: 5 do:
|
|
132 |
[:g|
|
|
133 |
0 to: 5 do:
|
|
134 |
[:b|
|
|
135 |
colorMap add: (Color red: (r*100//5) ceiling green: (g*100//5) ceiling blue: (b*100//5) ceiling)
|
|
136 |
]
|
|
137 |
]
|
|
138 |
].
|
|
139 |
|
|
140 |
1 to: 25 do:
|
|
141 |
[:g|
|
|
142 |
colorMap add: (Color gray: (g*100//26) ceiling)
|
|
143 |
].
|
|
144 |
|
|
145 |
^Dictionary new
|
|
146 |
at: '8-plane' put: colorMap;
|
|
147 |
at: '8-plane + mask' put: colorMap;
|
|
148 |
at: '4-plane' put: (colorMap copyFrom: 1 to: 16);
|
|
149 |
at: '4-plane + mask' put: (colorMap copyFrom: 1 to: 16);
|
|
150 |
at: '2-plane' put: (colorMap copyFrom: 1 to: 4);
|
|
151 |
at: '2-plane + mask' put: (colorMap copyFrom: 1 to: 4);
|
|
152 |
at: '1-plane' put: (colorMap copyFrom: 1 to: 2);
|
|
153 |
at: '1-plane + mask' put: (colorMap copyFrom: 1 to: 2);
|
|
154 |
yourself
|
|
155 |
!
|
|
156 |
|
|
157 |
listOfDefaultSizes
|
767
|
158 |
"returns the list of default sizes for a new image"
|
400
|
159 |
|
767
|
160 |
^#('22x22' '16x16' '32x32')
|
400
|
161 |
! !
|
|
162 |
|
460
|
163 |
!ImageEditor class methodsFor:'help specs'!
|
|
164 |
|
|
165 |
helpSpec
|
737
|
166 |
"This resource specification was automatically generated
|
|
167 |
by the UIHelpTool of ST/X."
|
|
168 |
|
|
169 |
"Do not manually edit this!! If it is corrupted,
|
|
170 |
the UIHelpTool may not be able to read the specification."
|
460
|
171 |
|
|
172 |
"
|
737
|
173 |
UIHelpTool openOnClass:ImageEditor
|
460
|
174 |
"
|
|
175 |
|
737
|
176 |
<resource: #help>
|
|
177 |
|
|
178 |
^super helpSpec addPairsFrom:#(
|
460
|
179 |
|
|
180 |
#colorMap
|
|
181 |
'Increases or reduces size of color map of the image.'
|
|
182 |
|
487
|
183 |
#colorMapTable
|
675
|
184 |
'Shows a list of used colors of the image.'
|
487
|
185 |
|
460
|
186 |
#drawModeBox
|
|
187 |
'Switches to mode drawing boxes.'
|
|
188 |
|
|
189 |
#drawModeCopy
|
|
190 |
'Switches to mode copying areas.'
|
|
191 |
|
|
192 |
#drawModeFill
|
|
193 |
'Switches to mode filling areas around selected point.'
|
|
194 |
|
|
195 |
#drawModeFilledBox
|
|
196 |
'Switches to mode drawing filled boxes.'
|
|
197 |
|
|
198 |
#drawModePaste
|
|
199 |
'Switches to mode pasting areas at selected point.'
|
|
200 |
|
|
201 |
#drawModePoint
|
|
202 |
'Switches to mode drawing points.'
|
|
203 |
|
|
204 |
#editFlipHorizontal
|
|
205 |
'Flips horizontally the image.'
|
|
206 |
|
|
207 |
#editFlipVertical
|
|
208 |
'Flips vertically the image.'
|
|
209 |
|
|
210 |
#editMagnifyImage
|
|
211 |
'Opens a dialog to magnify the image.'
|
|
212 |
|
|
213 |
#editNegate
|
|
214 |
'Convertes colors of image by negating them.'
|
|
215 |
|
|
216 |
#editResize
|
|
217 |
'Opens a dialog to resize the image with preserving the old image.'
|
|
218 |
|
|
219 |
#editRotate
|
|
220 |
'Opens a dialog to rotate the image in degrees.'
|
|
221 |
|
|
222 |
#fileLoadFromClass
|
651
|
223 |
'Opens a dialog for selecting and loading an image from resource method of a class.'
|
460
|
224 |
|
|
225 |
#fileLoadFromFile
|
651
|
226 |
'Opens a dialog for selecting and loading an image from a file.'
|
460
|
227 |
|
|
228 |
#fileNewImage
|
651
|
229 |
'Opens a dialog with choices of size and color depth to create an new image.'
|
460
|
230 |
|
|
231 |
#filePrint
|
|
232 |
'Print the image on a postscript printer.'
|
|
233 |
|
|
234 |
#fileSaveAs
|
675
|
235 |
'Opens a dialog to save the image to a file.'
|
460
|
236 |
|
|
237 |
#fileSaveMaskAs
|
675
|
238 |
'Opens a dialog to save the mask of the image to a file.'
|
460
|
239 |
|
|
240 |
#fileSaveMethod
|
675
|
241 |
'Saves the image on current class and selector.'
|
460
|
242 |
|
|
243 |
#fileSaveMethodAs
|
675
|
244 |
'Opens a dialog for selecting and saving the image in a resource method of a class.'
|
460
|
245 |
|
487
|
246 |
#magnificationNumber
|
|
247 |
'Shows current number of magnification.'
|
|
248 |
|
|
249 |
#magnifyImageDown
|
675
|
250 |
'Magnifies down the image.'
|
487
|
251 |
|
|
252 |
#magnifyImageUp
|
675
|
253 |
'Magnifies up the image.'
|
487
|
254 |
|
|
255 |
#mouseKeyColorMode
|
675
|
256 |
'Switches between left and right mouse button color.'
|
487
|
257 |
|
|
258 |
#previewView
|
675
|
259 |
'Shows preview of the image.'
|
487
|
260 |
|
460
|
261 |
)
|
|
262 |
! !
|
|
263 |
|
737
|
264 |
!ImageEditor class methodsFor:'image specs'!
|
|
265 |
|
|
266 |
leftMouseKeyIcon
|
|
267 |
"This resource specification was automatically generated
|
|
268 |
by the ImageEditor of ST/X."
|
|
269 |
|
|
270 |
"Do not manually edit this!! If it is corrupted,
|
|
271 |
the ImageEditor may not be able to read the specification."
|
|
272 |
|
|
273 |
"
|
|
274 |
ImageEditor openOnClass:self andSelector:#leftMouseKeyIcon
|
|
275 |
"
|
|
276 |
|
|
277 |
<resource: #image>
|
|
278 |
|
|
279 |
^Icon
|
|
280 |
constantNamed:#'ImageEditor leftMouseKeyIcon'
|
|
281 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@JEE@@B!!QP@@(TT@@@@@@@AUUP@@UUT@@EUU@@AUUP@@UUT@@EUU@@@UU@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 255 0 0 0 255 0]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@?0G? _>A?8G? _>A?8G? _>A?8G? O<@_ @@@b') ; yourself); yourself]!
|
|
282 |
|
|
283 |
rightMouseKeyIcon
|
|
284 |
"This resource specification was automatically generated
|
|
285 |
by the ImageEditor of ST/X."
|
|
286 |
|
|
287 |
"Do not manually edit this!! If it is corrupted,
|
|
288 |
the ImageEditor may not be able to read the specification."
|
|
289 |
|
|
290 |
"
|
|
291 |
ImageEditor openOnClass:self andSelector:#rightMouseKeyIcon
|
|
292 |
"
|
|
293 |
|
|
294 |
<resource: #image>
|
|
295 |
|
|
296 |
^Icon
|
|
297 |
constantNamed:#'ImageEditor rightMouseKeyIcon'
|
|
298 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@EEJ@@AQR @@TT(@@@@@@@AUUP@@UUT@@EUU@@AUUP@@UUT@@EUU@@@UU@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 255 0 0 0 255 0]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@?0G? _>A?8G? _>A?8G? _>A?8G? O<@_ @@@b') ; yourself); yourself]! !
|
|
299 |
|
400
|
300 |
!ImageEditor class methodsFor:'interface specs'!
|
|
301 |
|
767
|
302 |
dialogSpecForNewImage
|
737
|
303 |
"This resource specification was automatically generated
|
|
304 |
by the UIPainter of ST/X."
|
519
|
305 |
|
737
|
306 |
"Do not manually edit this!! If it is corrupted,
|
|
307 |
the UIPainter may not be able to read the specification."
|
519
|
308 |
|
|
309 |
"
|
767
|
310 |
UIPainter new openOnClass:ImageEditor andSelector:#dialogSpecForNewImage
|
|
311 |
ImageEditor new openInterface:#dialogSpecForNewImage
|
519
|
312 |
"
|
|
313 |
|
|
314 |
<resource: #canvas>
|
|
315 |
|
|
316 |
^
|
|
317 |
|
|
318 |
#(#FullSpec
|
672
|
319 |
#window:
|
519
|
320 |
#(#WindowSpec
|
672
|
321 |
#name: 'New Image'
|
737
|
322 |
#layout: #(#LayoutFrame 240 0 278 0 540 0 382 0)
|
672
|
323 |
#label: 'New Image'
|
|
324 |
#min: #(#Point 10 10)
|
|
325 |
#max: #(#Point 1152 900)
|
737
|
326 |
#bounds: #(#Rectangle 240 278 541 383)
|
672
|
327 |
#usePreferredExtent: false
|
519
|
328 |
)
|
672
|
329 |
#component:
|
519
|
330 |
#(#SpecCollection
|
672
|
331 |
#collection:
|
519
|
332 |
#(
|
|
333 |
#(#ViewSpec
|
672
|
334 |
#name: 'View'
|
737
|
335 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -35 1.0)
|
672
|
336 |
#component:
|
519
|
337 |
#(#SpecCollection
|
672
|
338 |
#collection:
|
519
|
339 |
#(
|
|
340 |
#(#FramedBoxSpec
|
672
|
341 |
#name: 'framedBox1'
|
737
|
342 |
#layout: #(#LayoutFrame 1 0.0 7 0.0 0 0.4 66 0)
|
672
|
343 |
#component:
|
519
|
344 |
#(#SpecCollection
|
672
|
345 |
#collection:
|
519
|
346 |
#(
|
|
347 |
#(#ComboBoxSpec
|
672
|
348 |
#name: 'defaultSizesComboBox'
|
|
349 |
#layout: #(#LayoutFrame 15 0.0 20 0.0 17 1.0 16 1.0)
|
|
350 |
#model: #selectionOfSize
|
|
351 |
#type: #string
|
|
352 |
#comboList: #listOfDefaultSizes
|
519
|
353 |
)
|
|
354 |
)
|
|
355 |
)
|
672
|
356 |
#label: 'Size'
|
|
357 |
#labelPosition: #topLeft
|
|
358 |
#style: #(#FontDescription #helvetica #medium #roman 12)
|
519
|
359 |
)
|
|
360 |
#(#FramedBoxSpec
|
672
|
361 |
#name: 'framedBox2'
|
737
|
362 |
#layout: #(#LayoutFrame 0 0.4 7 0.0 -1 1.0 66 0)
|
672
|
363 |
#component:
|
519
|
364 |
#(#SpecCollection
|
672
|
365 |
#collection:
|
519
|
366 |
#(
|
|
367 |
#(#ComboListSpec
|
672
|
368 |
#name: 'colorMapComboBox'
|
|
369 |
#layout: #(#LayoutFrame 15 0.0 20 0.0 18 1.0 16 1.0)
|
|
370 |
#model: #selectionOfColorMap
|
|
371 |
#comboList: #listOfColorMaps
|
|
372 |
#useIndex: false
|
519
|
373 |
)
|
|
374 |
)
|
|
375 |
)
|
672
|
376 |
#label: 'Color Map'
|
|
377 |
#labelPosition: #topLeft
|
|
378 |
#style: #(#FontDescription #helvetica #medium #roman 12)
|
519
|
379 |
)
|
|
380 |
)
|
|
381 |
)
|
672
|
382 |
#level: 1
|
519
|
383 |
)
|
672
|
384 |
#(#UISubSpecification
|
|
385 |
#name: 'UISubSpecification1'
|
737
|
386 |
#layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0)
|
672
|
387 |
#majorKey: #ToolApplicationModel
|
|
388 |
#minorKey: #windowSpecForCommitWithoutChannels
|
519
|
389 |
)
|
|
390 |
)
|
|
391 |
)
|
|
392 |
)
|
767
|
393 |
!
|
|
394 |
|
|
395 |
windowSpec
|
|
396 |
"This resource specification was automatically generated
|
|
397 |
by the UIPainter of ST/X."
|
|
398 |
|
|
399 |
"Do not manually edit this!! If it is corrupted,
|
|
400 |
the UIPainter may not be able to read the specification."
|
|
401 |
|
|
402 |
"
|
|
403 |
UIPainter new openOnClass:ImageEditor andSelector:#windowSpec
|
|
404 |
ImageEditor new openInterface:#windowSpec
|
|
405 |
ImageEditor open
|
|
406 |
"
|
|
407 |
|
|
408 |
<resource: #canvas>
|
|
409 |
|
|
410 |
^
|
|
411 |
|
|
412 |
#(#FullSpec
|
|
413 |
#window:
|
|
414 |
#(#WindowSpec
|
|
415 |
#name: 'Image Editor'
|
|
416 |
#layout: #(#LayoutFrame 167 0 330 0 666 0 675 0)
|
|
417 |
#label: 'Image Editor'
|
|
418 |
#min: #(#Point 400 320)
|
|
419 |
#max: #(#Point 1152 900)
|
|
420 |
#bounds: #(#Rectangle 167 330 667 676)
|
|
421 |
#menu: #menu
|
|
422 |
#usePreferredExtent: false
|
|
423 |
)
|
|
424 |
#component:
|
|
425 |
#(#SpecCollection
|
|
426 |
#collection:
|
|
427 |
#(
|
|
428 |
#(#MenuPanelSpec
|
|
429 |
#name: 'menuToolbarView'
|
|
430 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
|
|
431 |
#menu: #menuToolbar
|
|
432 |
#style: #(#FontDescription #helvetica #medium #roman 10)
|
|
433 |
#showSeparatingLines: true
|
|
434 |
)
|
|
435 |
#(#VariableHorizontalPanelSpec
|
|
436 |
#name: 'variableHorizontalPanel1'
|
|
437 |
#layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
|
|
438 |
#component:
|
|
439 |
#(#SpecCollection
|
|
440 |
#collection:
|
|
441 |
#(
|
|
442 |
#(#ViewSpec
|
|
443 |
#name: 'view1'
|
|
444 |
#component:
|
|
445 |
#(#SpecCollection
|
|
446 |
#collection:
|
|
447 |
#(
|
|
448 |
#(#VariableVerticalPanelSpec
|
|
449 |
#name: 'VariableVerticalPanel1'
|
|
450 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
451 |
#component:
|
|
452 |
#(#SpecCollection
|
|
453 |
#collection:
|
|
454 |
#(
|
|
455 |
#(#ViewSpec
|
|
456 |
#name: 'View1'
|
|
457 |
#component:
|
|
458 |
#(#SpecCollection
|
|
459 |
#collection:
|
|
460 |
#(
|
|
461 |
#(#MenuPanelSpec
|
|
462 |
#name: 'MouseButtonColorToolBar'
|
|
463 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0)
|
|
464 |
#menu: #menuMouseButtonColors
|
|
465 |
)
|
|
466 |
#(#DataSetSpec
|
|
467 |
#name: 'colorDataSetView'
|
|
468 |
#layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0)
|
|
469 |
#activeHelpKey: #colorMapTable
|
|
470 |
#model: #selectionOfColor
|
|
471 |
#style: #(#FontDescription #helvetica #medium #roman 10)
|
|
472 |
#hasHorizontalScrollBar: true
|
|
473 |
#hasVerticalScrollBar: true
|
|
474 |
#miniScrollerHorizontal: true
|
|
475 |
#miniScrollerVertical: true
|
|
476 |
#level: -1
|
|
477 |
#dataList: #listOfColors
|
|
478 |
#has3Dsepartors: true
|
|
479 |
#verticalSpacing: 1
|
|
480 |
#columns:
|
|
481 |
#(
|
|
482 |
#(#DataSetColumnSpec
|
|
483 |
#rendererType: #rowSelector
|
|
484 |
#backgroundSelector: #yourself
|
|
485 |
)
|
|
486 |
#(#DataSetColumnSpec
|
|
487 |
#label: 'R'
|
|
488 |
#labelAlignment: #left
|
|
489 |
#model: #rowRedByte
|
|
490 |
#canSelect: false
|
|
491 |
)
|
|
492 |
#(#DataSetColumnSpec
|
|
493 |
#label: 'G'
|
|
494 |
#labelAlignment: #left
|
|
495 |
#model: #rowGreenByte
|
|
496 |
#canSelect: false
|
|
497 |
)
|
|
498 |
#(#DataSetColumnSpec
|
|
499 |
#label: 'B'
|
|
500 |
#labelAlignment: #left
|
|
501 |
#model: #rowBlueByte
|
|
502 |
#canSelect: false
|
|
503 |
)
|
|
504 |
)
|
|
505 |
)
|
|
506 |
)
|
|
507 |
)
|
|
508 |
)
|
|
509 |
#(#ArbitraryComponentSpec
|
|
510 |
#name: 'imagePreView'
|
|
511 |
#activeHelpKey: #previewView
|
|
512 |
#hasHorizontalScrollBar: true
|
|
513 |
#hasVerticalScrollBar: true
|
|
514 |
#miniScrollerHorizontal: true
|
|
515 |
#miniScrollerVertical: true
|
|
516 |
#component: #ImageView
|
|
517 |
#hasBorder: false
|
|
518 |
)
|
|
519 |
)
|
|
520 |
)
|
|
521 |
#handles: #(#Any 0.723776 1.0)
|
|
522 |
)
|
|
523 |
)
|
|
524 |
)
|
|
525 |
)
|
|
526 |
#(#ViewSpec
|
|
527 |
#name: 'view2'
|
|
528 |
#component:
|
|
529 |
#(#SpecCollection
|
|
530 |
#collection:
|
|
531 |
#(
|
|
532 |
#(#ArbitraryComponentSpec
|
|
533 |
#name: 'imageEditView'
|
|
534 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0)
|
|
535 |
#hasHorizontalScrollBar: true
|
|
536 |
#hasVerticalScrollBar: true
|
|
537 |
#component: #ImageEditView
|
|
538 |
#hasBorder: false
|
|
539 |
)
|
|
540 |
#(#LabelSpec
|
|
541 |
#name: 'coordLabel'
|
|
542 |
#layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0)
|
|
543 |
#level: -1
|
|
544 |
#adjust: #left
|
|
545 |
#resizeForLabel: false
|
|
546 |
)
|
|
547 |
#(#ArrowButtonSpec
|
|
548 |
#name: 'magnifyDownButton'
|
|
549 |
#layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1)
|
|
550 |
#activeHelpKey: #magnifyImageDown
|
|
551 |
#model: #doMagnifyDown
|
|
552 |
#enableChannel: #imageIsLoaded
|
|
553 |
#isTriggerOnDown: true
|
|
554 |
#direction: #left
|
|
555 |
)
|
|
556 |
#(#ArrowButtonSpec
|
|
557 |
#name: 'magnifyUpButton'
|
|
558 |
#layout: #(#LayoutFrame -24 1 -22 1 -2 1 0 1)
|
|
559 |
#activeHelpKey: #magnifyImageUp
|
|
560 |
#model: #doMagnifyUp
|
|
561 |
#enableChannel: #imageIsLoaded
|
|
562 |
#isTriggerOnDown: true
|
|
563 |
#direction: #right
|
|
564 |
)
|
|
565 |
#(#InputFieldSpec
|
|
566 |
#name: 'magnificationInputField'
|
|
567 |
#layout: #(#LayoutFrame -57 1 -22 1 -26 1 0 1)
|
|
568 |
#activeHelpKey: #magnificationNumber
|
|
569 |
#enableChannel: #imageIsLoaded
|
|
570 |
#model: #valueOfMagnification
|
|
571 |
#type: #number
|
|
572 |
#acceptOnReturn: false
|
|
573 |
#acceptOnTab: false
|
|
574 |
#numChars: 2
|
|
575 |
)
|
|
576 |
)
|
|
577 |
)
|
|
578 |
#level: -1
|
|
579 |
)
|
|
580 |
)
|
|
581 |
)
|
|
582 |
#handles: #(#Any 0.276 1.0)
|
|
583 |
)
|
|
584 |
#(#UISubSpecification
|
|
585 |
#name: 'infoBarSubSpec'
|
|
586 |
#layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
|
|
587 |
#majorKey: #ToolApplicationModel
|
|
588 |
#minorKey: #windowSpecForInfoBar
|
|
589 |
)
|
|
590 |
)
|
|
591 |
)
|
|
592 |
)
|
519
|
593 |
! !
|
|
594 |
|
|
595 |
!ImageEditor class methodsFor:'menu specs'!
|
|
596 |
|
400
|
597 |
menu
|
737
|
598 |
"This resource specification was automatically generated
|
|
599 |
by the MenuEditor of ST/X."
|
400
|
600 |
|
737
|
601 |
"Do not manually edit this!! If it is corrupted,
|
|
602 |
the MenuEditor may not be able to read the specification."
|
400
|
603 |
|
|
604 |
"
|
|
605 |
MenuEditor new openOnClass:ImageEditor andSelector:#menu
|
|
606 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menu)) startUp
|
|
607 |
"
|
|
608 |
|
|
609 |
<resource: #menu>
|
|
610 |
|
|
611 |
^
|
|
612 |
|
|
613 |
#(#Menu
|
|
614 |
|
|
615 |
#(
|
|
616 |
#(#MenuItem
|
672
|
617 |
#label: 'About'
|
|
618 |
#activeHelpKey: #about
|
|
619 |
#labelImage: #(#ResourceRetriever nil #menuIcon)
|
|
620 |
#submenuChannel: #menuAbout
|
400
|
621 |
)
|
|
622 |
#(#MenuItem
|
672
|
623 |
#label: 'File'
|
|
624 |
#translateLabel: true
|
|
625 |
#activeHelpKey: #file
|
|
626 |
#submenu:
|
400
|
627 |
#(#Menu
|
|
628 |
|
|
629 |
#(
|
|
630 |
#(#MenuItem
|
672
|
631 |
#label: 'New...'
|
767
|
632 |
#value: #doNewImage
|
672
|
633 |
#activeHelpKey: #fileNewImage
|
400
|
634 |
)
|
|
635 |
#(#MenuItem
|
672
|
636 |
#label: '-'
|
400
|
637 |
)
|
|
638 |
#(#MenuItem
|
672
|
639 |
#label: 'Load...'
|
767
|
640 |
#value: #doLoadFromClass
|
672
|
641 |
#activeHelpKey: #fileLoadFromClass
|
400
|
642 |
)
|
|
643 |
#(#MenuItem
|
672
|
644 |
#label: 'Load From File...'
|
767
|
645 |
#value: #doLoadFromFile
|
672
|
646 |
#activeHelpKey: #fileLoadFromFile
|
400
|
647 |
)
|
|
648 |
#(#MenuItem
|
672
|
649 |
#label: '-'
|
400
|
650 |
)
|
|
651 |
#(#MenuItem
|
672
|
652 |
#label: 'Save'
|
767
|
653 |
#value: #doSaveMethod
|
672
|
654 |
#activeHelpKey: #fileSaveMethod
|
|
655 |
#enabled: #imageIsLoaded
|
400
|
656 |
)
|
|
657 |
#(#MenuItem
|
672
|
658 |
#label: 'Save As...'
|
767
|
659 |
#value: #doSaveMethodAs
|
672
|
660 |
#activeHelpKey: #fileSaveMethodAs
|
|
661 |
#enabled: #imageIsLoaded
|
|
662 |
)
|
|
663 |
#(#MenuItem
|
|
664 |
#label: '-'
|
400
|
665 |
)
|
|
666 |
#(#MenuItem
|
672
|
667 |
#label: 'Save To File...'
|
767
|
668 |
#value: #doSaveImageFileAs
|
672
|
669 |
#activeHelpKey: #fileSaveAs
|
|
670 |
#enabled: #imageIsLoaded
|
400
|
671 |
)
|
|
672 |
#(#MenuItem
|
672
|
673 |
#label: 'Save Mask To File...'
|
767
|
674 |
#value: #doSaveImageMaskFileAs
|
672
|
675 |
#activeHelpKey: #fileSaveMaskAs
|
|
676 |
#enabled: #imageIsLoaded
|
400
|
677 |
)
|
|
678 |
#(#MenuItem
|
672
|
679 |
#label: '-'
|
400
|
680 |
)
|
|
681 |
#(#MenuItem
|
672
|
682 |
#label: 'Print'
|
767
|
683 |
#value: #doPrint
|
672
|
684 |
#activeHelpKey: #filePrint
|
|
685 |
#enabled: #imageIsLoaded
|
400
|
686 |
)
|
|
687 |
#(#MenuItem
|
672
|
688 |
#label: '-'
|
400
|
689 |
)
|
|
690 |
#(#MenuItem
|
672
|
691 |
#label: 'Browse Class'
|
767
|
692 |
#value: #doBrowseClass
|
672
|
693 |
#activeHelpKey: #fileBrowseClass
|
|
694 |
#enabled: #imageIsLoaded
|
400
|
695 |
)
|
|
696 |
#(#MenuItem
|
672
|
697 |
#label: '-'
|
400
|
698 |
)
|
|
699 |
#(#MenuItem
|
672
|
700 |
#label: 'Exit'
|
|
701 |
#translateLabel: true
|
|
702 |
#value: #closeRequest
|
|
703 |
#activeHelpKey: #fileExit
|
400
|
704 |
)
|
|
705 |
) nil
|
|
706 |
nil
|
|
707 |
)
|
|
708 |
)
|
|
709 |
#(#MenuItem
|
672
|
710 |
#label: 'Edit'
|
|
711 |
#activeHelpKey: #edit
|
|
712 |
#enabled: #imageIsLoaded
|
|
713 |
#submenu:
|
400
|
714 |
#(#Menu
|
|
715 |
|
|
716 |
#(
|
|
717 |
#(#MenuItem
|
672
|
718 |
#label: 'Undo'
|
767
|
719 |
#value: #doUndo
|
672
|
720 |
#activeHelpKey: #editUndo
|
|
721 |
#enabled: #valueOfCanUndo
|
400
|
722 |
)
|
|
723 |
#(#MenuItem
|
672
|
724 |
#label: '-'
|
400
|
725 |
)
|
|
726 |
#(#MenuItem
|
672
|
727 |
#label: 'Flip - Vertical'
|
767
|
728 |
#value: #doFlipVertical
|
672
|
729 |
#activeHelpKey: #editFlipVertical
|
400
|
730 |
)
|
|
731 |
#(#MenuItem
|
672
|
732 |
#label: 'Flip - Horizontal'
|
767
|
733 |
#value: #doFlipHorizontal
|
672
|
734 |
#activeHelpKey: #editFlipHorizontal
|
400
|
735 |
)
|
|
736 |
#(#MenuItem
|
672
|
737 |
#label: '-'
|
400
|
738 |
)
|
|
739 |
#(#MenuItem
|
672
|
740 |
#label: 'Resize...'
|
767
|
741 |
#value: #doResizeImage
|
672
|
742 |
#activeHelpKey: #editResize
|
400
|
743 |
)
|
|
744 |
#(#MenuItem
|
672
|
745 |
#label: 'Magnify...'
|
767
|
746 |
#value: #doMagnifyImage
|
672
|
747 |
#activeHelpKey: #editMagnifyImage
|
400
|
748 |
)
|
|
749 |
#(#MenuItem
|
672
|
750 |
#label: 'Rotate...'
|
767
|
751 |
#value: #doRotateImage
|
672
|
752 |
#activeHelpKey: #editRotate
|
400
|
753 |
)
|
|
754 |
#(#MenuItem
|
672
|
755 |
#label: '-'
|
400
|
756 |
)
|
|
757 |
#(#MenuItem
|
672
|
758 |
#label: 'Negative'
|
767
|
759 |
#value: #doNegativeImage
|
672
|
760 |
#activeHelpKey: #editNegate
|
400
|
761 |
)
|
|
762 |
) nil
|
|
763 |
nil
|
|
764 |
)
|
|
765 |
)
|
|
766 |
#(#MenuItem
|
672
|
767 |
#label: 'Color Map'
|
|
768 |
#activeHelpKey: #colorMap
|
|
769 |
#enabled: #imageIsLoaded
|
|
770 |
#submenu:
|
400
|
771 |
#(#Menu
|
|
772 |
|
|
773 |
#(
|
|
774 |
#(#MenuItem
|
672
|
775 |
#label: '8-Plane'
|
|
776 |
#activeHelpKey: #colorMap
|
|
777 |
#argument: '8-plane'
|
|
778 |
#indication: #colorMapMode:value:
|
|
779 |
)
|
|
780 |
#(#MenuItem
|
|
781 |
#label: '4-Plane'
|
|
782 |
#activeHelpKey: #colorMap
|
|
783 |
#argument: '4-plane'
|
|
784 |
#indication: #colorMapMode:value:
|
400
|
785 |
)
|
|
786 |
#(#MenuItem
|
672
|
787 |
#label: '2-Plane'
|
|
788 |
#activeHelpKey: #colorMap
|
|
789 |
#argument: '2-plane'
|
|
790 |
#indication: #colorMapMode:value:
|
400
|
791 |
)
|
|
792 |
#(#MenuItem
|
672
|
793 |
#label: '1-Plane'
|
|
794 |
#activeHelpKey: #colorMap
|
|
795 |
#argument: '1-plane'
|
|
796 |
#indication: #colorMapMode:value:
|
400
|
797 |
)
|
|
798 |
#(#MenuItem
|
672
|
799 |
#label: '-'
|
|
800 |
)
|
|
801 |
#(#MenuItem
|
|
802 |
#label: '8-Plane + Mask'
|
|
803 |
#activeHelpKey: #colorMap
|
|
804 |
#argument: '8-plane + mask'
|
|
805 |
#indication: #colorMapMode:value:
|
400
|
806 |
)
|
|
807 |
#(#MenuItem
|
672
|
808 |
#label: '4-Plane + Mask'
|
|
809 |
#activeHelpKey: #colorMap
|
|
810 |
#argument: '4-plane + mask'
|
|
811 |
#indication: #colorMapMode:value:
|
400
|
812 |
)
|
|
813 |
#(#MenuItem
|
672
|
814 |
#label: '2-Plane + Mask'
|
|
815 |
#activeHelpKey: #colorMap
|
|
816 |
#argument: '2-plane + mask'
|
|
817 |
#indication: #colorMapMode:value:
|
|
818 |
)
|
|
819 |
#(#MenuItem
|
|
820 |
#label: '1-Plane + Mask'
|
|
821 |
#activeHelpKey: #colorMap
|
|
822 |
#argument: '1-plane + mask'
|
|
823 |
#indication: #colorMapMode:value:
|
400
|
824 |
)
|
|
825 |
) nil
|
|
826 |
nil
|
|
827 |
)
|
|
828 |
)
|
|
829 |
#(#MenuItem
|
737
|
830 |
#label: 'Settings'
|
|
831 |
#submenu:
|
|
832 |
#(#Menu
|
|
833 |
|
|
834 |
#(
|
|
835 |
#(#MenuItem
|
|
836 |
#label: 'Fonts'
|
|
837 |
#submenuChannel: #menuFont
|
|
838 |
)
|
|
839 |
) nil
|
|
840 |
nil
|
|
841 |
)
|
|
842 |
)
|
|
843 |
#(#MenuItem
|
756
|
844 |
#label: 'History'
|
|
845 |
#activeHelpKey: #history
|
|
846 |
#submenuChannel: #menuHistory
|
|
847 |
)
|
|
848 |
#(#MenuItem
|
672
|
849 |
#label: 'Help'
|
|
850 |
#startGroup: #right
|
|
851 |
#activeHelpKey: #help
|
|
852 |
#submenuChannel: #menuHelp
|
400
|
853 |
)
|
|
854 |
) nil
|
|
855 |
nil
|
|
856 |
)
|
|
857 |
!
|
|
858 |
|
679
|
859 |
menuMouseButtonColors
|
737
|
860 |
"This resource specification was automatically generated
|
|
861 |
by the MenuEditor of ST/X."
|
679
|
862 |
|
737
|
863 |
"Do not manually edit this!! If it is corrupted,
|
|
864 |
the MenuEditor may not be able to read the specification."
|
679
|
865 |
|
|
866 |
"
|
|
867 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuMouseButtonColors
|
|
868 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuMouseButtonColors)) startUp
|
|
869 |
"
|
|
870 |
|
|
871 |
<resource: #menu>
|
|
872 |
|
|
873 |
^
|
|
874 |
|
|
875 |
#(#Menu
|
|
876 |
|
|
877 |
#(
|
|
878 |
#(#MenuItem
|
|
879 |
#label: 'Left Mouse Button'
|
|
880 |
#nameKey: #leftMouseKeyButton
|
|
881 |
#activeHelpKey: #mouseKeyColorMode
|
|
882 |
#argument: '1'
|
|
883 |
#labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon)
|
|
884 |
#indication: #mouseKeyColorMode:value:
|
|
885 |
)
|
|
886 |
#(#MenuItem
|
|
887 |
#label: 'Right Mouse Button'
|
|
888 |
#nameKey: #rightMouseKeyButton
|
|
889 |
#activeHelpKey: #mouseKeyColorMode
|
|
890 |
#argument: '2'
|
|
891 |
#labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon)
|
|
892 |
#indication: #mouseKeyColorMode:value:
|
|
893 |
)
|
|
894 |
) nil
|
|
895 |
nil
|
|
896 |
)
|
|
897 |
!
|
|
898 |
|
400
|
899 |
menuToolbar
|
737
|
900 |
"This resource specification was automatically generated
|
|
901 |
by the MenuEditor of ST/X."
|
400
|
902 |
|
737
|
903 |
"Do not manually edit this!! If it is corrupted,
|
|
904 |
the MenuEditor may not be able to read the specification."
|
400
|
905 |
|
|
906 |
"
|
|
907 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuToolbar
|
|
908 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuToolbar)) startUp
|
|
909 |
"
|
|
910 |
|
|
911 |
<resource: #menu>
|
|
912 |
|
|
913 |
^
|
|
914 |
|
|
915 |
#(#Menu
|
|
916 |
|
|
917 |
#(
|
|
918 |
#(#MenuItem
|
672
|
919 |
#label: 'newImage'
|
|
920 |
#isButton: true
|
767
|
921 |
#value: #doNewImage
|
672
|
922 |
#activeHelpKey: #fileNewImage
|
|
923 |
#labelImage: #(#ResourceRetriever nil #newIcon)
|
400
|
924 |
)
|
|
925 |
#(#MenuItem
|
672
|
926 |
#label: 'loadFromClass'
|
|
927 |
#isButton: true
|
767
|
928 |
#value: #doLoadFromClass
|
672
|
929 |
#activeHelpKey: #fileLoadFromClass
|
|
930 |
#labelImage: #(#ResourceRetriever nil #loadIcon)
|
|
931 |
)
|
|
932 |
#(#MenuItem
|
|
933 |
#label: 'saveMethod'
|
|
934 |
#isButton: true
|
767
|
935 |
#value: #doSaveMethod
|
672
|
936 |
#activeHelpKey: #fileSaveMethod
|
|
937 |
#enabled: #imageIsLoaded
|
|
938 |
#labelImage: #(#ResourceRetriever nil #saveIcon)
|
400
|
939 |
)
|
|
940 |
#(#MenuItem
|
672
|
941 |
#label: ''
|
400
|
942 |
)
|
|
943 |
#(#MenuItem
|
672
|
944 |
#label: ''
|
|
945 |
)
|
|
946 |
#(#MenuItem
|
|
947 |
#label: ''
|
|
948 |
)
|
|
949 |
#(#MenuItem
|
|
950 |
#label: ''
|
400
|
951 |
)
|
|
952 |
#(#MenuItem
|
672
|
953 |
#label: 'Point'
|
|
954 |
#activeHelpKey: #drawModePoint
|
|
955 |
#enabled: #imageIsLoaded
|
|
956 |
#argument: 'point'
|
|
957 |
#indication: #editMode:value:
|
400
|
958 |
)
|
|
959 |
#(#MenuItem
|
672
|
960 |
#label: 'Box'
|
|
961 |
#activeHelpKey: #drawModeBox
|
|
962 |
#enabled: #imageIsLoaded
|
|
963 |
#argument: 'box'
|
|
964 |
#indication: #editMode:value:
|
400
|
965 |
)
|
|
966 |
#(#MenuItem
|
672
|
967 |
#label: 'Filled Box'
|
|
968 |
#activeHelpKey: #drawModeFilledBox
|
|
969 |
#enabled: #imageIsLoaded
|
|
970 |
#argument: 'filledBox'
|
|
971 |
#indication: #editMode:value:
|
400
|
972 |
)
|
|
973 |
#(#MenuItem
|
672
|
974 |
#label: 'Fill'
|
|
975 |
#activeHelpKey: #drawModeFill
|
|
976 |
#enabled: #imageIsLoaded
|
|
977 |
#argument: 'fill'
|
|
978 |
#indication: #editMode:value:
|
400
|
979 |
)
|
|
980 |
#(#MenuItem
|
672
|
981 |
#label: 'Copy'
|
|
982 |
#activeHelpKey: #drawModeCopy
|
|
983 |
#enabled: #imageIsLoaded
|
|
984 |
#argument: 'copy'
|
|
985 |
#indication: #editMode:value:
|
400
|
986 |
)
|
|
987 |
#(#MenuItem
|
672
|
988 |
#label: 'Paste'
|
|
989 |
#activeHelpKey: #drawModePaste
|
|
990 |
#enabled: #imageIsLoaded
|
|
991 |
#argument: 'paste'
|
|
992 |
#indication: #editMode:value:
|
400
|
993 |
)
|
|
994 |
) nil
|
|
995 |
nil
|
|
996 |
)
|
|
997 |
! !
|
|
998 |
|
|
999 |
!ImageEditor methodsFor:'accessing'!
|
|
1000 |
|
|
1001 |
image
|
767
|
1002 |
"returns the current editing image"
|
400
|
1003 |
|
|
1004 |
^self imageEditView image
|
|
1005 |
!
|
|
1006 |
|
|
1007 |
postOpenAction: anAction
|
767
|
1008 |
"sets an action which is evaluated after opening"
|
400
|
1009 |
|
|
1010 |
postOpenAction := anAction
|
|
1011 |
! !
|
|
1012 |
|
|
1013 |
!ImageEditor methodsFor:'accessing - views'!
|
|
1014 |
|
487
|
1015 |
coordLabel
|
767
|
1016 |
"returns the view the coord label"
|
487
|
1017 |
|
|
1018 |
^builder componentAt: #coordLabel
|
|
1019 |
!
|
|
1020 |
|
400
|
1021 |
imageEditView
|
767
|
1022 |
"returns the image editing view"
|
400
|
1023 |
|
|
1024 |
^(builder componentAt: #imageEditView) subViews first
|
|
1025 |
!
|
|
1026 |
|
|
1027 |
imagePreView
|
767
|
1028 |
"returns the preview of the image"
|
400
|
1029 |
|
|
1030 |
^(builder componentAt: #imagePreView) subViews first
|
475
|
1031 |
! !
|
|
1032 |
|
400
|
1033 |
!ImageEditor methodsFor:'aspects'!
|
|
1034 |
|
|
1035 |
imageIsLoaded
|
767
|
1036 |
"returns whether an image is loaded as value holder"
|
400
|
1037 |
|
|
1038 |
|holder|
|
|
1039 |
(holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[
|
|
1040 |
builder aspectAt:#imageIsLoaded put:(holder := false asValue).
|
|
1041 |
].
|
|
1042 |
^ holder
|
|
1043 |
!
|
|
1044 |
|
|
1045 |
listOfColors
|
767
|
1046 |
"returns the list of colors in a List"
|
400
|
1047 |
|
|
1048 |
|holder|
|
|
1049 |
(holder := builder bindingAt:#listOfColors) isNil ifTrue:[
|
|
1050 |
builder aspectAt:#listOfColors put:(holder := List new).
|
|
1051 |
].
|
|
1052 |
^ holder
|
|
1053 |
!
|
|
1054 |
|
|
1055 |
selectionOfColor
|
767
|
1056 |
"returns current selection of the edit color as an AspectAdaptor"
|
400
|
1057 |
|
|
1058 |
|holder|
|
|
1059 |
(holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[
|
|
1060 |
builder aspectAt:#selectionOfColor put:(
|
|
1061 |
holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex).
|
|
1062 |
].
|
|
1063 |
^ holder
|
|
1064 |
!
|
|
1065 |
|
|
1066 |
valueOfMagnification
|
767
|
1067 |
"returns current magnification of the image as an AspectAdaptor"
|
400
|
1068 |
|
|
1069 |
|holder|
|
|
1070 |
(holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[
|
|
1071 |
builder aspectAt:#valueOfMagnification put:(
|
|
1072 |
holder := AspectAdaptor new subject:self; forAspect:#magnification)
|
|
1073 |
].
|
|
1074 |
^ holder
|
|
1075 |
! !
|
|
1076 |
|
767
|
1077 |
!ImageEditor methodsFor:'change & update'!
|
|
1078 |
|
|
1079 |
findColorMapMode
|
|
1080 |
"finds the colorMapMode for an new image"
|
|
1081 |
|
|
1082 |
self image depth > 8 ifTrue: [colorMapMode := ''. self listOfColors removeAll. ^nil].
|
|
1083 |
colorMapMode := self image depth printString, '-plane'.
|
|
1084 |
self listOfColors isEmpty
|
|
1085 |
ifTrue:
|
|
1086 |
[
|
|
1087 |
self colorMapMode: colorMapMode value: nil
|
|
1088 |
].
|
|
1089 |
self imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])).
|
|
1090 |
(self image mask notNil and: [(self listOfColors includes: (Color basicNew setColorId:0)) not])
|
|
1091 |
ifTrue:
|
|
1092 |
[
|
|
1093 |
colorMapMode := colorMapMode, ' + mask'.
|
|
1094 |
self listOfColors addFirst: (Color basicNew setColorId:0).
|
|
1095 |
self imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)).
|
|
1096 |
].
|
|
1097 |
self selectionOfColor value: 0.
|
|
1098 |
self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor).
|
|
1099 |
!
|
|
1100 |
|
|
1101 |
updateForNoneImage
|
|
1102 |
"updates channels and view, if image is loaded"
|
|
1103 |
|
|
1104 |
self imageIsLoaded value: false.
|
|
1105 |
self listOfColors removeAll.
|
|
1106 |
self imagePreView image: nil
|
|
1107 |
|
|
1108 |
|
|
1109 |
|
|
1110 |
|
|
1111 |
!
|
|
1112 |
|
|
1113 |
updateLabelsAndHistory
|
|
1114 |
"updates labels and history, if something has changed"
|
|
1115 |
|
|
1116 |
self imageIsLoaded value: self image notNil.
|
|
1117 |
|
|
1118 |
self image isNil ifTrue: [^nil].
|
|
1119 |
|
|
1120 |
self updateInfoLabel.
|
|
1121 |
|
|
1122 |
self imageEditView resourceMessage asCollectionOfWords size = 2
|
|
1123 |
ifTrue: [self addToHistory: self imageEditView resourceMessage -> #loadFromMessage:].
|
|
1124 |
|
|
1125 |
self image fileName notNil
|
|
1126 |
ifTrue: [self addToHistory: self image fileName -> #loadFromFile:].
|
|
1127 |
|
|
1128 |
|
|
1129 |
|
|
1130 |
! !
|
|
1131 |
|
672
|
1132 |
!ImageEditor methodsFor:'help'!
|
|
1133 |
|
|
1134 |
defaultInfoLabel
|
767
|
1135 |
"returns the default info label"
|
672
|
1136 |
|
|
1137 |
(self imageEditView resourceClass isSymbol and: [(Smalltalk at: self imageEditView resourceClass) isClass])
|
|
1138 |
ifTrue:
|
|
1139 |
[
|
|
1140 |
^self imageEditView resourceClass, ' >> ', self imageEditView resourceSelector
|
|
1141 |
].
|
767
|
1142 |
^'No class and selector defined.'
|
674
|
1143 |
!
|
|
1144 |
|
702
|
1145 |
openDocumentation
|
767
|
1146 |
"opens the documentation file of the Image Editor"
|
674
|
1147 |
|
763
|
1148 |
self openHTMLDocument: 'tools/uipainter/ImageEditor.html'
|
|
1149 |
|
672
|
1150 |
! !
|
|
1151 |
|
767
|
1152 |
!ImageEditor methodsFor:'loading'!
|
|
1153 |
|
|
1154 |
loadFromFile: aFileName
|
|
1155 |
"loads an image from aFileName and sets up color map list and other info labels"
|
|
1156 |
|
|
1157 |
(self imageEditView loadFromFile: aFileName) notNil
|
|
1158 |
ifTrue:
|
|
1159 |
[
|
|
1160 |
self image notNil
|
|
1161 |
ifTrue:
|
|
1162 |
[
|
|
1163 |
self image colorMap notNil
|
|
1164 |
ifTrue:
|
|
1165 |
[
|
|
1166 |
self listOfColors contents: self image usedColors asSet.
|
|
1167 |
]
|
|
1168 |
ifFalse:
|
|
1169 |
[
|
|
1170 |
self listOfColors removeAll.
|
|
1171 |
].
|
|
1172 |
self findColorMapMode.
|
|
1173 |
self updateLabelsAndHistory.
|
|
1174 |
]
|
|
1175 |
ifFalse:
|
|
1176 |
[
|
|
1177 |
self updateForNoneImage
|
|
1178 |
]
|
|
1179 |
]
|
|
1180 |
!
|
|
1181 |
|
|
1182 |
loadFromImage: anImage
|
|
1183 |
"loads an image from anImage and sets up color map list and other info labels"
|
|
1184 |
|
|
1185 |
self imageEditView image: anImage.
|
|
1186 |
self image notNil
|
|
1187 |
ifTrue:
|
|
1188 |
[
|
|
1189 |
self image colorMap notNil
|
|
1190 |
ifTrue:
|
|
1191 |
[
|
|
1192 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1193 |
]
|
|
1194 |
ifFalse:
|
|
1195 |
[
|
|
1196 |
self listOfColors removeAll.
|
|
1197 |
].
|
|
1198 |
self findColorMapMode.
|
|
1199 |
self updateLabelsAndHistory.
|
|
1200 |
]
|
|
1201 |
ifFalse:
|
|
1202 |
[
|
|
1203 |
self updateForNoneImage
|
|
1204 |
]
|
|
1205 |
!
|
|
1206 |
|
|
1207 |
loadFromMessage: aMessage
|
|
1208 |
"loads an image by evaluating aMessage and sets up color map list and other info labels"
|
|
1209 |
|
|
1210 |
(self imageEditView loadFromMessage: aMessage) notNil
|
|
1211 |
ifTrue:
|
|
1212 |
[
|
|
1213 |
self image notNil
|
|
1214 |
ifTrue:
|
|
1215 |
[
|
|
1216 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1217 |
self findColorMapMode.
|
|
1218 |
self updateLabelsAndHistory.
|
|
1219 |
]
|
|
1220 |
ifFalse:
|
|
1221 |
[
|
|
1222 |
self updateForNoneImage
|
|
1223 |
]
|
|
1224 |
]
|
|
1225 |
!
|
|
1226 |
|
|
1227 |
loadFromOrPrepareForMessage: aMessage
|
|
1228 |
"loads an image by evaluating aMessage;
|
|
1229 |
if no image could extract from aMessage; do set the class and the selector from
|
|
1230 |
the aMessage for a saving at the end of editing"
|
|
1231 |
|
|
1232 |
(self imageEditView loadFromMessage: aMessage) notNil
|
|
1233 |
ifTrue:
|
|
1234 |
[
|
|
1235 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1236 |
self findColorMapMode.
|
|
1237 |
]
|
|
1238 |
ifFalse:
|
|
1239 |
[
|
|
1240 |
self imageEditView resourceMessage: aMessage.
|
|
1241 |
].
|
|
1242 |
self updateLabelsAndHistory.
|
|
1243 |
! !
|
|
1244 |
|
400
|
1245 |
!ImageEditor methodsFor:'menu modes'!
|
|
1246 |
|
|
1247 |
colorMapMode: aMode
|
767
|
1248 |
"returns whether colorMapMode is equal to aMode"
|
400
|
1249 |
|
|
1250 |
^colorMapMode = aMode
|
|
1251 |
!
|
|
1252 |
|
|
1253 |
colorMapMode: aMode value: aValue
|
767
|
1254 |
"calculates a new color map for the image from aMode"
|
400
|
1255 |
|
405
|
1256 |
|depth newColorMap newImage image newColors realColorMap oldFileName|
|
400
|
1257 |
|
|
1258 |
newColorMap := self class listOfColorMaps at: aMode.
|
|
1259 |
depth := (newColorMap size log: 2) asInteger.
|
|
1260 |
newImage := (Image implementorForDepth: depth) new.
|
|
1261 |
oldFileName := self image fileName.
|
|
1262 |
Object errorSignal handle:
|
|
1263 |
[:ex|
|
|
1264 |
Object errorSignal handle:
|
|
1265 |
[:ex|
|
|
1266 |
^self warn: 'Convertation failed!!'
|
|
1267 |
]
|
|
1268 |
do:
|
|
1269 |
[
|
|
1270 |
self image colorsFromX:0 y:0 toX:(self image width-1) y:(self image height-1) do:
|
|
1271 |
[:x :y :clr |
|
|
1272 |
(newColorMap includes: clr)
|
|
1273 |
ifTrue: [self image colorAtX:x y:y put:clr]
|
|
1274 |
ifFalse: [self image colorAtX:x y:y put: self image colorMap first]
|
|
1275 |
].
|
|
1276 |
image := newImage fromImage: self image.
|
|
1277 |
].
|
|
1278 |
]
|
|
1279 |
do:
|
|
1280 |
[
|
|
1281 |
image := newImage fromImage: self image
|
|
1282 |
].
|
|
1283 |
(String fromString: aMode) reverse readStream nextWord reverse = 'mask'
|
|
1284 |
ifTrue:
|
|
1285 |
[
|
|
1286 |
image mask isNil
|
|
1287 |
ifTrue:
|
|
1288 |
[
|
|
1289 |
image mask: (Depth1Image fromImage: (image asThresholdMonochromeImage: 0.1)).
|
|
1290 |
].
|
|
1291 |
]
|
|
1292 |
ifFalse:
|
|
1293 |
[
|
|
1294 |
image mask: nil.
|
405
|
1295 |
].
|
|
1296 |
realColorMap := OrderedCollection new.
|
|
1297 |
image realColorMap do:
|
|
1298 |
[:clr|
|
|
1299 |
(realColorMap includes: clr) ifFalse: [realColorMap add: clr]
|
400
|
1300 |
].
|
405
|
1301 |
newColors := realColorMap copyFrom: 1 to: (newColorMap size min: realColorMap size).
|
400
|
1302 |
newColorMap do:
|
|
1303 |
[:clr|
|
|
1304 |
((newColors size < newColorMap size) and: [(newColors includes: clr) not])
|
|
1305 |
ifTrue:
|
|
1306 |
[
|
|
1307 |
newColors add: clr
|
|
1308 |
]
|
405
|
1309 |
].
|
400
|
1310 |
image colorMap: newColors.
|
|
1311 |
colorMapMode := aMode.
|
|
1312 |
(self imageEditView image: image) notNil
|
|
1313 |
ifTrue:
|
|
1314 |
[
|
|
1315 |
self image fileName: oldFileName.
|
|
1316 |
self listOfColors contents: image colorMap.
|
|
1317 |
self findColorMapMode.
|
694
|
1318 |
self updateLabelsAndHistory.
|
400
|
1319 |
]
|
|
1320 |
!
|
|
1321 |
|
|
1322 |
editMode: aMode
|
767
|
1323 |
"returns whether editMode is equal to aMode"
|
400
|
1324 |
|
|
1325 |
^self imageEditView editMode = aMode
|
|
1326 |
!
|
|
1327 |
|
|
1328 |
editMode: aMode value: aValue
|
767
|
1329 |
"sets the editMode to aMode"
|
400
|
1330 |
|
|
1331 |
self imageEditView editMode: aMode
|
|
1332 |
!
|
|
1333 |
|
|
1334 |
mouseKeyColorMode: aMode
|
767
|
1335 |
"sets the mouseKeyColorMode to aMode"
|
400
|
1336 |
|
|
1337 |
^self imageEditView mouseKeyColorMode = aMode
|
|
1338 |
!
|
|
1339 |
|
|
1340 |
mouseKeyColorMode: aMode value: aValue
|
767
|
1341 |
"sets the mouseKeyColorMode to aMode"
|
400
|
1342 |
|
|
1343 |
self imageEditView mouseKeyColorMode: aMode.
|
|
1344 |
|
|
1345 |
self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor).
|
|
1346 |
! !
|
|
1347 |
|
535
|
1348 |
!ImageEditor methodsFor:'queries'!
|
|
1349 |
|
|
1350 |
preferredExtent
|
767
|
1351 |
"returns the preferred extent"
|
535
|
1352 |
|
|
1353 |
^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5)
|
|
1354 |
|
|
1355 |
|
|
1356 |
! !
|
|
1357 |
|
400
|
1358 |
!ImageEditor methodsFor:'selection'!
|
|
1359 |
|
|
1360 |
magnification
|
767
|
1361 |
"returns the magnification of the image"
|
400
|
1362 |
|
|
1363 |
(builder componentAt: #imageEditView) isNil ifTrue: [^1].
|
|
1364 |
^self imageEditView magnification x
|
|
1365 |
!
|
|
1366 |
|
|
1367 |
magnification: aValue
|
767
|
1368 |
"sets the magnification of the image"
|
400
|
1369 |
|
|
1370 |
|magnification|
|
|
1371 |
magnification := aValue asInteger asPoint.
|
767
|
1372 |
(magnification = self imageEditView magnification or: [magnification = (0@0)]) ifTrue: [^nil].
|
400
|
1373 |
self imageEditView magnification: magnification
|
|
1374 |
!
|
|
1375 |
|
|
1376 |
selectedColorIndex
|
767
|
1377 |
"returns the index of the selected color"
|
400
|
1378 |
|
|
1379 |
^selectedColorIndex
|
|
1380 |
!
|
|
1381 |
|
|
1382 |
selectedColorIndex: anIndex
|
767
|
1383 |
"sets the index of the selected color"
|
400
|
1384 |
|
|
1385 |
selectedColorIndex := anIndex.
|
|
1386 |
self imageEditView selectedColor: (self listOfColors at: anIndex ifAbsent: [^nil])
|
|
1387 |
|
|
1388 |
! !
|
|
1389 |
|
|
1390 |
!ImageEditor methodsFor:'startup / release'!
|
|
1391 |
|
|
1392 |
closeRequest
|
767
|
1393 |
"close request"
|
400
|
1394 |
|
|
1395 |
self imageEditView checkModified ifTrue:[super closeRequest]
|
|
1396 |
|
|
1397 |
!
|
|
1398 |
|
|
1399 |
open
|
767
|
1400 |
"after opening, sets the masterApplication of the imageEditView to self"
|
400
|
1401 |
|
|
1402 |
super open.
|
444
|
1403 |
|
672
|
1404 |
self imageEditView masterApplication: self
|
400
|
1405 |
!
|
|
1406 |
|
|
1407 |
postOpenWith:aBuilder
|
767
|
1408 |
"after opening, sets the masterApplication of the imageEditView to self;
|
|
1409 |
evaluate the postOpenAction"
|
400
|
1410 |
|
415
|
1411 |
self imageEditView masterApplication: self.
|
400
|
1412 |
postOpenAction notNil ifTrue: [postOpenAction value].
|
|
1413 |
|
767
|
1414 |
super postOpenWith:aBuilder
|
400
|
1415 |
! !
|
|
1416 |
|
|
1417 |
!ImageEditor methodsFor:'user actions - editing'!
|
|
1418 |
|
767
|
1419 |
doBrowseClass
|
|
1420 |
"opens a System Browser on the resourceClass and the resourceSelector"
|
400
|
1421 |
|
|
1422 |
SystemBrowser openInClass: (Smalltalk at: self imageEditView resourceClass ifAbsent: [^nil]) class selector: self imageEditView resourceSelector
|
|
1423 |
!
|
|
1424 |
|
767
|
1425 |
doFlipHorizontal
|
|
1426 |
"flips horizontally current image"
|
400
|
1427 |
|
|
1428 |
self imageEditView flipHorizontal
|
|
1429 |
!
|
|
1430 |
|
767
|
1431 |
doFlipVertical
|
|
1432 |
"flips vertically current image"
|
400
|
1433 |
|
|
1434 |
self imageEditView flipVertical
|
|
1435 |
!
|
|
1436 |
|
767
|
1437 |
doMagnifyDown
|
|
1438 |
"magnifies current image one step down"
|
400
|
1439 |
|
|
1440 |
self valueOfMagnification value > 1
|
|
1441 |
ifTrue:
|
|
1442 |
[
|
|
1443 |
self valueOfMagnification value: self valueOfMagnification value - 1
|
|
1444 |
]
|
|
1445 |
!
|
|
1446 |
|
767
|
1447 |
doMagnifyImage
|
|
1448 |
"magnifies current image"
|
400
|
1449 |
|
|
1450 |
self imageEditView magnifyImage.
|
|
1451 |
self updateInfoLabel
|
|
1452 |
!
|
|
1453 |
|
767
|
1454 |
doMagnifyUp
|
|
1455 |
"magnifies current image one step up"
|
400
|
1456 |
|
|
1457 |
self valueOfMagnification value < 99
|
|
1458 |
ifTrue:
|
|
1459 |
[
|
|
1460 |
self valueOfMagnification value: self valueOfMagnification value + 1
|
|
1461 |
]
|
|
1462 |
!
|
|
1463 |
|
767
|
1464 |
doNegativeImage
|
|
1465 |
"negates current image by negating the color map"
|
400
|
1466 |
|
|
1467 |
self imageEditView negativeImage.
|
|
1468 |
self listOfColors removeAll.
|
767
|
1469 |
self findColorMapMode
|
400
|
1470 |
!
|
|
1471 |
|
767
|
1472 |
doResizeImage
|
|
1473 |
"resizes current image"
|
400
|
1474 |
|
|
1475 |
self imageEditView resizeImage.
|
|
1476 |
self updateInfoLabel
|
|
1477 |
!
|
|
1478 |
|
767
|
1479 |
doRotateImage
|
|
1480 |
"rotates current image"
|
400
|
1481 |
|
|
1482 |
self imageEditView rotateImage.
|
|
1483 |
self updateInfoLabel
|
|
1484 |
!
|
|
1485 |
|
767
|
1486 |
doUndo
|
|
1487 |
"reverses last edit action"
|
400
|
1488 |
|
|
1489 |
self imageEditView undo
|
|
1490 |
! !
|
|
1491 |
|
|
1492 |
!ImageEditor methodsFor:'user actions - loading'!
|
|
1493 |
|
767
|
1494 |
doLoadFromClass
|
|
1495 |
"opens a dialog for loading an image from class and a (resource-) selector"
|
400
|
1496 |
|
574
|
1497 |
(self imageEditView loadFromClass) notNil
|
|
1498 |
ifTrue:
|
|
1499 |
[
|
|
1500 |
self image notNil
|
|
1501 |
ifTrue:
|
|
1502 |
[
|
|
1503 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1504 |
self findColorMapMode.
|
767
|
1505 |
self updateLabelsAndHistory
|
400
|
1506 |
]
|
|
1507 |
ifFalse:
|
|
1508 |
[
|
461
|
1509 |
self updateForNoneImage
|
|
1510 |
]
|
449
|
1511 |
]
|
400
|
1512 |
!
|
|
1513 |
|
767
|
1514 |
doLoadFromFile
|
|
1515 |
"opens a dialog for loading an image from a file"
|
|