1 #!/usr/local/bin/rune -x
9 alias stdio.File *stdout = stdio.stdout;
11 typedef gfx.Event Event;
12 typedef gfx.Frame Frame;
14 subclass Frame as MyFrame {
20 refreshFrame(int x, int y, int w, int h)
24 for (i = 0; i < 512; i += 32) {
25 for (j = 0; j < 512; j += 32) {
26 this.drawLine(0, i, j, 0);
35 if (this.holding == Event.XK_Pointer_Button1)
36 this.drawLineTo(ev->pos.x, ev->pos.y);
37 if (this.holding == Event.XK_Pointer_Button2)
38 this.drawPoint(ev->pos.x, ev->pos.y);
43 buttonPressed(Event *ev)
46 case Event.XK_Pointer_Button1:
47 this.savePos = ev->pos;
49 case Event.XK_Pointer_Button2:
50 this.drawPoint(ev->pos.x, ev->pos.y);
51 this.holding = ev->keySym;
52 stdout->show("position", ev->pos.x, ev->pos.y);
54 case -Event.XK_Pointer_Button1:
55 case -Event.XK_Pointer_Button2:
56 if (this.holding == Event.XK_Pointer_Button1) {
57 this.drawLineTo(ev->pos.x, ev->pos.y);
61 case Event.XK_Pointer_Button3:
62 this.pen->setFGColor(0xFFFF, 0, 0);
63 this.savePos = ev->pos;
65 case -Event.XK_Pointer_Button3:
66 this.fillRect(this.savePos.x, this.savePos.y,
67 ev->pos.x, ev->pos.y);
70 if (ev->keySym > 0 && ev->keyChar > 0UB) {
71 this.drawText(this.savePos.x, this.savePos.y,
73 this.savePos.x += this.textWidth(&ev->keyChar,
83 main(int ac, char **av)
89 frame.createFrame("BODY", &gfx.root, 512, 512, BODY);
93 # If we unlink and NULL out the frame, there will be no refs
94 # and Rune should destroy it.
96 # If we do not unlink the frame the frame thread will prevent
99 #stdout->show("should exit after 2.5 seconds");
101 Thread.tsleep(&waiting, 5000);
102 stdout->show("main woke up");
103 frame->unlinkFrame();
104 # frame->destroyFrame(); - NULLing it out should be good enough
106 stdout->show("waiting");
107 Thread.waitThreads(); # wait until all threads have exited
108 stdout->show("returning");
118 Thread.mssleep(2500);
119 Thread.wakeup(&waiting);