Fixed CDROM_Audio_Seek for non-linux systems.
[wine.git] / tools / wineconf.libs / dirbrowser.tcl
blob735351d4d01d3ac7e2632786563d6fa474c8b16f
1 proc TkW:dirbrowse {pattern patternF mode} {
2 # input arg: initial pattern mode (File or Folder
3 # returns selected folders as a global SelectFolder
4 # or selected file as a global: SelectFile
5 # variable: SelectFolder
7 # You can use WAITbrowse in the calling app to wait
8 # for dirbrowse to exit (set to 0 on exit, or -1 on CANCEL)
9 global WAITbrowse
10 global SelectFolder
11 global SelectFile
12 if {![info exists SelectFile]} {set SelectFile ""}
13 if {![info exists SelectFolder]} {set SelectFolder [pwd]}
14 global ndirs nfiles;set ndirs 0;set nfiles 0
15 global ModeBrowse Restore;set Restore $SelectFolder
16 global FTPcd
17 if {$mode == "local"} {set FTPcd 1} {set FTPcd 0}
18 set ModeBrowse $mode
19 global DIRBROWSE WinBrowse
20 ###################
21 # CREATING WIDGETS
22 ###################
23 if {$mode != "local" } {
24 toplevel .dirbrowse -class Toplevel \
25 -background #feffff
26 wm focusmodel .dirbrowse passive
27 wm geometry .dirbrowse 464x296
28 wm maxsize .dirbrowse 1265 994
29 wm minsize .dirbrowse 1 1
30 wm overrideredirect .dirbrowse 0
31 wm resizable .dirbrowse 1 1
32 wm deiconify .dirbrowse
33 wm title .dirbrowse "TkWine: $DIRBROWSE"
34 set WinBrowse dirbrowse
35 } else {
36 set WinBrowse ftp.browsers.local
37 #frame .$WinBrowse -background #feffff -height 300 -width 464
40 # Lang globals:
41 global FolderSelection OK CANCEL FILTERFOLD FILTERFILES
42 global RESCAN VIEW HELP
43 # Other globals:
44 global BrowsePattern;set BrowsePattern $pattern
45 global BrowsePatternF;set BrowsePatternF $patternF
46 global dirscroll MouseY
49 # label and entrybox for selection:
50 label .$WinBrowse.foldselLab \
51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
52 -relief groove -text $FolderSelection
53 entry .$WinBrowse.foldsel \
54 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
55 -textvariable SelectFolder
56 if {$ModeBrowse == "File"} {
57 .$WinBrowse.foldsel configure -textvar SelectFile
59 # frame for display of currently available folders:
60 frame .$WinBrowse.dirframe \
61 -borderwidth 1 -height 30 -relief sunken -width 30 \
62 -background #dddddd
63 scrollbar .$WinBrowse.dirframe_scr -width 10
64 frame .$WinBrowse.fileframe \
65 -borderwidth 1 -height 30 -relief sunken -width 30
66 scrollbar .$WinBrowse.fileframe_scr -width 10
67 # label/entry for pattern
68 label .$WinBrowse.patternLab \
69 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
70 -relief groove -text $FILTERFOLD
71 entry .$WinBrowse.patternF \
72 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
73 -textvariable BrowsePatternF
74 label .$WinBrowse.patternLabF \
75 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
76 -relief groove -text $FILTERFILES
77 entry .$WinBrowse.pattern \
78 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
79 -textvariable BrowsePattern
80 frame .$WinBrowse.fra25 \
81 -borderwidth 1 -height 30 -relief sunken -width 30
82 menubutton .$WinBrowse.fra25.men26 \
83 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
84 -menu .$WinBrowse.fra25.men26.m -padx 4 -pady 3 -relief ridge -text $VIEW
85 menu .$WinBrowse.fra25.men26.m \
86 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-*
87 button .$WinBrowse.fra25.but28 \
88 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* -padx 9 \
89 -pady 3 -relief ridge -text $HELP
90 button .$WinBrowse.butOK \
91 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* -padx 9 \
92 -pady 3 -text $OK \
93 -command {destroy .$WinBrowse
94 set WAITbrowse 0
95 return "$SelectFolder $SelectFile"
97 button .$WinBrowse.butCANCEL \
98 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* -padx 9 \
99 -pady 3 -text $CANCEL \
100 -command {destroy .$WinBrowse
101 set WAITbrowse -1
102 return "$SelectFolder $SelectFile"
104 button .$WinBrowse.butRESCAN \
105 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* -padx 9 \
106 -pady 3 -text $RESCAN -command {TkW:DisplayCurrentDir $BrowsePattern}
107 ###################
108 # SETTING GEOMETRY
109 ###################
110 global YHeight;set YHeight 170
111 if {$mode !="local" && $mode != "remote"} {
112 place .$WinBrowse.foldselLab \
113 -x 47 -y 270 -width 78 -height 20 -anchor nw -bordermode ignore
114 place .$WinBrowse.foldsel \
115 -x 148 -y 268 -width 290 -height 24 -anchor nw -bordermode ignore
116 place .$WinBrowse.dirframe \
117 -x 5 -y 90 -width 145 -height $YHeight -anchor nw -bordermode ignore
118 place .$WinBrowse.dirframe_scr -x 150 -y 90 -width 17 -height $YHeight
119 place .$WinBrowse.fileframe \
120 -x 180 -y 90 -width 175 -height 170 -anchor nw -bordermode ignore
121 place .$WinBrowse.fileframe_scr -x 355 -y 90 -width 17 -height $YHeight
122 place .$WinBrowse.patternLab \
123 -x 27 -y 60 -width 143 -height 20 -anchor nw -bordermode ignore
124 place .$WinBrowse.pattern \
125 -x 190 -y 58 -width 150 -height 24 -anchor nw -bordermode ignore
126 place .$WinBrowse.patternLabF \
127 -x 27 -y 35 -width 143 -height 20 -anchor nw -bordermode ignore
128 place .$WinBrowse.patternF \
129 -x 190 -y 32 -width 150 -height 24 -anchor nw -bordermode ignore
130 place .$WinBrowse.fra25 \
131 -x 0 -y 1 -width 455 -height 25 -anchor nw -bordermode ignore
132 place .$WinBrowse.fra25.men26 \
133 -x -1 -y 0 -width 67 -height 24 -anchor nw -bordermode ignore
134 place .$WinBrowse.fra25.but28 \
135 -x 397 -y -3 -width 60 -height 28 -anchor nw -bordermode ignore
136 place .$WinBrowse.butOK \
137 -x 380 -y 115 -width 77 -height 28 -anchor nw -bordermode ignore
138 place .$WinBrowse.butCANCEL \
139 -x 380 -y 155 -width 77 -height 28 -anchor nw -bordermode ignore
140 place .$WinBrowse.butRESCAN \
141 -x 380 -y 195 -width 77 -height 28 -anchor nw -bordermode ignore
142 } else {
143 # case of ftp filebrowser ....
145 bind .$WinBrowse.pattern <Return> {.$WinBrowse.butRESCAN invoke}
146 bind .$WinBrowse.patternF <Return> {.$WinBrowse.butRESCAN invoke}
148 place .$WinBrowse.pattern -x 0 -y 3 -width 145 -height 25
149 place .$WinBrowse.patternF -x 163 -y 3 -width 145 -height 25
151 place .$WinBrowse.dirframe -x 0 -y 28 -width 145 -height $YHeight
152 place .$WinBrowse.dirframe_scr -x 145 -y 28 -width 17 -height $YHeight
153 place .$WinBrowse.fileframe -x 163 -y 28 -width 145 -height $YHeight
154 place .$WinBrowse.fileframe_scr -x 308 -y 28 -width 17 -height $YHeight
158 # binding the scrollbar:
159 bind .$WinBrowse.dirframe_scr <ButtonPress> { TkW:ScrollDirs %x %y }
160 bind .$WinBrowse.dirframe_scr <ButtonRelease> { set dirscroll no; grab release .$WinBrowse.dirframe_scr }
161 bind .$WinBrowse.dirframe_scr <Motion> { set MouseY %y }
163 bind .$WinBrowse.fileframe_scr <ButtonPress> { TkW:ScrollFiles %x %y }
164 bind .$WinBrowse.fileframe_scr <ButtonRelease> { set filescroll no; grab release .$WinBrowse.fileframe_scr }
165 bind .$WinBrowse.fileframe_scr <Motion> { set MouseY %y }
167 global TKW
168 image create photo "fold" -file \
169 $TKW/shared/icons/smalls/small_folder_yellow.gif
170 image create photo "unknown" -file \
171 $TKW/shared/icons/smalls/unknown.gif
172 image create photo "execfile" -file \
173 $TKW/shared/icons/smalls/exec.gif
174 image create photo "imgfile" -file \
175 $TKW/shared/icons/smalls/xpaint.gif
176 image create photo "htmlfile" -file \
177 $TKW/shared/icons/smalls/html.gif
178 #image create photo "up" -file $TKW/shared/icons/up.gif
179 TkW:DisplayCurrentDir $BrowsePattern
182 proc TkW:DisplayCurrentDir {BrowsePattern} {
184 global ndirs nfiles Ybase dirlist filelist FYbase specialwhere
185 global FYbase BrowsePatternF ModeBrowse
186 DestroyDirs
187 set ndirs 0
188 set dirlist ""
189 set filelist ""
191 # First we get the directory list:
193 if {$ModeBrowse != "remote"} {
194 set fileList ""
195 set fileList [glob -nocomplain [pwd]/$BrowsePattern]
196 set fileList "$fileList [glob -nocomplain [pwd]/.$BrowsePattern]"
197 set UpLevel 0
198 foreach i $fileList {
199 if {[file tail $i] == ".."} {set UpLevel 1}
200 if { [file isdir $i] } { set dirlist "$dirlist \"$i\"" }
202 set fileList ""
203 set fileList [glob -nocomplain [pwd]/$BrowsePatternF]
204 set fileList "$fileList [glob -nocomplain [pwd]/.$BrowsePatternF]"
205 foreach i $fileList {
206 if { ![file isdir $i] } { set filelist "$filelist \"$i\"" }
208 if {$UpLevel == 0} {set dirlist ".. $dirlist"}
209 set dirlist [lsort $dirlist]
210 set filelist [lsort $filelist]
211 } else {set filelist ""; set dirlist ".."}
212 set Ybase 5
213 set FYbase 5
214 TkW:ShowDirs
215 TkW:ShowFiles
218 proc TkW:ShowDirs {} {
219 global dirlist ndirs
220 DestroyDirs
221 set ndirs 0
222 set showedIn 0
223 set showedbelow 0
224 set showedabove 0
225 foreach i $dirlist {
226 set inout [TkW:showdir $i]
227 if {$inout == 0} {set showedIn [expr $showedIn + 1]}
228 if {$inout == -1} {set showedabove [expr $showedabove + 1]}
229 if {$inout == 1} {set showedbelow [expr $showedbelow + 1]}
231 # Scrollbars management:
232 TkW:DirBrowseScroll [expr (100.*$showedabove/$ndirs)/100.] \
233 [expr 1. - (100.*$showedbelow/$ndirs)/100.]
234 update
237 proc TkW:DirBrowseScroll { y1 y2} {
238 global SliderY1 SliderY2 WinBrowse
239 set SliderY1 $y1
240 set SliderY2 $y2
241 .$WinBrowse.dirframe_scr set $y1 $y2
243 proc TkW:FileBrowseScroll { y1 y2} {
244 global FSliderY1 FSliderY2 WinBrowse
245 set FSliderY1 $y1
246 set FSliderY2 $y2
247 .$WinBrowse.fileframe_scr set $y1 $y2
249 proc TkW:hilightFold {y} {
251 global YDIRS ndirs DIRS SelectNum WinBrowse
252 global SelectFolder BrowsePattern FTPcd
254 if { $y > $YDIRS($ndirs)} {set num $ndirs} else {
255 set i 1
256 set ok 0
257 while {$ok == 0} {
258 if {
259 $YDIRS($i) < $y &&\
260 $y <= $YDIRS([expr $i + 1])} {
261 set num $i
262 set ok 1
263 } else { set i [expr $i + 1] }
268 if {$SelectFolder == $DIRS($num)} {
269 cd $SelectFolder
270 if {$FTPcd == 1} {FTP_Lcd $SelectFolder}
271 set SelectFolder [pwd]
272 TkW:DisplayCurrentDir $BrowsePattern
273 unset SelectNum
274 } else {
275 .$WinBrowse.dirframe.label$num configure -background #ffffff
276 set SelectFolder $DIRS($num)
277 if {[info exists SelectNum]} {
278 .$WinBrowse.dirframe.label$SelectNum configure \
279 -background #dddddd
281 set SelectNum $num
284 update
287 proc TkW:showdir {fulldirname} {
288 global TKW ndirs Ybase YHeight YDIRS DIRS Ydecal ModeBrowse WinBrowse
289 set Ydecal 20
290 set dirname [file tail $fulldirname]
291 if {$dirname == "."} return
292 set Y [expr $Ybase + $ndirs * $Ydecal]
293 set In 0
294 if {$Y < 0 } {set In -1}
295 if {$Y > [expr $YHeight - $Ydecal]} { set In 1 }
298 set ndirs [expr $ndirs + 1]
299 set YDIRS($ndirs) $Y
300 set DIRS($ndirs) $fulldirname
301 label .$WinBrowse.dirframe.icon$ndirs -image fold
302 label .$WinBrowse.dirframe.label$ndirs -text $dirname\
303 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-*
305 if {$In == 0} {
306 place .$WinBrowse.dirframe.icon$ndirs -x 5 -y $Y
307 place .$WinBrowse.dirframe.label$ndirs -x 30 -y $Y
310 #dirframe bindings
311 bind .$WinBrowse.dirframe.icon$ndirs <Button-1> {
312 set Y [expr %Y - [winfo rooty .$WinBrowse.dirframe] -$Ybase]
313 TkW:hilightFold $Y
315 #dirframe bindings
316 bind .$WinBrowse.dirframe.label$ndirs <ButtonPress-1> {
317 set Y [expr %Y - [winfo rooty .$WinBrowse.dirframe] -$Ybase]
318 TkW:hilightFold $Y
320 return $In
323 proc TkW:ScrollDirs {X Y} {
325 global Ybase Ydecal ndirs dirscroll global nextLoop MouseY WinBrowse
326 global SliderY1 SliderY2 YHeight Nabove Nbelow
328 set MinBase [expr -$Ydecal * ($ndirs - [expr $YHeight/$Ydecal])]
329 set Slider1 $SliderY1
330 set Slider2 $SliderY2
331 set MaxSlide1 [expr 1-($SliderY2-$SliderY1)]
332 set MinSlide2 [expr $SliderY2-$SliderY1]
333 switch [.$WinBrowse.dirframe_scr identify $X $Y] {
335 {arrow1} { set dirscroll UP; set modeUP 1}
336 {arrow2} { set dirscroll DOWN;set modeDOWN 1}
337 {slider} {set dirscroll SLIDER}
338 {trough1} {set dirscroll UP; set modeUP page}
339 {trough2} {set dirscroll DOWN;set modeDOWN page}
341 while {$dirscroll == "UP"} {
342 if {$modeUP == "1"} {set XUP 1} {
343 set XUP [expr ($YHeight/$Ydecal ) -1]
345 set Ybase [expr $Ybase + $XUP * $Ydecal]
346 if {$Ybase > $Ydecal} {
347 set Ybase 5
348 set dirscroll no
349 set Slider1 0
350 set Slider2 $MinSlide2
352 TkW:ReShowDirs
353 TkW:DirBrowseScroll [expr (100.*$Nabove/$ndirs)/100.] \
354 [expr 1. - (100.*$Nbelow/$ndirs)/100.]
355 set nextLoop 0
356 after 30 {set nextLoop 1}
357 while {$nextLoop == 0} {update}
358 set Slider1 $SliderY1
359 set Slider2 $SliderY2
361 while {$dirscroll == "DOWN"} {
362 if {$modeDOWN == "1"} {set XDOWN 1} {
363 set XDOWN [expr ($YHeight/$Ydecal ) -1]
365 set Ybase [expr $Ybase - $XDOWN * $Ydecal]
366 if {$Ybase < $MinBase} {
367 set Ybase $MinBase
368 set dirscroll no
369 set Slider2 1
370 set Slider1 $MaxSlide1
372 TkW:ReShowDirs
373 TkW:DirBrowseScroll [expr (100.*$Nabove/$ndirs)/100.] \
374 [expr 1. - (100.*$Nbelow/$ndirs)/100.]
375 set nextLoop 0
376 after 30 {set nextLoop 1}
377 while {$nextLoop == 0} {update}
378 set Slider1 $SliderY1
379 set Slider2 $SliderY2
381 while {$dirscroll == "SLIDER"} {
382 set nextLoop 0
383 after 20 {set nextLoop 1}
384 while {$nextLoop == 0} {
385 set Delta [expr (100.*($MouseY - $Y)/$YHeight)/100. ]
386 set Slider1 [expr $SliderY1 +$Delta]
387 set Slider2 [expr $SliderY2 +$Delta]
388 if {$Slider2 > 1} {
389 set Slider2 1
390 set Slider1 $MaxSlide1
392 if {$Slider1 < 0} {
393 set Slider1 0
394 set Slider2 $MinSlide2
396 .$WinBrowse.dirframe_scr set $Slider1 $Slider2
397 set Ybase [expr 5 - $Slider1 * $ndirs *$Ydecal]
398 TkW:ReShowDirs
399 update
402 set SliderY1 $Slider1
403 set SliderY2 $Slider2
405 proc TkW:ScrollFiles {X Y} {
407 global FYbase Ydecal nfiles filescroll nextLoop MouseY WinBrowse
408 global FSliderY1 FSliderY2 YHeight NFabove NFbelow
410 set MinBase [expr -$Ydecal * ($nfiles - [expr $YHeight/$Ydecal])]
411 set FSlider1 $FSliderY1
412 set FSlider2 $FSliderY2
413 set MaxSlide1 [expr 1-($FSliderY2-$FSliderY1)]
414 set MinSlide2 [expr $FSliderY2-$FSliderY1]
415 switch [.$WinBrowse.fileframe_scr identify $X $Y] {
417 {arrow1} { set filescroll UP; set modeUP 1}
418 {arrow2} { set filescroll DOWN;set modeDOWN 1}
419 {slider} {set filescroll SLIDER}
420 {trough1} {set filescroll UP; set modeUP page}
421 {trough2} {set filescroll DOWN;set modeDOWN page}
423 while {$filescroll == "UP"} {
424 if {$modeUP == "1"} {set XUP 1} {
425 set XUP [expr ($YHeight/$Ydecal ) -1]
427 set FYbase [expr $FYbase + $XUP * $Ydecal]
428 if {$FYbase > $Ydecal} {
429 set FYbase 5
430 set filescroll no
431 set FSlider1 0
432 set FSlider2 $MinSlide2
434 TkW:ReShowFiles
435 if {$nfiles != 0} {
436 TkW:FileBrowseScroll [expr (100.*$NFabove/$nfiles)/100.] \
437 [expr 1. - (100.*$NFbelow/$nfiles)/100.]
438 } else {
439 TkW:FileBrowseScroll 0 1
441 set nextLoop 0
442 after 30 {set nextLoop 1}
443 while {$nextLoop == 0} {update}
444 set FSlider1 $FSliderY1
445 set FSlider2 $FSliderY2
447 while {$filescroll == "DOWN"} {
448 if {$modeDOWN == "1"} {set XDOWN 1} {
449 set XDOWN [expr ($YHeight/$Ydecal ) -1]
451 set FYbase [expr $FYbase - $XDOWN * $Ydecal]
452 if {$FYbase < $MinBase} {
453 set FYbase $MinBase
454 set filescroll no
455 set FSlider2 1
456 set FSlider1 $MaxSlide1
458 TkW:ReShowFiles
459 if {$nfiles != 0} {
460 TkW:FileBrowseScroll [expr (100.*$NFabove/$nfiles)/100.] \
461 [expr 1. - (100.*$NFbelow/$nfiles)/100.]
462 } else {
463 TkW:FileBrowseScroll 0 1
465 set nextLoop 0
466 after 30 {set nextLoop 1}
467 while {$nextLoop == 0} {update}
468 set FSlider1 $FSliderY1
469 set FSlider2 $FSliderY2
471 while {$filescroll == "SLIDER"} {
472 set nextLoop 0
473 after 20 {set nextLoop 1}
474 while {$nextLoop == 0} {
475 set Delta [expr (100.*($MouseY - $Y)/$YHeight)/100. ]
476 set FSlider1 [expr $FSliderY1 +$Delta]
477 set FSlider2 [expr $FSliderY2 +$Delta]
478 if {$FSlider2 > 1} {
479 set FSlider2 1
480 set FSlider1 $MaxSlide1
482 if {$FSlider1 < 0} {
483 set FSlider1 0
484 set FSlider2 $MinSlide2
486 .$WinBrowse.fileframe_scr set $FSlider1 $FSlider2
487 set FYbase [expr 5 - $FSlider1 * $nfiles *$Ydecal]
488 TkW:ReShowFiles
489 update
492 set FSliderY1 $FSlider1
493 set FSliderY2 $FSlider2
496 proc TkW:ReShowDirs {} {
497 global dirlist Ybase Ydecal ndirs YHeight WinBrowse
498 global Nabove Nbelow
499 set n 0
500 set Nabove 0
501 set Nbelow 0
502 foreach i $dirlist {
503 set dirname [file tail $i]
504 if {$dirname != "."} {
505 set Y0 [expr $Ybase + $n * $Ydecal]
506 if {$Y0 < -5} {set Nabove [expr $Nabove + 1]}
507 if {$Y0 > [expr $YHeight - $Ydecal]} { set Nbelow [expr $Nbelow + 1]}
508 set n [expr $n + 1]
509 place .$WinBrowse.dirframe.icon$n -x 5 -y $Y0
510 place .$WinBrowse.dirframe.label$n -x 30 -y $Y0
514 proc TkW:ReShowFiles {} {
515 global filelist FYbase Ydecal nfiles YHeight WinBrowse
516 global NFabove NFbelow
517 set n 0
518 set NFabove 0
519 set NFbelow 0
520 foreach i $filelist {
521 set filename [file tail $i]
522 if {$filename != "."} {
523 set Y0 [expr $FYbase + $n * $Ydecal]
524 if {$Y0 < -5} {set NFabove [expr $NFabove + 1]}
525 if {$Y0 > [expr $YHeight - $Ydecal]} { set NFbelow [expr $NFbelow + 1]}
526 set n [expr $n + 1]
527 place .$WinBrowse.fileframe.icon$n -x 5 -y $Y0
528 place .$WinBrowse.fileframe.label$n -x 30 -y $Y0
533 proc TkW:ShowFiles {} {
534 global filelist nfiles
535 DestroyFiles
536 set nfiles 0
537 set FshowedIn 0
538 set NFbelow 0
539 set NFabove 0
540 foreach i $filelist {
541 set inout [TkW:showfile $i]
542 if {$inout == 0} {set FshowedIn [expr $FshowedIn + 1]}
543 if {$inout == -1} {set NFabove [expr $NFabove + 1]}
544 if {$inout == 1} {set NFbelow [expr $NFbelow + 1]}
546 # Scrollbar management:
547 if {$nfiles != 0} {
548 TkW:FileBrowseScroll [expr (100.*$NFabove/$nfiles)/100.] \
549 [expr 1. - (100.*$NFbelow/$nfiles)/100.]
550 } else {
551 TkW:FileBrowseScroll 0 1
555 proc TkW:showfile {fullfilename} {
556 global TKW nfiles FYbase YHeight YFILES Ydecal FILES
557 set Y [expr $FYbase + $nfiles * $Ydecal]
558 set In 0
559 if {$Y < 0 } {set In -1}
560 if {$Y > [expr $YHeight - $Ydecal]} { set In 1 }
563 set nfiles [expr $nfiles + 1]
564 set YFILES($nfiles) $Y
565 set FILES($nfiles) $fullfilename
566 createPlaceFileIcon $nfiles $Y
567 return $In
569 proc createPlaceFileIcon {n Y} {
570 global FILES ModeBrowse WinBrowse
571 set fullfilename $FILES($n)
572 set icon unknown
573 if {[file executable $fullfilename]} {set icon execfile}
574 if {[file extension $fullfilename] == ".html"} {set icon htmlfile}
575 if {[file extension $fullfilename] == ".htm"} {set icon htmlfile}
576 if {[file extension $fullfilename] == ".gif"} {set icon imgfile}
577 if {[file extension $fullfilename] == ".jpg"} {set icon imgfile}
578 set filename [file tail $fullfilename]
579 label .$WinBrowse.fileframe.icon$n -image $icon
580 label .$WinBrowse.fileframe.label$n -text $filename\
581 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-*\
582 -background #dddddd
584 place .$WinBrowse.fileframe.icon$n -x 5 -y $Y
585 place .$WinBrowse.fileframe.label$n -x 30 -y $Y
587 if {$ModeBrowse == "File"} {
588 #fileframe bindings
589 bind .$WinBrowse.fileframe.icon$n <Button-1> {
590 set Y [expr %Y - [winfo rooty .$WinBrowse.fileframe] -$FYbase]
591 TkW:hilightFile $Y
593 bind .$WinBrowse.fileframe.icon$n <Double-Button-1> {
594 destroy .$WinBrowse
595 set WAITbrowse 0
596 return "$SelectFolder $SelectFile"
598 #fileframe bindings
599 bind .$WinBrowse.fileframe.label$n <ButtonPress-1> {
600 set Y [expr %Y - [winfo rooty .$WinBrowse.fileframe] -$FYbase]
601 TkW:hilightFile $Y
603 bind .$WinBrowse.fileframe.label$n <Double-Button-1> {
604 destroy .$WinBrowse
605 set WAITbrowse 0
606 return "$SelectFolder $SelectFile"
611 proc DestroyDirs {} {
612 global ndirs WinBrowse
614 for {set i 1} {$i <= $ndirs} {set i [expr $i + 1 ]} {
615 if {[winfo exists .$WinBrowse.dirframe.icon$i]} {
616 destroy .$WinBrowse.dirframe.icon$i
617 destroy .$WinBrowse.dirframe.label$i
621 proc DestroyFiles {} {
622 global nfiles WinBrowse
624 for {set i 1} {$i <= $nfiles} {set i [expr $i + 1 ]} {
625 if {[winfo exists .$WinBrowse.fileframe.icon$i]} {
626 destroy .$WinBrowse.fileframe.icon$i
627 destroy .$WinBrowse.fileframe.label$i
632 proc TkW:hilightFile {y} {
634 global YFILES nfiles FILES SelectNumF WinBrowse
635 global SelectFile BrowsePattern
637 if { $y > $YFILES($nfiles)} {set num $nfiles} else {
638 set i 1
639 set ok 0
640 while {$ok == 0} {
641 if {
642 $YFILES($i) < $y &&\
643 $y <= $YFILES([expr $i + 1])} {
644 set num $i
645 set ok 1
646 } else { set i [expr $i + 1] }
651 if {$SelectFile == $FILES($num)} {
652 return
653 } else {
654 .$WinBrowse.fileframe.label$num configure -background #ffffff
655 set SelectFile $FILES($num)
656 if {[info exists SelectNumF]} {
657 .$WinBrowse.fileframe.label$SelectNumF configure -background #dddddd
659 set SelectNumF $num
662 update