application/main.c

branch
newapi
changeset 332
7e7c05af8f3a
parent 331
cdad8b7e83db
child 333
634e3ce80afe
equal deleted inserted replaced
331:cdad8b7e83db 332:7e7c05af8f3a
39 UiString *path; 39 UiString *path;
40 UiDouble *progress; 40 UiDouble *progress;
41 UiList *list; 41 UiList *list;
42 UiList *menulist; 42 UiList *menulist;
43 UiInteger *radio; 43 UiInteger *radio;
44 UiInteger *tabview;
44 } MyDocument; 45 } MyDocument;
45 46
46 MyDocument *doc1; 47 MyDocument *doc1;
47 MyDocument *doc2; 48 MyDocument *doc2;
48 49
83 doc->list = ui_list_new(docctx, "list"); 84 doc->list = ui_list_new(docctx, "list");
84 ui_list_append(doc->list, "test1"); 85 ui_list_append(doc->list, "test1");
85 ui_list_append(doc->list, "test2"); 86 ui_list_append(doc->list, "test2");
86 ui_list_append(doc->list, "test3"); 87 ui_list_append(doc->list, "test3");
87 doc->radio = ui_int_new(docctx, "radio"); 88 doc->radio = ui_int_new(docctx, "radio");
89 doc->tabview = ui_int_new(docctx, "tabview");
88 return doc; 90 return doc;
89 } 91 }
90 92
91 UiIcon *icon = NULL; 93 UiIcon *icon = NULL;
92 94
115 ui_list_notify(menu_list); 117 ui_list_notify(menu_list);
116 } 118 }
117 119
118 void action_menu_list(UiEvent *event, void *userdata) { 120 void action_menu_list(UiEvent *event, void *userdata) {
119 printf("menu list item: %d\n", event->intval); 121 printf("menu list item: %d\n", event->intval);
122 }
123
124 static int tab_x = 0;
125 void action_tab2_button(UiEvent *event, void *userdata) {
126 MyDocument *doc = event->document;
127 printf("current page: %d\n", (int)ui_get(doc->tabview));
128 ui_set(doc->tabview, 0);
120 } 129 }
121 130
122 void application_startup(UiEvent *event, void *data) { 131 void application_startup(UiEvent *event, void *data) {
123 // global list 132 // global list
124 UiContext *global = ui_global_context(); 133 UiContext *global = ui_global_context();
132 UiObject *obj = ui_window("Test", NULL); 141 UiObject *obj = ui_window("Test", NULL);
133 142
134 MyDocument *doc = create_doc(); 143 MyDocument *doc = create_doc();
135 ui_attach_document(obj->ctx, doc); 144 ui_attach_document(obj->ctx, doc);
136 145
137 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE) { 146 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") {
138 ui_tab(obj, "Tab 1") { 147 ui_tab(obj, "Tab 1") {
139 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { 148 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) {
140 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); 149 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
141 ui_togglebutton(obj, .label = "Toggle"); 150 ui_togglebutton(obj, .label = "Toggle");
142 ui_checkbox(obj, .label = "My Checkbox"); 151 ui_checkbox(obj, .label = "My Checkbox");
178 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); 187 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio");
179 } 188 }
180 } 189 }
181 } 190 }
182 ui_tab(obj, "Tab 2") { 191 ui_tab(obj, "Tab 2") {
183 ui_button(obj, .label = "Button"); 192 ui_button(obj, .label = "Button", .onclick=action_tab2_button);
184 } 193 }
185 } 194 }
186 195
187 /* 196 /*
188 197

mercurial