source: branches/uq/gui/scripts/gauge.tcl @ 5179

Last change on this file since 5179 was 5179, checked in by mmh, 9 years ago

improved PDF initial values

File size: 26.0 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
2# ----------------------------------------------------------------------
3#  COMPONENT: gauge - compact readout for real values
4#
5#  This widget is a readout for a real value.  It has a little glyph
6#  filled with color according to the value, followed by a numeric
7#  representation of the value itself.  The value can be edited, and
8#  a list of predefined values can be associated with a menu that
9#  drops down from the value.
10# ======================================================================
11#  AUTHOR:  Michael McLennan, Purdue University
12#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
13#
14#  See the file "license.terms" for information on usage and
15#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16# ======================================================================
17package require Itk
18package require BLT
19
20option add *Gauge.sampleWidth 30 widgetDefault
21option add *Gauge.sampleHeight 20 widgetDefault
22option add *Gauge.borderWidth 2 widgetDefault
23option add *Gauge.relief sunken widgetDefault
24option add *Gauge.valuePosition "right" widgetDefault
25option add *Gauge.textBackground #cccccc widgetDefault
26option add *Gauge.editable yes widgetDefault
27
28itcl::class Rappture::Gauge {
29    inherit itk::Widget
30
31    itk_option define -editable editable Editable ""
32    itk_option define -state state State "normal"
33    itk_option define -spectrum spectrum Spectrum ""
34    itk_option define -type type Type "real"
35    itk_option define -units units Units ""
36    itk_option define -minvalue minValue MinValue ""
37    itk_option define -maxvalue maxValue MaxValue ""
38    itk_option define -presets presets Presets ""
39    itk_option define -valueposition valuePosition ValuePosition ""
40    itk_option define -image image Image ""
41    itk_option define -samplewidth sampleWidth SampleWidth 0
42    itk_option define -sampleheight sampleHeight SampleHeight 0
43    itk_option define -log log Log ""
44    itk_option define -varname varname Varname ""
45    itk_option define -label label Label ""
46    itk_option define -validatecommand validateCommand ValidateCommand ""
47
48    constructor {args} { # defined below }
49
50    public method value {args}
51    public method edit {option}
52    public method bump {delta}
53
54    protected method _redraw {}
55    protected method _resize {}
56    protected method _hilite {comp state}
57    protected method _editor {option args}
58    protected method _presets {option}
59    protected method _layout {}
60    protected method _log {event args}
61    protected method _change_param_type {choice}
62    protected method _pop_uq {win}
63    protected method _pop_uq_deactivate {}
64
65    private variable _value 0  ;# value for this widget
66    private variable _mode exact ;# current mode
67    private variable _pde ""   ;# ProbDistEditor
68    private variable _val ""   ;# value choice combobox
69
70    blt::bitmap define GaugeArrow {
71        #define arrow_width 9
72        #define arrow_height 4
73        static unsigned char arrow_bits[] = {
74           0x7f, 0x00, 0x3e, 0x00, 0x1c, 0x00, 0x08, 0x00};
75    }
76}
77
78itk::usual Gauge {
79    keep -cursor -font -foreground -background
80    keep -selectbackground -selectforeground -selectborderwidth
81}
82
83# ----------------------------------------------------------------------
84# CONSTRUCTOR
85# ----------------------------------------------------------------------
86itcl::body Rappture::Gauge::constructor {args} {
87
88    itk_option remove hull.borderwidth hull.relief
89    component hull configure -borderwidth 0
90
91    itk_component add icon {
92        canvas $itk_interior.icon -width 1 -height 1 \
93            -borderwidth 0 -highlightthickness 0
94    } {
95        usual
96        ignore -highlightthickness -highlightbackground -highlightcolor
97        ignore -borderwidth -relief
98    }
99    bind $itk_component(icon) <Configure> [itcl::code $this _redraw]
100
101    itk_component add uq {
102        button $itk_interior.uq -image [Rappture::icon UQ] \
103            -command [itcl::code $this _pop_uq $itk_interior]
104    }
105
106    pack $itk_component(uq) -side right -padx 10
107
108    itk_component add -protected vframe {
109        frame $itk_interior.vframe
110    } {
111        keep -borderwidth -relief
112    }
113
114    itk_component add value {
115        label $itk_component(vframe).value -width 20 \
116            -borderwidth 1 -relief flat -textvariable [itcl::scope _value]
117    } {
118        keep -font
119        rename -background -textbackground textBackground Background
120    }
121    pack $itk_component(value) -side left -expand yes -fill both
122
123    bind $itk_component(value) <Enter> [itcl::code $this _hilite value on]
124    bind $itk_component(value) <Leave> [itcl::code $this _hilite value off]
125
126    bind $itk_component(value) <<Cut>> [itcl::code $this edit cut]
127    bind $itk_component(value) <<Copy>> [itcl::code $this edit copy]
128    bind $itk_component(value) <<Paste>> [itcl::code $this edit paste]
129
130    itk_component add emenu {
131        menu $itk_component(value).menu -tearoff 0
132    } {
133        usual
134        ignore -tearoff
135    }
136    $itk_component(emenu) add command -label "Cut" -accelerator "^X" \
137        -command [list event generate $itk_component(value) <<Cut>>]
138    $itk_component(emenu) add command -label "Copy" -accelerator "^C" \
139        -command [list event generate $itk_component(value) <<Copy>>]
140    $itk_component(emenu) add command -label "Paste" -accelerator "^V" \
141        -command [list event generate $itk_component(value) <<Paste>>]
142    bind $itk_component(value) <<PopupMenu>> \
143        [itcl::code $this _editor menu %X %Y]
144
145    itk_component add editor {
146        Rappture::Editor $itk_interior.editor \
147            -activatecommand [itcl::code $this _editor activate] \
148            -validatecommand [itcl::code $this _editor validate] \
149            -applycommand [itcl::code $this _editor apply]
150    }
151    bind $itk_component(value) <ButtonPress> \
152        [itcl::code $this _editor popup]
153
154
155    itk_component add spinner {
156        frame $itk_component(vframe).spinner
157    }
158
159    itk_component add spinup {
160        button $itk_component(spinner).up -image [Rappture::icon intplus] \
161            -borderwidth 1 -relief raised -highlightthickness 0 \
162            -command [itcl::code $this bump 1]
163    } {
164        usual
165        ignore -borderwidth -highlightthickness
166        rename -background -buttonbackground buttonBackground Background
167    }
168    pack $itk_component(spinup) -side left -expand yes -fill both
169
170    itk_component add spindn {
171        button $itk_component(spinner).down -image [Rappture::icon intminus] \
172            -borderwidth 1 -relief raised -highlightthickness 0 \
173            -command [itcl::code $this bump -1]
174    } {
175        usual
176        ignore -borderwidth -highlightthickness
177        rename -background -buttonbackground buttonBackground Background
178    }
179    pack $itk_component(spindn) -side right -expand yes -fill both
180
181    itk_component add presets {
182        button $itk_component(vframe).psbtn -bitmap GaugeArrow \
183            -borderwidth 1 -highlightthickness 0 -relief raised
184    } {
185        usual
186        ignore -borderwidth -relief -highlightthickness
187    }
188
189    bind $itk_component(presets) <Enter> [itcl::code $this _hilite presets on]
190    bind $itk_component(presets) <Leave> [itcl::code $this _hilite presets off]
191
192    itk_component add presetlist {
193        Rappture::Dropdownlist $itk_component(presets).plist \
194            -postcommand [itcl::code $this _presets post] \
195            -unpostcommand [itcl::code $this _presets unpost] \
196    }
197
198    bind $itk_component(presetlist) <<DropdownlistSelect>> \
199        [itcl::code $this _presets select]
200
201    $itk_component(presets) configure -command \
202        [list $itk_component(presetlist) post $itk_component(vframe) left]
203
204    eval itk_initialize $args
205}
206
207# ----------------------------------------------------------------------
208# USAGE: value ?-check? ?<newval>?
209#
210# Clients use this to query/set the value for this widget.  With
211# no args, it returns the current value for the widget.  If the
212# <newval> is specified, it sets the value of the widget and
213# sends a <<Value>> event.  If the -check flag is included, the
214# new value is not actually applied, but just checked for correctness.
215# ----------------------------------------------------------------------
216itcl::body Rappture::Gauge::value {args} {
217    #puts "Gauge value: $args"
218
219    # Query.  Just return the current value.
220    if {[llength $args] == 0} {
221        return $_value
222    }
223
224    set i [lsearch -exact $args -check]
225    if {$i >= 0} {
226        set onlycheck 1
227        set args [lreplace $args $i $i]
228    } else {
229        set onlycheck 0
230    }
231
232    if {[llength $args] != 1} {
233        error "wrong # args: should be \"value ?-check? ?newval?\""
234    }
235
236    set newval [Rappture::Units::mcheck_range [lindex $args 0] \
237    $itk_option(-minvalue) $itk_option(-maxvalue) $itk_option(-units)]
238
239    set newmode [lindex $newval 0]
240    switch -- $newmode {
241        uniform -
242        gaussian {
243            set _mode $newmode
244        }
245        exact -
246        default {
247            set _mode exact
248        }
249    }
250
251    switch -- $itk_option(-type) {
252        integer {
253            if { [scan $newval "%g" value] != 1 || int($newval) != $value } {
254                error "bad value \"$newval\": should be an integer value"
255            }
256        }
257    }
258
259    #
260    # If there's a -validatecommand option, then invoke the code
261    # now to check the new value.
262    #
263    if {[string length $itk_option(-validatecommand)] > 0} {
264        set cmd "uplevel #0 [list $itk_option(-validatecommand) [list $newval]]"
265        set result [eval $cmd]
266    }
267
268    if {$onlycheck} {
269        return
270    }
271
272    set _value $newval
273    $itk_component(value) configure -width [string length $_value]
274    _redraw
275    event generate $itk_component(hull) <<Value>>
276
277    if {"" != $_pde} {
278        set val [$_val translate [$_val value]]
279        $_val value $_mode
280        $_pde value $_value
281
282    }
283    return $_value
284}
285
286# ----------------------------------------------------------------------
287# USAGE: edit cut
288# USAGE: edit copy
289# USAGE: edit paste
290#
291# Used internally to handle cut/copy/paste operations for the current
292# value.  Usually invoked by <<Cut>>, <<Copy>>, <<Paste>> events, but
293# can also be called directly through this method.
294# ----------------------------------------------------------------------
295itcl::body Rappture::Gauge::edit {option} {
296    if {$itk_option(-state) == "disabled"} {
297        return  ;# disabled? then bail out here!
298    }
299    switch -- $option {
300        cut {
301            edit copy
302            _editor popup
303            $itk_component(editor) value ""
304            $itk_component(editor) deactivate
305        }
306        copy {
307            clipboard clear
308            clipboard append $_value
309        }
310        paste {
311            _editor popup
312            $itk_component(editor) value [clipboard get]
313            $itk_component(editor) deactivate
314        }
315        default {
316            error "bad option \"$option\": should be cut, copy, paste"
317        }
318    }
319}
320
321# ----------------------------------------------------------------------
322# USAGE: bump <delta>
323#
324# Changes the current value up/down by the <delta> value.  Used
325# internally by the up/down spinner buttons when the value is
326# -type integer.
327# ----------------------------------------------------------------------
328itcl::body Rappture::Gauge::bump {delta} {
329    set val $_value
330    if {$val == ""} {
331        set val 0
332    }
333    if {[catch {value [expr {$val+$delta}]} result]} {
334        if {[regexp {allowed here is (.+)} $result match newval]} {
335            set _value $newval
336            $itk_component(value) configure -text $newval
337        }
338        if {[regexp {^bad.*: +(.)(.+)} $result match first tail]
339              || [regexp {(.)(.+)} $result match first tail]} {
340            set result "[string toupper $first]$tail"
341        }
342        bell
343        Rappture::Tooltip::cue $itk_component(value) $result
344        _log warning $result
345        return 0
346    }
347    _log input [value]
348}
349
350# ----------------------------------------------------------------------
351# USAGE: _redraw
352#
353# Used internally to redraw the gauge on the internal canvas based
354# on the current value and the size of the widget.  In this simple
355# base class, the gauge is drawn as a colored block, with an optional
356# image in the middle of it.
357# ----------------------------------------------------------------------
358itcl::body Rappture::Gauge::_redraw {} {
359    set c $itk_component(icon)
360    set w [winfo width $c]
361    set h [winfo height $c]
362
363    if {"" == [$c find all]} {
364        # first time around, create the items
365        $c create rectangle 0 0 1 1 -outline black -tags block
366        $c create image 0 0 -anchor center -image "" -tags bimage
367        $c create rectangle 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags screen
368    }
369
370    if {"" != $itk_option(-spectrum)} {
371        set color [$itk_option(-spectrum) get $_value]
372    } else {
373        set color ""
374    }
375
376    # update the items based on current values
377    $c coords block 0 0 [expr {$w-1}] [expr {$h-1}]
378    $c coords screen 0 0 $w $h
379    $c itemconfigure block -fill $color
380
381    $c coords bimage [expr {0.5*$w}] [expr {0.5*$h}]
382
383    if {$itk_option(-state) == "disabled"} {
384        $c itemconfigure screen -fill white
385    } else {
386        $c itemconfigure screen -fill ""
387    }
388}
389
390# ----------------------------------------------------------------------
391# USAGE: _resize
392#
393# Used internally to resize the internal canvas based on the -image
394# option or the size of the text.
395# ----------------------------------------------------------------------
396itcl::body Rappture::Gauge::_resize {} {
397    set w 0
398    set h 0
399
400    if {"" != $itk_option(-image) || "" != $itk_option(-spectrum)} {
401        if {$itk_option(-samplewidth) > 0} {
402            set w $itk_option(-samplewidth)
403        } else {
404            if {$itk_option(-image) != ""} {
405                set w [expr {[image width $itk_option(-image)]+4}]
406            } else {
407                set w [winfo reqheight $itk_component(value)]
408            }
409        }
410
411        if {$itk_option(-sampleheight) > 0} {
412            set h $itk_option(-sampleheight)
413        } else {
414            if {$itk_option(-image) != ""} {
415                set h [expr {[image height $itk_option(-image)]+4}]
416            } else {
417                set h [winfo reqheight $itk_component(value)]
418            }
419        }
420    }
421
422    if {$w > 0 && $h > 0} {
423        $itk_component(icon) configure -width $w -height $h
424    }
425}
426
427# ----------------------------------------------------------------------
428# USAGE: _hilite <component> <state>
429#
430# Used internally to resize the internal canvas based on the -image
431# option or the size of the text.
432# ----------------------------------------------------------------------
433itcl::body Rappture::Gauge::_hilite {comp state} {
434    if {$itk_option(-state) == "disabled"} {
435        set state 0  ;# disabled? then don't hilite
436    }
437    if {$comp == "value" && !$itk_option(-editable)} {
438        $itk_component(value) configure -relief flat
439        return
440    }
441
442    if {$state} {
443        $itk_component($comp) configure -relief flat
444    } else {
445        if {$comp eq "presets"} {
446            $itk_component($comp) configure -relief raised
447        } else {
448            $itk_component($comp) configure -relief flat
449        }
450    }
451}
452
453# ----------------------------------------------------------------------
454# USAGE: _editor popup
455# USAGE: _editor activate
456# USAGE: _editor validate <value>
457# USAGE: _editor apply <value>
458# USAGE: _editor menu <rootx> <rooty>
459#
460# Used internally to handle the various functions of the pop-up
461# editor for the value of this gauge.
462# ----------------------------------------------------------------------
463itcl::body Rappture::Gauge::_editor {option args} {
464    # puts "Gauge::editor option=$option args=$args"
465    if {$itk_option(-state) == "disabled"} {
466        return  ;# disabled? then bail out here!
467    }
468    switch -- $option {
469        popup {
470            if {$itk_option(-editable)} {
471                $itk_component(editor) activate
472            }
473        }
474        activate {
475            return [list text $_value \
476                x [winfo rootx $itk_component(value)] \
477                y [winfo rooty $itk_component(value)] \
478                w [winfo width $itk_component(value)] \
479                h [winfo height $itk_component(value)]]
480        }
481        validate {
482            if {[llength $args] != 1} {
483                error "wrong # args: should be \"_editor validate val\""
484            }
485            set val [lindex $args 0]
486            if {[catch {value -check $val} result]} {
487                if {[regexp {allowed here is (.+)} $result match newval]} {
488                    $itk_component(editor) value $newval
489                }
490                if {[regexp {^bad.*: +(.)(.+)} $result match first tail]
491                      || [regexp {(.)(.+)} $result match first tail]} {
492                    set result "[string toupper $first]$tail"
493                }
494                bell
495                Rappture::Tooltip::cue $itk_component(editor) $result
496                _log warning $result
497                return 0
498            }
499        }
500        apply {
501            if {[llength $args] != 1} {
502                error "wrong # args: should be \"_editor apply val\""
503            }
504            set newval [lindex $args 0]
505            value $newval
506            _log input $newval
507        }
508        menu {
509            eval tk_popup $itk_component(emenu) $args
510        }
511        default {
512            error "bad option \"$option\": should be popup, activate, validate, apply, and menu"
513        }
514    }
515}
516
517# ----------------------------------------------------------------------
518# USAGE: _presets post
519# USAGE: _presets unpost
520# USAGE: _presets select
521#
522# Used internally to handle the list of presets for this gauge.  The
523# post/unpost options are invoked when the list is posted or unposted
524# to manage the relief of the controlling button.  The select option
525# is invoked whenever there is a selection from the list, to assign
526# the value back to the gauge.
527# ----------------------------------------------------------------------
528itcl::body Rappture::Gauge::_presets {option} {
529    switch -- $option {
530        post {
531            set i [$itk_component(presetlist) index $_value]
532            if {$i >= 0} {
533                $itk_component(presetlist) select clear 0 end
534                $itk_component(presetlist) select set $i
535            }
536            after 10 [list $itk_component(presets) configure -relief sunken]
537        }
538        unpost {
539            $itk_component(presets) configure -relief raised
540        }
541        select {
542            set val [$itk_component(presetlist) current]
543            if {"" != $val} {
544                value $val
545                _log input $val
546            }
547        }
548        default {
549            error "bad option \"$option\": should be post, unpost, select"
550        }
551    }
552}
553
554# ----------------------------------------------------------------------
555# USAGE: _layout
556#
557# Used internally to fix the layout of widgets whenever there is a
558# change in the options that affect layout.  Puts the value in the
559# proper position according to the -valueposition option.  Also,
560# adds or removes the icon if it needs to be shown.
561# ----------------------------------------------------------------------
562itcl::body Rappture::Gauge::_layout {} {
563    foreach w [pack slaves $itk_component(hull)] {
564        pack forget $w
565    }
566
567    if {$itk_option(-type) != "integer"} {
568        pack $itk_component(uq) -side right -padx 10
569    }
570
571    array set side2anchor {
572        left   e
573        right  w
574        top    s
575        bottom n
576    }
577    set pos $itk_option(-valueposition)
578    pack $itk_component(vframe) -side $pos \
579        -expand yes -fill both -ipadx 2
580    $itk_component(value) configure -anchor $side2anchor($pos)
581
582    if {"" != $itk_option(-image) || "" != $itk_option(-spectrum)} {
583        pack $itk_component(icon) -side $pos -padx 2
584    }
585}
586
587# ----------------------------------------------------------------------
588# USAGE: _log event ?arg arg...?
589#
590# Used internally to send info to the logging mechanism.  If the -log
591# argument is set, then this calls the Rappture::Logger mechanism to
592# log the rest of the arguments as an action.  Otherwise, it does
593# nothing.
594# ----------------------------------------------------------------------
595itcl::body Rappture::Gauge::_log {event args} {
596    if {$itk_option(-log) ne ""} {
597        eval Rappture::Logger::log $event [list $itk_option(-log)] $args
598    }
599}
600
601# ----------------------------------------------------------------------
602# CONFIGURATION OPTION: -editable
603# ----------------------------------------------------------------------
604itcl::configbody Rappture::Gauge::editable {
605    if {![string is boolean -strict $itk_option(-editable)]} {
606        error "bad value \"$itk_option(-editable)\": should be boolean"
607    }
608    if {!$itk_option(-editable) && [winfo ismapped $itk_component(editor)]} {
609        $itk_component(editor) deactivate -abort
610    }
611}
612
613# ----------------------------------------------------------------------
614# CONFIGURATION OPTION: -state
615# ----------------------------------------------------------------------
616itcl::configbody Rappture::Gauge::state {
617    set valid {normal disabled}
618    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
619        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
620    }
621    $itk_component(value) configure -state $itk_option(-state)
622    $itk_component(spinup) configure -state $itk_option(-state)
623    $itk_component(spindn) configure -state $itk_option(-state)
624    $itk_component(presets) configure -state $itk_option(-state)
625    _redraw  ;# fix gauge
626}
627
628# ----------------------------------------------------------------------
629# CONFIGURATION OPTION: -spectrum
630# ----------------------------------------------------------------------
631itcl::configbody Rappture::Gauge::spectrum {
632    if {$itk_option(-spectrum) != ""
633          && ([catch {$itk_option(-spectrum) isa ::Rappture::Spectrum} valid]
634               || !$valid)} {
635        error "bad option \"$itk_option(-spectrum)\": should be Rappture::Spectrum object"
636    }
637    _resize
638    _layout
639    _redraw
640}
641
642# ----------------------------------------------------------------------
643# CONFIGURATION OPTION: -image
644# ----------------------------------------------------------------------
645itcl::configbody Rappture::Gauge::image {
646    if {$itk_option(-image) != ""
647          && [catch {image width $itk_option(-image)}]} {
648        error "bad value \"$itk_option(-image)\": should be Tk image"
649    }
650    _resize
651    _layout
652    $itk_component(icon) itemconfigure bimage -image $itk_option(-image)
653}
654
655# ----------------------------------------------------------------------
656# CONFIGURATION OPTION: -units
657# ----------------------------------------------------------------------
658itcl::configbody Rappture::Gauge::units {
659    if {$itk_option(-units) != ""
660          && [::Rappture::Units::System::for $itk_option(-units)] == ""} {
661        error "unrecognized system of units \"$itk_option(-units)\""
662    }
663}
664
665# ----------------------------------------------------------------------
666# CONFIGURATION OPTION: -valueposition
667# ----------------------------------------------------------------------
668itcl::configbody Rappture::Gauge::valueposition {
669    set pos $itk_option(-valueposition)
670    set opts {left right top bottom}
671    if {[lsearch -exact $opts $pos] < 0} {
672        error "bad value \"$pos\": should be [join $opts {, }]"
673    }
674    _layout
675}
676
677# ----------------------------------------------------------------------
678# CONFIGURATION OPTION: -presets
679# ----------------------------------------------------------------------
680itcl::configbody Rappture::Gauge::presets {
681    if {"" == $itk_option(-presets)} {
682        pack forget $itk_component(presets)
683    } else {
684        if {$itk_option(-valueposition) == "left"} {
685            set s "left"
686        } else {
687            set s "right"
688        }
689        set first [lindex [pack slaves $itk_component(vframe)] 0]
690        pack $itk_component(presets) -before $first -side $s -fill y
691
692        $itk_component(presetlist) delete 0 end
693        $itk_component(presetlist) insert end $itk_option(-presets)
694    }
695}
696
697# ----------------------------------------------------------------------
698# CONFIGURATION OPTION: -type
699# ----------------------------------------------------------------------
700itcl::configbody Rappture::Gauge::type {
701    switch -- $itk_option(-type) {
702        integer {
703            set first [lindex [pack slaves $itk_component(vframe)] 0]
704            if {$first == $itk_component(presets)} {
705                pack $itk_component(spinner) -after $first -side left -fill y
706            } else {
707                pack $itk_component(spinner) -before $first -side right -fill y
708            }
709        }
710        real {
711            pack forget $itk_component(spinner)
712        }
713        default {
714            error "bad number type \"$itk_option(-type)\": should be integer or real"
715        }
716    }
717}
718
719itcl::body Rappture::Gauge::_pop_uq {win} {
720    # puts "min=$itk_option(-minvalue) max=$itk_option(-maxvalue) units=$itk_option(-units)"
721    set varname $itk_option(-varname)
722    set popup .pop_uq_$varname
723    if { ![winfo exists $popup] } {
724        Rappture::Balloon $popup -title $itk_option(-label)
725        set inner [$popup component inner]
726        frame $inner.type
727        pack $inner.type -side top -fill x
728        label $inner.type.l -text "Parameter Value:"
729        pack $inner.type.l -side left
730
731        set _val [Rappture::Combobox $inner.type.val -width 20 -editable no]
732        pack $_val -side left -expand yes -fill x
733        $_val choices insert end exact "Exact Value"
734        $_val choices insert end uniform "Uniform Distribution"
735        $_val choices insert end gaussian "Gaussian Distribution"
736        bind $_val <<Value>> [itcl::code $this _change_param_type $inner]
737
738        set _pde [Rappture::ProbDistEditor $inner.entry \
739        $itk_option(-minvalue) $itk_option(-maxvalue) $itk_option(-units) $_value]
740        $_val value $_mode
741        $_pde value $_value
742        pack $inner.entry -expand yes -fill both -pady {10 0}
743
744        $popup configure \
745        -deactivatecommand [itcl::code $this _pop_uq_deactivate]
746    }
747    update
748    $popup activate $win right
749}
750
751itcl::body Rappture::Gauge::_pop_uq_deactivate {} {
752    # puts "deactivate [$_pde value]"
753    value [$_pde value]
754}
755
756itcl::body Rappture::Gauge::_change_param_type {inner} {
757    set val [$_val translate [$_val value]]
758    $_pde mode $val
759}
Note: See TracBrowser for help on using the repository browser.