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 { |
|
38 char *name; |
|
39 char *mail; |
|
40 } Person; |
|
41 |
|
42 typedef struct Document { |
|
43 UiText text; |
|
44 } Document; |
|
45 |
|
46 void action_close(UiEvent *event, void *data) { |
|
47 ui_close(event->obj); |
|
48 } |
|
49 |
|
50 char* person_getvalue(Person *p, int column) { |
|
51 switch(column) { |
|
52 case 0: return p->name; |
|
53 case 1: return p->mail; |
|
54 } |
|
55 return NULL; |
|
56 } |
|
57 |
|
58 UiString name; |
|
59 UiString mail; |
|
60 |
|
61 UIWIDGET tabview = NULL; |
|
62 |
|
63 void action_activate(UiEvent *event, void *data) { |
|
64 UiListSelection *selection = event->eventdata; |
|
65 printf("activate: %d\n", event->intval); |
|
66 } |
|
67 |
|
68 void action_select(UiEvent *event, void *data) { |
|
69 UiListSelection *selection = event->eventdata; |
|
70 printf("selection[%d]: ", selection->count); |
|
71 for(int i=0;i<selection->count;i++) { |
|
72 printf("%d ", selection->rows[i]); |
|
73 } |
|
74 printf("\n"); |
|
75 } |
|
76 |
|
77 void action_button(UiEvent *event, void *data) { |
|
78 printf("button: %d\n", event->intval); |
|
79 //char *s = ui_gettext(event->obj, "text"); |
|
80 char *s = ui_getval(name); |
|
81 printf("{%s}\n", s); |
|
82 //printf("name: {%s}\n", ui_getval(name)); |
|
83 //printf("mail: {%s}\n", ui_getval(mail)); |
|
84 //ui_select_tab(tabview, 1); |
|
85 } |
|
86 |
|
87 void action_check(UiEvent *event, void *data) { |
|
88 printf("check: %d\n", event->intval); |
|
89 } |
|
90 |
|
91 void action_test(UiEvent *event, void *data) { |
|
92 //ui_select_tab(tabview, 0); |
|
93 } |
|
94 */ |
|
95 |
|
96 void action_menu(UiEvent *event, void *data) { |
36 void action_menu(UiEvent *event, void *data) { |
97 printf("action_menu test: {%s}\n", data); |
37 printf("action_menu test: {%s}\n", data); |
98 printf("text: {%s}\n", ui_gettext(event->obj, "text")); |
38 printf("text: {%s}\n", ui_gettext(event->obj, "text")); |
99 fflush(stdout); |
39 fflush(stdout); |
100 } |
40 } |
121 ui_toolitem("button2", "OK", action_button, NULL); |
61 ui_toolitem("button2", "OK", action_button, NULL); |
122 ui_toolbar_add_default("button1"); |
62 ui_toolbar_add_default("button1"); |
123 ui_toolbar_add_default("button2"); |
63 ui_toolbar_add_default("button2"); |
124 |
64 |
125 UiObject *obj = ui_window("Test", NULL); |
65 UiObject *obj = ui_window("Test", NULL); |
126 ui_textarea_nv(obj, "text"); |
66 |
|
67 UiTabbedPane *docs = ui_tabbed_document_view(obj); |
|
68 UiObject *tab; |
|
69 tab = ui_document_tab(docs); |
|
70 ui_textarea(tab, NULL); |
|
71 tab = ui_document_tab(docs); |
|
72 ui_textarea(tab, NULL); |
|
73 tab = ui_document_tab(docs); |
|
74 ui_textarea(tab, NULL); |
|
75 tab = ui_document_tab(docs); |
|
76 ui_textarea(tab, NULL); |
127 ui_show(obj); |
77 ui_show(obj); |
128 ui_main(); |
78 ui_main(); |
129 /* |
|
130 ui_locales_dir("/opt/app1/locales"); |
|
131 ui_load_lang_def(NULL, "en_EN"); |
|
132 //ui_openfilefunc(action_new, NULL); |
|
133 |
79 |
134 |
|
135 |
|
136 ui_menu("File"); |
|
137 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL); |
|
138 ui_checkitem("Test", action_check, NULL); |
|
139 //ui_checkitem("Check", action_button, NULL); |
|
140 |
|
141 ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); |
|
142 ui_toolbar_add_default("button"); |
|
143 |
|
144 printf("create window\n"); |
|
145 UiObject *window = ui_window("Mod0", NULL); |
|
146 |
|
147 UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1); |
|
148 model->getvalue = (ui_model_getvalue_f)person_getvalue; |
|
149 model->activate = action_activate; |
|
150 model->selection = action_select; |
|
151 UiList *list = ui_list_new(); |
|
152 Person *p1 = ui_malloc(window->ctx, sizeof(Person)); |
|
153 Person *p2 = ui_malloc(window->ctx, sizeof(Person)); |
|
154 Person *p3 = ui_malloc(window->ctx, sizeof(Person)); |
|
155 Person *p4 = ui_malloc(window->ctx, sizeof(Person)); |
|
156 p1->name = "Some Näme"; |
|
157 p1->mail = "mail@host.com"; |
|
158 p2->name = "押井守"; |
|
159 p2->mail = "other.person@provider.com"; |
|
160 p3->name = "My Self"; |
|
161 p3->mail = "my@self.org"; |
|
162 p4->name = "Gregory House"; |
|
163 p4->mail = "greg@pp"; |
|
164 ui_list_append(list, p1); |
|
165 ui_list_append(list, p2); |
|
166 ui_list_append(list, p3); |
|
167 ui_list_append(list, p4); |
|
168 |
|
169 ui_layout_fill(window, FALSE); |
|
170 ui_grid(window); |
|
171 ui_button(window, "Test", NULL, NULL); |
|
172 ui_button(window, "Test", NULL, NULL); |
|
173 ui_button(window, "Test", NULL, NULL); |
|
174 ui_newline(window); |
|
175 ui_textfield(window, NULL); |
|
176 ui_end(window); |
|
177 ui_listview(window, list, (ui_model_getvalue_f)person_getvalue, action_activate, NULL); |
|
178 ui_contextmenu(window); |
|
179 ui_widget_menuitem(window, "OK", action_test, NULL); |
|
180 ui_widget_menuitem(window, "1", action_test, NULL); |
|
181 ui_widget_menuitem(window, "2", action_test, NULL); |
|
182 ui_widget_menuitem(window, "3", action_test, NULL); |
|
183 ui_widget_menuitem(window, "4", action_test, NULL); |
|
184 ui_widget_menuitem_st(window, UI_STOCK_CLOSE, action_test, NULL); |
|
185 |
|
186 |
|
187 ui_show(window); |
|
188 ui_main(); |
|
189 */ |
|
190 return (EXIT_SUCCESS); |
80 return (EXIT_SUCCESS); |
191 } |
81 } |