--- a/FileSelectionBrowser.st Wed Feb 16 09:59:22 2000 +0100
+++ b/FileSelectionBrowser.st Wed Feb 16 11:19:25 2000 +0100
@@ -54,6 +54,11 @@
!FileSelectionBrowser class methodsFor:'instance creation'!
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
+ "ask for a file in some directory,
+ using a fileFilter (list of mathcPatterns).
+ Initial selection is aFileName.
+ return the pathName or nil if canceled."
+
^self new
title: aTitle;
fileName: aFileName;
@@ -62,66 +67,122 @@
open
"
- self
- request: 'Select Your Profile File'
- fileName: '.profile'
- inDirectory: Filename homeDirectory
- withFileFilters: #('.*')
+ self
+ request: 'Select Your Profile File'
+ fileName: '.profile'
+ inDirectory: Filename homeDirectory
+ withFileFilters: #('.*')
"
"Modified: / 17.8.1998 / 10:15:50 / cg"
!
-request: aTitle fileName: aFileName withFileFilters: fileFilters
- ^self new
+request:aTitle fileName:aFileName withFileFilters:fileFilters
+ "ask for a file in some directory,
+ using a fileFilter (list of mathcPatterns).
+ Initial selection is aFileName.
+ return the pathName or nil if canceled."
+
+ ^ self new
title: aTitle;
fileName: aFileName;
listOfFileFilters: fileFilters;
open
"
- self
- request: 'Select Your Profile File'
- fileName: '/etc/fstab'
- withFileFilters: #('*')
+ self
+ request: 'Select Your Profile File'
+ fileName: '/etc/fstab'
+ withFileFilters: #('*')
+ "
+
+ "Modified: / 17.8.1998 / 10:15:50 / cg"
+!
+
+request:aTitle inDirectory:aPath withFileFilters:fileFilters
+ "ask for a file in some directory,
+ using a fileFilter (list of mathcPatterns)
+ return the pathName or nil if canceled."
+
+ ^ (self new)
+ title:aTitle;
+ directory:aPath;
+ listOfFileFilters:fileFilters;
+ open
+
+ "
+ self
+ request: 'Select A File'
+ inDirectory: '/etc'
+ withFileFilters: #('*.conf')
"
"Modified: / 17.8.1998 / 10:15:50 / cg"
!
-request: aTitle pathName: aPath withFileFilters: fileFilters
- ^self new
- title: aTitle;
- directory: aPath;
- listOfFileFilters: fileFilters;
- open
+request:aTitle pathName:aPath withFileFilters:fileFilters
+ "ask for a file in some directory,
+ using a fileFilter (list of mathcPatterns)
+ return the pathName or nil if canceled.
+ Obsolete - for backward compatibility."
+
+ ^ self
+ request:aTitle inDirectory:aPath withFileFilters:fileFilters
"
- self
- request: 'Select A File'
- pathName: '/etc'
- withFileFilters: #('*.conf')
+ self
+ request: 'Select A File'
+ pathName: '/etc'
+ withFileFilters: #('*.conf')
"
"Modified: / 17.8.1998 / 10:15:50 / cg"
!
-request: aTitle withFileFilters: fileFilters
- ^ self new
- title: aTitle;
- listOfFileFilters: fileFilters;
+request:aTitle withFileFilters:fileFilters
+ "ask for a file in the current directory,
+ using a fileFilter (list of mathcPatterns)
+ return the pathName or nil if canceled"
+
+ ^ (self new)
+ title:aTitle;
+ listOfFileFilters:fileFilters;
open
+
"
- self request: 'Select A File' withFileFilters: #('.*')
+ self request:'Select A File' withFileFilters:#('.*')
+ self request:'Select A File' withFileFilters:#('*.mak;*.st')
"
"Modified: / 17.8.1998 / 10:15:49 / cg"
!
requestFileName
- ^self new title: 'Select A File'; open
+ "ask for a file in the current directory;
+ return the pathName or nil if canceled"
+
+ ^ self new
+ title:'Select A File';
+ open
+
+ "
+ self requestFileName
"
- self requestFileName
+
+ "Modified: / 17.8.1998 / 10:15:48 / cg"
+!
+
+requestFileNameInDirectory:aPath
+ "ask for a file in a directory;
+ return the pathName or nil if canceled"
+
+ ^ self new
+ title:'Select A File';
+ directory:aPath;
+ open
+
+ "
+ self requestFileNameInDirectory:'/etc'
"
"Modified: / 17.8.1998 / 10:15:48 / cg"
@@ -462,8 +523,9 @@
!
open
+ super open.
- super open.
+ "return the selected file or nil"
accept value ifTrue:[
^ (self selectionOfDirectory value ? '') asFilename
constructString:(self valueOfFileName value ? '')
--- 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