From ba58be95010e7a8fef177ea8f96c408371f7d82d Mon Sep 17 00:00:00 2001 From: treectrl Date: Thu, 23 Nov 2006 22:24:56 +0000 Subject: Added [DemoList] command to get the name of the main list rather than hard-coding .f2.f1.t everywhere. --- demos/biglist.tcl | 16 ++++---- demos/bitmaps.tcl | 4 +- demos/column-lock.tcl | 8 ++-- demos/demo.tcl | 95 +++++++++++++++++++++++++--------------------- demos/explorer.tcl | 12 +++--- demos/firefox.tcl | 4 +- demos/help.tcl | 6 +-- demos/imovie.tcl | 4 +- demos/layout.tcl | 4 +- demos/mailwasher.tcl | 4 +- demos/mycomputer.tcl | 4 +- demos/outlook-folders.tcl | 4 +- demos/outlook-newgroup.tcl | 8 ++-- demos/random.tcl | 6 +-- demos/span.tcl | 4 +- demos/textvariable.tcl | 4 +- demos/www-options.tcl | 6 +-- 17 files changed, 100 insertions(+), 93 deletions(-) diff --git a/demos/biglist.tcl b/demos/biglist.tcl index de01e05..2353ec0 100644 --- a/demos/biglist.tcl +++ b/demos/biglist.tcl @@ -1,11 +1,11 @@ -# RCS: @(#) $Id: biglist.tcl,v 1.10 2006/11/13 04:45:09 treectrl Exp $ +# RCS: @(#) $Id: biglist.tcl,v 1.11 2006/11/23 22:24:56 treectrl Exp $ set ::clip 1 proc DemoBigList {} { global BigList - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget @@ -129,9 +129,9 @@ if {$::clip} { BigListGetWindowHeight $T if {$::tile} { bind DemoBigList <> { - BigListGetWindowHeight .f2.f1.t - if {[.f2.f1.t item id {first visible tag info}] ne ""} { - .f2.f1.t item conf {tag info} -height $BigList(windowHeight) + BigListGetWindowHeight [DemoList] + if {[[DemoList] item id {first visible tag info}] ne ""} { + [DemoList] item conf {tag info} -height $BigList(windowHeight) } } } @@ -153,9 +153,9 @@ if {$::clip} { } bind DemoBigListChildWindow { - set x [expr {%X - [winfo rootx .f2.f1.t]}] - set y [expr {%Y - [winfo rooty .f2.f1.t]}] - BigListMotion .f2.f1.t $x $y + set x [expr {%X - [winfo rootx [DemoList]]}] + set y [expr {%Y - [winfo rooty [DemoList]]}] + BigListMotion [DemoList] $x $y } bindtags $T [list $T DemoBigList TreeCtrl [winfo toplevel $T] all] diff --git a/demos/bitmaps.tcl b/demos/bitmaps.tcl index f8f1843..787e416 100644 --- a/demos/bitmaps.tcl +++ b/demos/bitmaps.tcl @@ -1,11 +1,11 @@ -# RCS: @(#) $Id: bitmaps.tcl,v 1.9 2006/11/05 06:44:53 treectrl Exp $ +# RCS: @(#) $Id: bitmaps.tcl,v 1.10 2006/11/23 22:24:56 treectrl Exp $ # # Demo: Bitmaps # proc DemoBitmaps {} { - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/column-lock.tcl b/demos/column-lock.tcl index 60cf255..afd0e69 100644 --- a/demos/column-lock.tcl +++ b/demos/column-lock.tcl @@ -1,10 +1,10 @@ -# RCS: @(#) $Id: column-lock.tcl,v 1.8 2006/11/23 22:03:47 treectrl Exp $ +# RCS: @(#) $Id: column-lock.tcl,v 1.9 2006/11/23 22:24:56 treectrl Exp $ proc DemoColumnLock {} { global ColumnLock - set T .f2.f1.t + set T [DemoList] InitPics *checked @@ -318,7 +318,7 @@ proc ColumnLockUpdateSelection {w} { } proc ColumnLockAddText {} { - set w .f2.f1.t + set w [DemoList] $w style elements cell {cell.bd label1.text cell.selN cell.selS cell.selW cell.selE} - $w item text visible all abc + $w item text visible {lock none} abc } 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 { - 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 + [DemoList] notify install - .f2.f1.t notify install - .f2.f1.t notify install - .f2.f1.t notify install + [DemoList] notify install + [DemoList] notify install + [DemoList] notify install - .f2.f1.t notify install - .f2.f1.t notify install - .f2.f1.t notify install + [DemoList] notify install + [DemoList] notify install + [DemoList] notify install - .f2.f1.t notify install - .f2.f1.t notify install - .f2.f1.t notify install + [DemoList] notify install + [DemoList] notify install + [DemoList] notify install ### 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 { } + bind [DemoList] { } } # @@ -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 { +[DemoList] notify bind DontDelete { 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 { +[DemoList] notify bind DontDelete { %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 } diff --git a/demos/explorer.tcl b/demos/explorer.tcl index 3462030..8c0cd1f 100644 --- a/demos/explorer.tcl +++ b/demos/explorer.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: explorer.tcl,v 1.22 2006/11/22 03:31:56 treectrl Exp $ +# RCS: @(#) $Id: explorer.tcl,v 1.23 2006/11/23 22:24:56 treectrl Exp $ set Dir [file dirname [file dirname [info script]]] @@ -16,7 +16,7 @@ proc DemoExplorerAux {scriptDir scriptFile} { global Explorer global Dir - set T .f2.f1.t + set T [DemoList] set clicks [clock clicks] set globDirs [glob -nocomplain -types d -dir $Dir *] @@ -74,7 +74,7 @@ proc DemoExplorerAux {scriptDir scriptFile} { # proc DemoExplorerDetails {} { - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { @@ -296,7 +296,7 @@ proc ExplorerHeaderInvoke {T C} { proc DemoExplorerLargeIcons {} { - set T .f2.f1.t + set T [DemoList] # Item height is 32 for icon, 4 padding, 3 lines of text set itemHeight [expr {32 + 4 + [font metrics [$T cget -font] -linespace] * 3}] @@ -441,7 +441,7 @@ proc DemoExplorerLargeIcons {} { # Tree is horizontal, wrapping occurs at right edge of window, each item # is as wide as the smallest needed multiple of 110 pixels proc DemoExplorerSmallIcons {} { - set T .f2.f1.t + set T [DemoList] DemoExplorerList $T configure -orient horizontal \ -itemwidthmultiple 110 -itemwidthequal no @@ -452,7 +452,7 @@ proc DemoExplorerSmallIcons {} { # same width (as wide as the longest item), xscrollincrement is by range proc DemoExplorerList {} { - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { diff --git a/demos/firefox.tcl b/demos/firefox.tcl index 2a8fe87..a9f4a33 100644 --- a/demos/firefox.tcl +++ b/demos/firefox.tcl @@ -1,10 +1,10 @@ -# RCS: @(#) $Id: firefox.tcl,v 1.16 2006/11/13 04:45:09 treectrl Exp $ +# RCS: @(#) $Id: firefox.tcl,v 1.17 2006/11/23 22:24:56 treectrl Exp $ proc DemoFirefoxPrivacy {} { global FirefoxPrivacy - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/help.tcl b/demos/help.tcl index 7701e62..ff2cf14 100644 --- a/demos/help.tcl +++ b/demos/help.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: help.tcl,v 1.19 2006/11/19 00:53:40 treectrl Exp $ +# RCS: @(#) $Id: help.tcl,v 1.20 2006/11/23 22:24:56 treectrl Exp $ # # Demo: Help contents @@ -7,7 +7,7 @@ proc DemoHelpContents {} { global HelpContents - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { @@ -137,7 +137,7 @@ proc DemoHelpContents_2 {} { global HelpContents - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { diff --git a/demos/imovie.tcl b/demos/imovie.tcl index 5ac1398..fa9707b 100644 --- a/demos/imovie.tcl +++ b/demos/imovie.tcl @@ -1,11 +1,11 @@ -# RCS: @(#) $Id: imovie.tcl,v 1.14 2006/11/19 00:53:51 treectrl Exp $ +# RCS: @(#) $Id: imovie.tcl,v 1.15 2006/11/23 22:24:56 treectrl Exp $ # # Demo: iMovie # proc DemoIMovie {} { - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/layout.tcl b/demos/layout.tcl index d6628c4..2f96162 100644 --- a/demos/layout.tcl +++ b/demos/layout.tcl @@ -1,11 +1,11 @@ -# RCS: @(#) $Id: layout.tcl,v 1.11 2006/10/04 04:08:25 treectrl Exp $ +# RCS: @(#) $Id: layout.tcl,v 1.12 2006/11/23 22:24:56 treectrl Exp $ # # Demo: Layout # proc DemoLayout {} { - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/mailwasher.tcl b/demos/mailwasher.tcl index f87e97c..d87b506 100644 --- a/demos/mailwasher.tcl +++ b/demos/mailwasher.tcl @@ -1,11 +1,11 @@ -# RCS: @(#) $Id: mailwasher.tcl,v 1.15 2006/11/19 00:54:45 treectrl Exp $ +# RCS: @(#) $Id: mailwasher.tcl,v 1.16 2006/11/23 22:24:56 treectrl Exp $ # # Demo: MailWasher # proc DemoMailWasher {} { - set T .f2.f1.t + set T [DemoList] InitPics *checked diff --git a/demos/mycomputer.tcl b/demos/mycomputer.tcl index 19543b6..ad58385 100644 --- a/demos/mycomputer.tcl +++ b/demos/mycomputer.tcl @@ -1,8 +1,8 @@ -# RCS: @(#) $Id: mycomputer.tcl,v 1.4 2006/11/15 23:50:28 treectrl Exp $ +# RCS: @(#) $Id: mycomputer.tcl,v 1.5 2006/11/23 22:24:56 treectrl Exp $ proc DemoMyComputer {} { - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/outlook-folders.tcl b/demos/outlook-folders.tcl index 92abe4d..9345715 100644 --- a/demos/outlook-folders.tcl +++ b/demos/outlook-folders.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: outlook-folders.tcl,v 1.11 2006/10/04 04:08:25 treectrl Exp $ +# RCS: @(#) $Id: outlook-folders.tcl,v 1.12 2006/11/23 22:24:56 treectrl Exp $ # # Demo: Outlook Express folder list @@ -7,7 +7,7 @@ proc DemoOutlookFolders {} { InitPics outlook-* - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { diff --git a/demos/outlook-newgroup.tcl b/demos/outlook-newgroup.tcl index 70952f8..99ff108 100644 --- a/demos/outlook-newgroup.tcl +++ b/demos/outlook-newgroup.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: outlook-newgroup.tcl,v 1.17 2006/11/19 00:55:14 treectrl Exp $ +# RCS: @(#) $Id: outlook-newgroup.tcl,v 1.18 2006/11/23 22:24:56 treectrl Exp $ # # Demo: Outlook Express newsgroup messages @@ -9,7 +9,7 @@ proc DemoOutlookNewsgroup {} { InitPics outlook-* - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { @@ -180,7 +180,7 @@ proc MessageReadDelayed {} { global Message - set T .f2.f1.t + set T [DemoList] unset Message(afterId) set I $Message(afterId,item) @@ -211,7 +211,7 @@ proc DemoOutlookNewsgroup_2 {} { InitPics outlook-* - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { diff --git a/demos/random.tcl b/demos/random.tcl index 94e08b5..1294e66 100644 --- a/demos/random.tcl +++ b/demos/random.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: random.tcl,v 1.22 2006/11/19 00:55:37 treectrl Exp $ +# RCS: @(#) $Id: random.tcl,v 1.23 2006/11/23 22:24:56 treectrl Exp $ set RandomN 500 set RandomDepth 5 @@ -8,7 +8,7 @@ set RandomDepth 5 # proc DemoRandom {} { - set T .f2.f1.t + set T [DemoList] InitPics folder-* small-* @@ -398,7 +398,7 @@ proc RandomDrop {T target source pos} { # proc DemoRandom2 {} { - set T .f2.f1.t + set T [DemoList] DemoRandom diff --git a/demos/span.tcl b/demos/span.tcl index 165e546..9c443c4 100644 --- a/demos/span.tcl +++ b/demos/span.tcl @@ -1,11 +1,11 @@ -# RCS: @(#) $Id: span.tcl,v 1.2 2006/10/04 04:10:20 treectrl Exp $ +# RCS: @(#) $Id: span.tcl,v 1.3 2006/11/23 22:24:56 treectrl Exp $ # # Demo: Column span # proc DemoSpan {} { - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/textvariable.tcl b/demos/textvariable.tcl index 4f13d47..5f32ed6 100644 --- a/demos/textvariable.tcl +++ b/demos/textvariable.tcl @@ -1,8 +1,8 @@ -# RCS: @(#) $Id: textvariable.tcl,v 1.5 2006/11/23 00:39:34 treectrl Exp $ +# RCS: @(#) $Id: textvariable.tcl,v 1.6 2006/11/23 22:24:56 treectrl Exp $ proc DemoTextvariable {} { - set T .f2.f1.t + set T [DemoList] # # Configure the treectrl widget diff --git a/demos/www-options.tcl b/demos/www-options.tcl index 52717fc..c4eec66 100644 --- a/demos/www-options.tcl +++ b/demos/www-options.tcl @@ -1,10 +1,10 @@ -# RCS: @(#) $Id: www-options.tcl,v 1.12 2006/11/23 00:39:53 treectrl Exp $ +# RCS: @(#) $Id: www-options.tcl,v 1.13 2006/11/23 22:24:56 treectrl Exp $ proc DemoInternetOptions {} { global Options - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { @@ -158,7 +158,7 @@ proc DemoInternetOptions_2 {} { global Options - set T .f2.f1.t + set T [DemoList] set height [font metrics [$T cget -font] -linespace] if {$height < 18} { -- cgit v0.12