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

Last change on this file since 2138 was 2138, checked in by mmc, 13 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: 927 bytes
Line 
1object boolean -extends base {
2    palettes "Inputs"
3
4    help http://rappture.org/wiki/rp_xml_ele_boolean
5
6    attr default -title "Default Value" -type boolean -path default
7
8    storage {
9        private variable _val   ;# boolean value
10    }
11
12    import xml {xmlobj path} {
13        attr import $xmlobj $path
14        import_string [$xmlobj get $path.current]
15    }
16
17    export xml {xmlobj path} {
18        set v [expr {($_val) ? "true" : "false"}]
19        $xmlobj put $path $v
20    }
21
22    import string {val} {
23        if {[string is boolean -strict $val]} {
24            set _val $val
25        } else {
26            error "don't recognize value"
27        }
28    }
29
30    export string {var} {
31        upvar $var v
32        set v [expr {($_val) ? "true" : "false"}]
33    }
34
35    compare {
36        if {$_val && !$_val2} {
37            return 1
38        } elseif {!$_val && $_val} {
39            return -1
40        }
41        return 0
42    }
43}
Note: See TracBrowser for help on using the repository browser.