author | Claus Gittinger <cg@exept.de> |
Fri, 19 Apr 1996 14:35:26 +0200 | |
changeset 548 | c418699a90c0 |
parent 438 | 8df6f72d1569 |
child 585 | 8f395aba0173 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
ListSelectionBox subclass:#FileSelectionBox |
|
351 | 14 |
instanceVariableNames:'patternField selectingDirectory' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-DialogBoxes' |
|
0 | 18 |
! |
19 |
||
7 | 20 |
!FileSelectionBox class methodsFor:'documentation'! |
21 |
||
38 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
38 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
7 | 36 |
documentation |
37 |
" |
|
38 | 38 |
this class implements file selection boxes. Instances show a list of |
39 |
files, and perform an action block with the selected pathname as |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
40 |
argument when ok is clicked. It is also possible, to open the box |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
41 |
without action and ask it afterward if it has been left with ok |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
42 |
(i.e. the ST-80 way, asking 'aBox accepted ifTrue:[...]') |
38 | 43 |
|
44 |
There is an optional PatternField, which shows itself when a pattern |
|
45 |
is defined (i.e. if there is no pattern, it is hidden). |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
46 |
If there is a pattern, only files matching the pattern are shown in |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
47 |
the list. Directories are not affected by the patternField. |
38 | 48 |
|
49 |
In addition, there is an optional matchBlock (actually this is defined |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
50 |
in the FileSelectionList). Only names for which this matchblock |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
51 |
returns true will be presented. The matchBlock affects both regular files |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
52 |
and names of directories. The argument passed to the matchBlock is the full |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
53 |
pathname. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
54 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
55 |
All of the actual work is done in the fileList; see the documentation |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
56 |
of FileSelectionList for more options |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
57 |
(you can access a boxes fileList via 'aBox>>listView' and get access to all |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
58 |
of those fancy settings) |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
59 |
For example, by accessing the list, it is possible to hide all directories |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
60 |
('aBox listView ignoreDirectories:true'), to hide the parentDirectory alone |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
61 |
('aBox listView ignoreParentDirectory') and to turn off the marking |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
62 |
of subdirectories ('aBox listView markSubdirectories:false'). |
62 | 63 |
" |
64 |
! |
|
38 | 65 |
|
62 | 66 |
examples |
67 |
" |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
68 |
simple standard queries |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
69 |
|
238 | 70 |
very simple: |
351 | 71 |
|name| |
238 | 72 |
|
351 | 73 |
name := FileSelectionBox requestFilename. |
74 |
Transcript showCr:name |
|
38 | 75 |
|
238 | 76 |
|
77 |
simple: |
|
351 | 78 |
|name| |
238 | 79 |
|
351 | 80 |
name := FileSelectionBox requestFilename:'which file ?'. |
81 |
Transcript showCr:name |
|
38 | 82 |
|
238 | 83 |
|
84 |
with initial selection: |
|
351 | 85 |
|name| |
238 | 86 |
|
351 | 87 |
name := FileSelectionBox requestFilename:'which file ?' default:'Make.proto'. |
88 |
Transcript showCr:name |
|
38 | 89 |
|
238 | 90 |
|
12 | 91 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
92 |
more detailed setup |
238 | 93 |
|
94 |
setting title: |
|
38 | 95 |
|
351 | 96 |
|box| |
97 |
box := FileSelectionBox new. |
|
98 |
box title:'Which file ?'. |
|
99 |
box open. |
|
100 |
box accepted ifTrue:[ |
|
101 |
Transcript showCr:'you selected: ' , box |
|
102 |
] |
|
38 | 103 |
|
238 | 104 |
setting a matchpattern: |
38 | 105 |
|
351 | 106 |
|box| |
107 |
box := FileSelectionBox new. |
|
108 |
box title:'Which file ?'. |
|
109 |
box pattern:'*.rc'. |
|
110 |
box open |
|
111 |
||
112 |
setting multiple patterns: |
|
113 |
||
114 |
|box| |
|
115 |
box := FileSelectionBox new. |
|
116 |
box title:'Which file ?'. |
|
117 |
box pattern:'*.rc;*.st'. |
|
118 |
box open |
|
38 | 119 |
|
238 | 120 |
setting a matchblock: |
38 | 121 |
|
351 | 122 |
|box| |
123 |
box := FileSelectionBox new. |
|
124 |
box title:'Which file ?'. |
|
125 |
box directory:'/etc'. |
|
126 |
box pattern:'*'. |
|
127 |
box matchBlock:[:name | name asFilename baseName first between:$a and:$z]. |
|
128 |
box open |
|
44 | 129 |
|
238 | 130 |
both pattern and matchBlock: |
44 | 131 |
|
351 | 132 |
|box| |
133 |
box := FileSelectionBox new. |
|
134 |
box title:'Which directory ?'. |
|
135 |
box selectingDirectory:true. |
|
136 |
box pattern:'l*'. |
|
137 |
box matchBlock:[:name | OperatingSystem isDirectory:name]. |
|
138 |
box action:[:fn | Transcript showCr:fn]. |
|
139 |
box open |
|
238 | 140 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
141 |
dont show the parent directory: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
142 |
|
351 | 143 |
|box| |
144 |
box := FileSelectionBox new. |
|
145 |
box title:'Which directory ?'. |
|
146 |
box listView ignoreParentDirectory:true. |
|
147 |
box open |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
148 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
149 |
dont show any directory: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
150 |
|
351 | 151 |
|box| |
152 |
box := FileSelectionBox new. |
|
153 |
box title:'Which file ?'. |
|
154 |
box listView ignoreDirectories:true. |
|
155 |
box open |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
156 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
157 |
dont show any directory or hidden file: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
158 |
(notice the basename extraction - we are not interrested in the full pathName) |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
159 |
|
351 | 160 |
|box| |
161 |
box := FileSelectionBox new. |
|
162 |
box title:'Which file ?'. |
|
163 |
box listView ignoreDirectories:true. |
|
164 |
box matchBlock:[:name | (name asFilename baseName startsWith:'.') not]. |
|
165 |
box open |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
166 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
167 |
dont allow direct filename entry: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
168 |
(i.e. avoid the user choosing files from other directories) |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
169 |
|
351 | 170 |
|box| |
171 |
box := FileSelectionBox new. |
|
172 |
box title:'Which one ?'. |
|
173 |
box enterField beInvisible. |
|
174 |
box open. |
|
175 |
box accepted ifTrue:[ |
|
176 |
Transcript showCr:'path is ' , box pathName |
|
177 |
]. |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
178 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
179 |
combined with above directory ignoring, |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
180 |
this limits selection of files from a single directory: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
181 |
|
351 | 182 |
|box| |
183 |
box := FileSelectionBox new. |
|
184 |
box title:'Which file ?'. |
|
185 |
box enterField beInvisible. |
|
186 |
box listView ignoreDirectories:true. |
|
187 |
box open. |
|
188 |
box accepted ifTrue:[ |
|
189 |
Transcript showCr:'path is ' , box pathName |
|
190 |
]. |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
191 |
|
238 | 192 |
finally, an action: |
193 |
||
351 | 194 |
|box| |
195 |
box := FileSelectionBox new. |
|
196 |
box title:'Which directory ?'. |
|
197 |
box pattern:'l*'. |
|
198 |
box matchBlock:[:name | OperatingSystem isDirectory:name]. |
|
199 |
box action:[:name | Transcript showCr:name]. |
|
200 |
box open |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
201 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
202 |
concrete examples: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
203 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
204 |
only show files beginning with lowercase characters |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
205 |
and ending in '.c': |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
206 |
|
351 | 207 |
|box| |
208 |
box := FileSelectionBox new. |
|
209 |
box title:'Which directory ?'. |
|
210 |
box matchBlock:[:name | |
|
211 |
box pathName asFilename isDirectory |
|
212 |
or:[name first isLowercase |
|
213 |
and:[name endsWith:'.c']] |
|
214 |
]. |
|
215 |
box open. |
|
216 |
box accepted ifTrue:[ |
|
217 |
Transcript showCr:'full path: ' , box pathName. |
|
218 |
Transcript showCr:'files name: ' , box fileName. |
|
219 |
Transcript showCr:'directory : ' , box directory. |
|
220 |
] |
|
7 | 221 |
" |
222 |
! ! |
|
0 | 223 |
|
12 | 224 |
!FileSelectionBox class methodsFor:'defaults'! |
225 |
||
226 |
listViewType |
|
227 |
"return the type of listView - using a FileSelectionList here" |
|
228 |
||
229 |
^ FileSelectionList |
|
230 |
! ! |
|
231 |
||
197 | 232 |
!FileSelectionBox methodsFor:'accessing'! |
3 | 233 |
|
197 | 234 |
contents |
235 |
"return the current entered value (i.e. the enterFields string). |
|
236 |
redefined to return the full pathname." |
|
237 |
||
238 |
|string sep| |
|
3 | 239 |
|
197 | 240 |
string := super contents. |
241 |
string isNil ifTrue:[ |
|
242 |
^ selectionList directory pathName |
|
121 | 243 |
]. |
197 | 244 |
sep := Filename separator. |
245 |
(string startsWith:sep) ifTrue:[ |
|
246 |
^ string |
|
77 | 247 |
]. |
197 | 248 |
^ (selectionList directory pathName asFilename construct:string) asString |
132 | 249 |
! |
250 |
||
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
251 |
directory |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
252 |
"return the directory which is currently shown" |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
253 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
254 |
^ selectionList directory |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
255 |
! |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
256 |
|
197 | 257 |
directory:directoryName |
258 |
"change the directory shown in the list." |
|
41 | 259 |
|
197 | 260 |
selectionList directory:directoryName |
132 | 261 |
! |
262 |
||
351 | 263 |
fileName |
264 |
"if some filename has been entered, return it (without the directory path) |
|
265 |
otherwise, return nil" |
|
266 |
||
267 |
|string| |
|
268 |
||
269 |
string := super contents. |
|
270 |
string isNil ifTrue:[^ nil]. |
|
271 |
^ self pathName |
|
272 |
! |
|
273 |
||
197 | 274 |
matchBlock:aBlock |
275 |
"set the matchBlock (in the selectionList). Only files |
|
276 |
for which the block returns true are shown. |
|
277 |
The matching is actually done in the fileSelectionList." |
|
77 | 278 |
|
197 | 279 |
selectionList matchBlock:aBlock |
280 |
! |
|
0 | 281 |
|
38 | 282 |
openOn:aPath |
283 |
"open the box showing files in aPath. |
|
284 |
This is only a shortcut message - no new functionality." |
|
285 |
||
286 |
self directory:aPath. |
|
287 |
self showAtPointer |
|
288 |
! |
|
289 |
||
351 | 290 |
pathName |
291 |
"same as contents - return the full pathname of the selected file, |
|
292 |
or the pathname of the directory if nothing has been entered" |
|
293 |
||
294 |
^ self contents |
|
295 |
! |
|
296 |
||
3 | 297 |
pattern:aPattern |
38 | 298 |
"set the pattern - this also enables the PatternField |
299 |
(if the pattern is non-nil) or hides it (if nil)." |
|
7 | 300 |
|
130 | 301 |
|hidePatternField focusSequence| |
302 |
||
3 | 303 |
patternField initialText:aPattern. |
12 | 304 |
selectionList pattern:aPattern. |
305 |
aPattern isNil ifTrue:[ |
|
130 | 306 |
hidePatternField := true. |
59 | 307 |
realized ifTrue:[ |
308 |
patternField hide. |
|
77 | 309 |
]. |
130 | 310 |
focusSequence := (Array |
311 |
with:enterField |
|
312 |
with:selectionList |
|
313 |
with:okButton |
|
314 |
with:abortButton) |
|
12 | 315 |
] ifFalse:[ |
130 | 316 |
hidePatternField := false. |
59 | 317 |
realized ifTrue:[ |
318 |
patternField realize. |
|
319 |
]. |
|
130 | 320 |
focusSequence := (Array |
321 |
with:patternField |
|
322 |
with:enterField |
|
323 |
with:selectionList |
|
324 |
with:okButton |
|
325 |
with:abortButton) |
|
326 |
]. |
|
327 |
||
328 |
patternField hiddenOnRealize:hidePatternField. |
|
329 |
windowGroup notNil ifTrue:[ |
|
330 |
windowGroup focusSequence:focusSequence |
|
0 | 331 |
]. |
351 | 332 |
! |
333 |
||
334 |
selectingDirectory:aBoolean |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
335 |
selectingDirectory := aBoolean. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
336 |
aBoolean ifTrue:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
337 |
selectionList directoryChangeAction:[:entry | self directoryChanged]. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
338 |
selectionList directorySelectAction:[:entry | self directorySelected]. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
339 |
selectionList ignoreFiles:true. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
340 |
] |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
341 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
342 |
"Modified: 18.4.1996 / 18:50:10 / cg" |
197 | 343 |
! ! |
344 |
||
345 |
!FileSelectionBox methodsFor:'change & update'! |
|
346 |
||
347 |
update:something with:argument from:changedObject |
|
348 |
|commonName index s| |
|
349 |
||
350 |
something == #directory ifTrue:[ |
|
351 |
" |
|
352 |
sent by fileNameEnterField, if a filename |
|
353 |
completion was not possible due to multiple |
|
354 |
matches. |
|
355 |
" |
|
356 |
selectionList directory:argument. |
|
357 |
s := enterField contents. |
|
358 |
s notNil ifTrue:[ |
|
359 |
commonName := s asFilename baseName. |
|
360 |
commonName size > 0 ifTrue:[ |
|
361 |
index := selectionList list findFirst:[:entry | entry startsWith:commonName]. |
|
362 |
index ~~ 0 ifTrue:[ |
|
363 |
selectionList makeLineVisible:index |
|
364 |
] |
|
365 |
] |
|
366 |
] |
|
367 |
] |
|
368 |
! ! |
|
369 |
||
370 |
!FileSelectionBox methodsFor:'initialization'! |
|
371 |
||
372 |
createEnterField |
|
373 |
"if the (optional) class FilenameEditField is present, use |
|
374 |
it, since it provides filename completion. Otherwise, we have |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
375 |
to live with the dumb (default) field ... |
197 | 376 |
" |
377 |
FilenameEditField notNil ifTrue:[ |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
378 |
^ FilenameEditField new. |
197 | 379 |
]. |
380 |
^ super createEnterField |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
381 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
382 |
"Modified: 18.4.1996 / 20:02:24 / cg" |
38 | 383 |
! |
0 | 384 |
|
197 | 385 |
focusSequence |
386 |
patternField shown ifTrue:[ |
|
387 |
^ Array |
|
388 |
with:patternField |
|
389 |
with:enterField |
|
390 |
with:selectionList |
|
391 |
with:abortButton |
|
392 |
with:okButton |
|
393 |
]. |
|
394 |
^ super focusSequence |
|
395 |
! |
|
396 |
||
397 |
initialize |
|
398 |
|corner| |
|
399 |
||
400 |
super initialize. |
|
351 | 401 |
selectingDirectory := false. |
197 | 402 |
|
403 |
label := resources string:'File dialog'. |
|
0 | 404 |
|
197 | 405 |
labelField extent:(0.7 @ labelField height). |
406 |
labelField label:(resources string:'select a file:'). |
|
407 |
labelField adjust:#left. |
|
408 |
||
409 |
patternField := EditField in:self. |
|
410 |
self is3D ifTrue:[ |
|
351 | 411 |
corner := (1.0 @ (labelField origin y+patternField heightIncludingBorder)). |
197 | 412 |
] ifFalse:[ |
351 | 413 |
corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")]. |
197 | 414 |
]. |
415 |
patternField origin:(0.7 @ labelField origin y) corner:corner. |
|
416 |
patternField rightInset:ViewSpacing. |
|
417 |
patternField initialText:'*'. |
|
418 |
patternField leaveAction:[:reason | |
|
351 | 419 |
selectionList pattern:patternField contents. |
420 |
self updateList |
|
197 | 421 |
]. |
422 |
patternField hiddenOnRealize:true. "delay showing, until a pattern is defined" |
|
423 |
||
424 |
enterField addDependent:self. |
|
425 |
||
426 |
" |
|
427 |
FileSelectionBox open |
|
428 |
FileSelectionBox new show |
|
429 |
" |
|
38 | 430 |
! |
7 | 431 |
|
197 | 432 |
realize |
433 |
"if some default is present in the enterField, |
|
434 |
scroll to make this one visible" |
|
435 |
||
436 |
|contents| |
|
437 |
||
438 |
super realize. |
|
439 |
(contents := enterField contents) notNil ifTrue:[ |
|
440 |
contents notEmpty ifTrue:[ |
|
441 |
selectionList makeVisible:contents |
|
442 |
] |
|
443 |
] |
|
444 |
! ! |
|
445 |
||
446 |
!FileSelectionBox methodsFor:'private'! |
|
447 |
||
448 |
updateList |
|
449 |
selectionList updateList |
|
450 |
! ! |
|
38 | 451 |
|
197 | 452 |
!FileSelectionBox methodsFor:'queries'! |
453 |
||
454 |
preferredExtent |
|
455 |
"return my preferred extent - thats the minimum size |
|
456 |
to make everything visible" |
|
457 |
||
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
458 |
|wWanted hWanted mm| |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
459 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
460 |
mm := ViewSpacing. |
197 | 461 |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
462 |
wWanted := mm + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
463 |
labelField preferredExtent x + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
464 |
(mm * 2) + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
465 |
patternField preferredExtent x + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
466 |
mm. |
197 | 467 |
(wWanted < width) ifTrue:[ |
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
468 |
wWanted := width |
197 | 469 |
]. |
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
470 |
hWanted := mm + labelField height + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
471 |
mm + enterField height + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
472 |
mm + selectionList height + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
473 |
mm + buttonPanel preferredExtent y + |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
474 |
mm. |
38 | 475 |
|
197 | 476 |
(hWanted < height) ifTrue:[ |
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
477 |
hWanted := height |
197 | 478 |
]. |
479 |
^ (wWanted @ hWanted) |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
480 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
481 |
"Modified: 19.4.1996 / 14:34:47 / cg" |
197 | 482 |
! ! |
483 |
||
484 |
!FileSelectionBox methodsFor:'user actions'! |
|
485 |
||
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
486 |
directoryChanged |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
487 |
selectingDirectory ifTrue:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
488 |
selectionList changeDirectory. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
489 |
enterField contents:(selectionList directory pathName). |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
490 |
selectionList selection:nil. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
491 |
]. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
492 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
493 |
"Created: 18.4.1996 / 18:38:21 / cg" |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
494 |
"Modified: 18.4.1996 / 18:47:34 / cg" |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
495 |
! |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
496 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
497 |
directorySelected |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
498 |
selectingDirectory ifTrue:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
499 |
enterField contents:(selectionList directory pathName |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
500 |
, '/' , selectionList selectionValue). |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
501 |
]. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
502 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
503 |
"Modified: 18.4.1996 / 18:40:41 / cg" |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
504 |
"Created: 18.4.1996 / 18:46:15 / cg" |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
505 |
! |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
506 |
|
197 | 507 |
doubleClick |
508 |
|entry| |
|
509 |
||
510 |
entry := selectionList selectionValue. |
|
511 |
entry notNil ifTrue:[ |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
512 |
((selectionList directory typeOf:entry) == #directory) ifFalse:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
513 |
selectingDirectory ifFalse:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
514 |
enterField contents:entry. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
515 |
self okPressed |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
516 |
] |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
517 |
] |
38 | 518 |
]. |
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
519 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
520 |
"Modified: 18.4.1996 / 18:33:14 / cg" |
197 | 521 |
! |
522 |
||
523 |
okPressed |
|
524 |
"called for both on ok-press and on return-key" |
|
525 |
||
526 |
|dir string fname| |
|
527 |
||
528 |
string := enterField contents. |
|
351 | 529 |
(string notNil and:[string notEmpty]) ifTrue:[ |
530 |
string := string withoutSeparators. |
|
531 |
string asFilename isAbsolute ifTrue:[ |
|
532 |
fname := string asFilename |
|
533 |
] ifFalse:[ |
|
534 |
dir := selectionList directory pathName asFilename. |
|
535 |
fname := dir construct:string |
|
536 |
]. |
|
537 |
fname isDirectory ifTrue:[ |
|
538 |
selectingDirectory ifFalse:[ |
|
539 |
selectionList directory:fname asString. |
|
540 |
self updateList. |
|
541 |
^ self |
|
542 |
] |
|
543 |
] |
|
544 |
] ifFalse:[ |
|
545 |
selectingDirectory ifTrue:[ |
|
546 |
enterField contents:(selectionList directory pathName). |
|
547 |
]. |
|
38 | 548 |
]. |
351 | 549 |
|
197 | 550 |
super okPressed |
351 | 551 |
|
197 | 552 |
! |
553 |
||
554 |
selectionChanged |
|
555 |
|entry| |
|
556 |
||
557 |
entry := selectionList selectionValue. |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
558 |
((selectionList directory typeOf:entry) == #directory) ifFalse:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
559 |
selectingDirectory ifTrue:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
560 |
enterField contents:(selectionList directory pathName). |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
561 |
selectionList selection:nil. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
562 |
^ self |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
563 |
] |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
564 |
]. |
197 | 565 |
enterField contents:entry |
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
566 |
|
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
567 |
"Modified: 18.4.1996 / 18:34:57 / cg" |
0 | 568 |
! ! |
197 | 569 |
|
240 | 570 |
!FileSelectionBox class methodsFor:'documentation'! |
571 |
||
572 |
version |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
573 |
^ '$Header: /cvs/stx/stx/libwidg/Attic/FSelBox.st,v 1.30 1996-04-19 12:35:26 cg Exp $' |
240 | 574 |
! ! |