source: trunk/lang/tcl/scripts/objects/integer/integer.rp @ 2138

Last change on this file since 2138 was 2138, checked in by mmc, 14 years ago

More changes for the regression tester tool. Added a way for all ObjVal?
objects to import their attribute values. Once an ObjVal? has been imported,
it knows everything about itself without having to consult the XML.

Added Rappture::objects::viewer, which can be used to query the viewer for
a particular object type. Each object can have an "input" viewer for
specifying input values, and an "output" viewer for visualizing output
results. Right now, there is only one viewer implemented: an output viewer
for the CurveValue? object. We should create output viewers for all object
types, and then work on the input side too.

Added a "mkobjects.tcl" script used by the Makefile to build up the tclIndex
file. It looks for input/output viewers for all object classes and adds
them to tclIndex so they can be autoloaded.

File size: 1.8 KB
Line 
1object integer -extends base {
2    palettes "Inputs"
3
4    help http://rappture.org/wiki/rp_xml_ele_integer
5
6    attr default -title "Default Value" -type string:validate=int -path default
7    attr min -title "Minimum Value" -type string:validate=int -path min
8    attr max -title "Maximum Value" -type string:validate=int -path max
9
10    check default {
11        if {[string length [string trim $attr(default)]] == 0} {
12            return [list error "Must have a default value for this integer."]
13        }
14        if {"" != $attr(min) && $attr(default) < $attr(min)} {
15            return [list error "Default value is less than the minimum that you've specified for this value."]
16        }
17        if {"" != $attr(max) && $attr(default) > $attr(max)} {
18            return [list error "Default value is greater than the maximum that you've specified for this value."]
19        }
20    }
21
22    check min {
23        if {"" != $attr(min) && "" != $attr(max) && $attr(min) >= $attr(max)} {
24            return [list error "Minimum value should be less than the maximum.  If you don't want to see a min/max range, you can clear out either or both values."]
25        }
26    }
27
28    storage {
29        private variable _val 0     ;# integer value
30    }
31
32    import xml {xmlobj path} {
33        attr import $xmlobj $path
34        import_string [$xmlobj get $path.current]
35    }
36
37    export xml {xmlobj path} {
38        $xmlobj put $path $_val
39    }
40
41    import string {val} {
42        if {[string is integer -strict $val]} {
43            set _val $val
44        } else {
45            error "don't recognize value"
46        }
47    }
48
49    export string {var} {
50        upvar $var v
51        set v $_val
52    }
53
54    compare {
55        if {$_val < $_val2} {
56            return -1
57        } elseif {$_val > $_val2} {
58            return 1
59        } else {
60            return 0
61        }
62    }
63}
Note: See TracBrowser for help on using the repository browser.