equal
deleted
inserted
replaced
12 |
12 |
13 "{ Package: 'stx:libtool2' }" |
13 "{ Package: 'stx:libtool2' }" |
14 |
14 |
15 ToolApplicationModel subclass:#ImageEditor |
15 ToolApplicationModel 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 classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode |
19 classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode |
19 DefaultRelativeSizes' |
20 DefaultRelativeSizes' |
20 poolDictionaries:'' |
21 poolDictionaries:'' |
21 category:'Interface-UIPainter' |
22 category:'Interface-UIPainter' |
22 ! |
23 ! |
192 ! |
193 ! |
193 |
194 |
194 listOfDefaultSizes |
195 listOfDefaultSizes |
195 "returns the list of default sizes for a new image" |
196 "returns the list of default sizes for a new image" |
196 |
197 |
197 ^#('8x8' '16x16' '22x22' '32x32' '48x48' '64x64') |
198 ^ #('8x8' '16x16' '22x22' '32x32' '48x48' '64x64') |
198 |
199 |
199 "Modified: / 31.7.1998 / 01:57:34 / cg" |
200 "Modified: / 31.7.1998 / 01:57:34 / cg" |
200 ! |
201 ! |
201 |
202 |
202 namesOfColorMaps |
203 namesOfColorMaps |
3452 "Modified: / 10.2.2000 / 23:16:42 / cg" |
3453 "Modified: / 10.2.2000 / 23:16:42 / cg" |
3453 ! ! |
3454 ! ! |
3454 |
3455 |
3455 !ImageEditor methodsFor:'private'! |
3456 !ImageEditor methodsFor:'private'! |
3456 |
3457 |
|
3458 pointFromString:aString |
|
3459 |p s x y| |
|
3460 |
|
3461 p := Object readFromString:aString onError:nil. |
|
3462 p notNil ifTrue:[^ p]. |
|
3463 |
|
3464 s := aString readStream. |
|
3465 x := Number readFrom:s onError:nil. |
|
3466 x notNil ifTrue:[ |
|
3467 s skipSeparators. |
|
3468 [s atEnd not and:[s peek isDigit]] whileFalse:[s next]. |
|
3469 y := Number readFrom:s onError:nil. |
|
3470 y notNil ifTrue:[ |
|
3471 ^x@y |
|
3472 ] |
|
3473 ]. |
|
3474 ! |
|
3475 |
3457 sortBlockForColors |
3476 sortBlockForColors |
3458 ^ [:a :b | |
3477 ^ [:a :b | |
3459 a redByte == b redByte ifTrue:[ |
3478 a redByte == b redByte ifTrue:[ |
3460 a greenByte == b greenByte ifTrue:[ |
3479 a greenByte == b greenByte ifTrue:[ |
3461 a blueByte < b blueByte |
3480 a blueByte < b blueByte |
4715 box okText:(resources string:'OK'). |
4734 box okText:(resources string:'OK'). |
4716 box abortText:(resources string:'Cancel'). |
4735 box abortText:(resources string:'Cancel'). |
4717 box initialText:image extent printString. |
4736 box initialText:image extent printString. |
4718 box showAtPointer. |
4737 box showAtPointer. |
4719 (box accepted |
4738 (box accepted |
4720 and: [(newSize := Object readFromString:(box contents) onError:nil) notNil]) |
4739 and: [(newSize := self pointFromString:(box contents)) notNil]) |
4721 ifTrue:[ |
4740 ifTrue:[ |
4722 newSize isPoint ifFalse:[ |
4741 newSize isPoint ifFalse:[ |
4723 self warn:'please enter the new size as ''x @ y''.'. |
4742 self warn:'please enter the new size as ''x @ y''.'. |
4724 ^ self. |
4743 ^ self. |
4725 ]. |
4744 ]. |
4796 box okText:(resources string:'OK'). |
4815 box okText:(resources string:'OK'). |
4797 box abortText:(resources string:'Cancel'). |
4816 box abortText:(resources string:'Cancel'). |
4798 box initialText:image extent printString. |
4817 box initialText:image extent printString. |
4799 box showAtPointer. |
4818 box showAtPointer. |
4800 (box accepted |
4819 (box accepted |
4801 and: [(newSize := Object readFromString:(box contents) onError:nil) notNil]) |
4820 and: [(newSize := self pointFromString:(box contents)) notNil]) |
4802 ifTrue:[ |
4821 ifTrue:[ |
4803 imageEditView resizeImageTo:newSize. |
4822 imageEditView resizeImageTo:newSize. |
4804 ]. |
4823 ]. |
4805 ! |
4824 ! |
4806 |
4825 |
4826 "let user specify amount and shift" |
4845 "let user specify amount and shift" |
4827 |
4846 |
4828 |bindings amount img firstChange shiftAction acceptChannel wrapHolder| |
4847 |bindings amount img firstChange shiftAction acceptChannel wrapHolder| |
4829 |
4848 |
4830 acceptChannel := TriggerValue new. |
4849 acceptChannel := TriggerValue new. |
4831 wrapHolder := false asValue. |
4850 wrapHolder := (lastShiftUsedWrap ? true) asValue. |
4832 |
4851 |
4833 firstChange := true. |
4852 firstChange := true. |
4834 |
4853 |
4835 shiftAction := |
4854 shiftAction := |
4836 [:shiftH :shiftV | |
4855 [:shiftH :shiftV | |
4859 ifFalse:[ |
4878 ifFalse:[ |
4860 firstChange ~~ true ifTrue:[ |
4879 firstChange ~~ true ifTrue:[ |
4861 imageEditView undo |
4880 imageEditView undo |
4862 ] |
4881 ] |
4863 ]. |
4882 ]. |
|
4883 lastShiftUsedWrap := wrapHolder value. |
4864 |
4884 |
4865 "Created: / 7.9.1998 / 18:16:07 / cg" |
4885 "Created: / 7.9.1998 / 18:16:07 / cg" |
4866 "Modified: / 7.9.1998 / 18:20:42 / cg" |
4886 "Modified: / 7.9.1998 / 18:20:42 / cg" |
4867 ! |
4887 ! |
4868 |
4888 |
4951 ! |
4971 ! |
4952 |
4972 |
4953 doNewImage |
4973 doNewImage |
4954 "opens a dialog with choices of size and color map for creating a new image" |
4974 "opens a dialog with choices of size and color map for creating a new image" |
4955 |
4975 |
4956 |aspects width height cMapString cMapMode cMap imageClass image szString defaultSize| |
4976 |aspects width height cMapString cMapMode cMap imageClass image szString defaultSize ext| |
4957 |
4977 |
4958 defaultSize := (self class listOfDefaultSizes includes:'32x32') |
4978 defaultSize := (self class listOfDefaultSizes includes:'32x32') |
4959 ifTrue:['32x32'] |
4979 ifTrue:['32x32'] |
4960 ifFalse:[self class listOfDefaultSizes first]. |
4980 ifFalse:[self class listOfDefaultSizes first]. |
4961 |
4981 |
4967 yourself. |
4987 yourself. |
4968 |
4988 |
4969 (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
4989 (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
4970 ifTrue:[ |
4990 ifTrue:[ |
4971 szString := (aspects at:#selectionOfSize) value. |
4991 szString := (aspects at:#selectionOfSize) value. |
4972 width := "128 min: "(Integer readFromString: (szString upTo: $x) onError:[32]). |
4992 ext := self pointFromString:szString. |
4973 height := "128 min: " (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[32]). |
4993 width := ext x. |
|
4994 height := ext y. |
|
4995 |
|
4996 "/ width := "128 min: "(Integer readFromString: (szString upTo: $x) onError:[32]). |
|
4997 "/ height := "128 min: " (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[32]). |
4974 |
4998 |
4975 cMapString := (aspects at:#selectionOfColorMap) value. |
4999 cMapString := (aspects at:#selectionOfColorMap) value. |
4976 cMapMode := self class namesOfColorMaps keyAtEqualValue:cMapString. |
5000 cMapMode := self class namesOfColorMaps keyAtEqualValue:cMapString. |
4977 cMap := self class listOfColorMaps at:cMapMode. |
5001 cMap := self class listOfColorMaps at:cMapMode. |
4978 imageClass := Image implementorForDepth:(cMap size highBit-1). |
5002 imageClass := Image implementorForDepth:(cMap size highBit-1). |