7 static void display(Window *win);
8 static void keyboard(Window *win, int key, bool pressed);
9 static void button(Window *win, int bn, bool pressed, int x, int y);
10 static void motion(Window *win, int x, int y);
11 static void cleanup();
21 Window *win1 = new Window;
22 win1->set_title("red");
24 win1->resize(200, 300);
25 win1->set_display_callback(display);
26 win1->set_keyboard_callback(keyboard);
27 win1->set_mouse_button_callback(button);
28 win1->set_mouse_motion_callback(motion);
30 Window *win2 = new Window;
31 win2->set_title("green");
33 win2->resize(200, 300);
34 win2->set_display_callback(display);
35 win2->set_keyboard_callback(keyboard);
36 win2->set_mouse_button_callback(button);
37 win2->set_mouse_motion_callback(motion);
47 static void display(Window *win)
49 const char *win_title = win->get_title();
50 const char *t1 = "red";
51 const char *t2 = "green";
53 if(!strcmp(win_title, t1)) {
54 fill_rect(win->get_absolute_rect(), 255, 0, 0);
57 if(!strcmp(win_title, t2)) {
58 fill_rect(win->get_absolute_rect(), 0, 255, 0);
62 static void keyboard(Window *win, int key, bool pressed)
70 static void button(Window *win, int bn, bool pressed, int x, int y)
72 printf("WINDOW(%p) button %d %s\n", (void*)win, bn, pressed ? "press" : "release");
75 static void motion(Window *win, int x, int y)
77 printf("WINDOW(%p) motion %d %d\n", (void*)win, x, y);