application/main.c

changeset 86
3c63f57a8f77
parent 85
91f45354d1e2
child 88
04c81be1c5a0
equal deleted inserted replaced
85:91f45354d1e2 86:3c63f57a8f77
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 /*
37 typedef struct Person { 36 typedef struct Person {
38 char *name; 37 char *name;
39 char *mail; 38 char *mail;
40 } Person; 39 } Person;
41 40
89 } 88 }
90 89
91 void action_test(UiEvent *event, void *data) { 90 void action_test(UiEvent *event, void *data) {
92 //ui_select_tab(tabview, 0); 91 //ui_select_tab(tabview, 0);
93 } 92 }
94 */
95 93
96 void action_menu(UiEvent *event, void *data) { 94 void action_menu(UiEvent *event, void *data) {
97 printf("action_menu test: {%s}\n", data); 95 printf("action_menu test: {%s}\n", data);
98 fflush(stdout); 96 fflush(stdout);
99 } 97 }
100 98
101 void action_button(UiEvent *event, void *data) { 99 void action_combobox_select(UiEvent *event, void *data) {
102 printf("button clicked\n"); 100 UiList *list = data;
103 fflush(stdout); 101 int i = event->intval;
102 printf("selection{%s}[%d]\n", ui_list_get(list, i), i);
104 } 103 }
105 104
105
106 int main(int argc, char** argv) { 106 int main(int argc, char** argv) {
107 ui_locales_dir("/opt/app1/locales");
108 ui_load_lang_def(NULL, "en_EN");
107 ui_init("app1", argc, argv); 109 ui_init("app1", argc, argv);
108
109 ui_menu("File");
110 ui_menuitem("Hello", action_menu, "hello");
111 ui_submenu("Submenu1");
112 ui_submenu("Submenu2");
113 ui_menuitem("item2", NULL, NULL);
114 ui_submenu_end();
115 ui_menuitem("item3", NULL, NULL);
116 ui_submenu_end();
117 ui_menuitem("item4", NULL, NULL);
118
119 UiObject *obj = ui_window("Test", NULL);
120 ui_layout_fill(obj, FALSE);
121 ui_hbox(obj);
122 ui_button(obj, "HELLO", NULL, NULL);
123 ui_button(obj, "WORLD", NULL, NULL);
124 ui_layout_fill(obj, TRUE);
125 ui_button(obj, "BUTTON", NULL, NULL);
126 ui_end(obj);
127 ui_button(obj, "Test1", action_button, NULL);
128 ui_button(obj, "Test2", action_button, NULL);
129 ui_button(obj, "Test3", action_button, NULL);
130 ui_button(obj, "Test4", action_button, NULL);
131 ui_show(obj);
132 fflush(stdout);
133 ui_main();
134 /*
135 ui_locales_dir("/opt/app1/locales");
136 ui_load_lang_def(NULL, "en_EN");
137 //ui_openfilefunc(action_new, NULL); 110 //ui_openfilefunc(action_new, NULL);
138 111
139 112
140 113
141 ui_menu("File"); 114 ui_menu("File");
142 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL); 115 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL);
143 ui_checkitem("Test", action_check, NULL); 116 ui_checkitem("Test", action_check, NULL);
144 //ui_checkitem("Check", action_button, NULL); 117 //ui_checkitem("Check", action_button, NULL);
145 118
146 ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); 119 ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL);
120
121 UiList *cb = ui_list_new();
122 ui_list_append(cb, "Hello World");
123 ui_list_append(cb, "2");
124 ui_list_append(cb, "3");
125 ui_list_append(cb, "4");
126 ui_list_append(cb, "5");
127 ui_toolbar_combobox_str("combobox", cb, action_combobox_select, cb);
128
147 ui_toolbar_add_default("button"); 129 ui_toolbar_add_default("button");
130 ui_toolbar_add_default("combobox");
148 131
149 printf("create window\n"); 132 printf("create window\n");
150 UiObject *window = ui_window("Mod0", NULL); 133 UiObject *window = ui_window("Mod0", NULL);
151 134
152 UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1); 135 UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1);
189 ui_widget_menuitem_st(window, UI_STOCK_CLOSE, action_test, NULL); 172 ui_widget_menuitem_st(window, UI_STOCK_CLOSE, action_test, NULL);
190 173
191 174
192 ui_show(window); 175 ui_show(window);
193 ui_main(); 176 ui_main();
194 */
195 return (EXIT_SUCCESS); 177 return (EXIT_SUCCESS);
196 } 178 }

mercurial