Ignore:
Timestamp:
Sep 7, 2005, 10:03:19 AM (19 years ago)
Author:
mmc
Message:
  • Added a back door so we can debug Rappture applications running in the nanoHUB environment.
  • Added format and label controls to the axes of an XY plot.
  • Added a <molecule><about><emblems> directive, a boolean control indicating whether or not the molecule viewer should show the atom labels by default. If missing or "off", the labels are turned off. To turn labels on by default, this must be set to a boolean true value.
  • Fixed the packing bug that was causing tabbed notebooks to be the wrong size (size of last page, rather than max overall size).
  • Added -state option to comboboxes, so they can be disabled.
  • Added a grab stack, so that when a balloon dialog has the grab and a combobox steals it away, the balloon gets it back.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/combobox.tcl

    r11 r52  
    2121option add *Combobox.textBackground white widgetDefault
    2222option add *Combobox.textForeground black widgetDefault
     23option add *Combobox.disabledBackground white widgetDefault
     24option add *Combobox.disabledForeground gray widgetDefault
    2325option add *Combobox.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
    2426
     
    2729
    2830    itk_option define -editable editable Editable ""
     31    itk_option define -state state State "normal"
    2932    itk_option define -width width Width 0
     33    itk_option define -disabledbackground disabledBackground DisabledBackground ""
     34    itk_option define -disabledforeground disabledForeground DisabledForeground ""
    3035
    3136    constructor {args} { # defined below }
     
    3742    protected method _entry {option}
    3843    protected method _dropdown {option}
     44    protected method _fixState {}
    3945
    4046    blt::bitmap define ComboboxArrow {
     
    175181    switch -- $option {
    176182        apply {
    177             if {$itk_option(-editable)} {
     183            if {$itk_option(-editable) && $itk_option(-state) == "normal"} {
    178184                event generate $itk_component(hull) <<Value>>
    179185            }
    180186        }
    181187        click {
    182             if {!$itk_option(-editable)} {
     188            if {!$itk_option(-editable) && $itk_option(-state) == "normal"} {
    183189                $itk_component(button) configure -relief sunken
    184190                update idletasks; after 100
     
    233239
    234240# ----------------------------------------------------------------------
     241# USAGE: _fixState
     242#
     243# Used internally to fix the widget state when the -editable/-state
     244# options change.
     245# ----------------------------------------------------------------------
     246itcl::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# ----------------------------------------------------------------------
    235282# CONFIGURATION OPTION: -editable
    236283# ----------------------------------------------------------------------
     
    239286        error "bad value \"$itk_option(-editable)\": should be boolean"
    240287    }
    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# ----------------------------------------------------------------------
     294itcl::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.