Changeset 52 for trunk/gui/scripts/combobox.tcl
- Timestamp:
- Sep 7, 2005, 10:03:19 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/combobox.tcl
r11 r52 21 21 option add *Combobox.textBackground white widgetDefault 22 22 option add *Combobox.textForeground black widgetDefault 23 option add *Combobox.disabledBackground white widgetDefault 24 option add *Combobox.disabledForeground gray widgetDefault 23 25 option add *Combobox.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault 24 26 … … 27 29 28 30 itk_option define -editable editable Editable "" 31 itk_option define -state state State "normal" 29 32 itk_option define -width width Width 0 33 itk_option define -disabledbackground disabledBackground DisabledBackground "" 34 itk_option define -disabledforeground disabledForeground DisabledForeground "" 30 35 31 36 constructor {args} { # defined below } … … 37 42 protected method _entry {option} 38 43 protected method _dropdown {option} 44 protected method _fixState {} 39 45 40 46 blt::bitmap define ComboboxArrow { … … 175 181 switch -- $option { 176 182 apply { 177 if {$itk_option(-editable) } {183 if {$itk_option(-editable) && $itk_option(-state) == "normal"} { 178 184 event generate $itk_component(hull) <<Value>> 179 185 } 180 186 } 181 187 click { 182 if {!$itk_option(-editable) } {188 if {!$itk_option(-editable) && $itk_option(-state) == "normal"} { 183 189 $itk_component(button) configure -relief sunken 184 190 update idletasks; after 100 … … 233 239 234 240 # ---------------------------------------------------------------------- 241 # USAGE: _fixState 242 # 243 # Used internally to fix the widget state when the -editable/-state 244 # options change. 245 # ---------------------------------------------------------------------- 246 itcl::body Rappture::Combobox::_fixState {} { 247 if {$itk_option(-state) == "normal"} { 248 $itk_component(button) configure -state normal 249 $itk_component(entry) configure \ 250 -background $itk_option(-textbackground) \ 251 -foreground $itk_option(-textforeground) \ 252 -disabledbackground $itk_option(-textbackground) \ 253 -disabledforeground $itk_option(-textforeground) 254 } else { 255 $itk_component(button) configure -state disabled 256 $itk_component(entry) configure \ 257 -background $itk_option(-disabledbackground) \ 258 -foreground $itk_option(-disabledforeground) \ 259 -disabledbackground $itk_option(-disabledbackground) \ 260 -disabledforeground $itk_option(-disabledforeground) 261 } 262 263 if {$itk_option(-editable)} { 264 if {$itk_option(-state) == "normal"} { 265 $itk_component(entry) configure -state normal 266 } else { 267 $itk_component(entry) configure -state disabled 268 } 269 } else { 270 $itk_component(entry) configure -state disabled 271 } 272 273 if {!$itk_option(-editable) || $itk_option(-state) != "normal"} { 274 # can't keep focus here -- move it along to the next widget 275 if {[focus] == $itk_component(entry)} { 276 focus [tk_focusNext [focus]] 277 } 278 } 279 } 280 281 # ---------------------------------------------------------------------- 235 282 # CONFIGURATION OPTION: -editable 236 283 # ---------------------------------------------------------------------- … … 239 286 error "bad value \"$itk_option(-editable)\": should be boolean" 240 287 } 241 if {$itk_option(-editable)} { 242 $itk_component(entry) configure -state normal 243 } else { 244 $itk_component(entry) configure -state disabled 245 if {[focus] == $itk_component(entry)} { 246 focus [tk_focusNext [focus]] 247 } 248 } 249 } 288 _fixState 289 } 290 291 # ---------------------------------------------------------------------- 292 # CONFIGURATION OPTION: -state 293 # ---------------------------------------------------------------------- 294 itcl::configbody Rappture::Combobox::state { 295 set valid {normal disabled} 296 if {[lsearch -exact $valid $itk_option(-state)] < 0} { 297 error "bad value \"$itk_option(-state)\": should be [join $valid {, }]" 298 } 299 _fixState 300 }
Note: See TracChangeset
for help on using the changeset viewer.