application/main.c

changeset 133
6dd780cbc8c6
parent 127
ce342364fad5
child 136
1df2fb3d079c
equal deleted inserted replaced
132:a24465cc7262 133:6dd780cbc8c6
31 31
32 #include <ui/ui.h> 32 #include <ui/ui.h>
33 #include <ucx/buffer.h> 33 #include <ucx/buffer.h>
34 #include <ucx/utils.h> 34 #include <ucx/utils.h>
35 35
36 UiInteger radio;
37 UiRange range;
38 UIWIDGET drawingarea;
39
40 void action_menu(UiEvent *event, void *data) { 36 void action_menu(UiEvent *event, void *data) {
41 printf("action_menu test: {%s}\n", data); 37 printf("action_menu\n");
42 //printf("text: {%s}\n", ui_gettext(event->obj, "text"));
43 //fflush(stdout);
44 //
45 //char *file = ui_openfiledialog(event->obj);
46 ////printf("file: %s\n", file);
47 //fflush(stdout);
48 //free(file);
49 } 38 }
50 39
51 void action_button(UiEvent *event, void *data) { 40 void action_button(UiEvent *event, void *data) {
52 //printf("radio: %d\n", ui_getval(radio)); 41 printf("action_button\n");
53 }
54
55 void action_button2(UiEvent *event, void *data) {
56 ui_setval(radio, 1);
57 }
58
59 UiTextLayout *text;
60
61 void action_scroll(UiEvent *event, void *data) {
62 //ui_drawingarea_redraw(drawingarea);
63 printf("scroll\n");
64 } 42 }
65 43
66 44
67 void draw(UiEvent *event, UiGraphics *g, void *data) { 45 void application_startup(UiEvent *event, void *data) {
68 int width = g->width; 46 UiObject *obj = ui_window("Test", NULL);
69 int height = g->height; 47 ui_textarea(obj, NULL);
70 //printf("rec[%d,%d]\n", width, height); 48 ui_show(obj);
71
72 ui_graphics_color(g, 64, 64, 64);
73 ui_draw_rect(g, 0, 0, width, height, TRUE);
74
75
76 } 49 }
77 /*
78
79 void* model_getval(void *obj, int col) {
80 if(col == 0) {
81 return "folder";
82 } else if(col == 2) {
83 return "test@localhost";
84 }
85 return obj;
86 }
87
88 UIMENU ctxmenu;
89 void click(UiEvent *event, void *data) {
90 UiMouseEvent *me = event->eventdata;
91 printf("click[%d](%d,%d)\n", me->type, me->x, me->y);
92
93 if(me->button == 1) {
94 ui_contextmenu_popup(ctxmenu);
95 }
96
97 }
98
99 void window_close(UiEvent *event, void *data) {
100 printf("window close\n");
101 }
102 */
103 50
104 int main(int argc, char** argv) { 51 int main(int argc, char** argv) {
105 ui_init("app1", argc, argv); 52 ui_init("app1", argc, argv);
53 ui_onstartup(application_startup, NULL);
106 54
107 UiList *list = ui_list_new(); 55 // menu
108 ui_list_append(list, "Hello");
109 ui_list_append(list, "World");
110 ui_list_append(list, "Test");
111
112 ui_menu("File"); 56 ui_menu("File");
113 ui_menuitem("Hello", action_menu, "hello"); 57 ui_menuitem("Hello", action_menu, NULL);
114 ui_submenu("Submenu1"); 58 ui_submenu("Submenu1");
115 ui_submenu("Submenu2"); 59 ui_submenu("Submenu2");
116 ui_menuitem("item2", NULL, NULL); 60 ui_menuitem("item2", action_menu, NULL);
117 ui_submenu_end(); 61 ui_submenu_end();
118 ui_menuitem("item3", NULL, NULL); 62 ui_menuitem("item3", action_menu, NULL);
119 ui_submenu_end(); 63 ui_submenu_end();
120 ui_menuitem("item4", NULL, NULL); 64 ui_menuitem("item4", action_menu, NULL);
121 65
66 // toolbar
122 ui_toolitem("button1", "Test", action_button, NULL); 67 ui_toolitem("button1", "Test", action_button, NULL);
123 ui_toolitem("button2", "OK", action_button, NULL); 68 ui_toolitem("button2", "OK", action_button, NULL);
124 //ui_toolbar_combobox_str("combo", list, NULL, NULL);
125 ui_toolbar_add_default("button1"); 69 ui_toolbar_add_default("button1");
126 ui_toolbar_add_default("button2"); 70 ui_toolbar_add_default("button2");
127 //ui_toolbar_add_default("combo");
128 71
129 UiObject *obj = ui_window("Test", NULL);
130 //ui_context_closefunc(obj->ctx, window_close, NULL);
131 ui_drawingarea(obj, draw, NULL);
132
133 ui_show(obj);
134 ui_main(); 72 ui_main();
135 73
136 return (EXIT_SUCCESS); 74 return (EXIT_SUCCESS);
137 } 75 }

mercurial