1 |
578 |
markom |
#
|
2 |
|
|
# Fileselectionbox
|
3 |
|
|
# ----------------------------------------------------------------------
|
4 |
|
|
# Implements a file selection box in a style similar to the OSF/Motif
|
5 |
|
|
# standard XmFileselectionbox composite widget. The Fileselectionbox
|
6 |
|
|
# is composed of directory and file scrolled lists as well as filter
|
7 |
|
|
# and selection entry fields.
|
8 |
|
|
#
|
9 |
|
|
# ----------------------------------------------------------------------
|
10 |
|
|
# AUTHOR: Mark L. Ulferts EMAIL: mulferts@spd.dsccc.com
|
11 |
|
|
#
|
12 |
|
|
# @(#) $Id: fileselectionbox.itk,v 1.1.1.1 2002-01-16 10:24:50 markom Exp $
|
13 |
|
|
# ----------------------------------------------------------------------
|
14 |
|
|
# Copyright (c) 1997 DSC Technologies Corporation
|
15 |
|
|
# ======================================================================
|
16 |
|
|
# Permission to use, copy, modify, distribute and license this software
|
17 |
|
|
# and its documentation for any purpose, and without fee or written
|
18 |
|
|
# agreement with DSC, is hereby granted, provided that the above copyright
|
19 |
|
|
# notice appears in all copies and that both the copyright notice and
|
20 |
|
|
# warranty disclaimer below appear in supporting documentation, and that
|
21 |
|
|
# the names of DSC Technologies Corporation or DSC Communications
|
22 |
|
|
# Corporation not be used in advertising or publicity pertaining to the
|
23 |
|
|
# software without specific, written prior permission.
|
24 |
|
|
#
|
25 |
|
|
# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
26 |
|
|
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
|
27 |
|
|
# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
|
28 |
|
|
# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
|
29 |
|
|
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL
|
30 |
|
|
# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
31 |
|
|
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
32 |
|
|
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
|
33 |
|
|
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
34 |
|
|
# SOFTWARE.
|
35 |
|
|
# ======================================================================
|
36 |
|
|
|
37 |
|
|
#
|
38 |
|
|
# Usual options.
|
39 |
|
|
#
|
40 |
|
|
itk::usual Fileselectionbox {
|
41 |
|
|
keep -activebackground -activerelief -background -borderwidth -cursor \
|
42 |
|
|
-elementborderwidth -foreground -highlightcolor -highlightthickness \
|
43 |
|
|
-insertbackground -insertborderwidth -insertofftime -insertontime \
|
44 |
|
|
-insertwidth -jump -labelfont -selectbackground -selectborderwidth \
|
45 |
|
|
-textbackground -textfont -troughcolor
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
# ------------------------------------------------------------------
|
49 |
|
|
# FILESELECTIONBOX
|
50 |
|
|
# ------------------------------------------------------------------
|
51 |
|
|
class iwidgets::Fileselectionbox {
|
52 |
|
|
inherit itk::Widget
|
53 |
|
|
|
54 |
|
|
constructor {args} {}
|
55 |
|
|
destructor {}
|
56 |
|
|
|
57 |
|
|
itk_option define -childsitepos childSitePos Position s
|
58 |
|
|
itk_option define -fileson filesOn FilesOn true
|
59 |
|
|
itk_option define -dirson dirsOn DirsOn true
|
60 |
|
|
itk_option define -selectionon selectionOn SelectionOn true
|
61 |
|
|
itk_option define -filteron filterOn FilterOn true
|
62 |
|
|
itk_option define -mask mask Mask {*}
|
63 |
|
|
itk_option define -directory directory Directory {}
|
64 |
|
|
itk_option define -nomatchstring noMatchString NoMatchString {}
|
65 |
|
|
itk_option define -dirsearchcommand dirSearchCommand Command {}
|
66 |
|
|
itk_option define -filesearchcommand fileSearchCommand Command {}
|
67 |
|
|
itk_option define -selectioncommand selectionCommand Command {}
|
68 |
|
|
itk_option define -filtercommand filterCommand Command {}
|
69 |
|
|
itk_option define -selectdircommand selectDirCommand Command {}
|
70 |
|
|
itk_option define -selectfilecommand selectFileCommand Command {}
|
71 |
|
|
itk_option define -invalid invalid Command {bell}
|
72 |
|
|
itk_option define -filetype fileType FileType {regular}
|
73 |
|
|
itk_option define -width width Width 350
|
74 |
|
|
itk_option define -height height Height 300
|
75 |
|
|
|
76 |
|
|
public {
|
77 |
|
|
method childsite {}
|
78 |
|
|
method get {}
|
79 |
|
|
method filter {}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
public {
|
83 |
|
|
method _selectDir {}
|
84 |
|
|
method _dblSelectDir {}
|
85 |
|
|
method _selectFile {}
|
86 |
|
|
method _selectSelection {}
|
87 |
|
|
method _selectFilter {}
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
protected {
|
91 |
|
|
method _packComponents {{when later}}
|
92 |
|
|
method _updateLists {{when later}}
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
private {
|
96 |
|
|
method _setFilter {}
|
97 |
|
|
method _setSelection {}
|
98 |
|
|
method _setDirList {}
|
99 |
|
|
method _setFileList {}
|
100 |
|
|
|
101 |
|
|
method _nPos {}
|
102 |
|
|
method _sPos {}
|
103 |
|
|
method _ePos {}
|
104 |
|
|
method _wPos {}
|
105 |
|
|
method _topPos {}
|
106 |
|
|
method _centerPos {}
|
107 |
|
|
method _bottomPos {}
|
108 |
|
|
|
109 |
|
|
variable _packToken "" ;# non-null => _packComponents pending
|
110 |
|
|
variable _updateToken "" ;# non-null => _updateLists pending
|
111 |
|
|
variable _pwd "." ;# present working dir
|
112 |
|
|
variable _interior ;# original interior setting
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
#
|
117 |
|
|
# Provide a lowercased access method for the Fileselectionbox class.
|
118 |
|
|
#
|
119 |
|
|
proc ::iwidgets::fileselectionbox {pathName args} {
|
120 |
|
|
uplevel ::iwidgets::Fileselectionbox $pathName $args
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
#
|
124 |
|
|
# Use option database to override default resources of base classes.
|
125 |
|
|
#
|
126 |
|
|
option add *Fileselectionbox.borderWidth 2 widgetDefault
|
127 |
|
|
|
128 |
|
|
option add *Fileselectionbox.filterLabel Filter widgetDefault
|
129 |
|
|
option add *Fileselectionbox.dirsLabel Directories widgetDefault
|
130 |
|
|
option add *Fileselectionbox.filesLabel Files widgetDefault
|
131 |
|
|
option add *Fileselectionbox.selectionLabel Selection widgetDefault
|
132 |
|
|
|
133 |
|
|
option add *Fileselectionbox.width 350 widgetDefault
|
134 |
|
|
option add *Fileselectionbox.height 300 widgetDefault
|
135 |
|
|
|
136 |
|
|
# ------------------------------------------------------------------
|
137 |
|
|
# CONSTRUCTOR
|
138 |
|
|
# ------------------------------------------------------------------
|
139 |
|
|
body iwidgets::Fileselectionbox::constructor {args} {
|
140 |
|
|
#
|
141 |
|
|
# Add back to the hull width and height options and make the
|
142 |
|
|
# borderwidth zero since we don't need it.
|
143 |
|
|
#
|
144 |
|
|
itk_option add hull.width hull.height
|
145 |
|
|
component hull configure -borderwidth 0
|
146 |
|
|
|
147 |
|
|
set _interior $itk_interior
|
148 |
|
|
|
149 |
|
|
#
|
150 |
|
|
# Create the filter entry.
|
151 |
|
|
#
|
152 |
|
|
itk_component add filter {
|
153 |
|
|
iwidgets::Entryfield $itk_interior.filter -labelpos nw \
|
154 |
|
|
-command [code $this _selectFilter] -exportselection 0
|
155 |
|
|
} {
|
156 |
|
|
usual
|
157 |
|
|
|
158 |
|
|
rename -labeltext -filterlabel filterLabel Text
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
#
|
162 |
|
|
# Create the directory list.
|
163 |
|
|
#
|
164 |
|
|
itk_component add dirs {
|
165 |
|
|
iwidgets::Scrolledlistbox $itk_interior.dirs \
|
166 |
|
|
-selectioncommand [code $this _selectDir] \
|
167 |
|
|
-selectmode single -exportselection 0 \
|
168 |
|
|
-visibleitems 1x1 -labelpos nw \
|
169 |
|
|
-hscrollmode static -vscrollmode static \
|
170 |
|
|
-dblclickcommand [code $this _dblSelectDir]
|
171 |
|
|
} {
|
172 |
|
|
usual
|
173 |
|
|
|
174 |
|
|
rename -labeltext -dirslabel dirsLabel Text
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
#
|
178 |
|
|
# Create the files list.
|
179 |
|
|
#
|
180 |
|
|
itk_component add files {
|
181 |
|
|
iwidgets::Scrolledlistbox $itk_interior.files \
|
182 |
|
|
-selectioncommand [code $this _selectFile] \
|
183 |
|
|
-selectmode single -exportselection 0 \
|
184 |
|
|
-visibleitems 1x1 -labelpos nw \
|
185 |
|
|
-hscrollmode static -vscrollmode static
|
186 |
|
|
} {
|
187 |
|
|
usual
|
188 |
|
|
|
189 |
|
|
rename -labeltext -fileslabel filesLabel Text
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
#
|
193 |
|
|
# Create the selection entry.
|
194 |
|
|
#
|
195 |
|
|
itk_component add selection {
|
196 |
|
|
iwidgets::Entryfield $itk_interior.selection -labelpos nw \
|
197 |
|
|
-command [code $this _selectSelection] -exportselection 0
|
198 |
|
|
} {
|
199 |
|
|
usual
|
200 |
|
|
|
201 |
|
|
rename -labeltext -selectionlabel selectionLabel Text
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
#
|
205 |
|
|
# Create the child site widget.
|
206 |
|
|
#
|
207 |
|
|
itk_component add -protected childsite {
|
208 |
|
|
frame $itk_interior.fsbchildsite
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
#
|
212 |
|
|
# Set the interior variable to the childsite for derived classes.
|
213 |
|
|
#
|
214 |
|
|
set itk_interior $itk_component(childsite)
|
215 |
|
|
|
216 |
|
|
#
|
217 |
|
|
# Explicitly handle configs that may have been ignored earlier.
|
218 |
|
|
#
|
219 |
|
|
eval itk_initialize $args
|
220 |
|
|
|
221 |
|
|
#
|
222 |
|
|
# When idle, pack the childsite and update the lists.
|
223 |
|
|
#
|
224 |
|
|
_packComponents
|
225 |
|
|
_updateLists
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
# ------------------------------------------------------------------
|
229 |
|
|
# DESTRUCTOR
|
230 |
|
|
# ------------------------------------------------------------------
|
231 |
|
|
body iwidgets::Fileselectionbox::destructor {} {
|
232 |
|
|
if {$_packToken != ""} {after cancel $_packToken}
|
233 |
|
|
if {$_updateToken != ""} {after cancel $_updateToken}
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
# ------------------------------------------------------------------
|
237 |
|
|
# OPTIONS
|
238 |
|
|
# ------------------------------------------------------------------
|
239 |
|
|
|
240 |
|
|
# ------------------------------------------------------------------
|
241 |
|
|
# OPTION: -childsitepos
|
242 |
|
|
#
|
243 |
|
|
# Specifies the position of the child site in the selection box.
|
244 |
|
|
# ------------------------------------------------------------------
|
245 |
|
|
configbody iwidgets::Fileselectionbox::childsitepos {
|
246 |
|
|
_packComponents
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
# ------------------------------------------------------------------
|
250 |
|
|
# OPTION: -fileson
|
251 |
|
|
#
|
252 |
|
|
# Specifies whether or not to display the files list.
|
253 |
|
|
# ------------------------------------------------------------------
|
254 |
|
|
configbody iwidgets::Fileselectionbox::fileson {
|
255 |
|
|
_packComponents
|
256 |
|
|
}
|
257 |
|
|
|
258 |
|
|
# ------------------------------------------------------------------
|
259 |
|
|
# OPTION: -dirson
|
260 |
|
|
#
|
261 |
|
|
# Specifies whether or not to display the dirs list.
|
262 |
|
|
# ------------------------------------------------------------------
|
263 |
|
|
configbody iwidgets::Fileselectionbox::dirson {
|
264 |
|
|
_packComponents
|
265 |
|
|
}
|
266 |
|
|
|
267 |
|
|
# ------------------------------------------------------------------
|
268 |
|
|
# OPTION: -selectionon
|
269 |
|
|
#
|
270 |
|
|
# Specifies whether or not to display the selection entry widget.
|
271 |
|
|
# ------------------------------------------------------------------
|
272 |
|
|
configbody iwidgets::Fileselectionbox::selectionon {
|
273 |
|
|
_packComponents
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
# ------------------------------------------------------------------
|
277 |
|
|
# OPTION: -filteron
|
278 |
|
|
#
|
279 |
|
|
# Specifies whether or not to display the filter entry widget.
|
280 |
|
|
# ------------------------------------------------------------------
|
281 |
|
|
configbody iwidgets::Fileselectionbox::filteron {
|
282 |
|
|
_packComponents
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
# ------------------------------------------------------------------
|
286 |
|
|
# OPTION: -mask
|
287 |
|
|
#
|
288 |
|
|
# Specifies the initial file mask string.
|
289 |
|
|
# ------------------------------------------------------------------
|
290 |
|
|
configbody iwidgets::Fileselectionbox::mask {
|
291 |
|
|
global tcl_platform
|
292 |
|
|
set prefix $_pwd
|
293 |
|
|
|
294 |
|
|
#
|
295 |
|
|
# Remove automounter paths.
|
296 |
|
|
#
|
297 |
|
|
if {$tcl_platform(platform) == "unix"} {
|
298 |
|
|
regsub {^/(tmp_mnt|export)} $prefix {} prefix;
|
299 |
|
|
}
|
300 |
|
|
|
301 |
|
|
set curFilter $itk_option(-mask);
|
302 |
|
|
$itk_component(filter) delete 0 end
|
303 |
|
|
$itk_component(filter) insert 0 [file join $_pwd $itk_option(-mask)]
|
304 |
|
|
|
305 |
|
|
#
|
306 |
|
|
# Make sure the right most text is visable.
|
307 |
|
|
#
|
308 |
|
|
$itk_component(filter) xview moveto 1
|
309 |
|
|
}
|
310 |
|
|
|
311 |
|
|
# ------------------------------------------------------------------
|
312 |
|
|
# OPTION: -directory
|
313 |
|
|
#
|
314 |
|
|
# Specifies the initial default directory.
|
315 |
|
|
# ------------------------------------------------------------------
|
316 |
|
|
configbody iwidgets::Fileselectionbox::directory {
|
317 |
|
|
if {$itk_option(-directory) != {}} {
|
318 |
|
|
if {! [file exists $itk_option(-directory)]} {
|
319 |
|
|
error "bad directory option \"$itk_option(-directory)\":\
|
320 |
|
|
directory does not exist"
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
set olddir [pwd]
|
324 |
|
|
cd $itk_option(-directory)
|
325 |
|
|
set _pwd [pwd]
|
326 |
|
|
cd $olddir
|
327 |
|
|
|
328 |
|
|
configure -mask $itk_option(-mask)
|
329 |
|
|
_selectFilter
|
330 |
|
|
}
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
# ------------------------------------------------------------------
|
334 |
|
|
# OPTION: -nomatchstring
|
335 |
|
|
#
|
336 |
|
|
# Specifies the string to be displayed in the files list should
|
337 |
|
|
# not regular files exist in the directory.
|
338 |
|
|
# ------------------------------------------------------------------
|
339 |
|
|
configbody iwidgets::Fileselectionbox::nomatchstring {
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
# ------------------------------------------------------------------
|
343 |
|
|
# OPTION: -dirsearchcommand
|
344 |
|
|
#
|
345 |
|
|
# Specifies a command to be executed to perform a directory search.
|
346 |
|
|
# The command will receive the current working directory and filter
|
347 |
|
|
# mask as arguments. The command should return a list of files which
|
348 |
|
|
# will be placed into the directory list.
|
349 |
|
|
# ------------------------------------------------------------------
|
350 |
|
|
configbody iwidgets::Fileselectionbox::dirsearchcommand {
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
# ------------------------------------------------------------------
|
354 |
|
|
# OPTION: -filesearchcommand
|
355 |
|
|
#
|
356 |
|
|
# Specifies a command to be executed to perform a file search.
|
357 |
|
|
# The command will receive the current working directory and filter
|
358 |
|
|
# mask as arguments. The command should return a list of files which
|
359 |
|
|
# will be placed into the file list.
|
360 |
|
|
# ------------------------------------------------------------------
|
361 |
|
|
configbody iwidgets::Fileselectionbox::filesearchcommand {
|
362 |
|
|
}
|
363 |
|
|
|
364 |
|
|
# ------------------------------------------------------------------
|
365 |
|
|
# OPTION: -selectioncommand
|
366 |
|
|
#
|
367 |
|
|
# Specifies a command to be executed upon pressing return in the
|
368 |
|
|
# selection entry widget.
|
369 |
|
|
# ------------------------------------------------------------------
|
370 |
|
|
configbody iwidgets::Fileselectionbox::selectioncommand {
|
371 |
|
|
}
|
372 |
|
|
|
373 |
|
|
# ------------------------------------------------------------------
|
374 |
|
|
# OPTION: -filtercommand
|
375 |
|
|
#
|
376 |
|
|
# Specifies a command to be executed upon pressing return in the
|
377 |
|
|
# filter entry widget.
|
378 |
|
|
# ------------------------------------------------------------------
|
379 |
|
|
configbody iwidgets::Fileselectionbox::filtercommand {
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
# ------------------------------------------------------------------
|
383 |
|
|
# OPTION: -selectdircommand
|
384 |
|
|
#
|
385 |
|
|
# Specifies a command to be executed following selection of a
|
386 |
|
|
# directory in the directory list.
|
387 |
|
|
# ------------------------------------------------------------------
|
388 |
|
|
configbody iwidgets::Fileselectionbox::selectdircommand {
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
# ------------------------------------------------------------------
|
392 |
|
|
# OPTION: -selectfilecommand
|
393 |
|
|
#
|
394 |
|
|
# Specifies a command to be executed following selection of a
|
395 |
|
|
# file in the files list.
|
396 |
|
|
# ------------------------------------------------------------------
|
397 |
|
|
configbody iwidgets::Fileselectionbox::selectfilecommand {
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
# ------------------------------------------------------------------
|
401 |
|
|
# OPTION: -invalid
|
402 |
|
|
#
|
403 |
|
|
# Specify a command to executed should the filter contents be
|
404 |
|
|
# proven invalid.
|
405 |
|
|
# ------------------------------------------------------------------
|
406 |
|
|
configbody iwidgets::Fileselectionbox::invalid {
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
# ------------------------------------------------------------------
|
410 |
|
|
# OPTION: -filetype
|
411 |
|
|
#
|
412 |
|
|
# Specify the type of files which may appear in the file list.
|
413 |
|
|
# ------------------------------------------------------------------
|
414 |
|
|
configbody iwidgets::Fileselectionbox::filetype {
|
415 |
|
|
switch $itk_option(-filetype) {
|
416 |
|
|
regular -
|
417 |
|
|
directory -
|
418 |
|
|
any {
|
419 |
|
|
}
|
420 |
|
|
default {
|
421 |
|
|
error "bad filetype option \"$itk_option(-filetype)\":\
|
422 |
|
|
should be regular, directory, or any"
|
423 |
|
|
}
|
424 |
|
|
}
|
425 |
|
|
|
426 |
|
|
_updateLists
|
427 |
|
|
}
|
428 |
|
|
|
429 |
|
|
# ------------------------------------------------------------------
|
430 |
|
|
# OPTION: -width
|
431 |
|
|
#
|
432 |
|
|
# Specifies the width of the file selection box. The value may be
|
433 |
|
|
# specified in any of the forms acceptable to Tk_GetPixels.
|
434 |
|
|
# ------------------------------------------------------------------
|
435 |
|
|
configbody iwidgets::Fileselectionbox::width {
|
436 |
|
|
#
|
437 |
|
|
# The width option was added to the hull in the constructor.
|
438 |
|
|
# So, any width value given is passed automatically to the
|
439 |
|
|
# hull. All we have to do is play with the propagation.
|
440 |
|
|
#
|
441 |
|
|
if {$itk_option(-width) != 0} {
|
442 |
|
|
set propagate 0
|
443 |
|
|
} else {
|
444 |
|
|
set propagate 1
|
445 |
|
|
}
|
446 |
|
|
|
447 |
|
|
#
|
448 |
|
|
# Due to a bug in the tk4.2 grid, we have to check the
|
449 |
|
|
# propagation before setting it. Setting it to the same
|
450 |
|
|
# value it already is will cause it to toggle.
|
451 |
|
|
#
|
452 |
|
|
if {[grid propagate $itk_component(hull)] != $propagate} {
|
453 |
|
|
grid propagate $itk_component(hull) $propagate
|
454 |
|
|
}
|
455 |
|
|
}
|
456 |
|
|
|
457 |
|
|
# ------------------------------------------------------------------
|
458 |
|
|
# OPTION: -height
|
459 |
|
|
#
|
460 |
|
|
# Specifies the height of the file selection box. The value may be
|
461 |
|
|
# specified in any of the forms acceptable to Tk_GetPixels.
|
462 |
|
|
# ------------------------------------------------------------------
|
463 |
|
|
configbody iwidgets::Fileselectionbox::height {
|
464 |
|
|
#
|
465 |
|
|
# The height option was added to the hull in the constructor.
|
466 |
|
|
# So, any height value given is passed automatically to the
|
467 |
|
|
# hull. All we have to do is play with the propagation.
|
468 |
|
|
#
|
469 |
|
|
if {$itk_option(-height) != 0} {
|
470 |
|
|
set propagate 0
|
471 |
|
|
} else {
|
472 |
|
|
set propagate 1
|
473 |
|
|
}
|
474 |
|
|
|
475 |
|
|
#
|
476 |
|
|
# Due to a bug in the tk4.2 grid, we have to check the
|
477 |
|
|
# propagation before setting it. Setting it to the same
|
478 |
|
|
# value it already is will cause it to toggle.
|
479 |
|
|
#
|
480 |
|
|
if {[grid propagate $itk_component(hull)] != $propagate} {
|
481 |
|
|
grid propagate $itk_component(hull) $propagate
|
482 |
|
|
}
|
483 |
|
|
}
|
484 |
|
|
|
485 |
|
|
# ------------------------------------------------------------------
|
486 |
|
|
# METHODS
|
487 |
|
|
# ------------------------------------------------------------------
|
488 |
|
|
|
489 |
|
|
# ------------------------------------------------------------------
|
490 |
|
|
# METHOD: childsite
|
491 |
|
|
#
|
492 |
|
|
# Returns the path name of the child site widget.
|
493 |
|
|
# ------------------------------------------------------------------
|
494 |
|
|
body iwidgets::Fileselectionbox::childsite {} {
|
495 |
|
|
return $itk_component(childsite)
|
496 |
|
|
}
|
497 |
|
|
|
498 |
|
|
# ------------------------------------------------------------------
|
499 |
|
|
# METHOD: get
|
500 |
|
|
#
|
501 |
|
|
# Returns the current selection.
|
502 |
|
|
# ------------------------------------------------------------------
|
503 |
|
|
body iwidgets::Fileselectionbox::get {} {
|
504 |
|
|
return [$itk_component(selection) get]
|
505 |
|
|
}
|
506 |
|
|
|
507 |
|
|
# ------------------------------------------------------------------
|
508 |
|
|
# METHOD: filter
|
509 |
|
|
#
|
510 |
|
|
# The user has pressed Return in the filter. Make sure the contents
|
511 |
|
|
# contain a valid directory before setting default to directory.
|
512 |
|
|
# Use the invalid option to warn the user of any problems.
|
513 |
|
|
# ------------------------------------------------------------------
|
514 |
|
|
body iwidgets::Fileselectionbox::filter {} {
|
515 |
|
|
set newdir [file dirname [$itk_component(filter) get]]
|
516 |
|
|
|
517 |
|
|
if {! [file exists $newdir]} {
|
518 |
|
|
uplevel #0 "$itk_option(-invalid)"
|
519 |
|
|
return
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
set _pwd $newdir;
|
523 |
|
|
if {$_pwd == "."} {set _pwd [pwd]};
|
524 |
|
|
|
525 |
|
|
_updateLists
|
526 |
|
|
}
|
527 |
|
|
|
528 |
|
|
# ------------------------------------------------------------------
|
529 |
|
|
# PRIVATE METHOD: _updateLists ?now?
|
530 |
|
|
#
|
531 |
|
|
# Updates the contents of both the file and directory lists, as well
|
532 |
|
|
# resets the positions of the filter, and lists.
|
533 |
|
|
# ------------------------------------------------------------------
|
534 |
|
|
body iwidgets::Fileselectionbox::_updateLists {{when "later"}} {
|
535 |
|
|
switch -- $when {
|
536 |
|
|
later {
|
537 |
|
|
if {$_updateToken == ""} {
|
538 |
|
|
set _updateToken [after idle [code $this _updateLists now]]
|
539 |
|
|
}
|
540 |
|
|
}
|
541 |
|
|
now {
|
542 |
|
|
if {$itk_option(-dirson)} {_setDirList}
|
543 |
|
|
if {$itk_option(-fileson)} {_setFileList}
|
544 |
|
|
|
545 |
|
|
if {$itk_option(-filteron)} {
|
546 |
|
|
_setFilter
|
547 |
|
|
}
|
548 |
|
|
if {$itk_option(-selectionon)} {
|
549 |
|
|
$itk_component(selection) icursor end
|
550 |
|
|
}
|
551 |
|
|
if {$itk_option(-dirson)} {
|
552 |
|
|
$itk_component(dirs) justify left
|
553 |
|
|
}
|
554 |
|
|
if {$itk_option(-fileson)} {
|
555 |
|
|
$itk_component(files) justify left
|
556 |
|
|
}
|
557 |
|
|
set _updateToken ""
|
558 |
|
|
}
|
559 |
|
|
default {
|
560 |
|
|
error "bad option \"$when\": should be later or now"
|
561 |
|
|
}
|
562 |
|
|
}
|
563 |
|
|
}
|
564 |
|
|
|
565 |
|
|
# ------------------------------------------------------------------
|
566 |
|
|
# PRIVATE METHOD: _setFilter
|
567 |
|
|
#
|
568 |
|
|
# Set the filter to the current selection in the directory list plus
|
569 |
|
|
# any existing mask in the filter. Translate the two special cases
|
570 |
|
|
# of '.', and '..' directory names to full path names..
|
571 |
|
|
# ------------------------------------------------------------------
|
572 |
|
|
body iwidgets::Fileselectionbox::_setFilter {} {
|
573 |
|
|
global tcl_platform
|
574 |
|
|
set prefix [$itk_component(dirs) getcurselection]
|
575 |
|
|
set curFilter [file tail [$itk_component(filter) get]]
|
576 |
|
|
|
577 |
|
|
while {[regexp {\.$} $prefix]} {
|
578 |
|
|
if {[file tail $prefix] == "."} {
|
579 |
|
|
if {$prefix == "."} {
|
580 |
|
|
if {$_pwd == "."} {
|
581 |
|
|
set _pwd [pwd]
|
582 |
|
|
} elseif {$_pwd == ".."} {
|
583 |
|
|
set _pwd [file dirname [pwd]]
|
584 |
|
|
}
|
585 |
|
|
set prefix $_pwd
|
586 |
|
|
} else {
|
587 |
|
|
set prefix [file dirname $prefix]
|
588 |
|
|
}
|
589 |
|
|
} elseif {[file tail $prefix] == ".."} {
|
590 |
|
|
if {$prefix != ".."} {
|
591 |
|
|
set prefix [file dirname [file dirname $prefix]]
|
592 |
|
|
} else {
|
593 |
|
|
if {$_pwd == "."} {
|
594 |
|
|
set _pwd [pwd]
|
595 |
|
|
} elseif {$_pwd == ".."} {
|
596 |
|
|
set _pwd [file dirname [pwd]]
|
597 |
|
|
}
|
598 |
|
|
set prefix [file dirname $_pwd]
|
599 |
|
|
}
|
600 |
|
|
} else {
|
601 |
|
|
break
|
602 |
|
|
}
|
603 |
|
|
}
|
604 |
|
|
|
605 |
|
|
if { [file pathtype $prefix] != "absolute" } {
|
606 |
|
|
set prefix [file join $_pwd $prefix]
|
607 |
|
|
}
|
608 |
|
|
|
609 |
|
|
#
|
610 |
|
|
# Remove automounter paths.
|
611 |
|
|
#
|
612 |
|
|
if {$tcl_platform(platform) == "unix"} {
|
613 |
|
|
regsub {^/(tmp_mnt|export)} $prefix {} prefix
|
614 |
|
|
}
|
615 |
|
|
|
616 |
|
|
$itk_component(filter) delete 0 end
|
617 |
|
|
$itk_component(filter) insert 0 [file join $prefix $curFilter]
|
618 |
|
|
|
619 |
|
|
#
|
620 |
|
|
# Make sure insertion cursor is at the end.
|
621 |
|
|
#
|
622 |
|
|
$itk_component(filter) icursor end
|
623 |
|
|
|
624 |
|
|
#
|
625 |
|
|
# Make sure the right most text is visable.
|
626 |
|
|
#
|
627 |
|
|
$itk_component(filter) xview moveto 1
|
628 |
|
|
}
|
629 |
|
|
|
630 |
|
|
# ------------------------------------------------------------------
|
631 |
|
|
# PRIVATE METHOD: _setSelection
|
632 |
|
|
#
|
633 |
|
|
# Set the contents of the selection entry to either the current
|
634 |
|
|
# selection of the file or directory list dependent on which lists
|
635 |
|
|
# are currently mapped. For the file list, avoid seleciton of the
|
636 |
|
|
# no match string. As for the directory list, translate file names.
|
637 |
|
|
# ------------------------------------------------------------------
|
638 |
|
|
body iwidgets::Fileselectionbox::_setSelection {} {
|
639 |
|
|
global tcl_platform
|
640 |
|
|
$itk_component(selection) delete 0 end
|
641 |
|
|
|
642 |
|
|
if {$itk_option(-fileson)} {
|
643 |
|
|
set selection [$itk_component(files) getcurselection]
|
644 |
|
|
|
645 |
|
|
if {$selection != $itk_option(-nomatchstring)} {
|
646 |
|
|
if {[file pathtype $selection] != "absolute"} {
|
647 |
|
|
set selection [file join $_pwd $selection]
|
648 |
|
|
}
|
649 |
|
|
|
650 |
|
|
#
|
651 |
|
|
# Remove automounter paths.
|
652 |
|
|
#
|
653 |
|
|
if {$tcl_platform(platform) == "unix"} {
|
654 |
|
|
regsub {^/(tmp_mnt|export)} $selection {} selection;
|
655 |
|
|
}
|
656 |
|
|
|
657 |
|
|
$itk_component(selection) insert 0 $selection
|
658 |
|
|
} else {
|
659 |
|
|
$itk_component(files) selection clear 0 end
|
660 |
|
|
}
|
661 |
|
|
|
662 |
|
|
} else {
|
663 |
|
|
set selection [$itk_component(dirs) getcurselection]
|
664 |
|
|
|
665 |
|
|
if {[file tail $selection] == "."} {
|
666 |
|
|
if {$selection != "."} {
|
667 |
|
|
set selection [file dirname $selection]
|
668 |
|
|
} else {
|
669 |
|
|
set selection $_pwd
|
670 |
|
|
}
|
671 |
|
|
} elseif {[file tail $selection] == ".."} {
|
672 |
|
|
if {$selection != ".."} {
|
673 |
|
|
set selection [file dirname [file dirname $selection]]
|
674 |
|
|
} else {
|
675 |
|
|
set selection [file join $_pwd ..]
|
676 |
|
|
}
|
677 |
|
|
}
|
678 |
|
|
|
679 |
|
|
#
|
680 |
|
|
# Remove automounter paths.
|
681 |
|
|
#
|
682 |
|
|
if {$tcl_platform(platform) == "unix"} {
|
683 |
|
|
regsub {^/(tmp_mnt|export)} $selection {} selection;
|
684 |
|
|
}
|
685 |
|
|
|
686 |
|
|
$itk_component(selection) insert 0 $selection
|
687 |
|
|
}
|
688 |
|
|
|
689 |
|
|
$itk_component(selection) icursor end
|
690 |
|
|
|
691 |
|
|
#
|
692 |
|
|
# Make sure the right most text is visable.
|
693 |
|
|
#
|
694 |
|
|
$itk_component(selection) xview moveto 1
|
695 |
|
|
}
|
696 |
|
|
|
697 |
|
|
# ------------------------------------------------------------------
|
698 |
|
|
# PRIVATE METHOD: _setDirList
|
699 |
|
|
#
|
700 |
|
|
# Clear the directory list and dependent on whether the user has
|
701 |
|
|
# defined their own search procedure or not fill the list with their
|
702 |
|
|
# results or those of a glob. Select the first element if it exists.
|
703 |
|
|
# ------------------------------------------------------------------
|
704 |
|
|
body iwidgets::Fileselectionbox::_setDirList {} {
|
705 |
|
|
$itk_component(dirs) clear
|
706 |
|
|
|
707 |
|
|
if {$itk_option(-dirsearchcommand) == {}} {
|
708 |
|
|
foreach i [lsort [glob -nocomplain \
|
709 |
|
|
[file join $_pwd .*] [file join $_pwd *]]] {
|
710 |
|
|
if {[file isdirectory $i]} {
|
711 |
|
|
$itk_component(dirs) insert end [file tail "$i"]
|
712 |
|
|
}
|
713 |
|
|
}
|
714 |
|
|
|
715 |
|
|
} else {
|
716 |
|
|
set mask [file tail [$itk_component(filter) get]]
|
717 |
|
|
|
718 |
|
|
foreach file [uplevel #0 $itk_option(-dirsearchcommand) $_pwd $mask] {
|
719 |
|
|
$itk_component(dirs) insert end $file
|
720 |
|
|
}
|
721 |
|
|
}
|
722 |
|
|
|
723 |
|
|
if {[$itk_component(dirs) size]} {
|
724 |
|
|
$itk_component(dirs) selection clear 0 end
|
725 |
|
|
$itk_component(dirs) selection set 0
|
726 |
|
|
}
|
727 |
|
|
}
|
728 |
|
|
|
729 |
|
|
# ------------------------------------------------------------------
|
730 |
|
|
# PRIVATE METHOD: _setFileList
|
731 |
|
|
#
|
732 |
|
|
# Clear the file list and dependent on whether the user has defined
|
733 |
|
|
# their own search procedure or not fill the list with their results
|
734 |
|
|
# or those of a 'glob'. If the files list has no contents, then set
|
735 |
|
|
# the files list to the 'nomatchstring'. Clear all selections.
|
736 |
|
|
# ------------------------------------------------------------------
|
737 |
|
|
body iwidgets::Fileselectionbox::_setFileList {} {
|
738 |
|
|
$itk_component(files) clear
|
739 |
|
|
set mask [file tail [$itk_component(filter) get]]
|
740 |
|
|
|
741 |
|
|
if {$itk_option(-filesearchcommand) == {}} {
|
742 |
|
|
if {$mask == "*"} {
|
743 |
|
|
set files [lsort [glob -nocomplain \
|
744 |
|
|
[file join $_pwd .*] [file join $_pwd *]]]
|
745 |
|
|
} else {
|
746 |
|
|
set files [lsort [glob -nocomplain [file join $_pwd $mask]]]
|
747 |
|
|
}
|
748 |
|
|
|
749 |
|
|
foreach i $files {
|
750 |
|
|
if {($itk_option(-filetype) == "regular" && \
|
751 |
|
|
! [file isdirectory $i]) || \
|
752 |
|
|
($itk_option(-filetype) == "directory" && \
|
753 |
|
|
[file isdirectory $i]) || \
|
754 |
|
|
($itk_option(-filetype) == "any")} {
|
755 |
|
|
$itk_component(files) insert end [file tail "$i"]
|
756 |
|
|
}
|
757 |
|
|
}
|
758 |
|
|
|
759 |
|
|
} else {
|
760 |
|
|
foreach file [uplevel #0 $itk_option(-filesearchcommand) $_pwd $mask] {
|
761 |
|
|
$itk_component(files) insert end $file
|
762 |
|
|
}
|
763 |
|
|
}
|
764 |
|
|
|
765 |
|
|
if {[$itk_component(files) size] == 0} {
|
766 |
|
|
if {$itk_option(-nomatchstring) != {}} {
|
767 |
|
|
$itk_component(files) insert end $itk_option(-nomatchstring)
|
768 |
|
|
}
|
769 |
|
|
}
|
770 |
|
|
|
771 |
|
|
$itk_component(files) selection clear 0 end
|
772 |
|
|
}
|
773 |
|
|
|
774 |
|
|
# ------------------------------------------------------------------
|
775 |
|
|
# PRIVATE METHOD: _selectDir
|
776 |
|
|
#
|
777 |
|
|
# For a selection in the directory list, set the filter and possibly
|
778 |
|
|
# the selection entry based on the fileson option.
|
779 |
|
|
# ------------------------------------------------------------------
|
780 |
|
|
body iwidgets::Fileselectionbox::_selectDir {} {
|
781 |
|
|
_setFilter
|
782 |
|
|
|
783 |
|
|
if {$itk_option(-fileson)} {} {
|
784 |
|
|
_setSelection
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
if {$itk_option(-selectdircommand) != {}} {
|
788 |
|
|
uplevel #0 $itk_option(-selectdircommand)
|
789 |
|
|
}
|
790 |
|
|
}
|
791 |
|
|
|
792 |
|
|
# ------------------------------------------------------------------
|
793 |
|
|
# PRIVATE METHOD: _dblSelectDir
|
794 |
|
|
#
|
795 |
|
|
# For a double click event in the directory list, select the
|
796 |
|
|
# directory, set the default to the selection, and update both the
|
797 |
|
|
# file and directory lists.
|
798 |
|
|
# ------------------------------------------------------------------
|
799 |
|
|
body iwidgets::Fileselectionbox::_dblSelectDir {} {
|
800 |
|
|
filter
|
801 |
|
|
}
|
802 |
|
|
|
803 |
|
|
# ------------------------------------------------------------------
|
804 |
|
|
# PRIVATE METHOD: _selectFile
|
805 |
|
|
#
|
806 |
|
|
# The user has selected a file. Put the current selection in the
|
807 |
|
|
# file list in the selection entry widget.
|
808 |
|
|
# ------------------------------------------------------------------
|
809 |
|
|
body iwidgets::Fileselectionbox::_selectFile {} {
|
810 |
|
|
_setSelection
|
811 |
|
|
|
812 |
|
|
if {$itk_option(-selectfilecommand) != {}} {
|
813 |
|
|
uplevel #0 $itk_option(-selectfilecommand)
|
814 |
|
|
}
|
815 |
|
|
}
|
816 |
|
|
|
817 |
|
|
# ------------------------------------------------------------------
|
818 |
|
|
# PRIVATE METHOD: _selectSelection
|
819 |
|
|
#
|
820 |
|
|
# The user has pressed Return in the selection entry widget. Call
|
821 |
|
|
# the defined selection command if it exists.
|
822 |
|
|
# ------------------------------------------------------------------
|
823 |
|
|
body iwidgets::Fileselectionbox::_selectSelection {} {
|
824 |
|
|
if {$itk_option(-selectioncommand) != {}} {
|
825 |
|
|
uplevel #0 $itk_option(-selectioncommand)
|
826 |
|
|
}
|
827 |
|
|
}
|
828 |
|
|
|
829 |
|
|
# ------------------------------------------------------------------
|
830 |
|
|
# PRIVATE METHOD: _selectFilter
|
831 |
|
|
#
|
832 |
|
|
# The user has pressed Return in the filter entry widget. Call the
|
833 |
|
|
# defined selection command if it exists, otherwise just filter.
|
834 |
|
|
# ------------------------------------------------------------------
|
835 |
|
|
body iwidgets::Fileselectionbox::_selectFilter {} {
|
836 |
|
|
if {$itk_option(-filtercommand) != {}} {
|
837 |
|
|
uplevel #0 $itk_option(-filtercommand)
|
838 |
|
|
} else {
|
839 |
|
|
filter
|
840 |
|
|
}
|
841 |
|
|
}
|
842 |
|
|
|
843 |
|
|
# ------------------------------------------------------------------
|
844 |
|
|
# PRIVATE METHOD: _packComponents
|
845 |
|
|
#
|
846 |
|
|
# Pack the selection, items, and child site widgets based on options.
|
847 |
|
|
# Using the -in option of pack, put the childsite around the frame
|
848 |
|
|
# in the hull for n, s, e, and w positions. Make sure and raise
|
849 |
|
|
# the child site since using the 'in' option may obscure the site.
|
850 |
|
|
# ------------------------------------------------------------------
|
851 |
|
|
body iwidgets::Fileselectionbox::_packComponents {{when "later"}} {
|
852 |
|
|
if {$when == "later"} {
|
853 |
|
|
if {$_packToken == ""} {
|
854 |
|
|
set _packToken [after idle [code $this _packComponents now]]
|
855 |
|
|
}
|
856 |
|
|
return
|
857 |
|
|
} elseif {$when != "now"} {
|
858 |
|
|
error "bad option \"$when\": should be now or later"
|
859 |
|
|
}
|
860 |
|
|
|
861 |
|
|
set _packToken ""
|
862 |
|
|
|
863 |
|
|
#
|
864 |
|
|
# Forget about any previous placements via the grid and
|
865 |
|
|
# reset all the possible minsizes and weights for all
|
866 |
|
|
# the rows and columns.
|
867 |
|
|
#
|
868 |
|
|
foreach component {childsite filter dirs files selection} {
|
869 |
|
|
grid forget $itk_component($component)
|
870 |
|
|
}
|
871 |
|
|
|
872 |
|
|
for {set row 0} {$row < 6} {incr row} {
|
873 |
|
|
grid rowconfigure $_interior $row -minsize 0 -weight 0
|
874 |
|
|
}
|
875 |
|
|
|
876 |
|
|
for {set col 0} {$col < 4} {incr col} {
|
877 |
|
|
grid columnconfigure $_interior $col -minsize 0 -weight 0
|
878 |
|
|
}
|
879 |
|
|
|
880 |
|
|
#
|
881 |
|
|
# Place all the components based on the childsite poisition
|
882 |
|
|
# option.
|
883 |
|
|
#
|
884 |
|
|
switch $itk_option(-childsitepos) {
|
885 |
|
|
n { _nPos }
|
886 |
|
|
|
887 |
|
|
w { _wPos }
|
888 |
|
|
|
889 |
|
|
s { _sPos }
|
890 |
|
|
|
891 |
|
|
e { _ePos }
|
892 |
|
|
|
893 |
|
|
center { _centerPos }
|
894 |
|
|
|
895 |
|
|
top { _topPos }
|
896 |
|
|
|
897 |
|
|
bottom { _bottomPos }
|
898 |
|
|
|
899 |
|
|
default {
|
900 |
|
|
error "bad childsitepos option \"$itk_option(-childsitepos)\":\
|
901 |
|
|
should be n, e, s, w, center, top, or bottom"
|
902 |
|
|
}
|
903 |
|
|
}
|
904 |
|
|
}
|
905 |
|
|
|
906 |
|
|
# ------------------------------------------------------------------
|
907 |
|
|
# PRIVATE METHOD: _nPos
|
908 |
|
|
#
|
909 |
|
|
# Position the childsite to the north and all the other components
|
910 |
|
|
# appropriately based on the individual "on" options.
|
911 |
|
|
# ------------------------------------------------------------------
|
912 |
|
|
body iwidgets::Fileselectionbox::_nPos {} {
|
913 |
|
|
grid $itk_component(childsite) -row 0 -column 0 \
|
914 |
|
|
-columnspan 3 -rowspan 1 -sticky nsew
|
915 |
|
|
|
916 |
|
|
if {$itk_option(-filteron)} {
|
917 |
|
|
grid $itk_component(filter) -row 1 -column 0 \
|
918 |
|
|
-columnspan 3 -sticky ew
|
919 |
|
|
grid rowconfigure $_interior 2 -minsize 7
|
920 |
|
|
}
|
921 |
|
|
|
922 |
|
|
if {$itk_option(-dirson)} {
|
923 |
|
|
grid $itk_component(dirs) -row 3 -column 0 \
|
924 |
|
|
-columnspan 1 -sticky nsew
|
925 |
|
|
}
|
926 |
|
|
if {$itk_option(-fileson)} {
|
927 |
|
|
grid $itk_component(files) -row 3 -column 2 \
|
928 |
|
|
-columnspan 1 -sticky nsew
|
929 |
|
|
}
|
930 |
|
|
if {$itk_option(-dirson)} {
|
931 |
|
|
if {$itk_option(-fileson)} {
|
932 |
|
|
grid columnconfigure $_interior 1 -minsize 7
|
933 |
|
|
} else {
|
934 |
|
|
grid configure $itk_component(dirs) -columnspan 3 -column 0
|
935 |
|
|
}
|
936 |
|
|
} else {
|
937 |
|
|
if {$itk_option(-fileson)} {
|
938 |
|
|
grid configure $itk_component(files) -columnspan 3 -column 0
|
939 |
|
|
}
|
940 |
|
|
}
|
941 |
|
|
|
942 |
|
|
grid rowconfigure $_interior 3 -weight 1
|
943 |
|
|
|
944 |
|
|
if {$itk_option(-selectionon)} {
|
945 |
|
|
grid rowconfigure $_interior 4 -minsize 7
|
946 |
|
|
grid $itk_component(selection) -row 5 -column 0 \
|
947 |
|
|
-columnspan 3 -sticky ew
|
948 |
|
|
}
|
949 |
|
|
|
950 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
951 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
952 |
|
|
}
|
953 |
|
|
|
954 |
|
|
# ------------------------------------------------------------------
|
955 |
|
|
# PRIVATE METHOD: _sPos
|
956 |
|
|
#
|
957 |
|
|
# Position the childsite to the south and all the other components
|
958 |
|
|
# appropriately based on the individual "on" options.
|
959 |
|
|
# ------------------------------------------------------------------
|
960 |
|
|
body iwidgets::Fileselectionbox::_sPos {} {
|
961 |
|
|
if {$itk_option(-filteron)} {
|
962 |
|
|
grid $itk_component(filter) -row 0 -column 0 \
|
963 |
|
|
-columnspan 3 -sticky ew
|
964 |
|
|
grid rowconfigure $_interior 1 -minsize 7
|
965 |
|
|
}
|
966 |
|
|
|
967 |
|
|
if {$itk_option(-dirson)} {
|
968 |
|
|
grid $itk_component(dirs) -row 2 -column 0 \
|
969 |
|
|
-columnspan 1 -sticky nsew
|
970 |
|
|
}
|
971 |
|
|
if {$itk_option(-fileson)} {
|
972 |
|
|
grid $itk_component(files) -row 2 -column 2 \
|
973 |
|
|
-columnspan 1 -sticky nsew
|
974 |
|
|
}
|
975 |
|
|
if {$itk_option(-dirson)} {
|
976 |
|
|
if {$itk_option(-fileson)} {
|
977 |
|
|
grid columnconfigure $_interior 1 -minsize 7
|
978 |
|
|
} else {
|
979 |
|
|
grid configure $itk_component(dirs) -columnspan 3 -column 0
|
980 |
|
|
}
|
981 |
|
|
} else {
|
982 |
|
|
if {$itk_option(-fileson)} {
|
983 |
|
|
grid configure $itk_component(files) -columnspan 3 -column 0
|
984 |
|
|
}
|
985 |
|
|
}
|
986 |
|
|
|
987 |
|
|
grid rowconfigure $_interior 2 -weight 1
|
988 |
|
|
|
989 |
|
|
if {$itk_option(-selectionon)} {
|
990 |
|
|
grid rowconfigure $_interior 3 -minsize 7
|
991 |
|
|
grid $itk_component(selection) -row 4 -column 0 \
|
992 |
|
|
-columnspan 3 -sticky ew
|
993 |
|
|
}
|
994 |
|
|
|
995 |
|
|
grid $itk_component(childsite) -row 5 -column 0 \
|
996 |
|
|
-columnspan 3 -rowspan 1 -sticky nsew
|
997 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
998 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
999 |
|
|
}
|
1000 |
|
|
|
1001 |
|
|
# ------------------------------------------------------------------
|
1002 |
|
|
# PRIVATE METHOD: _ePos
|
1003 |
|
|
#
|
1004 |
|
|
# Position the childsite to the east and all the other components
|
1005 |
|
|
# appropriately based on the individual "on" options.
|
1006 |
|
|
# ------------------------------------------------------------------
|
1007 |
|
|
body iwidgets::Fileselectionbox::_ePos {} {
|
1008 |
|
|
if {$itk_option(-filteron)} {
|
1009 |
|
|
grid $itk_component(filter) -row 0 -column 0 \
|
1010 |
|
|
-columnspan 3 -sticky ew
|
1011 |
|
|
grid rowconfigure $_interior 1 -minsize 7
|
1012 |
|
|
}
|
1013 |
|
|
|
1014 |
|
|
if {$itk_option(-dirson)} {
|
1015 |
|
|
grid $itk_component(dirs) -row 2 -column 0 \
|
1016 |
|
|
-columnspan 1 -sticky nsew
|
1017 |
|
|
}
|
1018 |
|
|
if {$itk_option(-fileson)} {
|
1019 |
|
|
grid $itk_component(files) -row 2 -column 2 \
|
1020 |
|
|
-columnspan 1 -sticky nsew
|
1021 |
|
|
}
|
1022 |
|
|
if {$itk_option(-dirson)} {
|
1023 |
|
|
if {$itk_option(-fileson)} {
|
1024 |
|
|
grid columnconfigure $_interior 1 -minsize 7
|
1025 |
|
|
} else {
|
1026 |
|
|
grid configure $itk_component(dirs) -columnspan 3 -column 0
|
1027 |
|
|
}
|
1028 |
|
|
} else {
|
1029 |
|
|
if {$itk_option(-fileson)} {
|
1030 |
|
|
grid configure $itk_component(files) -columnspan 3 -column 0
|
1031 |
|
|
}
|
1032 |
|
|
}
|
1033 |
|
|
|
1034 |
|
|
grid rowconfigure $_interior 2 -weight 1
|
1035 |
|
|
|
1036 |
|
|
if {$itk_option(-selectionon)} {
|
1037 |
|
|
grid rowconfigure $_interior 3 -minsize 7
|
1038 |
|
|
grid $itk_component(selection) -row 4 -column 0 \
|
1039 |
|
|
-columnspan 3 -sticky ew
|
1040 |
|
|
}
|
1041 |
|
|
|
1042 |
|
|
grid $itk_component(childsite) -row 0 -column 3 \
|
1043 |
|
|
-rowspan 5 -columnspan 1 -sticky nsew
|
1044 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
1045 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
1046 |
|
|
}
|
1047 |
|
|
|
1048 |
|
|
# ------------------------------------------------------------------
|
1049 |
|
|
# PRIVATE METHOD: _wPos
|
1050 |
|
|
#
|
1051 |
|
|
# Position the childsite to the west and all the other components
|
1052 |
|
|
# appropriately based on the individual "on" options.
|
1053 |
|
|
# ------------------------------------------------------------------
|
1054 |
|
|
body iwidgets::Fileselectionbox::_wPos {} {
|
1055 |
|
|
grid $itk_component(childsite) -row 0 -column 0 \
|
1056 |
|
|
-rowspan 5 -columnspan 1 -sticky nsew
|
1057 |
|
|
|
1058 |
|
|
if {$itk_option(-filteron)} {
|
1059 |
|
|
grid $itk_component(filter) -row 0 -column 1 \
|
1060 |
|
|
-columnspan 3 -sticky ew
|
1061 |
|
|
grid rowconfigure $_interior 1 -minsize 7
|
1062 |
|
|
}
|
1063 |
|
|
|
1064 |
|
|
if {$itk_option(-dirson)} {
|
1065 |
|
|
grid $itk_component(dirs) -row 2 -column 1 \
|
1066 |
|
|
-columnspan 1 -sticky nsew
|
1067 |
|
|
}
|
1068 |
|
|
if {$itk_option(-fileson)} {
|
1069 |
|
|
grid $itk_component(files) -row 2 -column 3 \
|
1070 |
|
|
-columnspan 1 -sticky nsew
|
1071 |
|
|
}
|
1072 |
|
|
if {$itk_option(-dirson)} {
|
1073 |
|
|
if {$itk_option(-fileson)} {
|
1074 |
|
|
grid columnconfigure $_interior 2 -minsize 7
|
1075 |
|
|
} else {
|
1076 |
|
|
grid configure $itk_component(dirs) -columnspan 3 -column 1
|
1077 |
|
|
}
|
1078 |
|
|
} else {
|
1079 |
|
|
if {$itk_option(-fileson)} {
|
1080 |
|
|
grid configure $itk_component(files) -columnspan 3 -column 1
|
1081 |
|
|
}
|
1082 |
|
|
}
|
1083 |
|
|
|
1084 |
|
|
grid rowconfigure $_interior 2 -weight 1
|
1085 |
|
|
|
1086 |
|
|
if {$itk_option(-selectionon)} {
|
1087 |
|
|
grid rowconfigure $_interior 3 -minsize 7
|
1088 |
|
|
grid $itk_component(selection) -row 4 -column 1 \
|
1089 |
|
|
-columnspan 3 -sticky ew
|
1090 |
|
|
}
|
1091 |
|
|
|
1092 |
|
|
grid columnconfigure $_interior 1 -weight 1
|
1093 |
|
|
grid columnconfigure $_interior 3 -weight 1
|
1094 |
|
|
}
|
1095 |
|
|
|
1096 |
|
|
# ------------------------------------------------------------------
|
1097 |
|
|
# PRIVATE METHOD: _topPos
|
1098 |
|
|
#
|
1099 |
|
|
# Position the childsite below the filter but above the lists and
|
1100 |
|
|
# all the other components appropriately based on the individual
|
1101 |
|
|
# "on" options.
|
1102 |
|
|
# ------------------------------------------------------------------
|
1103 |
|
|
body iwidgets::Fileselectionbox::_topPos {} {
|
1104 |
|
|
if {$itk_option(-filteron)} {
|
1105 |
|
|
grid $itk_component(filter) -row 0 -column 0 \
|
1106 |
|
|
-columnspan 3 -sticky ew
|
1107 |
|
|
}
|
1108 |
|
|
|
1109 |
|
|
grid $itk_component(childsite) -row 1 -column 0 \
|
1110 |
|
|
-columnspan 3 -rowspan 1 -sticky nsew
|
1111 |
|
|
|
1112 |
|
|
if {$itk_option(-dirson)} {
|
1113 |
|
|
grid $itk_component(dirs) -row 2 -column 0 -sticky nsew
|
1114 |
|
|
}
|
1115 |
|
|
if {$itk_option(-fileson)} {
|
1116 |
|
|
grid $itk_component(files) -row 2 -column 2 -sticky nsew
|
1117 |
|
|
}
|
1118 |
|
|
if {$itk_option(-dirson)} {
|
1119 |
|
|
if {$itk_option(-fileson)} {
|
1120 |
|
|
grid columnconfigure $_interior 1 -minsize 7
|
1121 |
|
|
} else {
|
1122 |
|
|
grid configure $itk_component(dirs) -columnspan 3 -column 0
|
1123 |
|
|
}
|
1124 |
|
|
} else {
|
1125 |
|
|
if {$itk_option(-fileson)} {
|
1126 |
|
|
grid configure $itk_component(files) -columnspan 3 -column 0
|
1127 |
|
|
}
|
1128 |
|
|
}
|
1129 |
|
|
|
1130 |
|
|
grid rowconfigure $_interior 2 -weight 1
|
1131 |
|
|
|
1132 |
|
|
if {$itk_option(-selectionon)} {
|
1133 |
|
|
grid rowconfigure $_interior 3 -minsize 7
|
1134 |
|
|
grid $itk_component(selection) -row 4 -column 0 \
|
1135 |
|
|
-columnspan 3 -sticky ew
|
1136 |
|
|
}
|
1137 |
|
|
|
1138 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
1139 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
1140 |
|
|
}
|
1141 |
|
|
|
1142 |
|
|
# ------------------------------------------------------------------
|
1143 |
|
|
# PRIVATE METHOD: _centerPos
|
1144 |
|
|
#
|
1145 |
|
|
# Position the childsite between the lists and all the other
|
1146 |
|
|
# components appropriately based on the individual "on" options.
|
1147 |
|
|
# ------------------------------------------------------------------
|
1148 |
|
|
body iwidgets::Fileselectionbox::_centerPos {} {
|
1149 |
|
|
if {$itk_option(-filteron)} {
|
1150 |
|
|
grid $itk_component(filter) -row 0 -column 0 \
|
1151 |
|
|
-columnspan 3 -sticky ew
|
1152 |
|
|
grid rowconfigure $_interior 1 -minsize 7
|
1153 |
|
|
}
|
1154 |
|
|
|
1155 |
|
|
if {$itk_option(-dirson)} {
|
1156 |
|
|
grid $itk_component(dirs) -row 2 -column 0 \
|
1157 |
|
|
-columnspan 1 -sticky nsew
|
1158 |
|
|
}
|
1159 |
|
|
if {$itk_option(-fileson)} {
|
1160 |
|
|
grid $itk_component(files) -row 2 -column 2 \
|
1161 |
|
|
-columnspan 1 -sticky nsew
|
1162 |
|
|
}
|
1163 |
|
|
grid $itk_component(childsite) -row 2 \
|
1164 |
|
|
-columnspan 1 -rowspan 1 -sticky nsew
|
1165 |
|
|
|
1166 |
|
|
if {$itk_option(-dirson)} {
|
1167 |
|
|
if {$itk_option(-fileson)} {
|
1168 |
|
|
grid configure $itk_component(childsite) -column 1
|
1169 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
1170 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
1171 |
|
|
|
1172 |
|
|
} else {
|
1173 |
|
|
grid configure $itk_component(dirs) -columnspan 2 -column 0
|
1174 |
|
|
grid configure $itk_component(childsite) -column 2
|
1175 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
1176 |
|
|
grid columnconfigure $_interior 1 -weight 1
|
1177 |
|
|
}
|
1178 |
|
|
} else {
|
1179 |
|
|
grid configure $itk_component(childsite) -column 0
|
1180 |
|
|
if {$itk_option(-fileson)} {
|
1181 |
|
|
grid configure $itk_component(files) -columnspan 2 \
|
1182 |
|
|
-column 1
|
1183 |
|
|
grid columnconfigure $_interior 1 -weight 1
|
1184 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
1185 |
|
|
} else {
|
1186 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
1187 |
|
|
}
|
1188 |
|
|
}
|
1189 |
|
|
|
1190 |
|
|
grid rowconfigure $_interior 2 -weight 1
|
1191 |
|
|
|
1192 |
|
|
if {$itk_option(-selectionon)} {
|
1193 |
|
|
grid rowconfigure $_interior 3 -minsize 7
|
1194 |
|
|
grid $itk_component(selection) -row 4 -column 0 \
|
1195 |
|
|
-columnspan 3 -sticky ew
|
1196 |
|
|
}
|
1197 |
|
|
}
|
1198 |
|
|
|
1199 |
|
|
# ------------------------------------------------------------------
|
1200 |
|
|
# PRIVATE METHOD: _bottomPos
|
1201 |
|
|
#
|
1202 |
|
|
# Position the childsite below the lists and above the selection
|
1203 |
|
|
# and all the other components appropriately based on the individual
|
1204 |
|
|
# "on" options.
|
1205 |
|
|
# ------------------------------------------------------------------
|
1206 |
|
|
body iwidgets::Fileselectionbox::_bottomPos {} {
|
1207 |
|
|
if {$itk_option(-filteron)} {
|
1208 |
|
|
grid $itk_component(filter) -row 0 -column 0 \
|
1209 |
|
|
-columnspan 3 -sticky ew
|
1210 |
|
|
grid rowconfigure $_interior 1 -minsize 7
|
1211 |
|
|
}
|
1212 |
|
|
|
1213 |
|
|
if {$itk_option(-dirson)} {
|
1214 |
|
|
grid $itk_component(dirs) -row 2 -column 0 -sticky nsew
|
1215 |
|
|
}
|
1216 |
|
|
if {$itk_option(-fileson)} {
|
1217 |
|
|
grid $itk_component(files) -row 2 -column 2 -sticky nsew
|
1218 |
|
|
}
|
1219 |
|
|
if {$itk_option(-dirson)} {
|
1220 |
|
|
if {$itk_option(-fileson)} {
|
1221 |
|
|
grid columnconfigure $_interior 1 -minsize 7
|
1222 |
|
|
} else {
|
1223 |
|
|
grid configure $itk_component(dirs) -columnspan 3 -column 0
|
1224 |
|
|
}
|
1225 |
|
|
} else {
|
1226 |
|
|
if {$itk_option(-fileson)} {
|
1227 |
|
|
grid configure $itk_component(files) -columnspan 3 -column 0
|
1228 |
|
|
}
|
1229 |
|
|
}
|
1230 |
|
|
grid rowconfigure $_interior 2 -weight 1
|
1231 |
|
|
|
1232 |
|
|
grid $itk_component(childsite) -row 3 -column 0 \
|
1233 |
|
|
-columnspan 3 -rowspan 1 -sticky nsew
|
1234 |
|
|
|
1235 |
|
|
if {$itk_option(-selectionon)} {
|
1236 |
|
|
grid $itk_component(selection) -row 4 -column 0 \
|
1237 |
|
|
-columnspan 3 -sticky ew
|
1238 |
|
|
}
|
1239 |
|
|
|
1240 |
|
|
grid columnconfigure $_interior 0 -weight 1
|
1241 |
|
|
grid columnconfigure $_interior 2 -weight 1
|
1242 |
|
|
}
|