10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 "{ Package: 'stx:libtool2' }" |
13 "{ Package: 'stx:libtool2' }" |
14 |
14 |
15 ToolApplicationModel subclass:#ImageEditor |
15 ResourceSpecEditor subclass:#ImageEditor |
16 instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode |
16 instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode |
17 selectedColorIndex postOpenAction imageSeqNr drawingColormap |
17 selectedColorIndex postOpenAction imageSeqNr drawingColormap |
18 lastShiftUsedWrap' |
18 lastShiftUsedWrap' |
19 classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode |
19 classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode |
20 DefaultRelativeSizes' |
20 DefaultRelativeSizes' |
55 " |
55 " |
56 ! ! |
56 ! ! |
57 |
57 |
58 !ImageEditor class methodsFor:'instance creation'! |
58 !ImageEditor class methodsFor:'instance creation'! |
59 |
59 |
|
60 openLoadingImageWith:aBlock |
|
61 "opens an Image Editor on anImage" |
|
62 |
|
63 |editor| |
|
64 |
|
65 editor := self new. |
|
66 editor allButOpen. |
|
67 aBlock value:editor. |
|
68 editor openWindow |
|
69 ! |
|
70 |
60 openModalOnClass: aClass andSelector: aSelector |
71 openModalOnClass: aClass andSelector: aSelector |
61 "opens a modal Image Editor on aClass and aSelector" |
72 "opens a modal Image Editor on aClass and aSelector. |
62 |
73 Returns the real name of the edited resource method (in case, user changed it)." |
63 |imageEditor imageEditView className resourceClassName resourceSelector| |
74 |
|
75 |imageEditor imageEditView className resourceClass resourceSelector| |
64 |
76 |
65 imageEditor := self new. |
77 imageEditor := self new. |
66 |
78 |
67 aClass isClass ifTrue: [className := aClass name]. |
79 aClass isClass ifTrue: [className := aClass name]. |
68 aClass isString ifTrue: [className := aClass]. |
80 aClass isString ifTrue: [className := aClass]. |
69 aClass isNil ifTrue: [className := '']. |
81 aClass isNil ifTrue: [className := '']. |
70 |
82 |
71 imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector]. |
83 imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. |
|
84 imageEditor loadFromOrPrepareForClass: aClass andSelector: aSelector]. |
72 imageEditor openModal. |
85 imageEditor openModal. |
73 |
86 |
74 resourceClassName := imageEditView resourceClass name. |
87 resourceClass := imageEditView resourceClass. |
75 resourceSelector := imageEditView resourceSelector. |
88 resourceSelector := imageEditView resourceSelector. |
76 |
89 |
77 ((className asString ~= resourceClassName) |
90 (resourceClass isNil or:[resourceSelector isNil]) ifTrue:[^ nil]. |
78 or:[aSelector asString ~= resourceSelector]) |
91 ^ Array with:resourceClass with:resourceSelector |
79 ifTrue: [^resourceClassName, ' ', resourceSelector] |
|
80 ifFalse:[^nil] |
|
81 |
92 |
82 " |
93 " |
83 self openModalOnClass: self andSelector: #leftMouseKeyIcon |
94 self openModalOnClass: self andSelector: #leftMouseKeyIcon |
84 " |
95 " |
85 ! |
96 ! |
86 |
97 |
87 openOnClass:aClass andSelector:aSelector |
98 openOnClass:aClass andSelector:aSelector |
88 "opens an Image Editor on aClass and aSelector" |
99 "opens an Image Editor on aClass and aSelector" |
89 |
100 |
90 |editor| |
101 self openLoadingImageWith:[:editor | editor loadFromClass:aClass theNonMetaclass andSelector:aSelector.] |
91 |
|
92 editor := self new. |
|
93 editor allButOpen. |
|
94 editor loadFromClass:aClass selector:aSelector. |
|
95 editor openWindow |
|
96 |
102 |
97 " |
103 " |
98 self openOnClass:self andSelector:#leftMouseKeyIcon |
104 self openOnClass:self andSelector:#leftMouseKeyIcon |
99 self openOnClass:self andSelector:nil |
105 self openOnClass:self andSelector:nil |
100 " |
106 " |
103 ! |
109 ! |
104 |
110 |
105 openOnFile:aFileName |
111 openOnFile:aFileName |
106 "opens an Image Editor on aFileName" |
112 "opens an Image Editor on aFileName" |
107 |
113 |
108 |editor| |
114 self openLoadingImageWith:[:editor | editor loadFromFile:aFileName.] |
109 |
115 |
110 editor := self new. |
116 " |
111 editor allButOpen. |
117 self openOnFile: '../../goodies/bitmaps/gifImages/back.gif' |
112 editor loadFromFile:aFileName. |
|
113 editor openWindow |
|
114 |
|
115 " |
|
116 self openOnFile: 'bitmaps/SmalltalkX.xbm' |
|
117 " |
118 " |
118 |
119 |
119 "Modified: / 16.3.1999 / 21:33:25 / cg" |
120 "Modified: / 16.3.1999 / 21:33:25 / cg" |
120 ! |
121 ! |
121 |
122 |
122 openOnImage:anImage |
123 openOnImage:anImage |
123 "opens an Image Editor on anImage" |
124 "opens an Image Editor on anImage" |
124 |
125 |
125 |editor| |
126 self openLoadingImageWith:[:editor | editor loadFromImage: anImage.] |
126 |
|
127 editor := self new. |
|
128 editor allButOpen. |
|
129 editor loadFromImage: anImage. |
|
130 editor openWindow |
|
131 |
127 |
132 " |
128 " |
133 self openOnImage: Icon startIcon |
129 self openOnImage: Icon startIcon |
134 " |
130 " |
135 |
131 |
463 |
459 |
464 <resource: #image> |
460 <resource: #image> |
465 |
461 |
466 ^Icon |
462 ^Icon |
467 constantNamed:#'ImageEditor class copyIcon' |
463 constantNamed:#'ImageEditor class copyIcon' |
468 ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@** @@J)UUTB*Z*)@*&**PJ)**$B*Z*)@*&**PJ)**$@@Z*)@@F**P@AUUT@@@@@@b') ; colorMapFromArray:#[0 0 0 0 0 128 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@C? O>@??3??O?<??3??O?<??3??@_<A?0@@@@a') ; yourself); yourself] |
464 ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@** @@J)UUTB*Z*)@*&**PJ)**$B*Z*)@*&**PJ)**$@@Z*)@@F**P@AUUT@@@@@@b') ; colorMapFromArray:#[0 0 0 0 0 128 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@C? O>@??3??O?<??3??O?<??3??@_<A?0@@@@a') ; yourself); yourself] |
469 ! |
465 ! |
470 |
466 |
471 fillIcon |
467 fillIcon |
472 "This resource specification was automatically generated |
468 "This resource specification was automatically generated |
473 by the ImageEditor of ST/X." |
469 by the ImageEditor of ST/X." |
483 |
479 |
484 <resource: #image> |
480 <resource: #image> |
485 |
481 |
486 ^Icon |
482 ^Icon |
487 constantNamed:#'ImageEditor class fillIcon' |
483 constantNamed:#'ImageEditor class fillIcon' |
488 ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@ @@@@*H@@D*(@@DUUP@EAUU@AAEU@@@@U@@DDA@@@@@@@@PP@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C @Q@BN@I<@?8C?0[?!!G<@O P\@@ D@@@@@@@@@a') ; yourself); yourself] |
484 ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@ @@@@*H@@D*(@@DUUP@EAUU@AAEU@@@@U@@DDA@@@@@@@@PP@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C @Q@BN@I<@?8C?0[?!!G<@O P\@@ D@@@@@@@@@a') ; yourself); yourself] |
489 ! |
485 ! |
490 |
486 |
491 fillRectIcon |
487 fillRectIcon |
492 "This resource specification was automatically generated |
488 "This resource specification was automatically generated |
493 by the ImageEditor of ST/X." |
489 by the ImageEditor of ST/X." |
542 |
538 |
543 <resource: #image> |
539 <resource: #image> |
544 |
540 |
545 ^Icon |
541 ^Icon |
546 constantNamed:#'ImageEditor class pasteIcon' |
542 constantNamed:#'ImageEditor class pasteIcon' |
547 ifAbsentPut:[(Depth4Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L@@@@@@AL3@3M&X@@SL0L0A&@@D3LC@@A @AL3@3@FX@@QDPY&Y& |
543 ifAbsentPut:[(Depth4Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(4)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L@@@@@@AL3A&Y&X@@SL0Y A&@@D3LF@@A @AL3A&@FX@@QDPY&Y& |
548 @@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C0A?8O?0??C?<O?0??C?>O?8??#?>O?8_? G>@@a') ; yourself); yourself] |
544 @@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C0A?8O?0??C?<O?0??C?>O?8??#?>O?8_? G>@@a') ; yourself); yourself] |
549 ! |
545 ! |
550 |
546 |
551 pasteUnderIcon |
547 pasteUnderIcon |
552 "This resource specification was automatically generated |
548 "This resource specification was automatically generated |
553 by the ImageEditor of ST/X." |
549 by the ImageEditor of ST/X." |
563 |
559 |
564 <resource: #image> |
560 <resource: #image> |
565 |
561 |
566 ^Icon |
562 ^Icon |
567 constantNamed:#'ImageEditor class pasteUnderIcon' |
563 constantNamed:#'ImageEditor class pasteUnderIcon' |
568 ifAbsentPut:[(Depth4Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L@@@@@@AL3@3M&X@@SL0L0A&@@D3LC@@A @AL3@3@FX@@QDPY&Y& |
564 ifAbsentPut:[(Depth4Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(4)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L3LP@@@AL3L3E&X@@SL3L0A&@@D3L3@@A @AL3L3@FX@@QDQDQY& |
569 @@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C0A?8O?0??C?<O?0??C?>O?8??#?>O?8_? G>@@a') ; yourself); yourself] |
565 @@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C0A?8O?0??C?<O?0??C?>O?8??#?>O?8_? G>@@a') ; yourself); yourself] |
570 ! |
566 ! |
571 |
567 |
572 pasteWithMaskIcon |
568 pasteWithMaskIcon |
573 "This resource specification was automatically generated |
569 "This resource specification was automatically generated |
574 by the ImageEditor of ST/X." |
570 by the ImageEditor of ST/X." |
605 |
601 |
606 <resource: #image> |
602 <resource: #image> |
607 |
603 |
608 ^Icon |
604 ^Icon |
609 constantNamed:#'ImageEditor class pointIcon' |
605 constantNamed:#'ImageEditor class pointIcon' |
610 ifAbsentPut:[(Depth1Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@A@@@@@@@@@@@@@@@C@@@@@B@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@0@G@@8@G@@8@G@@8@G@@X@B@@@@@@@@@a') ; yourself); yourself] |
606 ifAbsentPut:[(Depth1Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@A@@@@@@@@@@@@@@@C@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 14; height: 14; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@0@G@@8@G@@8@G@@8@G@@X@@@@@@@@@@@a') ; yourself); yourself] |
611 ! |
607 ! |
612 |
608 |
613 rectIcon |
609 rectIcon |
614 "This resource specification was automatically generated |
610 "This resource specification was automatically generated |
615 by the ImageEditor of ST/X." |
611 by the ImageEditor of ST/X." |
777 step: 1 |
773 step: 1 |
778 ) |
774 ) |
779 (LabelSpec |
775 (LabelSpec |
780 name: 'HueColorLabel' |
776 name: 'HueColorLabel' |
781 layout: (LayoutFrame 10 0.0 109 0 -10 1.0 148 0) |
777 layout: (LayoutFrame 10 0.0 109 0 -10 1.0 148 0) |
|
778 backgroundChannel: hlsColor |
782 translateLabel: true |
779 translateLabel: true |
783 backgroundChannel: hlsColor |
|
784 ) |
780 ) |
785 (HorizontalPanelViewSpec |
781 (HorizontalPanelViewSpec |
786 name: 'HorizontalPanel1' |
782 name: 'HorizontalPanel1' |
787 layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1) |
783 layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1) |
788 horizontalLayout: fitSpace |
784 horizontalLayout: fitSpace |
1540 layout: (LayoutFrame -57 1 -22 1 -26 1 0 1) |
1536 layout: (LayoutFrame -57 1 -22 1 -26 1 0 1) |
1541 activeHelpKey: magnificationNumber |
1537 activeHelpKey: magnificationNumber |
1542 enableChannel: imageIsLoaded |
1538 enableChannel: imageIsLoaded |
1543 model: valueOfMagnification |
1539 model: valueOfMagnification |
1544 type: numberInRange |
1540 type: numberInRange |
1545 acceptOnReturn: false |
1541 acceptOnReturn: true |
1546 acceptOnTab: false |
1542 acceptOnTab: true |
1547 numChars: 2 |
1543 numChars: 2 |
1548 minValue: 1 |
1544 minValue: 1 |
1549 maxValue: 99 |
1545 maxValue: 99 |
1550 acceptOnPointerLeave: false |
1546 acceptOnPointerLeave: true |
1551 ) |
1547 ) |
1552 ) |
1548 ) |
1553 |
1549 |
1554 ) |
1550 ) |
1555 ) |
1551 ) |
1797 activeHelpKey: fileSaveMethodAs |
1793 activeHelpKey: fileSaveMethodAs |
1798 enabled: imageIsLoaded |
1794 enabled: imageIsLoaded |
1799 label: 'Save As...' |
1795 label: 'Save As...' |
1800 itemValue: doSaveMethodAs |
1796 itemValue: doSaveMethodAs |
1801 translateLabel: true |
1797 translateLabel: true |
1802 isVisible: notInBrowser |
1798 isVisible: isStandAlone |
1803 ) |
1799 ) |
1804 (MenuItem |
1800 (MenuItem |
1805 activeHelpKey: fileSaveAs |
1801 activeHelpKey: fileSaveAs |
1806 enabled: imageIsLoaded |
1802 enabled: imageIsLoaded |
1807 label: 'Save to File...' |
1803 label: 'Save to File...' |
1855 itemValue: doPrint |
1851 itemValue: doPrint |
1856 translateLabel: true |
1852 translateLabel: true |
1857 ) |
1853 ) |
1858 (MenuItem |
1854 (MenuItem |
1859 label: '-' |
1855 label: '-' |
1860 isVisible: notInBrowser |
1856 isVisible: isStandAlone |
1861 ) |
1857 ) |
1862 (MenuItem |
1858 (MenuItem |
1863 activeHelpKey: fileBrowseClass |
1859 activeHelpKey: fileBrowseClass |
1864 enabled: hasClassDefined |
1860 enabled: hasClassDefined |
1865 label: 'Browse Class' |
1861 label: 'Browse Class' |
1866 itemValue: doBrowseClass |
1862 itemValue: doBrowseClass |
1867 translateLabel: true |
1863 translateLabel: true |
1868 isVisible: notInBrowser |
1864 isVisible: isStandAlone |
1869 ) |
1865 ) |
1870 (MenuItem |
1866 (MenuItem |
1871 label: 'Inspect Image' |
1867 label: 'Inspect Image' |
1872 itemValue: doInspectImage |
1868 itemValue: doInspectImage |
1873 translateLabel: true |
1869 translateLabel: true |
1874 isVisible: notInBrowser |
1870 isVisible: isStandAlone |
1875 ) |
1871 ) |
1876 (MenuItem |
1872 (MenuItem |
1877 label: '-' |
1873 label: '-' |
1878 isVisible: notInBrowser |
1874 isVisible: isStandAlone |
1879 ) |
1875 ) |
1880 (MenuItem |
1876 (MenuItem |
1881 activeHelpKey: fileExit |
1877 activeHelpKey: fileExit |
1882 label: 'Exit' |
1878 label: 'Exit' |
1883 itemValue: closeRequest |
1879 itemValue: closeRequest |
1884 translateLabel: true |
1880 translateLabel: true |
1885 isVisible: notInBrowser |
1881 isVisible: isStandAlone |
1886 ) |
1882 ) |
1887 ) |
1883 ) |
1888 nil |
1884 nil |
1889 nil |
1885 nil |
1890 ) |
1886 ) |
2408 activeHelpKey: fileLoadFromClass |
2404 activeHelpKey: fileLoadFromClass |
2409 label: 'loadFromClass' |
2405 label: 'loadFromClass' |
2410 itemValue: doLoadFromClass |
2406 itemValue: doLoadFromClass |
2411 translateLabel: true |
2407 translateLabel: true |
2412 isButton: true |
2408 isButton: true |
2413 isVisible: notInBrowser |
2409 isVisible: isStandAlone |
2414 submenuChannel: menuHistory |
2410 submenuChannel: menuHistory |
2415 labelImage: (ResourceRetriever XPToolbarIconLibrary loadImageFromMethodIcon) |
2411 labelImage: (ResourceRetriever XPToolbarIconLibrary loadImageFromMethodIcon) |
2416 keepLinkedMenu: true |
2412 keepLinkedMenu: true |
2417 ) |
2413 ) |
2418 (MenuItem |
2414 (MenuItem |
2420 enabled: imageIsLoaded |
2416 enabled: imageIsLoaded |
2421 label: 'saveAsMethod' |
2417 label: 'saveAsMethod' |
2422 itemValue: doSaveMethodAs |
2418 itemValue: doSaveMethodAs |
2423 translateLabel: true |
2419 translateLabel: true |
2424 isButton: true |
2420 isButton: true |
2425 isVisible: notInBrowser |
2421 isVisible: isStandAlone |
2426 labelImage: (ResourceRetriever XPToolbarIconLibrary saveImageAsMethodAsIcon) |
2422 labelImage: (ResourceRetriever XPToolbarIconLibrary saveImageAsMethodAsIcon) |
2427 ) |
2423 ) |
2428 (MenuItem |
2424 (MenuItem |
2429 activeHelpKey: fileSaveMethod |
2425 activeHelpKey: fileSaveMethod |
2430 enabled: imageIsLoaded |
2426 enabled: imageIsLoaded |
2431 label: 'saveAsMethod' |
2427 label: 'saveAsMethod' |
2432 itemValue: doSaveMethod |
2428 itemValue: doSaveMethod |
2433 translateLabel: true |
2429 translateLabel: true |
2434 isButton: true |
2430 isButton: true |
2435 isVisible: onlyInBrowser |
2431 isVisible: isNotStandAlone |
2436 labelImage: (ResourceRetriever XPToolbarIconLibrary saveImageAsMethodAsIcon) |
2432 labelImage: (ResourceRetriever XPToolbarIconLibrary saveImageAsMethodAsIcon) |
2437 ) |
2433 ) |
2438 (MenuItem |
2434 (MenuItem |
2439 label: '-' |
2435 label: '-' |
2440 ) |
2436 ) |
3008 holder := AspectAdaptor new subject:self; forAspect:#magnification) |
3005 holder := AspectAdaptor new subject:self; forAspect:#magnification) |
3009 ]. |
3006 ]. |
3010 ^ holder |
3007 ^ holder |
3011 ! ! |
3008 ! ! |
3012 |
3009 |
3013 !ImageEditor methodsFor:'aspects-menu item visibility'! |
|
3014 |
|
3015 notInBrowser |
|
3016 ^ self masterApplication isNil |
|
3017 ! |
|
3018 |
|
3019 onlyInBrowser |
|
3020 ^ self masterApplication notNil |
|
3021 ! ! |
|
3022 |
|
3023 !ImageEditor methodsFor:'change & update'! |
3010 !ImageEditor methodsFor:'change & update'! |
3024 |
3011 |
3025 findColorMapMode |
3012 findColorMapMode |
3026 "finds the colorMapMode for a new image" |
3013 "finds the colorMapMode for a new image" |
3027 |
3014 |
3028 |image listOfColors colorMapModeKey drawColor1 drawColor2 someOrAllUsedColors| |
3015 |image listOfColors colorMapModeKey drawColor1 drawColor2 someOrAllUsedColors| |
3029 |
3016 |
3030 image := self image. |
3017 image := self image. |
|
3018 image isNil ifTrue:[^ self ]. |
3031 |
3019 |
3032 image mask notNil ifTrue: [ |
3020 image mask notNil ifTrue: [ |
3033 colorMapModeKey := 'masked'. |
3021 colorMapModeKey := 'masked'. |
3034 ] ifFalse:[ |
3022 ] ifFalse:[ |
3035 colorMapModeKey := 'depth'. |
3023 colorMapModeKey := 'depth'. |
3214 self imageIsLoaded value: image notNil. |
3202 self imageIsLoaded value: image notNil. |
3215 image isNil ifTrue: [^nil]. |
3203 image isNil ifTrue: [^nil]. |
3216 |
3204 |
3217 self updateInfoLabel. |
3205 self updateInfoLabel. |
3218 |
3206 |
3219 imageEditView resourceMessage asCollectionOfWords size = 2 |
3207 imageEditView resourceClass notNil ifTrue:[ |
3220 ifTrue: [self addToHistory: imageEditView resourceMessage -> #loadFromMessage:]. |
3208 imageEditView resourceSelector notNil ifTrue:[ |
3221 |
3209 self addHistoryEntryForClass:imageEditView resourceClass selector:imageEditView resourceSelector. |
3222 image fileName notNil |
3210 ] |
3223 ifTrue: [self addToHistory: image fileName -> #loadFromFile:]. |
3211 ]. |
|
3212 |
|
3213 image fileName notNil ifTrue: [ |
|
3214 self addHistoryEntryForFile:image fileName. |
|
3215 ]. |
3224 ! |
3216 ! |
3225 |
3217 |
3226 updateListOfColorsAndColormapMode |
3218 updateListOfColorsAndColormapMode |
3227 |colorMap image| |
3219 |colorMap image| |
3228 |
3220 |
3229 image := self image. |
3221 image := self image. |
3230 colorMap := image colorMap. |
3222 image isNil ifTrue:[ |
3231 colorMap size <= 4096 ifTrue:[ |
3223 self listOfColors removeAll. |
3232 self listOfColors contents:colorMap. |
|
3233 ] ifFalse:[ |
3224 ] ifFalse:[ |
3234 self listOfColors removeAll. |
3225 colorMap := image colorMap. |
3235 colorMap isFixedPalette ifTrue:[ |
3226 colorMap size <= 4096 ifTrue:[ |
3236 image colorMap:nil. |
3227 self listOfColors contents:colorMap. |
3237 image photometric:#rgb. |
3228 ] ifFalse:[ |
3238 image samplesPerPixel:3. |
3229 self listOfColors removeAll. |
3239 |
3230 colorMap isFixedPalette ifTrue:[ |
3240 image bitsPerSample:(Array |
3231 image colorMap:nil. |
3241 with:(colorMap bitsRed) |
3232 image photometric:#rgb. |
3242 with:(colorMap bitsGreen) |
3233 image samplesPerPixel:3. |
3243 with:(colorMap bitsBlue)). |
3234 |
|
3235 image bitsPerSample:(Array |
|
3236 with:(colorMap bitsRed) |
|
3237 with:(colorMap bitsGreen) |
|
3238 with:(colorMap bitsBlue)). |
|
3239 ]. |
3244 ]. |
3240 ]. |
3245 ]. |
3241 ]. |
3246 self findColorMapMode. |
3242 self findColorMapMode. |
3247 ! ! |
3243 ! ! |
3248 |
3244 |
3409 |
3405 |
3410 ! ! |
3406 ! ! |
3411 |
3407 |
3412 !ImageEditor methodsFor:'loading'! |
3408 !ImageEditor methodsFor:'loading'! |
3413 |
3409 |
3414 loadFromClass:class selector:selector |
3410 loadFromClass:aClass andSelector:aSelector |
3415 "loads an image by evaluating aMessage and sets up color map list and other info labels" |
3411 "loads an image from the method specified by class and selector" |
3416 |
3412 |
3417 (class isNil or:[selector]) isNil ifTrue:[ |
3413 self assert:(aClass isNil or:[aClass isClass]). |
3418 imageEditView resourceClass:class. |
3414 |
3419 imageEditView resourceSelector:selector. |
3415 (aClass isNil or:[aSelector]) isNil ifTrue:[ |
|
3416 imageEditView resourceClass:aClass. |
|
3417 imageEditView resourceSelector:aSelector. |
3420 imageEditView image:nil. |
3418 imageEditView image:nil. |
3421 ^ self. |
3419 ^ self. |
3422 ]. |
3420 ]. |
3423 |
3421 |
3424 (imageEditView resourceClass == class |
3422 (imageEditView resourceClass == aClass |
3425 and:[ imageEditView resourceSelector == selector ]) ifTrue:[ |
3423 and:[ imageEditView resourceSelector == aSelector ]) ifTrue:[ |
3426 imageEditView modified ifFalse:[ |
3424 imageEditView modified ifFalse:[ |
3427 ^ self. |
3425 ^ self. |
3428 ]. |
3426 ]. |
3429 ]. |
3427 ]. |
3430 |
3428 |
3431 (imageEditView loadFromClass:class selector:selector) notNil ifTrue:[ |
3429 (imageEditView loadFromClass:aClass andSelector:aSelector) notNil ifTrue:[ |
3432 self updateAfterImageChange. |
3430 self updateAfterImageChange. |
3433 ] |
3431 ] |
|
3432 |
|
3433 "Modified: / 16.3.1999 / 21:44:41 / cg" |
3434 ! |
3434 ! |
3435 |
3435 |
3436 loadFromFile: aFileName |
3436 loadFromFile: aFileName |
3437 "loads an image from aFileName and sets up color map list and other info labels" |
3437 "loads an image from aFileName and sets up color map list and other info labels" |
3438 |
3438 |
3467 "/ ] |
3467 "/ ] |
3468 |
3468 |
3469 "Modified: / 16.3.1999 / 21:43:56 / cg" |
3469 "Modified: / 16.3.1999 / 21:43:56 / cg" |
3470 ! |
3470 ! |
3471 |
3471 |
3472 loadFromMessage: aMessage |
3472 loadFromOrPrepareForClass: aClass andSelector: aSelector |
3473 "loads an image by evaluating aMessage and sets up color map list and other info labels" |
|
3474 |
|
3475 (imageEditView loadFromMessage: aMessage) notNil ifTrue:[ |
|
3476 self updateAfterImageChange. |
|
3477 ] |
|
3478 |
|
3479 "Modified: / 16.3.1999 / 21:44:41 / cg" |
|
3480 ! |
|
3481 |
|
3482 loadFromOrPrepareForMessage: aMessage |
|
3483 "loads an image by evaluating aMessage; |
3473 "loads an image by evaluating aMessage; |
3484 if no image could extract from aMessage; do set the class and the selector from |
3474 if no image could extract from aMessage; do set the class and the selector from |
3485 the aMessage for a saving at the end of editing" |
3475 the aMessage for a saving at the end of editing" |
3486 |
3476 |
3487 (imageEditView loadFromMessage: aMessage) notNil ifTrue: [ |
3477 (imageEditView loadFromClass:aClass andSelector:aSelector) notNil ifTrue: [ |
3488 self updateColorsFromImage:self image. |
3478 self updateColorsFromImage:self image. |
3489 self findColorMapMode. |
3479 self findColorMapMode. |
3490 ] ifFalse: [ |
3480 ] ifFalse: [ |
3491 imageEditView resourceMessage: aMessage. |
3481 imageEditView resourceClass: aClass. |
|
3482 imageEditView resourceSelector:aSelector. |
3492 ]. |
3483 ]. |
3493 self updateLabelsAndHistory. |
3484 self updateLabelsAndHistory. |
3494 |
3485 |
3495 "Modified: / 16.3.1999 / 21:45:07 / cg" |
3486 "Modified: / 16.3.1999 / 21:45:07 / cg" |
3496 ! |
3487 ! |
3544 |
3535 |
3545 "Modified: / 10.2.2000 / 23:16:42 / cg" |
3536 "Modified: / 10.2.2000 / 23:16:42 / cg" |
3546 ! ! |
3537 ! ! |
3547 |
3538 |
3548 !ImageEditor methodsFor:'private'! |
3539 !ImageEditor methodsFor:'private'! |
|
3540 |
|
3541 checkModified |
|
3542 imageEditView modified value ifTrue:[ |
|
3543 (Dialog |
|
3544 confirm:(resources string:'Image was not saved. Proceed anyway ?') |
|
3545 yesLabel:(resources string:'Proceed') |
|
3546 noLabel:(resources string:'Cancel') |
|
3547 initialAnswer:false |
|
3548 ) ifFalse: [^false]. |
|
3549 |
|
3550 imageEditView clearModified. |
|
3551 ]. |
|
3552 ^ true |
|
3553 |
|
3554 "Modified: / 29.7.1998 / 18:55:24 / cg" |
|
3555 ! |
3549 |
3556 |
3550 pointFromString:aString |
3557 pointFromString:aString |
3551 |p s x y| |
3558 |p s x y| |
3552 |
3559 |
3553 p := Object readFromString:aString onError:nil. |
3560 p := Object readFromString:aString onError:nil. |
3683 ! |
3694 ! |
3684 |
3695 |
3685 postBuildWith:aBuilder |
3696 postBuildWith:aBuilder |
3686 super postBuildWith:aBuilder. |
3697 super postBuildWith:aBuilder. |
3687 |
3698 |
3688 DefaultRelativeSizes notNil ifTrue:[ |
|
3689 (aBuilder componentAt:#horizontalPanel) relativeCorners:DefaultRelativeSizes first. |
|
3690 (aBuilder componentAt:#verticalPanel) relativeCorners:DefaultRelativeSizes second. |
|
3691 ]. |
|
3692 ! |
|
3693 |
|
3694 postOpenWith:aBuilder |
|
3695 "after opening, sets the masterApplication of the imageEditView to self; |
|
3696 evaluate the postOpenAction" |
|
3697 |
|
3698 imageEditView undoImages addDependent:self. |
3699 imageEditView undoImages addDependent:self. |
3699 imageEditView imageInfoHolder:(self imageInfoHolder). |
3700 imageEditView imageInfoHolder:(self imageInfoHolder). |
3700 imageEditView activityInfoHolder:(self activityInfoHolder). |
3701 imageEditView activityInfoHolder:(self activityInfoHolder). |
|
3702 |
3701 imageEditView clickInfoCallBack:[:button :point | |
3703 imageEditView clickInfoCallBack:[:button :point | |
3702 |mouseButtonColorToolBar| |
3704 |mouseButtonColorToolBar| |
3703 |
3705 |
3704 mouseButtonColorToolBar := self componentAt:#MouseButtonColorToolBar. |
3706 mouseButtonColorToolBar := self componentAt:#MouseButtonColorToolBar. |
3705 (mouseButtonColorToolBar itemAt:button) toggleIndication. |
3707 (mouseButtonColorToolBar itemAt:button) toggleIndication. |
3706 mouseButtonColorToolBar do: [:i| i updateIndicators]. |
3708 mouseButtonColorToolBar do: [:i| i updateIndicators]. |
3707 ]. |
3709 ]. |
|
3710 |
3708 imageEditView addDependent:self. |
3711 imageEditView addDependent:self. |
3709 imageEditView modifiedHolder addDependent:self. |
3712 imageEditView modifiedHolder addDependent:self. |
|
3713 |
|
3714 DefaultRelativeSizes notNil ifTrue:[ |
|
3715 (aBuilder componentAt:#horizontalPanel) relativeCorners:DefaultRelativeSizes first. |
|
3716 (aBuilder componentAt:#verticalPanel) relativeCorners:DefaultRelativeSizes second. |
|
3717 ]. |
|
3718 ! |
|
3719 |
|
3720 postOpenWith:aBuilder |
|
3721 "after opening, sets the masterApplication of the imageEditView to self; |
|
3722 evaluate the postOpenAction" |
3710 |
3723 |
3711 postOpenAction value. |
3724 postOpenAction value. |
3712 |
3725 |
3713 super postOpenWith:aBuilder. |
3726 super postOpenWith:aBuilder. |
3714 |
3727 |
5018 doLoadFromClass |
5031 doLoadFromClass |
5019 "opens a dialog for loading an image from class and a (resource-) selector" |
5032 "opens a dialog for loading an image from class and a (resource-) selector" |
5020 |
5033 |
5021 |img| |
5034 |img| |
5022 |
5035 |
|
5036 self checkModified ifFalse:[ ^ self ]. |
|
5037 |
5023 (imageEditView loadFromClass) notNil ifTrue:[ |
5038 (imageEditView loadFromClass) notNil ifTrue:[ |
5024 imageSeqNr := nil. |
5039 imageSeqNr := nil. |
5025 (img := self image) notNil ifTrue: [ |
5040 (img := self image) notNil ifTrue: [ |
5026 self updateColorsFromImage:img. |
5041 self updateColorsFromImage:img. |
5027 self findColorMapMode. |
5042 self findColorMapMode. |
5063 ! |
5080 ! |
5064 |
5081 |
5065 doNewImage |
5082 doNewImage |
5066 "opens a dialog with choices of size and color map for creating a new image" |
5083 "opens a dialog with choices of size and color map for creating a new image" |
5067 |
5084 |
5068 |aspects width height cMapString cMapMode cMap imageClass image szString defaultSize ext| |
5085 |dialogAspects width height cMapString cMapMode cMap imageClass image szString defaultSize ext| |
|
5086 |
|
5087 self checkModified ifFalse:[ ^ self ]. |
5069 |
5088 |
5070 defaultSize := (self class listOfDefaultSizes includes:'32x32') |
5089 defaultSize := (self class listOfDefaultSizes includes:'32x32') |
5071 ifTrue:['32x32'] |
5090 ifTrue:['32x32'] |
5072 ifFalse:[self class listOfDefaultSizes first]. |
5091 ifFalse:[self class listOfDefaultSizes first]. |
5073 |
5092 |
5074 aspects := IdentityDictionary new |
5093 dialogAspects := IdentityDictionary new |
5075 at:#listOfSizes put: self class listOfDefaultSizes asValue; |
5094 at:#listOfSizes put: self class listOfDefaultSizes asValue; |
5076 at:#listOfColorMaps put: self class namesOfColorMaps values asSortedCollection asValue; |
5095 at:#listOfColorMaps put: self class namesOfColorMaps values asSortedCollection asValue; |
5077 at:#selectionOfSize put: (LastSizeString ? defaultSize) asValue; |
5096 at:#selectionOfSize put: (LastSizeString ? defaultSize) asValue; |
5078 at:#selectionOfColorMap put: (LastColormapMode ? self class namesOfColorMaps values asSortedCollection first) asValue; |
5097 at:#selectionOfColorMap put: (LastColormapMode ? self class namesOfColorMaps values asSortedCollection first) asValue; |
5079 yourself. |
5098 yourself. |
5080 |
5099 |
5081 (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
5100 (self openDialogInterface:#dialogSpecForNewImage withBindings:dialogAspects) |
5082 ifTrue:[ |
5101 ifTrue:[ |
5083 szString := (aspects at:#selectionOfSize) value. |
5102 szString := (dialogAspects at:#selectionOfSize) value. |
5084 ext := self pointFromString:szString. |
5103 ext := self pointFromString:szString. |
5085 ext isNil ifTrue:[ |
5104 ext isNil ifTrue:[ |
5086 width := height := 32 |
5105 width := height := 32 |
5087 ] ifFalse:[ |
5106 ] ifFalse:[ |
5088 width := ext x. |
5107 width := ext x. |
5089 height := ext y. |
5108 height := ext y. |
5090 ]. |
5109 ]. |
5091 "/ width := "128 min: "(Integer readFromString: (szString upTo: $x) onError:[32]). |
5110 "/ width := "128 min: "(Integer readFromString: (szString upTo: $x) onError:[32]). |
5092 "/ height := "128 min: " (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[32]). |
5111 "/ height := "128 min: " (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[32]). |
5093 |
5112 |
5094 cMapString := (aspects at:#selectionOfColorMap) value. |
5113 cMapString := (dialogAspects at:#selectionOfColorMap) value. |
5095 cMapMode := self class namesOfColorMaps keyAtEqualValue:cMapString. |
5114 cMapMode := self class namesOfColorMaps keyAtEqualValue:cMapString. |
5096 cMap := self class listOfColorMaps at:cMapMode. |
5115 cMap := self class listOfColorMaps at:cMapMode. |
5097 imageClass := Image implementorForDepth:(cMap size highBit-1). |
5116 imageClass := Image implementorForDepth:(cMap size highBit-1). |
5098 image := imageClass width: width height: height. |
5117 image := imageClass width: width height: height. |
5099 image bits:(ByteArray new:(image bytesPerRow*height)). |
5118 image bits:(ByteArray new:(image bytesPerRow*height)). |
5114 ! |
5133 ! |
5115 |
5134 |
5116 doNewImageFromClipboard |
5135 doNewImageFromClipboard |
5117 |image| |
5136 |image| |
5118 |
5137 |
|
5138 self checkModified ifFalse:[ ^ self ]. |
|
5139 |
5119 image := imageEditView clipBoard. |
5140 image := imageEditView clipBoard. |
5120 |
5141 imageEditView image:image. |
5121 (imageEditView image:image) notNil |
5142 |
5122 ifTrue:[ |
5143 image notNil ifTrue:[ |
5123 self updateColorsFromImage:image. |
5144 self updateColorsFromImage:image. |
5124 self findColorMapMode. |
5145 self findColorMapMode. |
5125 self updateLabelsAndHistory. |
5146 self updateLabelsAndHistory. |
5126 ] |
5147 ] |
5127 ! |
5148 ! |
5128 |
5149 |
5129 grabScreenImage |
5150 grabScreenImage |
5130 "let user choose an area and grab that are for editing" |
5151 "let user choose an area and grab that are for editing" |
|
5152 |
|
5153 self checkModified ifFalse:[ ^ self ]. |
5131 |
5154 |
5132 Processor |
5155 Processor |
5133 addTimedBlock:[ |
5156 addTimedBlock:[ |
5134 |image d8image img| |
5157 |image d8image img| |
5135 |
5158 |
5257 |
5280 |
5258 imageEditView saveImageMaskFileAs. |
5281 imageEditView saveImageMaskFileAs. |
5259 ! |
5282 ! |
5260 |
5283 |
5261 doSaveMethod |
5284 doSaveMethod |
5262 "saves current image on current class and selector" |
5285 "saves the image in current class and selector" |
5263 |
5286 |
5264 imageEditView saveMethod notNil |
5287 imageEditView saveMethod ifTrue:[ |
5265 ifTrue: |
|
5266 [ |
|
5267 self updateLabelsAndHistory |
5288 self updateLabelsAndHistory |
5268 ] |
5289 ] |
5269 ! |
5290 ! |
5270 |
5291 |
5271 doSaveMethodAs |
5292 doSaveMethodAs |
5272 "opens a dialog for saving current image on a class and a selector" |
5293 "opens a dialog for saving current image on a class and a selector" |
5273 |
5294 |
5274 imageEditView saveMethodAs notNil |
5295 imageEditView saveMethodAs ifTrue:[ |
5275 ifTrue: |
|
5276 [ |
|
5277 self updateLabelsAndHistory |
5296 self updateLabelsAndHistory |
5278 ] |
5297 ] |
5279 ! |
5298 ! |
5280 |
5299 |
5281 doShowStoreString |
5300 doShowStoreString |