*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Wed, 25 Jan 2006 12:27:59 +0100
changeset 1960 62c7258f3c31
parent 1959 fd6bf76e712a
child 1961 d9082e597adb
*** empty log message ***
ImageEditor.st
--- a/ImageEditor.st	Wed Jan 25 11:42:17 2006 +0100
+++ b/ImageEditor.st	Wed Jan 25 12:27:59 2006 +0100
@@ -14,7 +14,8 @@
 
 ToolApplicationModel subclass:#ImageEditor
 	instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode
-		selectedColorIndex postOpenAction imageSeqNr drawingColormap'
+		selectedColorIndex postOpenAction imageSeqNr drawingColormap
+		lastShiftUsedWrap'
 	classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode
 		DefaultRelativeSizes'
 	poolDictionaries:''
@@ -194,7 +195,7 @@
 listOfDefaultSizes
     "returns the list of default sizes for a new image"
 
-    ^#('8x8' '16x16' '22x22' '32x32' '48x48' '64x64')
+    ^ #('8x8' '16x16' '22x22' '32x32' '48x48' '64x64')
 
     "Modified: / 31.7.1998 / 01:57:34 / cg"
 !
@@ -3454,6 +3455,24 @@
 
 !ImageEditor methodsFor:'private'!
 
+pointFromString:aString
+    |p s x y|
+
+    p := Object readFromString:aString onError:nil.
+    p notNil ifTrue:[^ p].
+
+    s := aString readStream.
+    x := Number readFrom:s onError:nil.
+    x notNil ifTrue:[
+        s skipSeparators.
+        [s atEnd not and:[s peek isDigit]] whileFalse:[s next].
+        y := Number readFrom:s onError:nil.
+        y notNil ifTrue:[
+            ^x@y
+        ]
+    ].
+!
+
 sortBlockForColors
     ^ [:a :b |
             a redByte == b redByte ifTrue:[
@@ -4717,7 +4736,7 @@
     box initialText:image extent printString.
     box showAtPointer.
     (box accepted 
-    and: [(newSize := Object readFromString:(box contents) onError:nil) notNil])
+    and: [(newSize := self pointFromString:(box contents)) notNil])
     ifTrue:[
         newSize isPoint ifFalse:[
             self warn:'please enter the new size as ''x @ y''.'.
@@ -4798,7 +4817,7 @@
     box initialText:image extent printString.
     box showAtPointer.
     (box accepted 
-    and: [(newSize := Object readFromString:(box contents) onError:nil) notNil])
+    and: [(newSize := self pointFromString:(box contents)) notNil])
     ifTrue:[
         imageEditView resizeImageTo:newSize.
     ].
@@ -4828,7 +4847,7 @@
     |bindings amount img firstChange shiftAction acceptChannel wrapHolder|
 
     acceptChannel := TriggerValue new.
-    wrapHolder := false asValue.
+    wrapHolder := (lastShiftUsedWrap ? true) asValue.
 
     firstChange := true.
 
@@ -4861,6 +4880,7 @@
           imageEditView undo
         ]
     ].
+    lastShiftUsedWrap := wrapHolder value.
 
     "Created: / 7.9.1998 / 18:16:07 / cg"
     "Modified: / 7.9.1998 / 18:20:42 / cg"
@@ -4953,7 +4973,7 @@
 doNewImage
     "opens a dialog with choices of size and color map for creating a new image"
 
-    |aspects width height cMapString cMapMode cMap imageClass image szString defaultSize|
+    |aspects width height cMapString cMapMode cMap imageClass image szString defaultSize ext|
 
     defaultSize := (self class listOfDefaultSizes includes:'32x32') 
                         ifTrue:['32x32'] 
@@ -4969,8 +4989,12 @@
     (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects)
     ifTrue:[
         szString := (aspects at:#selectionOfSize) value.
-        width  := "128 min: "(Integer readFromString: (szString upTo: $x) onError:[32]).
-        height := "128 min: " (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[32]).
+        ext := self pointFromString:szString.
+        width := ext x.
+        height := ext y.
+
+"/        width  := "128 min: "(Integer readFromString: (szString upTo: $x) onError:[32]).
+"/        height := "128 min: " (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[32]).
 
         cMapString := (aspects at:#selectionOfColorMap) value.
         cMapMode   := self class namesOfColorMaps keyAtEqualValue:cMapString.