Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / tcl / class / runme.tcl
1 # file: runme.tcl
2
3 # This file illustrates the high level C++ interface.
4 # In this case C++ classes work kind of like Tk widgets
5
6 catch { load ./example[info sharedlibextension] example}
7
8 # ----- Object creation -----
9
10 puts "Creating some objects:"
11 Circle c 10
12 puts "    Created circle [c cget -this]"
13 Square s 10
14 puts "    Created square [s cget -this]"
15
16 # ----- Access a static member -----
17
18 puts "\nA total of $Shape_nshapes shapes were created"
19
20 # ----- Member data access -----
21
22 # Set the location of the object
23
24 c configure -x 20 -y 30
25 s configure -x -10 -y 5
26
27 puts "\nHere is their current position:"
28 puts "    Circle = ([c cget -x], [c cget -y])"
29 puts "    Square = ([s cget -x], [s cget -y])"
30
31 # ----- Call some methods -----
32
33 puts "\nHere are some properties of the shapes:"
34 foreach o "c s" {
35       puts "    [$o cget -this]"
36       puts "        area      = [$o area]"
37       puts "        perimeter = [$o perimeter]"
38 }
39
40 # ----- Delete everything -----
41
42 puts "\nGuess I'll clean up now"
43
44 # Note: this invokes the virtual destructor
45 rename c ""
46 rename s ""
47
48 puts "$Shape_nshapes shapes remain"
49 puts "Goodbye"
50