From 8892641fcc63266bc08b6390c252e79525a7702f Mon Sep 17 00:00:00 2001 From: treectrl Date: Tue, 29 Mar 2005 20:26:13 +0000 Subject: Added standard block comments to highlight steps of creating and using a treectrl widget. --- demos/bitmaps.tcl | 20 +++++++++++ demos/explorer.tcl | 62 ++++++++++++++++++++++++++++++++ demos/help.tcl | 44 ++++++++++++++++++++++- demos/imovie.tcl | 55 +++++++++++++++++++---------- demos/layout.tcl | 20 +++++++++++ demos/mailwasher.tcl | 88 +++++++++++++++++++++++++++++----------------- demos/outlook-folders.tcl | 21 +++++++++++ demos/outlook-newgroup.tcl | 44 ++++++++++++++++++++++- demos/random.tcl | 22 +++++++++++- demos/www-options.tcl | 46 ++++++++++++++++++++++-- 10 files changed, 366 insertions(+), 56 deletions(-) diff --git a/demos/bitmaps.tcl b/demos/bitmaps.tcl index a129a39..4f0f700 100644 --- a/demos/bitmaps.tcl +++ b/demos/bitmaps.tcl @@ -5,12 +5,24 @@ proc DemoBitmaps {} { set T .f2.f1.t + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no \ -selectmode browse -orient horizontal -wrap "5 items" \ -showheader no -backgroundimage sky + # + # Create columns + # + $T column create -itembackground {gray90 {}} + # + # Create elements + # + $T element create elemTxt text -fill [list $::SystemHighlightText {selected focus}] $T element create elemSelTxt rect -fill [list $::SystemHighlight {selected focus}] \ -showfocus yes @@ -21,6 +33,10 @@ proc DemoBitmaps {} { -background linen \ -bitmap {question {selected}} + # + # Create styles using the elements + # + set S [$T style create STYLE -orient vertical] $T style elements $S {elemSelBmp elemBmp elemSelTxt elemTxt} $T style layout $S elemSelBmp -union elemBmp \ @@ -32,6 +48,10 @@ proc DemoBitmaps {} { # Set default item style $T configure -defaultstyle [list $S] + # + # Create items and assign styles + # + set bitmapNames [list error gray75 gray50 gray25 gray12 hourglass info \ questhead question warning] diff --git a/demos/explorer.tcl b/demos/explorer.tcl index dc37de7..a796cad 100644 --- a/demos/explorer.tcl +++ b/demos/explorer.tcl @@ -52,12 +52,21 @@ proc DemoExplorerDetails {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no -itemheight $height \ -selectmode extended -xscrollincrement 20 \ -scrollmargin 16 -xscrolldelay "500 50" -yscrolldelay "500 50" InitPics small-* + # + # Create columns + # + $T column create -text Name -tag name -width 200 \ -arrow up -arrowpad 6 $T column create -text Size -tag size -justify right -width 60 \ @@ -65,6 +74,10 @@ proc DemoExplorerDetails {} { $T column create -text Type -tag type -width 120 $T column create -text Modified -tag modified -width 120 + # + # Create elements + # + $T element create e1 image -image {small-folderSel {selected} small-folder {}} $T element create e2 text -fill [list $::SystemHighlightText {selected focus}] \ -lines 1 @@ -73,6 +86,10 @@ proc DemoExplorerDetails {} { $T element create txtDate text -datatype time -format "%d/%m/%y %I:%M %p" -lines 1 $T element create e4 rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] -showfocus yes + # + # Create styles using the elements + # + # image + text set S [$T style create styName -orient horizontal] $T style elements $S {e4 e1 e2} @@ -107,6 +124,10 @@ proc DemoExplorerDetails {} { %T item text %I 0 %t } + # + # Create items and assign styles + # + set scriptDir { set item [$T item create] $T item style set $item 0 styName 2 styType 3 styDate @@ -212,6 +233,10 @@ proc DemoExplorerLargeIcons {} { # Item height is 32 for icon, 4 padding, 3 lines of text set itemHeight [expr {32 + 4 + [font metrics [$T cget -font] -linespace] * 3}] + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no \ -selectmode extended -wrap window -orient horizontal \ -itemheight $itemHeight -showheader no \ @@ -219,13 +244,25 @@ proc DemoExplorerLargeIcons {} { InitPics big-* + # + # Create columns + # + $T column create -width 75 + # + # Create elements + # + $T element create elemImg image -image {big-folderSel {selected} big-folder {}} $T element create elemTxt text -fill [list $::SystemHighlightText {selected focus}] \ -justify center -lines 1 -width 71 -wrap word $T element create elemSel rect -fill [list $::SystemHighlight {selected focus} gray {selected}] -showfocus yes + # + # Create styles using the elements + # + # image + text set S [$T style create STYLE -orient vertical] $T style elements $S {elemSel elemImg elemTxt} @@ -245,6 +282,10 @@ proc DemoExplorerLargeIcons {} { %T item text %I 0 %t } + # + # Create items and assign styles + # + set scriptDir { set item [$T item create] $T item style set $item 0 STYLE @@ -304,19 +345,36 @@ proc DemoExplorerList {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no -itemheight $height \ -selectmode extended -wrap window -showheader no \ -scrollmargin 16 -xscrolldelay "500 50" -yscrolldelay "500 50" InitPics small-* + # + # Create columns + # + $T column create -widthhack yes + # + # Create elements + # + $T element create elemImg image -image {small-folderSel {selected} small-folder {}} $T element create elemTxt text -fill [list $::SystemHighlightText {selected focus}] \ -lines 1 $T element create elemSel rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] -showfocus yes + # + # Create styles using the elements + # + # image + text set S [$T style create STYLE] $T style elements $S {elemSel elemImg elemTxt} @@ -336,6 +394,10 @@ proc DemoExplorerList {} { %T item text %I 0 %t } + # + # Create items and assign styles + # + set scriptDir { set item [$T item create] $T item style set $item 0 STYLE diff --git a/demos/help.tcl b/demos/help.tcl index 803fd72..8d8638d 100644 --- a/demos/help.tcl +++ b/demos/help.tcl @@ -9,22 +9,39 @@ proc DemoHelpContents {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no -itemheight $height \ -selectmode browse InitPics help-* + # + # Create columns + # + $T column create -text "Help Contents" # Define a new item state $T state define mouseover + # + # Create elements + # + $T element create e1 image -image help-page $T element create e2 image -image {help-book-open {open} help-book-closed {}} $T element create e3 text -fill [list $::SystemHighlightText {selected focus} blue {mouseover}] \ -font [list "[$T cget -font] underline" {mouseover}] $T element create e4 rect -fill [list $::SystemHighlight {selected focus}] -showfocus yes + # + # Create styles using the elements + # + # book set S [$T style create s1] $T style elements $S {e4 e1 e3} @@ -39,6 +56,10 @@ proc DemoHelpContents {} { $T style layout $S e3 -expand ns $T style layout $S e4 -union [list e3] -iexpand ns -ipadx 2 + # + # Create items and assign styles + # + set parentList [list root {} {} {} {} {} {}] set parent root foreach {depth style text} { @@ -121,13 +142,26 @@ proc DemoHelpContents2 {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no -itemheight $height \ -selectmode browse InitPics help-* + # + # Create columns + # + $T column create -text "Help Contents" + # + # Create elements + # + $T element create e1 image -image help-page $T element create e2 image -image {help-book-open {open} help-book-closed {}} $T element create e3 text -fill [list $::SystemHighlightText {selected focus}] @@ -135,6 +169,10 @@ proc DemoHelpContents2 {} { $T element create e5 text -fill [list $::SystemHighlightText {selected focus} blue {}] \ -font "[$T cget -font] underline" + # + # Create styles using the elements + # + # book set S [$T style create s1] $T style elements $S {e4 e1 e3} @@ -163,6 +201,10 @@ proc DemoHelpContents2 {} { $T style layout $S e5 -expand ns $T style layout $S e4 -union [list e5] -iexpand ns -ipadx {1 2} + # + # Create items and assign styles + # + set parentList [list root {} {} {} {} {} {}] set parent root foreach {depth style text} { @@ -327,7 +369,7 @@ proc TreeCtrl::HelpMotion {w x y} { return } -# Alternate implementation doesn't rely on mouseover state +# Alternate implementation that does not rely on run-time states proc TreeCtrl::HelpMotion2 {w x y} { variable Priv set id [$w identify $x $y] diff --git a/demos/imovie.tcl b/demos/imovie.tcl index ac05335..bf73da3 100644 --- a/demos/imovie.tcl +++ b/demos/imovie.tcl @@ -5,10 +5,18 @@ proc DemoIMovie {} { set T .f2.f1.t + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no \ -selectmode browse -orient horizontal -wrap window \ -showheader no -background #dcdcdc + # + # Create columns + # + $T column create InitPics imovie-* @@ -29,6 +37,10 @@ proc DemoIMovie {} { } } + # + # Create elements + # + $T element create elemTime text -font [list $font1] $T element create elemName text -font [list $font2] -lines 1 -width 80 $T element create elemRect rect -fill {#ffdc5a {selected} white {}} \ @@ -36,6 +48,10 @@ proc DemoIMovie {} { $T element create elemImg image $T element create elemShadow rect -outline gray -outlinewidth 1 -open wn + # + # Create styles using the elements + # + set S [$T style create STYLE -orient vertical] $T style elements $S {elemShadow elemRect elemTime elemImg elemName} $T style layout $S elemShadow -detach yes -padx {1 2} -pady {1 2} -iexpand es @@ -48,24 +64,28 @@ proc DemoIMovie {} { # Set default item style $T configure -defaultstyle [list $S] -for {set i 0} {$i < 5} {incr i} { - foreach {time name image} { - 15:20 "Clip 1" imovie-01 - 19:18 "Clip 2" imovie-02 - 07:20 "Clip 3" imovie-03 - 07:20 "Clip 4" imovie-04 - 07:20 "Clip 5" imovie-05 - 07:20 "Clip 6" imovie-06 - 07:20 "Clip 7" imovie-07 - } { - set I [$T item create] -# $T item style set $I 0 $S - $T item element configure $I 0 elemTime -text $time - $T item element configure $I 0 elemImg -image $image - $T item element configure $I 0 elemName -text $name - $T item lastchild root $I + # + # Create items and assign styles + # + + for {set i 0} {$i < 5} {incr i} { + foreach {time name image} { + 15:20 "Clip 1" imovie-01 + 19:18 "Clip 2" imovie-02 + 07:20 "Clip 3" imovie-03 + 07:20 "Clip 4" imovie-04 + 07:20 "Clip 5" imovie-05 + 07:20 "Clip 6" imovie-06 + 07:20 "Clip 7" imovie-07 + } { + set I [$T item create] +# $T item style set $I 0 $S + $T item element configure $I 0 elemTime -text $time + $T item element configure $I 0 elemImg -image $image + $T item element configure $I 0 elemName -text $name + $T item lastchild root $I + } } -} $T notify bind $T { %T item element configure %I %C %E -text %t @@ -113,7 +133,6 @@ proc iMovieButton1 {T x y} { $T.entry selection clear scan [$T item bbox $I] "%d %d %d %d" x1 y1 x2 y2 place $T.entry -x [expr {$x1 + 1}] -width [expr {$x2 - $x1 - 5}] -puts @[expr {$x - ($x1 + 1)}] $T.entry icursor [$T.entry index @[expr {$x - ($x1 + 1)}]] } } diff --git a/demos/layout.tcl b/demos/layout.tcl index 4476650..7a3ca89 100644 --- a/demos/layout.tcl +++ b/demos/layout.tcl @@ -5,11 +5,23 @@ proc DemoLayout {} { set T .f2.f1.t + # + # Configure the treectrl widget + # + $T configure -showroot no -showrootbutton yes -showbuttons yes \ -showlines yes -itemheight 0 -selectmode browse + # + # Create columns + # + $T column create -text Layout + # + # Create elements + # + $T element create e1 rect -width 30 -height 30 -fill gray20 $T element create e2 rect -width 30 -height 30 -fill gray40 \ -outline blue -outlinewidth 3 @@ -21,6 +33,10 @@ proc DemoLayout {} { $T element create e7 rect -fill {"sky blue"} -width 30 -height 16 $T element create e8 rect -fill gray70 -height 1 + # + # Create styles using the elements + # + set S [$T style create s1] $T style elements $S {e4 e3 e1 e2 e5 e6 e7} $T style layout $S e1 -padx {28 4} -pady 4 @@ -31,6 +47,10 @@ proc DemoLayout {} { $T style layout $S e6 -detach yes -expand ws -padx {0 2} -pady {2 0} $T style layout $S e7 -detach yes -expand wn -padx {0 2} -pady {0 2} + # + # Create items and assign styles + # + set I [$T item create -button yes] $T item style set $I 0 $S $T item lastchild root $I diff --git a/demos/mailwasher.tcl b/demos/mailwasher.tcl index 6225a78..627d836 100644 --- a/demos/mailwasher.tcl +++ b/demos/mailwasher.tcl @@ -11,10 +11,19 @@ proc DemoMailWasher {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showrootbutton no -showbuttons no \ -showlines no -itemheight $height -selectmode browse \ -xscrollincrement 1 + # + # Create columns + # + set pad 4 $T column create -text Delete -textpadx $pad -tag delete $T column create -text Bounce -textpadx $pad -tag bounce @@ -27,6 +36,10 @@ proc DemoMailWasher {} { $T state define CHECK + # + # Create elements + # + $T element create border rect -open nw -outline gray -outlinewidth 1 \ -fill [list $::SystemHighlight {selected}] $T element create imgCheck image -image {checked CHECK unchecked {}} @@ -45,6 +58,10 @@ proc DemoMailWasher {} { $T element create txtBlacklist text -text "Blacklisted" \ -fill [list $::SystemHighlightText {selected} #FF5800 {}] -lines 1 + # + # Create styles using the elements + # + set S [$T style create styCheck] $T style elements $S [list border imgCheck] $T style layout $S border -detach yes -iexpand es @@ -58,41 +75,46 @@ proc DemoMailWasher {} { $T style layout $S border -detach yes -iexpand es $T style layout $S txt$name -padx $pad -squeeze x -expand ns } -for {set i 0} {$i < 1} {incr i} { - foreach {from subject} { - baldy@spammer.com "Your hair is thinning" - flat@spammer.com "Your breasts are too small" - tiny@spammer.com "Your penis is too small" - dumbass@spammer.com "You are not very smart" - bankrobber@spammer.com "You need more money" - loser@spammer.com "You need better friends" - gossip@spammer.com "Find out what your coworkers think about you" - whoami@spammer.com "Find out what you think about yourself" - downsized@spammer.com "You need a better job" - poorhouse@spammer.com "Your mortgage is a joke" - spam4ever@spammer.com "You need more spam" - } { - set item [$T item create] - set status [lindex [list styNormal styPossSpam styProbSpam styBlacklist] [expr int(rand() * 4)]] - set delete [expr int(rand() * 2)] - set bounce [expr int(rand() * 2)] - set attachments [lindex [list styNone styYes] [expr int(rand() * 2)]] - $T item style set $item 0 styCheck 1 styCheck 2 $status 3 styAny \ - 4 styAny 5 styAny 6 styAny 7 $attachments - if {$delete} { - $T item state forcolumn $item delete CHECK - } - if {$bounce} { - $T item state forcolumn $item bounce CHECK + + # + # Create items and assign styles + # + + for {set i 0} {$i < 1} {incr i} { + foreach {from subject} { + baldy@spammer.com "Your hair is thinning" + flat@spammer.com "Your breasts are too small" + tiny@spammer.com "Your penis is too small" + dumbass@spammer.com "You are not very smart" + bankrobber@spammer.com "You need more money" + loser@spammer.com "You need better friends" + gossip@spammer.com "Find out what your coworkers think about you" + whoami@spammer.com "Find out what you think about yourself" + downsized@spammer.com "You need a better job" + poorhouse@spammer.com "Your mortgage is a joke" + spam4ever@spammer.com "You need more spam" + } { + set item [$T item create] + set status [lindex [list styNormal styPossSpam styProbSpam styBlacklist] [expr int(rand() * 4)]] + set delete [expr int(rand() * 2)] + set bounce [expr int(rand() * 2)] + set attachments [lindex [list styNone styYes] [expr int(rand() * 2)]] + $T item style set $item 0 styCheck 1 styCheck 2 $status 3 styAny \ + 4 styAny 5 styAny 6 styAny 7 $attachments + if {$delete} { + $T item state forcolumn $item delete CHECK + } + if {$bounce} { + $T item state forcolumn $item bounce CHECK + } + set bytes [expr {512 + int(rand() * 1024 * 12)}] + set size [expr {$bytes / 1024 + 1}]KB + set seconds [expr {[clock seconds] - int(rand() * 100000)}] + set received [clock format $seconds -format "%d/%m/%y %I:%M %p"] + $T item text $item 3 $size 4 $from 5 $subject 6 $received + $T item lastchild root $item } - set bytes [expr {512 + int(rand() * 1024 * 12)}] - set size [expr {$bytes / 1024 + 1}]KB - set seconds [expr {[clock seconds] - int(rand() * 100000)}] - set received [clock format $seconds -format "%d/%m/%y %I:%M %p"] - $T item text $item 3 $size 4 $from 5 $subject 6 $received - $T item lastchild root $item } -} if 0 { $T notify bind MailWasher { %T item style set %I %C styOff diff --git a/demos/outlook-folders.tcl b/demos/outlook-folders.tcl index 7fceacc..7bd8ed9 100644 --- a/demos/outlook-folders.tcl +++ b/demos/outlook-folders.tcl @@ -11,11 +11,24 @@ proc DemoOutlookFolders {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -itemheight $height -selectmode browse \ -showroot yes -showrootbutton no -showbuttons yes -showlines yes + # + # Create columns + # + $T column create -text Folders + # + # Create elements + # + $T element create e1 image $T element create e2 text -fill [list $::SystemHighlightText {selected focus}] \ -lines 1 @@ -26,6 +39,10 @@ proc DemoOutlookFolders {} { $T element create e6 rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] \ -showfocus yes + # + # Create styles using the elements + # + # image + text set S [$T style create s1] $T style elements $S {e6 e1 e2} @@ -56,6 +73,10 @@ proc DemoOutlookFolders {} { $T style layout $S e4 -expand ns $T style layout $S e6 -union [list e3] -iexpand ns -ipadx 2 + # + # Create items and assign styles + # + $T item style set root 0 s1 $T item complex root [list [list e1 -image outlook-main] [list e2 -text "Outlook Express"]] diff --git a/demos/outlook-newgroup.tcl b/demos/outlook-newgroup.tcl index 29e1ef3..44837e5 100644 --- a/demos/outlook-newgroup.tcl +++ b/demos/outlook-newgroup.tcl @@ -13,9 +13,18 @@ proc DemoOutlookNewsgroup {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -itemheight $height -selectmode browse \ -showroot no -showrootbutton no -showbuttons yes -showlines no + # + # Create columns + # + $T column create -image outlook-clip -tag clip $T column create -image outlook-arrow -tag arrow $T column create -image outlook-watch -tag watch @@ -33,6 +42,10 @@ proc DemoOutlookNewsgroup {} { # State for a message with unread descendants $T state define unread + # + # Create elements + # + $T element create elemImg image -image { outlook-read-2Sel {selected read unread !open} outlook-read-2 {read unread !open} @@ -47,6 +60,10 @@ proc DemoOutlookNewsgroup {} { $T element create sel.w rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] -open w -showfocus yes $T element create sel.we rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] -open we -showfocus yes + # + # Create styles using the elements + # + # Image + text set S [$T style create s1] $T style elements $S {sel.e elemImg elemTxt} @@ -69,6 +86,10 @@ proc DemoOutlookNewsgroup {} { # Set default item style $T configure -defaultstyle [list "" "" "" s1 s2.we s2.we s2.w] + # + # Create items and assign styles + # + set msgCnt 100 set thread 0 @@ -176,7 +197,7 @@ proc MessageReadDelayed {} { } } -# Alternate implementation which does not rely on run-time states +# Alternate implementation that does not rely on run-time states proc DemoOutlookNewsgroup2 {} { global Message @@ -189,9 +210,18 @@ proc DemoOutlookNewsgroup2 {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -itemheight $height -selectmode browse \ -showroot no -showrootbutton no -showbuttons yes -showlines no + # + # Create columns + # + $T column create -image outlook-clip -tag clip $T column create -image outlook-arrow -tag arrow $T column create -image outlook-watch -tag watch @@ -202,6 +232,10 @@ proc DemoOutlookNewsgroup2 {} { $T configure -treecolumn 3 + # + # Create elements + # + $T element create image.unread image -image outlook-unread $T element create image.read image -image outlook-read $T element create image.read2 image -image outlook-read-2 @@ -213,6 +247,10 @@ proc DemoOutlookNewsgroup2 {} { $T element create sel.w rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] -open w -showfocus yes $T element create sel.we rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] -open we -showfocus yes + # + # Create styles using the elements + # + # Image + text set S [$T style create unread] $T style elements $S {sel.e image.unread text.unread} @@ -258,6 +296,10 @@ proc DemoOutlookNewsgroup2 {} { $T style layout $S text.read -padx 6 -squeeze x -expand ns $T style layout $S sel.w -detach yes -iexpand es + # + # Create items and assign styles + # + set msgCnt 100 set thread 0 diff --git a/demos/random.tcl b/demos/random.tcl index 4127dab..dace0a6 100644 --- a/demos/random.tcl +++ b/demos/random.tcl @@ -13,14 +13,27 @@ proc DemoRandom {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -itemheight $height -selectmode extended \ -showroot yes -showrootbutton yes -showbuttons yes -showlines yes \ -scrollmargin 16 -xscrolldelay "500 50" -yscrolldelay "500 50" + # + # Create columns + # + $T column create -expand yes -text Item -itembackground {#e0e8f0 {}} -tag item $T column create -text Parent -justify center -itembackground {gray90 {}} -tag parent $T column create -text Depth -justify center -itembackground {linen {}} -tag depth + # + # Create elements + # + $T element create e1 image -image {folder-open {open} folder-closed {}} $T element create e2 image -image small-file $T element create e3 text \ @@ -30,6 +43,10 @@ proc DemoRandom {} { $T element create e5 rect -showfocus yes \ -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] + # + # Create styles using the elements + # + $T style create s1 $T style elements s1 {e5 e1 e3 e4} $T style layout s1 e1 -padx {0 4} -expand ns @@ -56,6 +73,10 @@ proc DemoRandom {} { {item s2 e2 e3} } + # + # Create items and assign styles + # + set clicks [clock clicks] set items [$T index root] for {set i 1} {$i < $::RandomN} {incr i} { @@ -138,7 +159,6 @@ proc TreeCtrl::RandomButton1 {T x y} { variable Priv focus $T set id [$T identify $x $y] - puts $id set Priv(buttonMode) "" # Click outside any item diff --git a/demos/www-options.tcl b/demos/www-options.tcl index 00cdcb9..bb604ca 100644 --- a/demos/www-options.tcl +++ b/demos/www-options.tcl @@ -6,17 +6,30 @@ proc DemoInternetOptions {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no -itemheight $height \ -selectmode browse InitPics internet-* + # + # Create columns + # + $T column create -text "Internet Options" $T state define check $T state define radio $T state define on + # + # Create elements + # + $T element create e1 image -image { internet-check-on {check on} internet-check-off {check} @@ -26,12 +39,20 @@ proc DemoInternetOptions {} { $T element create e2 text -fill [list $::SystemHighlightText {selected focus}] $T element create e3 rect -fill [list $::SystemHighlight {selected focus}] -showfocus yes + # + # Create styles using the elements + # + set S [$T style create s1] $T style elements $S {e3 e1 e2} $T style layout $S e1 -padx {0 4} -expand ns $T style layout $S e2 -expand ns $T style layout $S e3 -union [list e2] -iexpand ns -ipadx 2 + # + # Create items and assign styles + # + set parentList [list root {} {} {} {} {} {}] set parent root foreach {depth setting text option group} { @@ -136,7 +157,7 @@ proc TreeCtrl::OptionButton1 {T x y} { } -# Alternate implementation that doesn't rely on run-time styles +# Alternate implementation that does not rely on run-time states proc DemoInternetOptions_2 {} { set T .f2.f1.t @@ -145,23 +166,44 @@ proc DemoInternetOptions_2 {} { if {$height < 18} { set height 18 } + + # + # Configure the treectrl widget + # + $T configure -showroot no -showbuttons no -showlines no -itemheight $height \ -selectmode browse InitPics internet-* - $T column configure 0 -text "Internet Options" + # + # Create columns + # + + $T column create -text "Internet Options" + + # + # Create elements + # $T element create e1 image $T element create e2 text -fill [list $::SystemHighlightText {selected focus}] $T element create e3 rect -fill [list $::SystemHighlight {selected focus}] -showfocus yes + # + # Create styles using the elements + # + set S [$T style create s1] $T style elements $S {e3 e1 e2} $T style layout $S e1 -padx {0 4} -expand ns $T style layout $S e2 -expand ns $T style layout $S e3 -union [list e2] -iexpand ns -ipadx 2 + # + # Create items and assign styles + # + set parentList [list root {} {} {} {} {} {}] set parent root foreach {depth setting text option group} { -- cgit v0.12