76 |
76 |
77 void action_button(UiEvent *event, void *data) { |
77 void action_button(UiEvent *event, void *data) { |
78 printf("button: %d\n", event->intval); |
78 printf("button: %d\n", event->intval); |
79 char *s = ui_gettext(event->obj, "text"); |
79 char *s = ui_gettext(event->obj, "text"); |
80 printf("{%s}\n", s); |
80 printf("{%s}\n", s); |
81 printf("name: {%s}\n", ui_getval(name)); |
81 //printf("name: {%s}\n", ui_getval(name)); |
82 printf("mail: {%s}\n", ui_getval(mail)); |
82 //printf("mail: {%s}\n", ui_getval(mail)); |
83 ui_select_tab(tabview, 0); |
83 //ui_select_tab(tabview, 0); |
84 } |
84 } |
85 |
85 |
86 void action_test(UiEvent *event, void *data) { |
86 void action_test(UiEvent *event, void *data) { |
87 ui_select_tab(tabview, 1); |
87 //ui_select_tab(tabview, 1); |
88 } |
88 } |
89 |
89 |
90 int main(int argc, char** argv) { |
90 int main(int argc, char** argv) { |
91 ui_init("app1", argc, argv); |
91 ui_init("app1", argc, argv); |
92 ui_locales_dir("/opt/app1/locales"); |
92 ui_locales_dir("/opt/app1/locales"); |
95 |
95 |
96 |
96 |
97 |
97 |
98 ui_menu("File"); |
98 ui_menu("File"); |
99 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL); |
99 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL); |
100 ui_checkitem("Check", action_button, NULL); |
100 //ui_checkitem("Check", action_button, NULL); |
101 |
101 |
102 ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); |
102 ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); |
103 ui_toolbar_add_default("button"); |
103 ui_toolbar_add_default("button"); |
104 |
104 |
105 printf("create window\n"); |
105 printf("create window\n"); |
106 UiObject *window = ui_window("Mod0", NULL); |
106 UiObject *window = ui_window("Mod0", NULL); |
107 |
107 |
108 UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1); |
108 ui_button(window, "Test1", action_button, NULL); |
109 model->getvalue = (ui_model_getvalue_f)person_getvalue; |
109 ui_button(window, "Test2", action_button, NULL); |
110 model->activate = action_activate; |
|
111 model->selection = action_select; |
|
112 UiList *list = ui_list_new(); |
|
113 Person *p1 = ui_malloc(window->ctx, sizeof(Person)); |
|
114 Person *p2 = ui_malloc(window->ctx, sizeof(Person)); |
|
115 Person *p3 = ui_malloc(window->ctx, sizeof(Person)); |
|
116 Person *p4 = ui_malloc(window->ctx, sizeof(Person)); |
|
117 p1->name = "Some Näme"; |
|
118 p1->mail = "mail@host.com"; |
|
119 p2->name = "押井守"; |
|
120 p2->mail = "other.person@provider.com"; |
|
121 p3->name = "My Self"; |
|
122 p3->mail = "my@self.org"; |
|
123 p4->name = "Gregory House"; |
|
124 p4->mail = "greg@pp"; |
|
125 ui_list_append(list, p1); |
|
126 ui_list_append(list, p2); |
|
127 ui_list_append(list, p3); |
|
128 ui_list_append(list, p4); |
|
129 |
110 |
130 /* |
111 ui_hbox(window); |
131 ui_sidebar(window); |
112 |
132 ui_layout_fill(window, FALSE); |
113 ui_layout_fill(window, FALSE); |
133 ui_vbox(window); |
114 ui_vbox(window); |
134 ui_button(window, "Test1", NULL, NULL); |
115 ui_button(window, "A", NULL, NULL); |
135 ui_button(window, "Test2", NULL, NULL); |
116 ui_button(window, "B", NULL, NULL); |
136 ui_button(window, "Test3", NULL, NULL); |
117 ui_button(window, "C", NULL, NULL); |
137 ui_button(window, "Test4", NULL, NULL); |
|
138 ui_button(window, "Test5", NULL, NULL); |
|
139 ui_button(window, "Test6", NULL, NULL); |
|
140 ui_button(window, "Test7", NULL, NULL); |
|
141 ui_button(window, "Test8", NULL, NULL); |
|
142 ui_end(window); |
|
143 ui_end(window); |
|
144 ui_table(window, list, model); |
|
145 */ |
|
146 ui_layout_fill(window, FALSE); |
|
147 ui_grid(window); |
|
148 ui_label(window, "Name"); |
|
149 ui_textfield(window, &name); |
|
150 ui_newline(window); |
|
151 ui_label(window, "Email"); |
|
152 ui_textfield(window, &mail); |
|
153 ui_newline(window); |
|
154 ui_end(window); |
118 ui_end(window); |
155 |
119 |
156 tabview = ui_tabview(window); |
|
157 |
|
158 ui_tab(window, "Editor"); |
|
159 ui_textarea_nv(window, "text"); |
120 ui_textarea_nv(window, "text"); |
160 ui_button(window, "Submit", action_test, NULL); |
|
161 ui_end(window); |
121 ui_end(window); |
162 |
122 |
163 ui_tab(window, "Button"); |
123 ui_button(window, "Test4", action_button, NULL); |
164 ui_button(window, "TestButton", NULL, NULL); |
|
165 ui_end(window); |
|
166 |
|
167 ui_end(window); |
|
168 ui_button(window, "End", NULL, NULL); |
|
169 /* |
|
170 UiTabbedPane *view = ui_tabbed_document_view(window); |
|
171 |
|
172 UiObject *tab1 = ui_document_tab(view); |
|
173 Document *doc1 = ui_document_new(1024); |
|
174 UiContext *ctx1 = ui_document_context(doc1); |
|
175 ui_document_regtext(doc1, "text", &doc1->text); |
|
176 ui_textarea_nv(tab1, "text"); |
|
177 ui_set_document(tab1, doc1); |
|
178 |
|
179 |
|
180 UiObject *tab2 = ui_document_tab(view); |
|
181 Document *doc2 = ui_document_new(1024); |
|
182 UiContext *ctx2 = ui_document_context(doc2); |
|
183 ui_document_regtext(doc2, "text", &doc2->text); |
|
184 ui_textarea_nv(tab2, "text"); |
|
185 ui_set_document(tab2, doc2); |
|
186 |
|
187 UiObject *tab3 = ui_document_tab(view); |
|
188 Document *doc3 = ui_document_new(1024); |
|
189 UiContext *ctx3 = ui_document_context(doc3); |
|
190 ui_document_regtext(doc3, "text", &doc3->text); |
|
191 ui_textarea_nv(tab3, "text"); |
|
192 ui_set_document(tab3, doc3); |
|
193 */ |
|
194 |
124 |
195 ui_show(window); |
125 ui_show(window); |
196 ui_main(); |
126 ui_main(); |
197 |
127 |
198 return (EXIT_SUCCESS); |
128 return (EXIT_SUCCESS); |