Ignore:
Timestamp:
Mar 18, 2009 2:59:21 PM (15 years ago)
Author:
gah
Message:

preliminary HQ output from molvisviewer; unexpand tabs; all jpeg generation at 100%

File:
1 edited

Legend:

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

    r1277 r1342  
    4848
    4949    blt::bitmap define ComboboxArrow {
    50         #define arrow_width 8
    51         #define arrow_height 4
    52         static unsigned char arrow_bits[] = {
    53            0xfe, 0x7c, 0x38, 0x10};
    54     }
    55 }
    56                                                                                
     50        #define arrow_width 8
     51        #define arrow_height 4
     52        static unsigned char arrow_bits[] = {
     53           0xfe, 0x7c, 0x38, 0x10};
     54    }
     55}
     56                                                                               
    5757itk::usual Combobox {
    5858    keep -cursor -font
     
    6969
    7070    itk_component add button {
    71         button $itk_interior.btn -bitmap ComboboxArrow -padx 0 \
    72             -borderwidth 1 -relief raised -highlightthickness 0
     71        button $itk_interior.btn -bitmap ComboboxArrow -padx 0 \
     72            -borderwidth 1 -relief raised -highlightthickness 0
    7373    } {
    74         usual
    75         ignore -highlightthickness -highlightbackground -highlightcolor
    76         ignore -borderwidth -relief
     74        usual
     75        ignore -highlightthickness -highlightbackground -highlightcolor
     76        ignore -borderwidth -relief
    7777    }
    7878    pack $itk_component(button) -side right -fill y
    7979
    8080    itk_component add entry {
    81         entry $itk_interior.entry -borderwidth 0 -relief flat
     81        entry $itk_interior.entry -borderwidth 0 -relief flat
    8282    } {
    83         usual
    84         keep -width
    85         rename -highlightbackground -textbackground textBackground Background
    86         rename -background -textbackground textBackground Background
    87         rename -foreground -textforeground textForeground Foreground
    88         rename -disabledbackground -textbackground textBackground Background
    89         rename -disabledforeground -textforeground textForeground Foreground
    90         ignore -borderwidth -relief
     83        usual
     84        keep -width
     85        rename -highlightbackground -textbackground textBackground Background
     86        rename -background -textbackground textBackground Background
     87        rename -foreground -textforeground textForeground Foreground
     88        rename -disabledbackground -textbackground textBackground Background
     89        rename -disabledforeground -textforeground textForeground Foreground
     90        ignore -borderwidth -relief
    9191    }
    9292    pack $itk_component(entry) -side left -expand yes -fill both
    9393
    9494    bind $itk_component(entry) <KeyPress-Return> \
    95         [itcl::code $this _entry apply]
     95        [itcl::code $this _entry apply]
    9696    bind $itk_component(entry) <ButtonPress> \
    97         [itcl::code $this _entry click]
     97        [itcl::code $this _entry click]
    9898
    9999    itk_component add ddlist {
    100         Rappture::Dropdownlist $itk_component(button).ddlist \
    101             -postcommand [itcl::code $this _dropdown post] \
    102             -unpostcommand [itcl::code $this _dropdown unpost] \
     100        Rappture::Dropdownlist $itk_component(button).ddlist \
     101            -postcommand [itcl::code $this _dropdown post] \
     102            -unpostcommand [itcl::code $this _dropdown unpost] \
    103103    }
    104104
    105105    bind $itk_component(ddlist) <<DropdownlistSelect>> \
    106         [itcl::code $this _dropdown select]
     106        [itcl::code $this _dropdown select]
    107107
    108108    $itk_component(button) configure -command \
    109         [list $itk_component(ddlist) post $itk_component(hull) left]
     109        [list $itk_component(ddlist) post $itk_component(hull) left]
    110110
    111111    eval itk_initialize $args
     
    122122itcl::body Rappture::Combobox::value {args} {
    123123    if {[llength $args] == 1} {
    124         set newval [lindex $args 0]
    125 
    126         $itk_component(entry) configure -state normal
    127         $itk_component(entry) delete 0 end
    128         $itk_component(entry) insert 0 $newval
    129         if {!$itk_option(-editable)} {
    130             $itk_component(entry) configure -state disabled
    131         }
    132 
    133         after 10 [list catch [list event generate $itk_component(hull) <<Value>>]]
     124        set newval [lindex $args 0]
     125
     126        $itk_component(entry) configure -state normal
     127        $itk_component(entry) delete 0 end
     128        $itk_component(entry) insert 0 $newval
     129        if {!$itk_option(-editable)} {
     130            $itk_component(entry) configure -state disabled
     131        }
     132
     133        after 10 [list catch [list event generate $itk_component(hull) <<Value>>]]
    134134    } elseif {[llength $args] != 0} {
    135         error "wrong # args: should be \"value ?newval?\""
     135        error "wrong # args: should be \"value ?newval?\""
    136136    }
    137137    return [$itk_component(entry) get]
     
    148148itcl::body Rappture::Combobox::translate {value} {
    149149    foreach {val label} [choices get -both] {
    150         if {$label == $value} {
    151             return $val
    152         }
     150        if {$label == $value} {
     151            return $val
     152        }
    153153    }
    154154    return ""
     
    183183itcl::body Rappture::Combobox::_entry {option} {
    184184    switch -- $option {
    185         apply {
    186             if {$itk_option(-editable) && $itk_option(-state) == "normal"} {
    187                 event generate $itk_component(hull) <<Value>>
    188             }
    189         }
    190         click {
    191             if {!$itk_option(-editable) && $itk_option(-state) == "normal"} {
    192                 $itk_component(button) configure -relief sunken
    193                 update idletasks; after 100
    194                 $itk_component(button) configure -relief raised
    195 
    196                 $itk_component(ddlist) post $itk_component(hull) left
    197             }
    198         }
    199         default {
    200             error "bad option \"$option\": should be apply, click"
    201         }
     185        apply {
     186            if {$itk_option(-editable) && $itk_option(-state) == "normal"} {
     187                event generate $itk_component(hull) <<Value>>
     188            }
     189        }
     190        click {
     191            if {!$itk_option(-editable) && $itk_option(-state) == "normal"} {
     192                $itk_component(button) configure -relief sunken
     193                update idletasks; after 100
     194                $itk_component(button) configure -relief raised
     195
     196                $itk_component(ddlist) post $itk_component(hull) left
     197            }
     198        }
     199        default {
     200            error "bad option \"$option\": should be apply, click"
     201        }
    202202    }
    203203}
     
    216216itcl::body Rappture::Combobox::_dropdown {option} {
    217217    switch -- $option {
    218         post {
    219             set value [$itk_component(entry) get]
    220             set i [$itk_component(ddlist) index -label $value]
    221             if {$i >= 0} {
    222                 $itk_component(ddlist) select clear 0 end
    223                 $itk_component(ddlist) select set $i
    224             }
    225         }
    226         unpost {
    227             if {$itk_option(-editable)} {
    228                 focus $itk_component(entry)
    229             }
    230         }
    231         select {
    232             set val [$itk_component(ddlist) current -label]
    233             if {"" != $val} {
    234                 value $val
    235             }
    236         }
    237         default {
    238             error "bad option \"$option\": should be post, unpost, select"
    239         }
     218        post {
     219            set value [$itk_component(entry) get]
     220            set i [$itk_component(ddlist) index -label $value]
     221            if {$i >= 0} {
     222                $itk_component(ddlist) select clear 0 end
     223                $itk_component(ddlist) select set $i
     224            }
     225        }
     226        unpost {
     227            if {$itk_option(-editable)} {
     228                focus $itk_component(entry)
     229            }
     230        }
     231        select {
     232            set val [$itk_component(ddlist) current -label]
     233            if {"" != $val} {
     234                value $val
     235            }
     236        }
     237        default {
     238            error "bad option \"$option\": should be post, unpost, select"
     239        }
    240240    }
    241241}
     
    249249itcl::body Rappture::Combobox::_fixState {} {
    250250    if {$itk_option(-state) == "normal"} {
    251         $itk_component(button) configure -state normal
    252         $itk_component(entry) configure \
    253             -background $itk_option(-textbackground) \
    254             -foreground $itk_option(-textforeground) \
    255             -disabledbackground $itk_option(-textbackground) \
    256             -disabledforeground $itk_option(-textforeground)
     251        $itk_component(button) configure -state normal
     252        $itk_component(entry) configure \
     253            -background $itk_option(-textbackground) \
     254            -foreground $itk_option(-textforeground) \
     255            -disabledbackground $itk_option(-textbackground) \
     256            -disabledforeground $itk_option(-textforeground)
    257257    } else {
    258         $itk_component(button) configure -state disabled
    259         $itk_component(entry) configure \
    260             -background $itk_option(-disabledbackground) \
    261             -foreground $itk_option(-disabledforeground) \
    262             -disabledbackground $itk_option(-disabledbackground) \
    263             -disabledforeground $itk_option(-disabledforeground)
     258        $itk_component(button) configure -state disabled
     259        $itk_component(entry) configure \
     260            -background $itk_option(-disabledbackground) \
     261            -foreground $itk_option(-disabledforeground) \
     262            -disabledbackground $itk_option(-disabledbackground) \
     263            -disabledforeground $itk_option(-disabledforeground)
    264264    }
    265265
    266266    if {$itk_option(-editable)} {
    267         if {$itk_option(-state) == "normal"} {
    268             $itk_component(entry) configure -state normal
    269         } else {
    270             $itk_component(entry) configure -state disabled
    271         }
     267        if {$itk_option(-state) == "normal"} {
     268            $itk_component(entry) configure -state normal
     269        } else {
     270            $itk_component(entry) configure -state disabled
     271        }
    272272    } else {
    273         $itk_component(entry) configure -state disabled
     273        $itk_component(entry) configure -state disabled
    274274    }
    275275
    276276    if {!$itk_option(-editable) || $itk_option(-state) != "normal"} {
    277         # can't keep focus here -- move it along to the next widget
    278         if {[focus] == $itk_component(entry)} {
    279             focus [tk_focusNext [focus]]
    280         }
     277        # can't keep focus here -- move it along to the next widget
     278        if {[focus] == $itk_component(entry)} {
     279            focus [tk_focusNext [focus]]
     280        }
    281281    }
    282282}
     
    287287itcl::configbody Rappture::Combobox::editable {
    288288    if {![string is boolean -strict $itk_option(-editable)]} {
    289         error "bad value \"$itk_option(-editable)\": should be boolean"
     289        error "bad value \"$itk_option(-editable)\": should be boolean"
    290290    }
    291291    _fixState
     
    298298    set valid {normal disabled}
    299299    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
    300         error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
     300        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
    301301    }
    302302    _fixState
Note: See TracChangeset for help on using the changeset viewer.