|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc RunSample {w} { |
|
set top [frame $w.f -bd 1 -relief raised] |
|
set box [tixButtonBox $w.b -bd 1 -relief raised] |
|
|
|
pack $box -side bottom -fill both |
|
pack $top -side top -fill both -expand yes |
|
|
|
|
|
|
|
set p [tixPanedWindow $top.p -orient horizontal] |
|
pack $p -expand yes -fill both -padx 4 -pady 4 |
|
|
|
set p1 [$p add pane1 -expand 1] |
|
set p2 [$p add pane2 -expand 4] |
|
|
|
$p1 config -relief flat |
|
$p2 config -relief flat |
|
|
|
|
|
|
|
tixDirTree $p1.dirtree -options { |
|
hlist.width 28 |
|
} |
|
|
|
pack $p1.dirtree -expand yes -fill both -padx 4 -pady 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
tixScrolledTList $p2.st -options { |
|
tlist.orient vertical |
|
tlist.selectMode single |
|
tlist.width 60 |
|
tlist.height 25 |
|
} |
|
pack $p2.st -expand yes -fill both -padx 4 -pady 4 |
|
|
|
set tlist [$p2.st subwidget tlist] |
|
|
|
|
|
|
|
$p1.dirtree config \ |
|
-browsecmd [list TList:listdir $tlist] \ |
|
-command [list TList:listdir $tlist] |
|
|
|
|
|
|
|
TList:listdir $tlist [pwd] |
|
|
|
|
|
|
|
$box add ok -text Ok -command [list destroy $w] -width 6 |
|
$box add cancel -text Cancel -command [list destroy $w] -width 6 |
|
} |
|
|
|
proc TList:listdir {w dir} { |
|
$w delete 0 end |
|
|
|
if {[catch {glob -nocomplain -directory $dir *} entries]} { |
|
|
|
|
|
return |
|
} |
|
|
|
set files "" |
|
foreach fname [lsort -dictionary $entries] { |
|
if {[file isdirectory $fname]} { |
|
set image [tix getimage folder] |
|
} else { |
|
lappend files [file tail $fname] |
|
continue |
|
} |
|
$w insert end -itemtype imagetext \ |
|
-text [file tail $fname] -image $image |
|
} |
|
|
|
foreach fname $files { |
|
switch -glob -- $fname { |
|
{*.[ch]} { set image [tix getimage srcfile] } |
|
*.tcl - |
|
*.o { set image [tix getimage file] } |
|
default { set image [tix getimage textfile] } |
|
} |
|
$w insert end -itemtype imagetext -text $fname -image $image |
|
} |
|
} |
|
|
|
|
|
if {![info exists tix_demo_running]} { |
|
wm withdraw . |
|
set w .demo |
|
toplevel $w; wm transient $w "" |
|
RunSample $w |
|
bind $w <Destroy> exit |
|
} |
|
|