Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | * buttonbox.tcl: Added tagging mechanism to buttonbox. When using $bbox add, the first parameter is a list of tags for the button. Then use $bbox setbuttonstate to change the state of a tag. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f3ebbcbe31e5b48322d9d46931b9e591 |
User & Date: | ericm 1999-09-17 20:50:22.000 |
Context
1999-09-17
| ||
22:30 | Updated to reflect recent TEA changes check-in: 2911677e6b user: wart tags: trunk | |
20:50 | * buttonbox.tcl: Added tagging mechanism to buttonbox. When using $bbox add, the first parameter is a list of tags for the button. Then use $bbox setbuttonstate to change the state of a tag. check-in: f3ebbcbe31 user: ericm tags: trunk | |
17:46 | * mainframe.tcl: Modified menu creation/setmenustate functions to support a new model of menustate. Instead of enabling/disabling a menu item whenever any one of its tags changes state, now it only enables menu items if all of its tags are set. This makes it really easy to, say, only enable the "New Action" entry if both a project is open and an element is selected. check-in: 0406abeac2 user: ericm tags: trunk | |
Changes
Changes to buttonbox.tcl.
︙ | ︙ | |||
96 97 98 99 100 101 102 | return [Widget::cget $path $option] } # ------------------------------------------------------------------------------ # Command ButtonBox::add # ------------------------------------------------------------------------------ | | > > > > > > > > > > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | return [Widget::cget $path $option] } # ------------------------------------------------------------------------------ # Command ButtonBox::add # ------------------------------------------------------------------------------ proc ButtonBox::add { path tags args } { variable $path upvar 0 $path data set but $path.b$data(nbuttons) set spacing [Widget::getoption $path -spacing] if { $data(nbuttons) == $data(default) } { set style active } elseif { $data(default) == -1 } { set style disabled } else { set style normal } eval Button::create $but \ -background [Widget::getoption $path -background]\ -padx [Widget::getoption $path -padx] \ -pady [Widget::getoption $path -pady] \ $args \ -default $style # [email protected]: set up tags, just like the menu items foreach tag $tags { lappend data(tags,$tag) $but if { ![info exists data(tagstate,$tag)] } { set data(tagstate,$tag) 0 } } set data(buttontags,$but) $tags # [email protected] set idx [expr {2*$data(nbuttons)}] if { ![string compare [Widget::getoption $path -orient] "horizontal"] } { grid $but -column $idx -row 0 -sticky nsew if { [Widget::getoption $path -homogeneous] } { set req [winfo reqwidth $but] if { $req > $data(max) } { |
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | } } incr data(nbuttons) return $but } # ------------------------------------------------------------------------------ # Command ButtonBox::itemconfigure # ------------------------------------------------------------------------------ proc ButtonBox::itemconfigure { path index args } { if { [set idx [lsearch $args -default]] != -1 } { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | } } incr data(nbuttons) return $but } # ::ButtonBox::setbuttonstate -- # # Set the state of a given button tag. If this makes any buttons # enable-able (ie, all of their tags are TRUE), enable them. # # Arguments: # path the button box widget name # tag the tag to modify # state the new state of $tag (0 or 1) # # Results: # None. proc ::ButtonBox::setbuttonstate {path tag state} { variable $path upvar 0 $path data # First see if this is a real tag if { [info exists data(tagstate,$tag)] } { set data(tagstate,$tag) $state foreach but $data(tags,$tag) { set expression "1" foreach buttontag $data(buttontags,$but) { append expression " && $data(tagstate,$buttontag)" } if { [expr $expression] } { set state normal } else { set state disabled } $but configure -state $state } } return } # ------------------------------------------------------------------------------ # Command ButtonBox::itemconfigure # ------------------------------------------------------------------------------ proc ButtonBox::itemconfigure { path index args } { if { [set idx [lsearch $args -default]] != -1 } { |
︙ | ︙ |