diff options
author | treectrl <treectrl> | 2006-11-23 22:24:56 (GMT) |
---|---|---|
committer | treectrl <treectrl> | 2006-11-23 22:24:56 (GMT) |
commit | ba58be95010e7a8fef177ea8f96c408371f7d82d (patch) | |
tree | 0502a17ce9ecc1e154bb7f01b0406e3a590efa99 /demos/demo.tcl | |
parent | 0a730735d7727e045df33ef8be54ca434aa81143 (diff) | |
download | tktreectrl-ba58be95010e7a8fef177ea8f96c408371f7d82d.zip tktreectrl-ba58be95010e7a8fef177ea8f96c408371f7d82d.tar.gz tktreectrl-ba58be95010e7a8fef177ea8f96c408371f7d82d.tar.bz2 |
Added [DemoList] command to get the name of the main list rather than hard-coding .f2.f1.t everywhere.
Diffstat (limited to 'demos/demo.tcl')
-rw-r--r-- | demos/demo.tcl | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/demos/demo.tcl b/demos/demo.tcl index 7113f43..01503df 100644 --- a/demos/demo.tcl +++ b/demos/demo.tcl @@ -1,6 +1,6 @@ #!/bin/wish84.exe -# RCS: @(#) $Id: demo.tcl,v 1.55 2006/11/22 03:31:42 treectrl Exp $ +# RCS: @(#) $Id: demo.tcl,v 1.56 2006/11/23 22:24:56 treectrl Exp $ set VERSION 2.2 @@ -325,17 +325,17 @@ proc MakeEventsWindow {} { return } proc RebuildEventsMenus {T m} { - foreach event [lsort -dictionary [.f2.f1.t notify eventnames]] { - set details [lsort -dictionary [.f2.f1.t notify detailnames $event]] + foreach event [lsort -dictionary [[DemoList] notify eventnames]] { + set details [lsort -dictionary [[DemoList] notify detailnames $event]] foreach detail $details { set pattern <$event-$detail> - set linkage [.f2.f1.t notify linkage $pattern] + set linkage [[DemoList] notify linkage $pattern] lappend patterns $pattern $linkage lappend patterns2($linkage) $pattern } if {![llength $details]} { set pattern <$event> - set linkage [.f2.f1.t notify linkage $pattern] + set linkage [[DemoList] notify linkage $pattern] lappend patterns $pattern $linkage lappend patterns2($linkage) $pattern } @@ -362,7 +362,7 @@ proc RebuildEventsMenus {T m} { set ::Events {} set ::EventsId "" foreach {pattern linkage} $patterns { - .f2.f1.t notify bind $T $pattern { + [DemoList] notify bind $T $pattern { lappend Events %? if {$EventsId eq ""} { set EventsId [after idle [list RecordEvents %W]] @@ -423,7 +423,7 @@ proc ToggleEventsWindow {} { return } proc ToggleEvent {T pattern} { - .f2.f1.t notify configure $T $pattern -active $::EventTrack($pattern) + [DemoList] notify configure $T $pattern -active $::EventTrack($pattern) return } proc ToggleEvents {T patterns} { @@ -440,8 +440,8 @@ proc MakeIdentifyWindow {} { wm withdraw $w wm title $w "TkTreeCtrl Identify" set wText $w.text - text $wText -state disabled -width 50 -height 2 -font [.f2.f1.t cget -font] - $wText tag configure tagBold -font "[.f2.f1.t cget -font] bold" + text $wText -state disabled -width 50 -height 2 -font [[DemoList] cget -font] + $wText tag configure tagBold -font "[[DemoList] cget -font] bold" pack $wText -expand yes -fill both wm protocol $w WM_DELETE_WINDOW "ToggleIdentifyWindow" return @@ -538,7 +538,7 @@ proc ToggleStyleEditorWindow {} { set w .styleEditor if {![winfo exists $w]} { source [Path style-editor.tcl] - StyleEditor::Init .f2.f1.t + StyleEditor::Init [DemoList] StyleEditor::SetListOfStyles } elseif {[winfo ismapped $w]} { wm withdraw $w @@ -788,11 +788,11 @@ proc MakeMainWindow {} { # Tree + scrollbars TreePlusScrollbarsInAFrame .f2.f1 1 1 - .f2.f1.t configure -indent 19 + [DemoList] configure -indent 19 # Give it a big border to debug drawing if {!$::tileFull} { - .f2.f1.t configure -borderwidth 6 -relief ridge -highlightthickness 3 + [DemoList] configure -borderwidth 6 -relief ridge -highlightthickness 3 } grid columnconfigure .f2 0 -weight 1 @@ -801,16 +801,16 @@ proc MakeMainWindow {} { # Window to display result of "T identify" bind TagIdentify <Motion> { - if {"%W" ne ".f2.f1.t"} { - set x [expr {%X - [winfo rootx .f2.f1.t]}] - set y [expr {%Y - [winfo rooty .f2.f1.t]}] + if {"%W" ne [DemoList]} { + set x [expr {%X - [winfo rootx [DemoList]]}] + set y [expr {%Y - [winfo rooty [DemoList]]}] } else { set x %x set y %y } - UpdateIdentifyWindow .f2.f1.t $x $y + UpdateIdentifyWindow [DemoList] $x $y } - AddBindTag .f2.f1.t TagIdentify + AddBindTag [DemoList] TagIdentify .pw2 add .pw1 -width 200 .pw2 add .f2 -width 450 @@ -833,24 +833,28 @@ proc MakeMainWindow {} { # generated by the "notify generate" command. The following events # are generated by the library scripts. - .f2.f1.t notify install <Header-invoke> + [DemoList] notify install <Header-invoke> - .f2.f1.t notify install <ColumnDrag-begin> - .f2.f1.t notify install <ColumnDrag-end> - .f2.f1.t notify install <ColumnDrag-receive> + [DemoList] notify install <ColumnDrag-begin> + [DemoList] notify install <ColumnDrag-end> + [DemoList] notify install <ColumnDrag-receive> - .f2.f1.t notify install <Drag-begin> - .f2.f1.t notify install <Drag-end> - .f2.f1.t notify install <Drag-receive> + [DemoList] notify install <Drag-begin> + [DemoList] notify install <Drag-end> + [DemoList] notify install <Drag-receive> - .f2.f1.t notify install <Edit-begin> - .f2.f1.t notify install <Edit-end> - .f2.f1.t notify install <Edit-accept> + [DemoList] notify install <Edit-begin> + [DemoList] notify install <Edit-end> + [DemoList] notify install <Edit-accept> ### return } +proc DemoList {} { + return .f2.f1.t +} + proc MakeListPopup {T} { set m [menu $T.mTree -tearoff no] @@ -1117,7 +1121,7 @@ proc ShowPopup {T x y X Y} { # Allow "scan" bindings if {$::thisPlatform eq "windows"} { - bind .f2.f1.t <Control-ButtonPress-3> { } + bind [DemoList] <Control-ButtonPress-3> { } } # @@ -1186,8 +1190,8 @@ proc DemoSet {cmd file} { uplevel #0 $cmd set clicks [expr {[clock clicks] - $clicks}] dbwin "set list in [ClicksToSeconds $clicks] seconds ($clicks clicks)\n" - .f2.f1.t xview moveto 0 - .f2.f1.t yview moveto 0 + [DemoList] xview moveto 0 + [DemoList] yview moveto 0 update DisplayStylesInList ShowSource $file @@ -1196,7 +1200,7 @@ proc DemoSet {cmd file} { StyleEditor::SetListOfStyles } } - AddBindTag .f2.f1.t TagIdentify + AddBindTag [DemoList] TagIdentify return } @@ -1209,7 +1213,7 @@ proc DemoSet {cmd file} { proc DisplayStylesInList {} { - set T .f2.f1.t + set T [DemoList] set t .f4.t # Create elements and styles the first time this is called @@ -1286,7 +1290,7 @@ proc DisplayStylesInList {} { proc DisplayStylesInItem {item} { - set T .f2.f1.t + set T [DemoList] set t .f3.t $t column configure C0 -text "Styles in item [$T item id $item]" @@ -1368,7 +1372,7 @@ proc DisplayStylesInItem {item} { # When one item is selected in the demo list, display the styles in that item. # See DemoClear for why the tag "DontDelete" is used. -.f2.f1.t notify bind DontDelete <Selection> { +[DemoList] notify bind DontDelete <Selection> { if {%c == 1} { DisplayStylesInItem [%T selection get 0] } @@ -1376,19 +1380,22 @@ proc DisplayStylesInItem {item} { # Move columns when ColumnDrag-receive is generated. # See DemoClear for why the tag "DontDelete" is used. -.f2.f1.t notify bind DontDelete <ColumnDrag-receive> { +[DemoList] notify bind DontDelete <ColumnDrag-receive> { %T column move %C %b } proc DemoClear {} { - set T .f2.f1.t + set T [DemoList] # Clear the demo list $T item delete all # Clear all bindings on the demo list added by the previous demo. - # This is why DontDelete is used for some bindings (see above). + # The bindings are removed from the tag $T only. For those + # bindings that should not be deleted we use the tag DontDelete. + # DontDelete is not a special name it just needs to be different + # than $T. $T notify unbind $T # Clear all run-time states @@ -1448,7 +1455,7 @@ proc DemoClear {} { # proc DemoPictureCatalog {} { - set T .f2.f1.t + set T [DemoList] $T configure -showroot no -showbuttons no -showlines no \ -selectmode multiple -orient horizontal -wrap window \ @@ -1481,7 +1488,7 @@ proc DemoPictureCatalog {} { # proc DemoPictureCatalog2 {} { - set T .f2.f1.t + set T [DemoList] $T configure -showroot no -showbuttons no -showlines no \ -selectmode multiple -orient horizontal -wrap window \ @@ -1724,11 +1731,11 @@ if {[llength [info commands loupe]]} { proc RandomPerfTest {} { set ::RandomN 15000 DemoSet DemoRandom random.tcl - .f2.f1.t item expand all - .f2.f1.t style layout styFolder elemTxtName -squeeze x - .f2.f1.t style layout styFile elemTxtName -squeeze x - .f2.f1.t elem conf elemTxtName -lines 1 + [DemoList] item expand all + [DemoList] style layout styFolder elemTxtName -squeeze x + [DemoList] style layout styFile elemTxtName -squeeze x + [DemoList] elem conf elemTxtName -lines 1 update - puts [time {.f2.f1.t colu conf 0 -width 160 ; update}] + puts [time {[DemoList] colu conf 0 -width 160 ; update}] return } |