Changeset 1135


Ignore:
Timestamp:
Sep 2, 2008 1:32:34 PM (16 years ago)
Author:
gah
Message:

use different icon for switch check

Location:
trunk/gui/scripts
Files:
2 added
3 edited

Legend:

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

    r1076 r1135  
    123123        set newval [lindex $args 0]
    124124        $itk_component(switch) value $newval
     125        event generate $itk_component(hull) <<Value>>
    125126        return $newval
    126127
  • trunk/gui/scripts/sequenceresult.tcl

    r997 r1135  
    212212    }
    213213    lappend _dlist $dataobj
    214 
    215214    $_dispatcher event -idle !rebuild
    216215}
     
    289288# ----------------------------------------------------------------------
    290289itcl::body Rappture::SequenceResult::download {option args} {
     290    if { ![winfo exists $itk_component(area).viewer] } {
     291        return ""; # No data, no viewer, no download.
     292    }
    291293    switch $option {
    292294        coming {
    293             return [$itk_component(area).viewer download coming]
     295            return [$itk_component(area).viewer download coming]
    294296        }
    295297        controls {
     
    336338# ----------------------------------------------------------------------
    337339itcl::body Rappture::SequenceResult::play {} {
     340    if { [llength $_indices] == 0 } {
     341        return;                         # No frames (i.e. no data).
     342    }
    338343    # cancel any existing animation
    339344    pause
     
    477482            }
    478483            default {
    479                 error "don't know how to view sequences of $type"
     484                puts stderr "don't know how to view sequences of type \"$type\""
     485                puts stderr "Is the sequence empty?"
     486                return
    480487            }
    481488        }
  • trunk/gui/scripts/switch.tcl

    r1120 r1135  
    33#
    44#  This widget is used to control a (boolean) on/off value. 
    5 # It is just a wrapper around a checkbutton.
     5# It is just a wrapper around a button.
    66# ======================================================================
    77#  AUTHOR:  Michael McLennan, Purdue University
     
    2222    public method value {args}
    2323    public method updateText {}
     24    private method _toggle {args}
    2425    private variable _value 0  ;# value for this widget
    2526}
     
    3435itcl::body Rappture::Switch::constructor {args} {
    3536
    36     itk_component add value {
    37         checkbutton $itk_interior.value \
    38             -variable [itcl::scope _value] \
    39             -command [itcl::code $this updateText]
     37    itk_component add button {
     38        button $itk_interior.value \
     39            -compound left \
     40            -overrelief flat -relief flat -padx 3 -pady 0 -bd 0 \
     41            -command [itcl::code $this _toggle]
    4042    } {
    4143        #rename -background -textbackground textBackground Background
    4244    }
    43     pack $itk_component(value) -side left -expand yes -fill both
     45    pack $itk_component(button) -side left -expand yes -fill both
    4446    eval itk_initialize $args
    4547}
     
    6163        set args [lreplace $args $i $i]
    6264    }
    63 
    6465    if {[llength $args] == 1} {
    6566        set newval [lindex $args 0]
     
    8081}
    8182
     83# ----------------------------------------------------------------------
     84# _toggle
     85#
     86#       Use internally to convert the toggled button into the
     87#       proper boolean format.  Yes, right now it's hardcoded to
     88#       yes/no.  But in the future it could be some other text.
     89#
     90#       Can't use old "value" method because _value is already set
     91#       be the widget and doesn't pass the value on the command line.
     92#
     93# ----------------------------------------------------------------------
     94itcl::body Rappture::Switch::_toggle {} {
     95    set _value [expr ($_value==0) ]
     96    event generate $itk_component(hull) <<Value>>
     97    updateText
     98}
     99
    82100itcl::body Rappture::Switch::updateText {} {
    83     set mesg [expr {($_value) ? "on" : "off"}]
    84     $itk_component(value) configure -text $mesg
     101    if { $_value } {
     102        $itk_component(button) configure -text "yes" \
     103            -image [Rappture::icon cbon]
     104    } else {
     105        $itk_component(button) configure -text "no" \
     106            -image [Rappture::icon cboff]
     107    }
    85108}
    86109   
     
    90113# ----------------------------------------------------------------------
    91114itcl::configbody Rappture::Switch::oncolor {
    92     $itk_component(value) configure -selectcolor $itk_option(-oncolor)
     115    #$itk_component(button) configure -selectcolor $itk_option(-oncolor)
    93116}
    94117
     
    101124        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
    102125    }
    103     $itk_component(value) configure -state $itk_option(-state)
     126    $itk_component(button) configure -state $itk_option(-state)
    104127}
Note: See TracChangeset for help on using the changeset viewer.