application/main.c

changeset 103
6a6718269c22
parent 102
2988f00ed9d6
child 104
3efe0210e27e
equal deleted inserted replaced
102:2988f00ed9d6 103:6a6718269c22
41 41
42 void action_button(UiEvent *event, void *data) { 42 void action_button(UiEvent *event, void *data) {
43 printf("button clicked\n"); 43 printf("button clicked\n");
44 fflush(stdout); 44 fflush(stdout);
45 } 45 }
46 /* 46
47 void draw(UiEvent *event, UiGraphics *g, void *data) { 47 void draw(UiEvent *event, UiGraphics *g, void *data) {
48
48 int width = g->width; 49 int width = g->width;
49 int height = g->height; 50 int height = g->height;
50 //printf("rec[%d,%d]\n", width, height); 51 printf("rec[%d,%d]\n", width, height);
52
51 ui_graphics_color(g, 64, 64, 64); 53 ui_graphics_color(g, 64, 64, 64);
52 ui_draw_rect(g, 0, 0, width, height, TRUE); 54 ui_draw_rect(g, 0, 0, width, height, TRUE);
53 55
54 UiTextLayout *text = ui_text(g); 56 UiTextLayout *text = ui_text(g);
55 ui_text_setfont(text, "Monospace", 12); 57 ui_text_setfont(text, "Monospace", 12);
61 ui_graphics_color(g, 255, 255, 255); 63 ui_graphics_color(g, 255, 255, 255);
62 ui_draw_text(g, 50, 50, text); 64 ui_draw_text(g, 50, 50, text);
63 65
64 ui_text_free(text); 66 ui_text_free(text);
65 } 67 }
66 */
67 68
68 void click(UiEvent *event, void *data) { 69 void click(UiEvent *event, void *data) {
69 UiMouseEvent *me = event->eventdata; 70 UiMouseEvent *me = event->eventdata;
70 printf("click[%d](%d,%d)\n", me->type, me->x, me->y); 71 printf("click[%d](%d,%d)\n", me->type, me->x, me->y);
71 } 72 }
87 ui_toolitem("button2", "OK", action_button, NULL); 88 ui_toolitem("button2", "OK", action_button, NULL);
88 ui_toolbar_add_default("button1"); 89 ui_toolbar_add_default("button1");
89 ui_toolbar_add_default("button2"); 90 ui_toolbar_add_default("button2");
90 91
91 UiObject *obj = ui_window("Test", NULL); 92 UiObject *obj = ui_window("Test", NULL);
92 //UIWIDGET w = ui_drawingarea(obj, draw, NULL); 93 UIWIDGET w = ui_drawingarea(obj, draw, NULL);
93 //ui_mouse_handler(obj, w, click, NULL); 94 //ui_mouse_handler(obj, w, click, NULL);
94 95
96 /*
95 ui_grid_sp(obj, 8, 4, 4); 97 ui_grid_sp(obj, 8, 4, 4);
96 98
97 ui_button(obj, "OK", NULL, NULL); 99 ui_button(obj, "OK", NULL, NULL);
98 ui_button(obj, "Google", NULL, NULL); 100 ui_button(obj, "Google", NULL, NULL);
99 ui_textfield(obj, NULL); 101 ui_textfield(obj, NULL);
111 ui_layout_vexpand(obj, TRUE); 113 ui_layout_vexpand(obj, TRUE);
112 ui_textarea(obj, NULL); 114 ui_textarea(obj, NULL);
113 ui_button(obj, "BTN1", NULL, NULL); 115 ui_button(obj, "BTN1", NULL, NULL);
114 116
115 ui_end(obj); 117 ui_end(obj);
118 */
116 119
117 ui_show(obj); 120 ui_show(obj);
118 ui_main(); 121 ui_main();
119 122
120 return (EXIT_SUCCESS); 123 return (EXIT_SUCCESS);

mercurial