--- a/FSelBox.st Thu Dec 16 12:02:42 1993 +0100
+++ b/FSelBox.st Thu Dec 16 12:04:09 1993 +0100
@@ -11,8 +11,7 @@
"
ListSelectionBox subclass:#FileSelectionBox
- instanceVariableNames:'patternField directory timeStamp directoryId
- directoryContents directoryFileTypes'
+ instanceVariableNames:'patternField'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
@@ -23,7 +22,7 @@
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/FSelBox.st,v 1.4 1993-12-11 01:44:10 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/FSelBox.st,v 1.5 1993-12-16 11:02:38 claus Exp $
written Jan 90 by claus
'!
@@ -31,19 +30,27 @@
documentation
"
-this class implements file selection boxes. They show a list of
+this class implements file selection boxes. Instances show a list of
files, and perform an action block with the selected pathname as
argument when ok is clicked.
+
There is an optional PatternField, which shows itself when a pattern
is defined. If there is such a pattern, only files matching the pattern
will be shown in the list (and directories).
"
! !
+!FileSelectionBox class methodsFor:'defaults'!
+
+listViewType
+ "return the type of listView - using a FileSelectionList here"
+
+ ^ FileSelectionList
+! !
+
!FileSelectionBox methodsFor:'initialization'!
initialize
- directory := FileDirectory currentDirectory.
super initialize.
labelField extent:(0.7 @ labelField height).
@@ -58,127 +65,47 @@
patternField leaveAction:[:p | self updateList].
patternField hidden:true.
- "selections in list get forwarded to enterfield if not a directory;
- otherwise directory is changed"
-
- selectionList action:[:lineNr |
+ selectionList action:[:line |
|entry|
entry := selectionList selectionValue.
- (entry endsWith:' ...') ifTrue:[
- entry := entry copyTo:(entry size - 4).
- ].
- ((directory typeOf:entry) == #directory) ifTrue:[
- (directory isReadable:entry) ifFalse:[
- self warn:(resources string:'not allowed to read directory %1' with:entry)
- ] ifTrue:[
- (directory isExecutable:entry) ifFalse:[
- self warn:(resources string:'not allowed to change to directory %1' with:entry)
- ] ifTrue:[
- self directory:(directory pathName , Filename separator asString , entry)
- ]
- ].
- ] ifFalse:[
- enterField contents:entry
- ]
- ]
+ enterField contents:entry
+ ].
+ selectionList doubleClickAction:[:line |
+ |entry|
+
+ entry := selectionList selectionValue.
+ enterField contents:entry.
+ self okPressed
+ ].
"FileSelectionBox new show"
-!
-
-reinitialize
- directory := FileDirectory currentDirectory.
- super reinitialize
! !
!FileSelectionBox methodsFor:'accessing'!
directory:nameOrDirectory
- "set the lists contents to the filenames in the directory name"
-
- |oldPath name|
+ "change the directory shown in the list"
- (nameOrDirectory isKindOf:String) ifTrue:[
- name := nameOrDirectory
- ] ifFalse:[
- name := nameOrDirectory pathName
- ].
- oldPath := directory pathName.
- directory pathName:name.
- (directory pathName = oldPath) ifFalse:[
- self updateList
- ]
+ selectionList directory:nameOrDirectory
!
pattern:aPattern
"set the pattern - this enables the PatternField."
patternField initialText:aPattern.
- patternField hidden:false.
- realized ifTrue:[
- patternField realize.
- self updateList
- ].
-! !
-
-!FileSelectionBox methodsFor:'private'!
-
-updateList
- "set the lists contents to the filenames in the directory"
-
- |oldCursor oldListCursor files pattern newList index|
-
- oldCursor := cursor.
- oldListCursor := selectionList cursor.
- self cursor:(Cursor read).
- selectionList cursor:(Cursor read).
- directoryId == directory id ifFalse:[
- timeStamp := directory timeOfLastChange.
- directoryId := directory id.
- directoryContents := directory asText sort.
- directoryFileTypes := OrderedCollection new.
- directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)].
+ selectionList pattern:aPattern.
+ aPattern isNil ifTrue:[
+ patternField hidden:true.
+ realized ifTrue:[
+ patternField hide.
+ ]
+ ] ifFalse:[
+ patternField hidden:false.
+ realized ifTrue:[
+ patternField realize.
+ ].
].
- files := directoryContents.
- pattern := patternField contents.
- newList := OrderedCollection new.
- index := 1.
- files do:[:name |
- (directoryFileTypes at:index) == #directory ifTrue:[
- name = '..' ifTrue:[
- newList add:name
- ] ifFalse:[
- name = '.' ifTrue:[
- ] ifFalse:[
- newList add:(name , ' ...')
- ]
- ]
- ] ifFalse:[
- (pattern isEmpty or:[pattern match:name]) ifTrue:[
- newList add:name
- ]
- ].
- index := index + 1
- ].
- self list:newList.
- self cursor:oldCursor.
- selectionList cursor:oldListCursor
-! !
-
-!FileSelectionBox methodsFor:'events'!
-
-show
- "make the box visible; redefined to check if directory is still
- valid (using timestamp and inode numbers) - reread if not"
-
- (timeStamp isNil
- or:[(directory timeOfLastChange > timeStamp)
- or:[(directoryId isNil)
- or:[directoryId ~~ directory id]]]) ifTrue:[
- directoryId := nil.
- self updateList
- ].
- super show
! !
!FileSelectionBox methodsFor:'user interaction'!
@@ -194,7 +121,7 @@
(string startsWith:(Filename separator)) ifTrue:[
absPath := string
] ifFalse:[
- absPath := directory pathName , Filename separator asString , string
+ absPath := selectionList directory pathName , Filename separator asString , string
].
okAction value:absPath
]
--- a/FileSelectionBox.st Thu Dec 16 12:02:42 1993 +0100
+++ b/FileSelectionBox.st Thu Dec 16 12:04:09 1993 +0100
@@ -11,8 +11,7 @@
"
ListSelectionBox subclass:#FileSelectionBox
- instanceVariableNames:'patternField directory timeStamp directoryId
- directoryContents directoryFileTypes'
+ instanceVariableNames:'patternField'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
@@ -23,7 +22,7 @@
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.4 1993-12-11 01:44:10 claus Exp $
+$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.5 1993-12-16 11:02:38 claus Exp $
written Jan 90 by claus
'!
@@ -31,19 +30,27 @@
documentation
"
-this class implements file selection boxes. They show a list of
+this class implements file selection boxes. Instances show a list of
files, and perform an action block with the selected pathname as
argument when ok is clicked.
+
There is an optional PatternField, which shows itself when a pattern
is defined. If there is such a pattern, only files matching the pattern
will be shown in the list (and directories).
"
! !
+!FileSelectionBox class methodsFor:'defaults'!
+
+listViewType
+ "return the type of listView - using a FileSelectionList here"
+
+ ^ FileSelectionList
+! !
+
!FileSelectionBox methodsFor:'initialization'!
initialize
- directory := FileDirectory currentDirectory.
super initialize.
labelField extent:(0.7 @ labelField height).
@@ -58,127 +65,47 @@
patternField leaveAction:[:p | self updateList].
patternField hidden:true.
- "selections in list get forwarded to enterfield if not a directory;
- otherwise directory is changed"
-
- selectionList action:[:lineNr |
+ selectionList action:[:line |
|entry|
entry := selectionList selectionValue.
- (entry endsWith:' ...') ifTrue:[
- entry := entry copyTo:(entry size - 4).
- ].
- ((directory typeOf:entry) == #directory) ifTrue:[
- (directory isReadable:entry) ifFalse:[
- self warn:(resources string:'not allowed to read directory %1' with:entry)
- ] ifTrue:[
- (directory isExecutable:entry) ifFalse:[
- self warn:(resources string:'not allowed to change to directory %1' with:entry)
- ] ifTrue:[
- self directory:(directory pathName , Filename separator asString , entry)
- ]
- ].
- ] ifFalse:[
- enterField contents:entry
- ]
- ]
+ enterField contents:entry
+ ].
+ selectionList doubleClickAction:[:line |
+ |entry|
+
+ entry := selectionList selectionValue.
+ enterField contents:entry.
+ self okPressed
+ ].
"FileSelectionBox new show"
-!
-
-reinitialize
- directory := FileDirectory currentDirectory.
- super reinitialize
! !
!FileSelectionBox methodsFor:'accessing'!
directory:nameOrDirectory
- "set the lists contents to the filenames in the directory name"
-
- |oldPath name|
+ "change the directory shown in the list"
- (nameOrDirectory isKindOf:String) ifTrue:[
- name := nameOrDirectory
- ] ifFalse:[
- name := nameOrDirectory pathName
- ].
- oldPath := directory pathName.
- directory pathName:name.
- (directory pathName = oldPath) ifFalse:[
- self updateList
- ]
+ selectionList directory:nameOrDirectory
!
pattern:aPattern
"set the pattern - this enables the PatternField."
patternField initialText:aPattern.
- patternField hidden:false.
- realized ifTrue:[
- patternField realize.
- self updateList
- ].
-! !
-
-!FileSelectionBox methodsFor:'private'!
-
-updateList
- "set the lists contents to the filenames in the directory"
-
- |oldCursor oldListCursor files pattern newList index|
-
- oldCursor := cursor.
- oldListCursor := selectionList cursor.
- self cursor:(Cursor read).
- selectionList cursor:(Cursor read).
- directoryId == directory id ifFalse:[
- timeStamp := directory timeOfLastChange.
- directoryId := directory id.
- directoryContents := directory asText sort.
- directoryFileTypes := OrderedCollection new.
- directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)].
+ selectionList pattern:aPattern.
+ aPattern isNil ifTrue:[
+ patternField hidden:true.
+ realized ifTrue:[
+ patternField hide.
+ ]
+ ] ifFalse:[
+ patternField hidden:false.
+ realized ifTrue:[
+ patternField realize.
+ ].
].
- files := directoryContents.
- pattern := patternField contents.
- newList := OrderedCollection new.
- index := 1.
- files do:[:name |
- (directoryFileTypes at:index) == #directory ifTrue:[
- name = '..' ifTrue:[
- newList add:name
- ] ifFalse:[
- name = '.' ifTrue:[
- ] ifFalse:[
- newList add:(name , ' ...')
- ]
- ]
- ] ifFalse:[
- (pattern isEmpty or:[pattern match:name]) ifTrue:[
- newList add:name
- ]
- ].
- index := index + 1
- ].
- self list:newList.
- self cursor:oldCursor.
- selectionList cursor:oldListCursor
-! !
-
-!FileSelectionBox methodsFor:'events'!
-
-show
- "make the box visible; redefined to check if directory is still
- valid (using timestamp and inode numbers) - reread if not"
-
- (timeStamp isNil
- or:[(directory timeOfLastChange > timeStamp)
- or:[(directoryId isNil)
- or:[directoryId ~~ directory id]]]) ifTrue:[
- directoryId := nil.
- self updateList
- ].
- super show
! !
!FileSelectionBox methodsFor:'user interaction'!
@@ -194,7 +121,7 @@
(string startsWith:(Filename separator)) ifTrue:[
absPath := string
] ifFalse:[
- absPath := directory pathName , Filename separator asString , string
+ absPath := selectionList directory pathName , Filename separator asString , string
].
okAction value:absPath
]
--- a/LSelBox.st Thu Dec 16 12:02:42 1993 +0100
+++ b/LSelBox.st Thu Dec 16 12:04:09 1993 +0100
@@ -24,7 +24,7 @@
this class implements boxes for selection from a list
-$Header: /cvs/stx/stx/libwidg/Attic/LSelBox.st,v 1.3 1993-10-13 02:48:17 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/LSelBox.st,v 1.4 1993-12-16 11:03:01 claus Exp $
written Jan 90 by claus
'!
@@ -33,6 +33,13 @@
defaultExtent
^ (Display pixelPerMillimeter * (80 @ 100)) rounded
+!
+
+listViewType
+ "return the type of listView
+ - for easier redefinition in subclasses"
+
+ ^ SelectionInListView
! !
!ListSelectionBox class methodsFor:'instance creation'!
@@ -60,7 +67,7 @@
space2 := 2 * ViewSpacing.
- v := ScrollableView for:SelectionInListView in:self.
+ v := ScrollableView for:(self class listViewType) in:self.
"kludge: see note in EnterBox"
v origin:(ViewSpacing
--- a/ListSelectionBox.st Thu Dec 16 12:02:42 1993 +0100
+++ b/ListSelectionBox.st Thu Dec 16 12:04:09 1993 +0100
@@ -24,7 +24,7 @@
this class implements boxes for selection from a list
-$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.3 1993-10-13 02:48:17 claus Exp $
+$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.4 1993-12-16 11:03:01 claus Exp $
written Jan 90 by claus
'!
@@ -33,6 +33,13 @@
defaultExtent
^ (Display pixelPerMillimeter * (80 @ 100)) rounded
+!
+
+listViewType
+ "return the type of listView
+ - for easier redefinition in subclasses"
+
+ ^ SelectionInListView
! !
!ListSelectionBox class methodsFor:'instance creation'!
@@ -60,7 +67,7 @@
space2 := 2 * ViewSpacing.
- v := ScrollableView for:SelectionInListView in:self.
+ v := ScrollableView for:(self class listViewType) in:self.
"kludge: see note in EnterBox"
v origin:(ViewSpacing
--- a/Make.proto Thu Dec 16 12:02:42 1993 +0100
+++ b/Make.proto Thu Dec 16 12:04:09 1993 +0100
@@ -23,7 +23,8 @@
YesNoBox.$(O) MenuView.$(O) ETxtView.$(O) \
Toggle.$(O) ErrNotify.$(O) LSelBox.$(O) \
EnterBox2.$(O) ClckMenuV.$(O) EditField.$(O) TextColl.$(O) \
- Workspace.$(O) CodeView.$(O)
+ Workspace.$(O) CodeView.$(O) \
+ FSelList.$(O)
# these can be autoloaded in small-memory systems
@@ -88,6 +89,7 @@
WarnBox.$(O) \
YesNoBox.$(O) \
MenuView.$(O) \
+ FSelList.$(O) \
ETxtView.$(O) \
VarHPanel.$(O) \
RetButton.$(O) \
@@ -186,6 +188,7 @@
ListView.$(O): ListView.st $(VIEW)
SelListV.$(O): SelListV.st $(LISTVIEW)
MenuView.$(O): MenuView.st $(SELLISTVIEW)
+FSelList.$(O): FSelList.st $(SELLISTVIEW)
TextView.$(O): TextView.st $(LISTVIEW)
ETxtView.$(O): ETxtView.st $(TEXTVIEW)
EditField.$(O): EditField.st $(EDITTEXTVIEW)
--- a/MenuView.st Thu Dec 16 12:02:42 1993 +0100
+++ b/MenuView.st Thu Dec 16 12:04:09 1993 +0100
@@ -24,7 +24,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.4 1993-12-11 01:46:47 claus Exp $
+$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.5 1993-12-16 11:03:19 claus Exp $
'!
!MenuView class methodsFor:'documentation'!
@@ -290,6 +290,15 @@
self redrawLine:index
]
]
+ ] ifFalse:[
+ "try submenus for convenience"
+ (indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
+ subMenus do:[:m |
+ m notNil ifTrue:[
+ m disable:indexOrName
+ ]
+ ]
+ ]
]
!
@@ -306,6 +315,15 @@
self redrawLine:index
]
]
+ ] ifFalse:[
+ "try submenus for convenience"
+ (indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
+ subMenus do:[:m |
+ m notNil ifTrue:[
+ m enable:indexOrName
+ ]
+ ]
+ ]
]
!
--- a/PopUpMenu.st Thu Dec 16 12:02:42 1993 +0100
+++ b/PopUpMenu.st Thu Dec 16 12:04:09 1993 +0100
@@ -23,7 +23,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.4 1993-12-11 01:47:42 claus Exp $
+$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.5 1993-12-16 11:03:36 claus Exp $
written summer 89 by claus;
ST-80 compatibility added Dec 92;
@@ -222,6 +222,12 @@
menuView selectorAt:index put:aSymbol
!
+subMenuAt:indexOrName
+ "return a submenu - or nil if there is none"
+
+ ^ menuView subMenuAt:indexOrName
+!
+
subMenuAt:indexOrName put:aMenu
"define a submenu to be shown for entry indexOrName"