source: trunk/gui/scripts/gauge.tcl @ 3394

Last change on this file since 3394 was 3330, checked in by gah, 11 years ago

merge (by hand) with Rappture1.2 branch

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