application/main.c

changeset 99
ea1a2d5de765
parent 98
efaae97bd95b
child 101
1c943d43fa81
equal deleted inserted replaced
98:efaae97bd95b 99:ea1a2d5de765
45 } 45 }
46 46
47 void draw(UiEvent *event, UiGraphics *g, void *data) { 47 void draw(UiEvent *event, UiGraphics *g, void *data) {
48 int width = g->width; 48 int width = g->width;
49 int height = g->height; 49 int height = g->height;
50 printf("rec[%d,%d]\n", width, height); 50 //printf("rec[%d,%d]\n", width, height);
51 ui_graphics_color(g, 64, 64, 64); 51 ui_graphics_color(g, 64, 64, 64);
52 ui_draw_rect(g, 0, 0, width, height, TRUE); 52 ui_draw_rect(g, 0, 0, width, height, TRUE);
53 53
54 UiTextLayout *text = ui_text(g); 54 UiTextLayout *text = ui_text(g);
55 ui_text_setfont(text, "Monospace", 12); 55 ui_text_setfont(text, "Monospace", 12);
56 ui_text_setstring(text, "Hello World"); 56 ui_text_setstring(text, "Hello World");
57 int w, h; 57 int w, h;
58 ui_text_getsize(text, &w, &h); 58 ui_text_getsize(text, &w, &h);
59 printf("ext[%d,%d]\n", w, h); 59 //printf("ext[%d,%d]\n", w, h);
60 60
61 ui_graphics_color(g, 255, 255, 255); 61 ui_graphics_color(g, 255, 255, 255);
62 ui_draw_text(g, 50, 50, text); 62 ui_draw_text(g, 50, 50, text);
63 63
64 ui_text_free(text); 64 ui_text_free(text);
86 ui_toolitem("button2", "OK", action_button, NULL); 86 ui_toolitem("button2", "OK", action_button, NULL);
87 ui_toolbar_add_default("button1"); 87 ui_toolbar_add_default("button1");
88 ui_toolbar_add_default("button2"); 88 ui_toolbar_add_default("button2");
89 89
90 UiObject *obj = ui_window("Test", NULL); 90 UiObject *obj = ui_window("Test", NULL);
91 UIWIDGET w = ui_drawingarea(obj, draw, NULL); 91 //UIWIDGET w = ui_drawingarea(obj, draw, NULL);
92 ui_mouse_handler(obj, w, click, NULL); 92 //ui_mouse_handler(obj, w, click, NULL);
93
94 ui_grid_sp(obj, 40, 4, 4);
95 ui_button(obj, "OK", NULL, NULL);
96 ui_button(obj, "Google", NULL, NULL);
97 ui_textfield(obj, NULL);
98 ui_newline(obj);
99
100 ui_button(obj, "OK", NULL, NULL);
101 ui_space(obj);
102 ui_textfield(obj, NULL);
103 ui_newline(obj);
104
105 ui_vbox(obj);
106 ui_button(obj, "txt", NULL, NULL);
107 ui_end(obj);
108 ui_layout_hexpand(obj, TRUE);
109 ui_layout_vexpand(obj, TRUE);
110 ui_textarea(obj, NULL);
111
112 ui_end(obj);
93 113
94 ui_show(obj); 114 ui_show(obj);
95 ui_main(); 115 ui_main();
96 116
97 return (EXIT_SUCCESS); 117 return (EXIT_SUCCESS);

mercurial