--- a/FileSelectionBox.st Wed Sep 09 22:27:16 1998 +0200
+++ b/FileSelectionBox.st Wed Sep 09 22:35:43 1998 +0200
@@ -308,19 +308,45 @@
"Modified: / 9.9.1998 / 21:23:16 / cg"
!
-ied: / 9.9.1998 / 21:23:16 / cg"
+directory
+ "return the directory which is currently shown"
+
+ ^ selectionList directory
!
-^ selectionList directory
+directory:directoryName
+ "change the directory shown in the list."
+
+ selectionList directory:directoryName
!
-tionList directory:directoryName
+fileName
+ "if some filename has been entered, return it (without the directory path)
+ otherwise, return nil"
+
+ |string|
+
+ string := super contents.
+ string isNil ifTrue:[^ nil].
+ ^ self pathName asFilename baseName
+
+ "Modified: / 12.8.1998 / 09:54:01 / cg"
!
-ed: / 12.8.1998 / 09:54:01 / cg"
+matchBlock:aBlock
+ "set the matchBlock (in the selectionList). Only files
+ for which the block returns true are shown.
+ The matching is actually done in the fileSelectionList."
+
+ selectionList matchBlock:aBlock
!
-selectionList matchBlock:aBlock
+openOn:aPath
+ "open the box showing files in aPath.
+ This is only a shortcut message - no new functionality."
+
+ self directory:aPath.
+ self showAtPointer
!
pathName
@@ -330,9 +356,38 @@
^ self contents
!
-entered"
+pattern:aPattern
+ "set the pattern - this also enables the PatternField
+ (if the pattern is non-nil) or hides it (if nil)."
+
+ |focusSequence|
- ^ self contents
+ patternField initialText:aPattern.
+ selectionList pattern:aPattern.
+ aPattern isNil ifTrue:[
+ patternField beInvisible.
+ self makeUntabable:patternField.
+ focusSequence := (Array
+ with:enterField
+ with:selectionList
+ with:okButton
+ with:abortButton)
+ ] ifFalse:[
+ patternField beVisible.
+ self makeTabable:patternField before:enterField.
+ focusSequence := (Array
+ with:patternField
+ with:enterField
+ with:selectionList
+ with:okButton
+ with:abortButton)
+ ].
+
+ windowGroup notNil ifTrue:[
+ windowGroup focusSequence:focusSequence
+ ].
+
+ "Modified: 18.10.1997 / 03:02:05 / cg"
!
selectingDirectory:aBoolean
@@ -376,30 +431,159 @@
!FileSelectionBox methodsFor:'initialization'!
-ionBox methodsFor:'initialization'!
+createEnterField
+ "if the (optional) class FilenameEditField is present, use
+ it, since it provides filename completion. Otherwise, we have
+ to live with the dumb (default) field ...
+ "
+ FilenameEditField notNil ifTrue:[
+ ^ FilenameEditField new.
+ ].
+ ^ super createEnterField
-fied: 18.4.1996 / 20:02:24 / cg"
+ "Modified: 18.4.1996 / 20:02:24 / cg"
!
-ied: 18.10.1997 / 02:47:49 / cg"
+initialize
+ |corner|
+
+ super initialize.
+ selectingDirectory := false.
+
+ label := resources string:'File dialog'.
+
+ labelField extent:(0.7 @ labelField height).
+ labelField label:(resources string:'select a file:').
+ labelField adjust:#left.
+
+ patternField := EditField in:self.
+ self is3D ifTrue:[
+ corner := (1.0 @ (labelField origin y+patternField heightIncludingBorder)).
+ ] ifFalse:[
+ corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")].
+ ].
+ patternField origin:(0.7 @ labelField origin y) corner:corner.
+ patternField rightInset:ViewSpacing.
+ patternField initialText:'*'.
+ patternField leaveAction:[:reason | self patternChanged].
+ patternField crAction:[self patternChanged].
+ patternField hiddenOnRealize:true. "delay showing, until a pattern is defined"
+"/ no, since its invisible
+"/ self makeTabable:patternField before:enterField.
+
+ enterField addDependent:self.
+
+ "
+ FileSelectionBox open
+ FileSelectionBox new show
+ "
+
+ "Modified: 18.10.1997 / 02:47:49 / cg"
+!
+
+postRealize
+ "if some default is present in the enterField,
+ scroll to make this one visible"
+
+ |contents|
+
+ super postRealize.
+ (contents := enterField contents) notNil ifTrue:[
+ contents notEmpty ifTrue:[
+ selectionList makeVisible:contents
+ ]
+ ]
+
+ "Created: 24.7.1997 / 18:19:14 / cg"
! !
!FileSelectionBox methodsFor:'private'!
-eSelectionBox methodsFor:'private'! !
+updateList
+ selectionList updateList
+! !
!FileSelectionBox methodsFor:'queries'!
-eSelectionBox methodsFor:'queries'! !
+preferredExtent
+ "return my preferred extent - thats the minimum size
+ to make everything visible"
+
+ |wWanted hWanted mm|
+
+ "/ If I have an explicit preferredExtent ..
+
+ preferredExtent notNil ifTrue:[
+ ^ preferredExtent
+ ].
+
+ mm := ViewSpacing.
+
+ wWanted := mm +
+ labelField preferredExtent x +
+ (mm * 2) +
+ patternField preferredExtent x +
+ mm.
+ (wWanted < width) ifTrue:[
+ wWanted := width
+ ].
+ hWanted := mm + labelField height +
+ mm + enterField height +
+ mm + selectionList height +
+ mm + buttonPanel preferredExtent y +
+ mm.
+
+ (hWanted < height) ifTrue:[
+ hWanted := height
+ ].
+ ^ (wWanted @ hWanted)
+
+ "Modified: 19.7.1996 / 20:44:04 / cg"
+! !
!FileSelectionBox methodsFor:'user actions'!
-ctionBox methodsFor:'user actions'!
+directoryChanged
+ selectingDirectory ifTrue:[
+ selectionList changeDirectory.
+ enterField contents:(selectionList directory pathName).
+ selectionList setSelection:nil.
+ ].
-fied: 25.5.1996 / 12:27:05 / cg"
+ "Created: 18.4.1996 / 18:38:21 / cg"
+ "Modified: 25.5.1996 / 12:27:05 / cg"
!
-ied: / 7.8.1998 / 17:19:26 / cg"
+directorySelected
+ "a directory was selected - show the new path in the inputField,
+ if we are in directory mode"
+
+ selectingDirectory ifTrue:[
+ |newDir|
+
+ newDir := (selectionList directory)
+ construct:selectionList selectionValue.
+ enterField contents:newDir pathName.
+ ].
+
+ "Created: / 18.4.1996 / 18:46:15 / cg"
+ "Modified: / 7.8.1998 / 17:19:26 / cg"
+!
+
+doubleClick
+ |entry|
+
+ entry := selectionList selectionValue.
+ entry notNil ifTrue:[
+ ((selectionList directory asFilename construct:entry) isDirectory) ifFalse:[
+ selectingDirectory ifFalse:[
+ enterField contents:entry.
+ self okPressed
+ ]
+ ]
+ ].
+
+ "Modified: 19.10.1997 / 00:17:37 / cg"
!
okPressed
@@ -432,29 +616,34 @@
super okPressed
-<<<<<<< FSelBox.st
- "Modified: / 9.9.1998 / 21:42:33 / cg"
+ "Modified: / 9.9.1998 / 21:21:14 / cg"
!
-].
- ].
-
- super okPressed
-
- "Modified: / 9.9.1998 / 21:21:14 / cg"
-=======
- "Modified: / 9.9.1998 / 21:21:14 / cg"
->>>>>>> 1.52
-!
-
-:patternField contents.
+patternChanged
+ selectionList pattern:patternField contents.
self updateList
"Created: 4.6.1996 / 20:30:23 / cg"
+!
+
+selectionChanged
+ |entry|
+
+ entry := selectionList selectionValue.
+ (selectionList directory asFilename construct:entry) type == #directory ifFalse:[
+ selectingDirectory ifTrue:[
+ enterField contents:(selectionList directory pathName).
+ selectionList setSelection:nil.
+ ^ self
+ ]
+ ].
+ enterField contents:entry
+
+ "Modified: 21.9.1997 / 12:07:55 / cg"
! !
!FileSelectionBox class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.53 1998-09-09 20:27:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.54 1998-09-09 20:35:43 cg Exp $'
! !