Rune - Content-locking work 1/2
[rune.git] / tests / gfxbutton2.d
1 #!/usr/local/bin/rune -x
2 #
3 #       Graphical test
4
5 limport "sys";
6 import "stdio";
7 import "gfx";
8 import "gadgets";
9
10 alias stdio.File *stdout = stdio.stdout;
11
12 typedef gfx.Event               Event;
13 typedef gfx.Frame               Frame;
14 typedef gadgets.ButtonFrame     Button;
15
16 subclass Button as MyButton {
17         refine public method
18         void
19         buttonExecute()
20         {
21                 stdout->show("BUTTON!", this.text);
22         }
23 }
24
25 int
26 main(int ac, char **av)
27 {
28         Frame *frame;
29         Frame *frame1;
30         Frame *frame2;
31         MyButton *button;
32         int i;
33         int j;
34
35         frame.createFrame("BODY", &gfx.root, 1024, 512, BODY);
36         frame->setBGColor(255, 129, 0);
37         for (i = 0; i < 20; ++i) {
38                 # Note the use of context-sensitive constants like 'ABOVE'.
39                 # Access outside of a method argument would be something
40                 # like 'Frame.ABOVE'.
41                 #
42                 if (i < 10)
43                         frame1.createFrame("ABOVE", frame,
44                                            0, 0, ABOVE|FILLX);
45                 else
46                         frame1.createFrame("BELOW", frame,
47                                            0, 0, BELOW|FILLX);
48                 for (j = 0; j < 10; ++j) {
49                         button.createButton(frame1, 0, 0, LEFT, "TestL");
50                 }
51                 for (j = 0; j < 10; ++j) {
52                         button.createButton(frame1, 0, 0, RIGHT, "TestR");
53                 }
54         }
55         button.createButton(frame, 0, 0, BODY|FILLX|FILLY, "TestM");
56         frame->recalc();
57         frame->flush();
58         Thread.waitThreads();           # wait until all threads have exited
59
60         return(0);
61 }