--- a/Win32FileDialog.st Tue Oct 26 18:44:44 2010 +0200
+++ b/Win32FileDialog.st Tue Oct 26 18:49:16 2010 +0200
@@ -42,6 +42,12 @@
other person. No title to or ownership of the software is
hereby transferred.
"
+!
+
+documentation
+"
+ interface to windows file dialogs
+"
! !
!Win32FileDialog class methodsFor:'initialization'!
@@ -68,123 +74,131 @@
!Win32FileDialog class methodsFor:'accessing'!
getInitialDirectory
+ ^ InitialDirectory
- ^ InitialDirectory
+ "Modified: / 26-10-2010 / 18:47:46 / cg"
!
-setInitialDirectory: aName
+setInitialDirectory:aName
+ InitialDirectory := Directory pathName:aName
- InitialDirectory := Directory pathName: aName
+ "Modified: / 26-10-2010 / 18:47:48 / cg"
! !
!Win32FileDialog class methodsFor:'constants'!
-commonDialogConstantAt: aString
+commonDialogConstantAt:aString
+ ^ self commonDialogConstants at:aString
+ ifAbsent:[
+ Transcript showCR:'Common Dialog Constant ' , aString , ' notfound!!'
+ ]
- ^ self commonDialogConstants at: aString ifAbsent:[Transcript showCR: 'Common Dialog Constant ', aString, ' notfound!!']
+ "Modified: / 26-10-2010 / 18:47:51 / cg"
!
commonDialogConstants
-
CommonDialogConstants isNil ifTrue:[
- CommonDialogConstants := self generateCommonDialogConstants
+ CommonDialogConstants := self generateCommonDialogConstants
].
^ CommonDialogConstants
+
+ "Modified: / 26-10-2010 / 18:47:54 / cg"
!
generateCommonDialogConstants
-
|dictionary|
dictionary := Dictionary new.
dictionary
- at: 'CcPreventfullopen' put: 4;
- at: 'FrShowhelp' put: 128;
- at: 'PdEnablesetuptemplate' put: 32768;
- at: 'FrNoupdown' put: 1024;
- at: 'CfNosimulations' put: 4096;
- at: 'OfnPathmustexist' put: 2048;
- at: 'CfWysiwyg' put: 32768;
- at: 'PdReturndc' put: 256;
- at: 'PdEnableprinthook' put: 4096;
- at: 'CfInittologfontstruct' put: 64;
- at: 'CfScalableonly' put: 131072;
- at: 'PdPrinttofile' put: 32;
- at: 'CfEffects' put: 256;
- at: 'PdShowhelp' put: 2048;
- at: 'OfnEnabletemplatehandle' put: 128;
- at: 'CfBoth' put: 3;
- at: 'OfnReadonly' put: 1;
- at: 'PdNopagenums' put: 8;
- at: 'PdDisableprinttofile' put: 524288;
- at: 'PdHideprinttofile' put: 1048576;
- at: 'OfnAllowmultiselect' put: 512;
- at: 'CfPrinterfonts' put: 2;
- at: 'CfEnabletemplatehandle' put: 32;
- at: 'PdSelection' put: 1;
- at: 'OfnHidereadonly' put: 4;
- at: 'PdPrintsetup' put: 64;
- at: 'OfnExtentiondifferent' put: 1024;
- at: 'FrReplaceall' put: 32;
- at: 'FrMatchcase' put: 4;
- at: 'OfnFilemustexist' put: 4096;
- at: 'PdCollate' put: 16;
- at: 'CfFixedpitchonly' put: 16384;
- at: 'PdEnablesetuphook' put: 8192;
- at: 'OfnShareaware' put: 16384;
- at: 'CcEnablehook' put: 16;
- at: 'CfEnabletemplate' put: 16;
- at: 'Findmsgstring' put: 'commdlgFindreplace';
- at: 'CfLimitsize' put: 8192;
- at: 'OfnNochangedir' put: 8;
- at: 'OfnCreateprompt' put: 8192;
- at: 'ScreenFonttype' put: 8192;
- at: 'PdUsedevmodecopies' put: 262144;
- at: 'CcRgbinit' put: 1;
- at: 'FrFindnext' put: 8;
- at: 'CfUsestyle' put: 128;
- at: 'FrEnablehook' put: 256;
- at: 'PdEnableprinttemplatehandle' put: 65536;
- at: 'CfShowhelp' put: 4;
- at: 'FrNowholeword' put: 4096.
- dictionary
- at: 'ShareExist' put: 16448;
- at: 'OfnOverwriteprompt' put: 2;
- at: 'OfnEnablehook' put: 32;
- at: 'OfnShowhelp' put: 16;
- at: 'CcEnabletemplatehandle' put: 64;
- at: 'SimulatedFonttype' put: 32768;
- at: 'FrDown' put: 1;
- at: 'PdEnableprinttemplate' put: 16384;
- at: 'CfNovectorfonts' put: 2048;
- at: 'PdNoselection' put: 4;
- at: 'CfAnsionly' put: 1024;
- at: 'OfnNovalidate' put: 256;
- at: 'CfScreenfonts' put: 1;
- at: 'FrWholeword' put: 2;
- at: 'FrEnabletemplatehandle' put: 8192;
- at: 'PdAllpages' put: 0;
- at: 'CfForcefontexist' put: 65536;
- at: 'CcEnabletemplate' put: 32;
- at: 'PdPagenums' put: 2;
- at: 'FrReplace' put: 16;
- at: 'PdEnablesetuptemplatehandle' put: 131072;
- at: 'CfApply' put: 512;
- at: 'OfnEnabletemplate' put: 64;
- at: 'DnDefaultprn' put: 1;
- at: 'PdNowarning' put: 128;
- at: 'CfTtonly' put: 262144;
- at: 'PrinterFonttype' put: 16384;
- at: 'CcShowhelp' put: 8;
- at: 'CcFullopen' put: 2;
- at: 'PdReturnic' put: 512;
- at: 'FrEnabletemplate' put: 512;
- at: 'FrDialogterm' put: 64;
- at: 'Helpmsgstring' put: 'commdlgHelp';
- at: 'PdReturndefault' put: 1024;
- at: 'FrNomatchcase' put: 2048;
- at: 'CfEnablehook' put: 8.
+ at:'CcPreventfullopen' put:4;
+ at:'FrShowhelp' put:128;
+ at:'PdEnablesetuptemplate' put:32768;
+ at:'FrNoupdown' put:1024;
+ at:'CfNosimulations' put:4096;
+ at:'OfnPathmustexist' put:2048;
+ at:'CfWysiwyg' put:32768;
+ at:'PdReturndc' put:256;
+ at:'PdEnableprinthook' put:4096;
+ at:'CfInittologfontstruct' put:64;
+ at:'CfScalableonly' put:131072;
+ at:'PdPrinttofile' put:32;
+ at:'CfEffects' put:256;
+ at:'PdShowhelp' put:2048;
+ at:'OfnEnabletemplatehandle' put:128;
+ at:'CfBoth' put:3;
+ at:'OfnReadonly' put:1;
+ at:'PdNopagenums' put:8;
+ at:'PdDisableprinttofile' put:524288;
+ at:'PdHideprinttofile' put:1048576;
+ at:'OfnAllowmultiselect' put:512;
+ at:'CfPrinterfonts' put:2;
+ at:'CfEnabletemplatehandle' put:32;
+ at:'PdSelection' put:1;
+ at:'OfnHidereadonly' put:4;
+ at:'PdPrintsetup' put:64;
+ at:'OfnExtentiondifferent' put:1024;
+ at:'FrReplaceall' put:32;
+ at:'FrMatchcase' put:4;
+ at:'OfnFilemustexist' put:4096;
+ at:'PdCollate' put:16;
+ at:'CfFixedpitchonly' put:16384;
+ at:'PdEnablesetuphook' put:8192;
+ at:'OfnShareaware' put:16384;
+ at:'CcEnablehook' put:16;
+ at:'CfEnabletemplate' put:16;
+ at:'Findmsgstring' put:'commdlgFindreplace';
+ at:'CfLimitsize' put:8192;
+ at:'OfnNochangedir' put:8;
+ at:'OfnCreateprompt' put:8192;
+ at:'ScreenFonttype' put:8192;
+ at:'PdUsedevmodecopies' put:262144;
+ at:'CcRgbinit' put:1;
+ at:'FrFindnext' put:8;
+ at:'CfUsestyle' put:128;
+ at:'FrEnablehook' put:256;
+ at:'PdEnableprinttemplatehandle' put:65536;
+ at:'CfShowhelp' put:4;
+ at:'FrNowholeword' put:4096.
+ dictionary
+ at:'ShareExist' put:16448;
+ at:'OfnOverwriteprompt' put:2;
+ at:'OfnEnablehook' put:32;
+ at:'OfnShowhelp' put:16;
+ at:'CcEnabletemplatehandle' put:64;
+ at:'SimulatedFonttype' put:32768;
+ at:'FrDown' put:1;
+ at:'PdEnableprinttemplate' put:16384;
+ at:'CfNovectorfonts' put:2048;
+ at:'PdNoselection' put:4;
+ at:'CfAnsionly' put:1024;
+ at:'OfnNovalidate' put:256;
+ at:'CfScreenfonts' put:1;
+ at:'FrWholeword' put:2;
+ at:'FrEnabletemplatehandle' put:8192;
+ at:'PdAllpages' put:0;
+ at:'CfForcefontexist' put:65536;
+ at:'CcEnabletemplate' put:32;
+ at:'PdPagenums' put:2;
+ at:'FrReplace' put:16;
+ at:'PdEnablesetuptemplatehandle' put:131072;
+ at:'CfApply' put:512;
+ at:'OfnEnabletemplate' put:64;
+ at:'DnDefaultprn' put:1;
+ at:'PdNowarning' put:128;
+ at:'CfTtonly' put:262144;
+ at:'PrinterFonttype' put:16384;
+ at:'CcShowhelp' put:8;
+ at:'CcFullopen' put:2;
+ at:'PdReturnic' put:512;
+ at:'FrEnabletemplate' put:512;
+ at:'FrDialogterm' put:64;
+ at:'Helpmsgstring' put:'commdlgHelp';
+ at:'PdReturndefault' put:1024;
+ at:'FrNomatchcase' put:2048;
+ at:'CfEnablehook' put:8.
^ dictionary
+
+ "Modified: / 26-10-2010 / 18:47:57 / cg"
! !
!Win32FileDialog class methodsFor:'examples'!
@@ -207,54 +221,61 @@
!Win32FileDialog class methodsFor:'filters'!
-filterPatternDescription: filterPattern
+filterPatternDescription:filterPattern
+ ^ self filterPatternDescriptions at:filterPattern ifAbsent:''
- ^ self filterPatternDescriptions at: filterPattern ifAbsent: ''
+ "Modified: / 26-10-2010 / 18:48:24 / cg"
!
filterPatternDescriptions
+ FilterPatternDescriptions isNil ifTrue:[
+ FilterPatternDescriptions := self generateFilterPatternDescriptions
+ ].
+ ^ FilterPatternDescriptions
- FilterPatternDescriptions isNil ifTrue:[ FilterPatternDescriptions := self generateFilterPatternDescriptions ].
- ^ FilterPatternDescriptions
+ "Modified: / 26-10-2010 / 18:48:25 / cg"
!
-filtersFor: pattern
-
+filtersFor:pattern
|filters filterPatterns|
- pattern isEmptyOrNil ifTrue:[^ nil].
-
+ pattern isEmptyOrNil ifTrue:[
+ ^ nil
+ ].
filters := OrderedCollection new.
- filterPatterns := pattern subStrings: $;.
+ filterPatterns := pattern subStrings:$;.
filterPatterns do:[:filterPattern |
filterPattern notEmpty ifTrue:[
- filters add: (Array with: (self filterPatternDescription: filterPattern)
- with:filterPattern)
+ filters add:(Array with:(self filterPatternDescription:filterPattern)
+ with:filterPattern)
].
].
^ filters asArray
+
+ "Modified: / 26-10-2010 / 18:48:26 / cg"
!
generateFilterPatternDescriptions
+ ^ (Dictionary new)
+ at:'*.txt' put:'Text files (*.txt)';
+ at:'*.st' put:'Smalltalk files (*.st)';
+ at:'*.csv' put:'CSV files (*.csv)';
+ at:'*.xml' put:'XML files (*.xml)';
+ at:'*.zip' put:'ZIP files (*.zip)';
+ at:'*.xls' put:'Excel files (*.xls)';
+ at:'*.ent' put:'SGML Entity files (*.ent)';
+ at:'*.ccs' put:'CCS files (*.ccs)';
+ at:'*.ini' put:'Configuration files (*.ini)';
+ at:'*.prn' put:'Printer Text files (*.prn)';
+ at:'*.dir' put:'DapasX Database files (*.dir)';
+ at:'*.dat' put:'DapasX Database files (*.dat)';
+ at:'*.prg' put:'DapasX Program files (*.prg)';
+ at:'*.dcf' put:'DapasX Options files (*.dcf)';
+ at:'*.ext' put:'DapasX Backup files (*.ext)';
+ at:'*.mpl' put:'DapasX Project files (*.mpl)';
+ yourself
- ^ Dictionary new
- at: '*.txt' put: 'Text files (*.txt)';
- at: '*.st' put: 'Smalltalk files (*.st)';
- at: '*.csv' put: 'CSV files (*.csv)';
- at: '*.xml' put: 'XML files (*.xml)';
- at: '*.zip' put: 'ZIP files (*.zip)';
- at: '*.xls' put: 'Excel files (*.xls)';
- at: '*.ent' put: 'SGML Entity files (*.ent)';
- at: '*.ccs' put: 'CCS files (*.ccs)';
- at: '*.ini' put: 'Configuration files (*.ini)';
- at: '*.prn' put: 'Printer Text files (*.prn)';
- at: '*.dir' put: 'DapasX Database files (*.dir)';
- at: '*.dat' put: 'DapasX Database files (*.dat)';
- at: '*.prg' put: 'DapasX Program files (*.prg)';
- at: '*.dcf' put: 'DapasX Options files (*.dcf)';
- at: '*.ext' put: 'DapasX Backup files (*.ext)';
- at: '*.mpl' put: 'DapasX Project files (*.mpl)';
- yourself
+ "Modified: / 26-10-2010 / 18:48:28 / cg"
! !
!Win32FileDialog class methodsFor:'opening'!
@@ -295,69 +316,89 @@
self addFilter: '*.*' description: 'All Files (*.*)'.
!
-addFilter: aFilter description: aDescription
- "Add aFilter and aDescription to the list of File dialog
- filters."
+addFilter:aFilter description:aDescription
+ "Add aFilter and aDescription to the list of File dialog filters."
+
+ filters add:(Association key:aFilter value:aDescription).
- filters add: ( Association key: aFilter value: aDescription ).
+ "Modified: / 26-10-2010 / 18:45:27 / cg"
!
addSmalltalkFileFilters
+ ^ smalltalkFileFilters
- ^ smalltalkFileFilters
+ "Modified: / 26-10-2010 / 18:45:29 / cg"
!
-defExtension: aDefExtension
- "Specifies the default extension of File dialog."
+defExtension:aDefExtension
+ "Specifies the default extension of File dialog."
+
+ defExtension := aDefExtension.
- defExtension := aDefExtension.
+ "Modified: / 26-10-2010 / 18:45:54 / cg"
!
defFilter
- "Answers the aDefFilterString as the default filter of File dialog."
+ "Answers the aDefFilterString as the default filter of File dialog."
+
+ ^ defFilter
- ^ defFilter
+ "Modified: / 26-10-2010 / 18:45:56 / cg"
!
-defFilter: aDefFilterString
- "Specifies the aDefFilterString as the default filter of File dialog."
+defFilter:aDefFilterString
+ "Specifies the aDefFilterString as the default filter of File dialog."
+
+ defFilter := aDefFilterString
- defFilter := aDefFilterString
+ "Modified: / 26-10-2010 / 18:45:58 / cg"
!
-defFilterIndex: defaultFilterIndex
+defFilterIndex:defaultFilterIndex
+ defFilterIndex := defaultFilterIndex.
- defFilterIndex := defaultFilterIndex.
+ "Modified: / 26-10-2010 / 18:46:01 / cg"
!
directory
- "Answer the selected directory."
+ "Answer the selected directory."
+
InitialDirectory isNil ifTrue:[
^ Filename currentDirectory pathName asFilename
].
^ InitialDirectory "? OperatingSystem getCurrentDirectory asFilename"
+
+ "Modified: / 26-10-2010 / 18:46:03 / cg"
!
-directory: directory
- "Sets the initial directory."
+directory:directory
+ "Sets the initial directory."
+
+ |aFilename|
- | aFilename |
+ directory isNil ifTrue:[
+ ^ self.
+ ].
+ aFilename := directory asFilename.
+ aFilename exists ifTrue:[
+ InitialDirectory := aFilename
+ ].
- directory isNil ifTrue:[^ self.].
- aFilename := directory asFilename.
- aFilename exists ifTrue: [ InitialDirectory := aFilename ].
+ "Modified: / 26-10-2010 / 18:46:06 / cg"
!
file
- "Answer the selected file."
+ "Answer the selected file."
+
+ ^ fileName
- ^fileName
+ "Modified: / 26-10-2010 / 18:46:10 / cg"
!
fileSpec: aFileSpec
- "Sets the initial fileName and directory in the File Dialog."
+ "Sets the initial fileName and directory in the File Dialog."
- | array dir |
+ | array dir |
"SHOULD assign initial fileName and directory separately using #fileName: and #directory"
@@ -371,11 +412,13 @@
"/
"/ self directory: dir.
"/ fileName := array at: 3
+
+ "Modified: / 26-10-2010 / 18:46:22 / cg"
!
filters
- "Private - answers a string containing all filters and sets up
- the defFilterIndex property"
+ "Private - answers a string containing all filters and sets up
+ the defFilterIndex property"
| filterString count defaultFilterIndex defaultFilter|
@@ -411,54 +454,71 @@
self defFilterIndex: defaultFilterIndex.
^filterString
+
+ "Modified: / 26-10-2010 / 18:46:35 / cg"
!
flags
- "Private - Answers the dialog box current flags.
- For compatibility reasons -> use style instead"
+ "Private - Answers the dialog box current flags.
+ For compatibility reasons -> use style instead"
+
+ ^ openFileNameStruct flags
- ^openFileNameStruct flags
+ "Modified: / 26-10-2010 / 18:46:38 / cg"
!
-flags: flags
+flags:flags
+ "Private - Specifies the dialog box creation flags.
+ Kept for compatibility reasons. Use style: instead"
+
+ self style:flags
- "Private - Specifies the dialog box creation flags.
- Kept for compatibility reasons. Use style: instead"
-
- self style: flags
+ "Modified: / 26-10-2010 / 18:46:42 / cg"
!
hideReadonly
+ "Hides the file dialog's Readonly check box. "
+
+ self
+ style:self style | (self class commonDialogConstantAt:'OfnHidereadonly')
- "Hides the file dialog's Readonly check box. "
-
- self style: self style | (self class commonDialogConstantAt: 'OfnHidereadonly')
+ "Modified: / 26-10-2010 / 18:46:48 / cg"
!
-initialFileName: filename
- "Sets the initial fileName string in the File Dialog."
+initialFileName:filename
+ "Sets the initial fileName string in the File Dialog."
+
+ |aString|
- | aString |
- filename isNil ifTrue:[^ self.].
+ filename isNil ifTrue:[
+ ^ self.
+ ].
aString := filename.
- filename isFilename ifTrue:[ aString := filename baseName].
+ filename isFilename ifTrue:[
+ aString := filename baseName
+ ].
fileName := aString.
+
+ "Modified: / 26-10-2010 / 18:46:50 / cg"
!
overwritePrompt
+ "Prompt if the user attempts to overwrite a file"
+
+ self style:self style
+ | (self class commonDialogConstantAt:'OfnOverwriteprompt')
- "Prompt if the user attempts to overwrite a file"
-
- self style: self style | (self class commonDialogConstantAt: 'OfnOverwriteprompt')
+ "Modified: / 26-10-2010 / 18:47:19 / cg"
!
-owner: ownerWindow
-
- "Sets the owner of the Dialog box."
-
+owner:ownerWindow
+ "Sets the owner of the Dialog box."
+
|mainView handle|
- ownerWindow isNil ifTrue:[^ self].
+ ownerWindow isNil ifTrue:[
+ ^ self
+ ].
mainView := ownerWindow windowGroup mainView.
mainView notNil ifTrue:[
handle := mainView id.
@@ -467,28 +527,30 @@
].
].
-"/ super owner: anOwner.
-"/ owner isWindow
-"/ ifTrue: [ parent := owner ]
-"/ ifFalse: [ parent := owner mainView.
-"/ parent isWindow ifFalse: [
-"/ parent := Notifier findWindow: WindowHandle queryActive ]].
+ "/ super owner: anOwner.
+ "/ owner isWindow
+ "/ ifTrue: [ parent := owner ]
+ "/ ifFalse: [ parent := owner mainView.
+ "/ parent isWindow ifFalse: [
+ "/ parent := Notifier findWindow: WindowHandle queryActive ]].
+
+ "Modified: / 26-10-2010 / 18:47:22 / cg"
!
pathMustExist
+ self style:self style | 16r800.
- "Private & DEFAULT!!."
- "Changed by K3/EES5-Mg, 29.01.97"
-
- self style: self style | 16r800.
+ "Modified: / 26-10-2010 / 18:47:27 / cg"
!
shareAware
+ "Allows a previously opened file to be opened
+ (e.g. change.log)"
+
+ self
+ style:self style | (self class commonDialogConstantAt:'OfnShareaware')
- "Allows a previously opened file to be opened
- (e.g. change.log)"
-
- self style: self style | (self class commonDialogConstantAt: 'OfnShareaware')
+ "Modified: / 26-10-2010 / 18:47:36 / cg"
!
style
@@ -499,98 +561,112 @@
style := something.
!
-title: aTitle
+title:aTitle
+ "Specifies the string to be placed in the title bar of the
+ File dialog."
+
+ title := aTitle
- "Specifies the string to be placed in the title bar of the
- File dialog."
-
- title := aTitle
+ "Modified: / 26-10-2010 / 18:47:41 / cg"
! !
!Win32FileDialog methodsFor:'dapas'!
dapasOpenFile
-
- "Brings up the default open file dialog "
- "Changed by K3/EES5-Mg, 28.02.96"
+ "Brings up the default open file dialog "
+
+ self
+ hideReadonly;
+ shareAware;
+ addFilter:'*.*' description:'All Files (*.*)'.
+ self defFilter isNil ifTrue:[
+ self defFilter:'*.*'
+ ].
+ self open.
- self hideReadonly;
- shareAware;
- addFilter: '*.*' description: 'All Files (*.*)'.
-
- self defFilter isNil ifTrue:[ self defFilter: '*.*'].
-
- self open.
+ "Modified: / 26-10-2010 / 18:45:46 / cg"
!
dapasSaveFile
-
- "Brings up the file save dialog."
- "Changed by K3/EES5-Mg, 28.02.96"
+ "Brings up the file save dialog."
+
+ self
+ hideReadonly;
+ overwritePrompt;
+ addFilter:'*.*' description:'All Files (*.*)'.
+ self save.
- self hideReadonly;
- overwritePrompt;
- addFilter: '*.*' description: 'All Files (*.*)'.
-
- self save.
+ "Modified: / 26-10-2010 / 18:45:52 / cg"
!
openFileXml
-
- "Brings up the default open file dialog "
- "Changed by K3/EES5-Mg, 28.02.96"
- "Changed by GS-EC/EES3 - Bernd Eisenmann, 14.08.03"
+ "Brings up the default open file dialog "
+
+ self
+ hideReadonly;
+ shareAware;
+ addFilter:'*.xml' description:'XML-Files'.
+ self defFilter isNil ifTrue:[
+ self defFilter:'*.*'
+ ].
+ self open.
- self hideReadonly;
- shareAware;
- addFilter: '*.xml' description: 'XML-Datei'.
-
- self defFilter isNil ifTrue:[ self defFilter: '*.*'].
-
- self open.
+ "Modified: / 26-10-2010 / 18:49:00 / cg"
!
openFileXmlZip
-
- "Brings up the default open file dialog "
- "Changed by K3/EES5-Mg, 28.02.96"
- "Changed by GS-EC/EES3 - Bernd Eisenmann, 14.08.03"
+ "Brings up the default open file dialog "
+
+ self
+ hideReadonly;
+ shareAware;
+ addFilter:'*.xml' description:'XML-Datei';
+ addFilter:'*.zip' description:'ZIP-Datei'.
+ self defFilter isNil ifTrue:[
+ self defFilter:'*.*'
+ ].
+ self open.
- self hideReadonly;
- shareAware;
- addFilter: '*.xml' description: 'XML-Datei';
- addFilter: '*.zip' description: 'ZIP-Datei'.
-
- self defFilter isNil ifTrue:[ self defFilter: '*.*'].
-
- self open.
+ "Modified: / 26-10-2010 / 18:47:14 / cg"
! !
!Win32FileDialog methodsFor:'initialize & release'!
cleanUp
- "Private - Free openFileNameStruct."
+ "Private - Free openFileNameStruct."
+
+ self style:self flags.
+ lpstrFilter notNil ifTrue:[
+ lpstrFilter free
+ ].
+ lpstrFile notNil ifTrue:[
+ lpstrFile free
+ ].
+ lpstrInitialDir notNil ifTrue:[
+ lpstrInitialDir free
+ ].
+ lpstrTitle notNil ifTrue:[
+ lpstrTitle free
+ ].
+ lpstrDefExt notNil ifTrue:[
+ lpstrDefExt free
+ ].
+ openFileNameStruct := nil
- self style: self flags.
- lpstrFilter notNil ifTrue: [lpstrFilter free].
- lpstrFile notNil ifTrue: [lpstrFile free].
- lpstrInitialDir notNil ifTrue: [lpstrInitialDir free].
- lpstrTitle notNil ifTrue: [ lpstrTitle free ].
- lpstrDefExt notNil ifTrue: [ lpstrDefExt free ].
-
- openFileNameStruct := nil
+ "Modified: / 26-10-2010 / 18:45:33 / cg"
!
initialize
-
- "Private - Initialize openFileNameStruct"
-
+ "Private - Initialize openFileNameStruct"
+
super initialize.
- openFileNameStruct := OpenFilenameStructure new.
- openFileNameStruct lStructSize: openFileNameStruct sizeInBytes.
+ openFileNameStruct := OpenFilenameStructure new.
+ openFileNameStruct lStructSize:openFileNameStruct sizeInBytes.
fileName := String new.
filters := OrderedCollection new.
- self style: (self class commonDialogConstantAt: 'OfnNochangedir')
+ self style:(self class commonDialogConstantAt:'OfnNochangedir')
+
+ "Modified: / 26-10-2010 / 18:46:52 / cg"
! !
!Win32FileDialog methodsFor:'opening'!
@@ -600,93 +676,101 @@
|error rslt openFileNameStructExternalBytes|
- Lock critical:[
- [
- self fillStruct.
- parent notNil ifTrue:[
- openFileNameStruct hwndOwner:parent.
- ].
- style notNil ifTrue:[
- openFileNameStruct flags:style
+ Lock
+ critical:[
+ [
+ self fillStruct.
+ parent notNil ifTrue:[
+ openFileNameStruct hwndOwner:parent.
+ ].
+ style notNil ifTrue:[
+ openFileNameStruct flags:style
+ ].
+ openFileNameStructExternalBytes := ExternalBytes
+ from:openFileNameStruct asByteArray.
+ rslt := OperatingSystem
+ getOpenFilename:openFileNameStructExternalBytes address.
+ rslt ifTrue:[
+ self getFileName
+ ] ifFalse:[
+ fileName := nil.
+ error := OperatingSystem commDlgExtendedError.
+ ].
+ ] ensure:[
+ openFileNameStructExternalBytes free.
+ self cleanUp.
].
- openFileNameStructExternalBytes := ExternalBytes from:openFileNameStruct asByteArray.
- rslt := OperatingSystem getOpenFilename:openFileNameStructExternalBytes address.
- rslt ifTrue:[
- self getFileName
- ] ifFalse:[
- fileName := nil.
- error := OperatingSystem commDlgExtendedError.
- ].
- ] ensure:[
- openFileNameStructExternalBytes free.
- self cleanUp.
].
- ].
(error notNil and:[ error ~= 0 ]) ifTrue:[
self error:error
].
- "Modified: / 26-10-2010 / 12:51:49 / cg"
+ "Modified: / 26-10-2010 / 18:46:55 / cg"
!
openFile
- "Brings up the default open file dialog. The title is set to 'Open File'
- and fileSpec is set to '*.*'. "
+ "Brings up the default open file dialog. The title is set to 'Open File'
+ and fileSpec is set to '*.*'."
+
+ self openFile:'*.*'.
- self openFile: '*.*'.
+ "Modified: / 26-10-2010 / 18:47:00 / cg"
!
-openFile: initialFileName
-
- "Brings up the default open file dialog. The title is set to 'Open File'
- and fileSpec is set to patternString. "
-
- self title: 'Open'.
- initialFileName notNil ifTrue: [ self initialFileName: initialFileName ].
+openFile:initialFileName
+ "Brings up the default open file dialog. The title is set to 'Open File'
+ and fileSpec is set to patternString."
+
+ self title:'Open'.
+ initialFileName notNil ifTrue:[
+ self initialFileName:initialFileName
+ ].
self
hideReadonly;
shareAware;
addAllFilesFilter;
- addFilter: '*.txt' description: 'Text Files (*.txt)'.
- Smalltalk isStandAloneApp ifFalse: [ self addSmalltalkFileFilters ].
- self defFilter isNil ifTrue:[ self defFilter: '*.*'].
+ addFilter:'*.txt' description:'Text Files (*.txt)'.
+ Smalltalk isStandAloneApp ifFalse:[
+ self addSmalltalkFileFilters
+ ].
+ self defFilter isNil ifTrue:[
+ self defFilter:'*.*'
+ ].
self open.
+
+ "Modified: / 26-10-2010 / 18:47:03 / cg"
!
-openFor:ownerWindow
- save:isSaveDialog
- title:titleOrNil
- inDirectory:dirPathOrNil
- initialAnswer:initialOrNil
- filter:filterArrayOrNil
- extension:extensionOrNil
-
- self
- owner: ownerWindow;
- title: titleOrNil;
- initialFileName: initialOrNil;
- defFilter: extensionOrNil;
- directory: dirPathOrNil.
-
+openFor:ownerWindow save:isSaveDialog title:titleOrNil inDirectory:dirPathOrNil initialAnswer:initialOrNil filter:filterArrayOrNil extension:extensionOrNil
+ self
+ owner:ownerWindow;
+ title:titleOrNil;
+ initialFileName:initialOrNil;
+ defFilter:extensionOrNil;
+ directory:dirPathOrNil.
filterArrayOrNil notNil ifTrue:[
- filterArrayOrNil do:[:each | self addFilter: each last description: each first].
+ filterArrayOrNil do:[:each |
+ self addFilter:each last description:each first
+ ].
].
-
self addAllFilesFilter.
+
"/ self defFilter isNil ifTrue:[ self defFilter: '*.*'].
+
+ isSaveDialog ifTrue:[
+ self
+ hideReadonly;
+ overwritePrompt;
+ save.
+ ] ifFalse:[
+ self
+ hideReadonly;
+ shareAware;
+ open.
+ ].
+ ^ self file
- isSaveDialog
- ifTrue:[
- self hideReadonly;
- overwritePrompt;
- save.
- ] ifFalse:[
- self hideReadonly;
- shareAware;
- open.
- ].
-
- ^ self file
+ "Modified: / 26-10-2010 / 18:47:16 / cg"
!
save
@@ -694,62 +778,67 @@
|error rslt openFileNameStructExternalBytes|
- Lock critical:[
- [
- self fillStruct.
- parent notNil ifTrue:[
- openFileNameStruct hwndOwner:parent.
- ].
- style notNil ifTrue:[
- openFileNameStruct flags:style
+ Lock
+ critical:[
+ [
+ self fillStruct.
+ parent notNil ifTrue:[
+ openFileNameStruct hwndOwner:parent.
+ ].
+ style notNil ifTrue:[
+ openFileNameStruct flags:style
+ ].
+ openFileNameStructExternalBytes := ExternalBytes
+ from:openFileNameStruct asByteArray.
+ rslt := OperatingSystem
+ getSaveFilename:openFileNameStructExternalBytes address.
+ rslt ifTrue:[
+ self getFileName
+ ] ifFalse:[
+ fileName := nil.
+ error := OperatingSystem commDlgExtendedError.
+ ].
+ ] ensure:[
+ openFileNameStructExternalBytes free.
+ self cleanUp.
].
- openFileNameStructExternalBytes := ExternalBytes from:openFileNameStruct asByteArray.
- rslt := OperatingSystem getSaveFilename:openFileNameStructExternalBytes address.
- rslt ifTrue:[
- self getFileName
- ] ifFalse:[
- fileName := nil.
- error := OperatingSystem commDlgExtendedError.
- ].
- ] ensure:[
- openFileNameStructExternalBytes free.
- self cleanUp.
].
- ].
(error notNil and:[ error ~= 0 ]) ifTrue:[
self error:error
].
- "Modified: / 26-10-2010 / 12:51:59 / cg"
+ "Modified: / 26-10-2010 / 18:47:29 / cg"
!
-saveFile: aString
+saveFile:aString
+ "Brings up the save file dialog with aString as the
+ default name. The title is set to 'Save File'."
+
+ self saveTitle:'Save File' fileName:aString
- "Brings up the save file dialog with aString as the
- default name. The title is set to 'Save File'. "
-
- self saveTitle: 'Save File' fileName: aString
+ "Modified: / 26-10-2010 / 18:47:32 / cg"
!
-saveTitle: aTitle fileName: initialFileName
-
- "Brings up the file save dialog with aTitle and aString
- as the default name."
+saveTitle:aTitle fileName:initialFileName
+ "Brings up the file save dialog with aTitle and aString
+ as the default name."
+
+ self
+ title:aTitle;
+ initialFileName:initialFileName;
+ hideReadonly;
+ overwritePrompt;
+ addAllFilesFilter;
+ addFilter:'*.txt' description:'Text Files (*.txt)'.
+ self save.
- self title: aTitle;
- initialFileName: initialFileName;
- hideReadonly;
- overwritePrompt;
- addAllFilesFilter;
- addFilter: '*.txt' description: 'Text Files (*.txt)'.
-
- self save.
+ "Modified: / 26-10-2010 / 18:47:35 / cg"
! !
!Win32FileDialog methodsFor:'private'!
fillStruct
- "Private - fills the openFileNameStruct"
+ "Private - fills the openFileNameStruct"
| temp |
@@ -779,17 +868,21 @@
( temp := title ) notNil ifTrue: [
lpstrTitle := ExternalBytes newNullTerminatedFromString: temp.
openFileNameStruct lpstrTitle: lpstrTitle address ].
+
+ "Modified: / 26-10-2010 / 18:46:28 / cg"
!
getFileName
- "Private - get the filename"
-
- | directory |
+ "Private - get the filename"
+
+ |directory|
- self style: self flags.
- fileName := lpstrFile stringAt: 1.
- directory := fileName copyFrom: 1 to: openFileNameStruct nFileOffset.
- self directory: directory asFilename.
+ self style:self flags.
+ fileName := lpstrFile stringAt:1.
+ directory := fileName copyFrom:1 to:openFileNameStruct nFileOffset.
+ self directory:directory asFilename.
+
+ "Modified: / 26-10-2010 / 18:46:45 / cg"
! !
!Win32FileDialog::OpenFilenameStructure class methodsFor:'accessing'!
@@ -1083,11 +1176,11 @@
!Win32FileDialog class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Win32FileDialog.st,v 1.8 2010-10-26 16:44:44 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Win32FileDialog.st,v 1.9 2010-10-26 16:49:16 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/Win32FileDialog.st,v 1.8 2010-10-26 16:44:44 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Win32FileDialog.st,v 1.9 2010-10-26 16:49:16 cg Exp $'
! !
Win32FileDialog initialize!