--- a/ImageEditor.st Wed Feb 16 09:59:22 2000 +0100
+++ b/ImageEditor.st Wed Feb 16 11:19:25 2000 +0100
@@ -13,7 +13,7 @@
ToolApplicationModel subclass:#ImageEditor
instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode
selectedColorIndex postOpenAction'
- classVariableNames:''
+ classVariableNames:'LastDirectory'
poolDictionaries:''
category:'Interface-UIPainter'
!
@@ -1222,7 +1222,7 @@
#(#Menu
#(
#(#MenuItem
- #label: 'Grid Magnification...'
+ #label: 'Grid Magnification Limit...'
#translateLabel: true
#value: #doChangeGridMagnification
#activeHelpKey: #settingsGridMagnification
@@ -2525,12 +2525,6 @@
"Modified: / 31.7.1998 / 02:01:15 / cg"
!
-doChangeGridMagnification
- "change grid magnification"
-
- imageEditView changeGridMagnification
-!
-
doCropAll
"find all borders and cut them off"
@@ -2636,7 +2630,22 @@
doMagnifyImage
"magnifies current image"
- imageEditView magnifyImage.
+ |box newSize image|
+
+ image := imageEditView image.
+
+ box := EnterBox new.
+ box title:(resources string:'Images new size:').
+ box okText:(resources string:'OK').
+ box abortText:(resources string:'Cancel').
+ box initialText:image extent printString.
+ box showAtPointer.
+ (box accepted
+ and: [(newSize := Object readFromString:(box contents) onError:nil) notNil])
+ ifTrue:[
+ imageEditView magnifyImageTo:newSize.
+ ].
+
self updateInfoLabel
!
@@ -2663,17 +2672,42 @@
!
doResizeImage
- "resizes current image"
-
- imageEditView resizeImage.
- self updateInfoLabel
+ "resizes the current image"
+
+ |box newSize image|
+
+ image := imageEditView image.
+
+ box := EnterBox new.
+ box title:(resources string:'Images new size:').
+ box okText:(resources string:'OK').
+ box abortText:(resources string:'Cancel').
+ box initialText:image extent printString.
+ box showAtPointer.
+ (box accepted
+ and: [(newSize := Object readFromString:(box contents) onError:nil) notNil])
+ ifTrue:[
+ imageEditView resizeImageTo:newSize.
+ ].
+
!
doRotateImage
"rotates current image"
- imageEditView rotateImage.
- self updateInfoLabel
+ |box rotation|
+
+ box := EnterBox new.
+ box title:(resources string:'Rotate by (degrees, clockwise):').
+ box okText:(resources string:'OK').
+ box abortText:(resources string:'Cancel').
+ box initialText: '0'.
+ box showAtPointer.
+ (box accepted and: [(rotation := Object readFromString: box contents onError:nil) notNil])
+ ifTrue:[
+ imageEditView rotateImageBy:rotation.
+ self updateInfoLabel
+ ].
!
doUndo
@@ -2703,13 +2737,32 @@
doLoadFromFile
"opens a dialog for loading an image from a file"
- |img|
-
- self loadFromFile:
- (FileSelectionBrowser
- request: 'Load Image From'
- fileName: ((img := self image) notNil ifTrue: [img fileName] ifFalse: [nil])
- withFileFilters: FileSelectionBrowser loadImageFileNameFilters)
+ |img file dir filters|
+
+ img := self image.
+ img notNil ifTrue: [
+ file := img fileName
+ ] ifFalse:[
+ dir := LastDirectory
+ ].
+
+ filters := FileSelectionBrowser loadImageFileNameFilters.
+
+ file notNil ifTrue:[
+ file := FileSelectionBrowser
+ request:'Load Image From'
+ fileName:file
+ withFileFilters:filters.
+ ] ifFalse:[
+ file := FileSelectionBrowser
+ request:'Load Image From'
+ inDirectory:dir
+ withFileFilters:filters.
+ ].
+ file notNil ifTrue:[
+ LastDirectory := file asFilename directoryName.
+ self loadFromFile:file
+ ]
!
doNewImage
@@ -2847,6 +2900,32 @@
TextBox openOn:img storeString
! !
+!ImageEditor methodsFor:'user actions - settings'!
+
+doChangeGridMagnification
+ "change grid magnification"
+
+ |box oldGridLimit newGridLimit|
+
+ oldGridLimit := imageEditView class gridMagnificationLimit asPoint.
+
+ box := EnterBox new.
+ box title:(resources string:'Grid Magnification Limit:').
+ box okText:(resources string:'OK').
+ box abortText:(resources string:'Cancel').
+ box initialText:(oldGridLimit x printString).
+ box showAtPointer.
+
+ (box accepted
+ and: [(newGridLimit := Number readFromString:(box contents) onError:[2]) notNil]
+ ) ifTrue:[
+ newGridLimit := (99 min: (2 max:newGridLimit)) asPoint.
+ imageEditView class gridMagnificationLimit:newGridLimit.
+ imageEditView invalidate
+ ]
+
+! !
+
!ImageEditor class methodsFor:'documentation'!
version