3 define app = ((GuiApplication)__thisModule);
5 struct WindowAsteroid {
10 get { return win.position.x; }
11 set { win.position.x = value; }
14 get { return win.position.y; }
15 set { win.position.y = value; }
18 get { return win.size.w; }
19 set { win.size.w = value; }
22 get { return win.size.h; }
23 set { win.size.h = value; }
27 class WindowAsteroidField : struct {
33 void Initialize(uint wcount, Window win[]) {
37 item = new WindowAsteroid[wcount];
38 for (i=0; i<wcount; i++) {
41 item[i].dx = GetRandom(-3,3);
42 item[i].dy = GetRandom(-3,3);
43 } while (!item[i].dx && !item[i].dy);
48 WindowAsteroid *i = item;
53 if (i->x<0 && i->dx<0 || (i->x+i->w >= holder.clientSize.w && i->dx>0))
55 if (i->y<0 && i->dy<0 || (i->y+i->h >= holder.clientSize.h && i->dy>0))
60 ~WindowAsteroidField() {
67 text = "Enabled/Disabled";
68 background = activeBorder;
69 borderStyle = sizable;
75 anchor = { horz = -11, vert = -126 };
77 WindowAsteroidField astfield {this};
92 Button button = button5;
93 button.position.x += waste_direction;
94 if (button.position.x < 0) {
95 button.position.x = 0;
96 if (waste_direction<0)
97 waste_direction = -waste_direction;
98 } else if (button.position.x > size.w-button.size.w) {
99 button.position.x = size.w-button.size.w;
100 if (waste_direction>0)
101 waste_direction = -waste_direction;
107 uint counter0, counter1;
110 this, text = "Waste CPU cycles", size = { 135, 21 }, position = { 120, 120 }, isCheckbox = true;
112 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
114 wasteCPUTimer.started = button.checked;
120 this, text = "Asteroid Field", size = { 103, 21 }, position = { 416, 48 }, isCheckbox = true;
122 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
124 asteroidTimer.started = button.checked;
130 this, text = "Enabled", position = { 288, 88 }, isCheckbox = true, checked = true;
132 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
134 button2.disabled = !button.checked;
138 EditBox editBox1 { this, text = "editBox1", contents = "0", position = { 96, 56 }, readOnly = true };
139 EditBox editBox2 { this, text = "editBox2", contents = "0", position = { 296, 56 }, readOnly = true };
142 this, text = "Enabled", position = { 88, 88 }, isCheckbox = true, checked = true;
144 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
146 button1.disabled = !button.checked;
152 this, text = "Up Me", size = { 119, 21 }, position = { 280, 24 };
154 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
157 editBox2.SetContents("%u\n", counter1);
163 this, text = "Up Me", size = { 95, 21 }, position = { 88, 24 };
165 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
168 editBox1.SetContents("%u\n", counter0);
175 Window windows[] = {button5, button6, button4, editBox1, editBox2, button3, button2, button1};
176 astfield.Initialize(sizeof(windows)/sizeof(*windows), windows);
177 app.timerResolution = 100;