application/main.c

changeset 95
29f5cd5f5367
parent 94
d51e334c1439
child 97
1a786201465f
equal deleted inserted replaced
94:d51e334c1439 95:29f5cd5f5367
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) {
48 int width = g->width;
49 int height = g->height;
50 ui_graphics_color(g, 64, 64, 64);
51 ui_draw_rect(g, 0, 0, width, height, TRUE);
52
53 UiTextLayout *text = ui_text(g);
54 ui_text_setfont(text, "Monospace", 12);
55 ui_text_setstring(text, "Hello World");
56
57 ui_graphics_color(g, 255, 255, 255);
58 ui_draw_text(g, 50, 50, text);
59
60 ui_text_free(text);
61 }
62
47 int main(int argc, char** argv) { 63 int main(int argc, char** argv) {
48 ui_init("app1", argc, argv); 64 ui_init("app1", argc, argv);
49 65
50 ui_menu("File"); 66 ui_menu("File");
51 ui_menuitem("Hello", action_menu, "hello"); 67 ui_menuitem("Hello", action_menu, "hello");
61 ui_toolitem("button2", "OK", action_button, NULL); 77 ui_toolitem("button2", "OK", action_button, NULL);
62 ui_toolbar_add_default("button1"); 78 ui_toolbar_add_default("button1");
63 ui_toolbar_add_default("button2"); 79 ui_toolbar_add_default("button2");
64 80
65 UiObject *obj = ui_window("Test", NULL); 81 UiObject *obj = ui_window("Test", NULL);
66 82 ui_drawingarea(obj, draw, NULL);
67 ui_layout_fill(obj, FALSE);
68 ui_grid_sp(obj, 10, 2);
69
70 ui_rlabel(obj, "Name");
71 ui_textfield(obj, NULL);
72 ui_newline(obj);
73
74 ui_rlabel(obj, "Email");
75 ui_textfield(obj, NULL);
76 ui_button(obj, "OK", NULL, NULL);
77 ui_newline(obj);
78
79 ui_checkbox(obj, "fuck", NULL);
80 ui_rlabel(obj, "FUCK");
81 ui_newline(obj);
82 ui_checkbox(obj, "this", NULL);
83 ui_newline(obj);
84 ui_checkbox(obj, "shit", NULL);
85 ui_newline(obj);
86
87 ui_label(obj, "Awesome Button");
88 UIWIDGET button = ui_button(obj, "...", NULL, NULL);
89
90 ui_end(obj);
91
92 ui_checkbox(obj, "A", NULL);
93 ui_checkbox(obj, "B", NULL);
94 ui_checkbox(obj, "C", NULL);
95 ui_checkbox(obj, "D", NULL);
96 ui_checkbox(obj, "E", NULL);
97 ui_checkbox(obj, "F", NULL);
98 ui_space(obj);
99
100 ui_separator(obj);
101
102 ui_layout_fill(obj, FALSE);
103 ui_hbox(obj);
104 ui_button(obj, "Submit", NULL, NULL);
105 //ui_space(obj);
106 ui_button(obj, "Cancel", NULL, NULL);
107 ui_end(obj);
108 83
109 ui_show(obj); 84 ui_show(obj);
110 ui_main(); 85 ui_main();
111 86
112 return (EXIT_SUCCESS); 87 return (EXIT_SUCCESS);

mercurial