99 |
100 |
100 char *str = elm; |
101 char *str = elm; |
101 return col == 0 ? str : "x"; |
102 return col == 0 ? str : "x"; |
102 } |
103 } |
103 |
104 |
|
105 static UiList *menu_list; |
|
106 int new_item_count = 0; |
|
107 |
|
108 void action_add_menu_item(UiEvent *event, void *userdata) { |
|
109 char str[64]; |
|
110 snprintf(str, 64, "new item %d", new_item_count++); |
|
111 |
|
112 ui_list_append(menu_list, strdup(str)); |
|
113 ui_list_notify(menu_list); |
|
114 } |
|
115 |
|
116 void action_menu_list(UiEvent *event, void *userdata) { |
|
117 printf("menu list item: %d\n", event->intval); |
|
118 } |
|
119 |
104 void application_startup(UiEvent *event, void *data) { |
120 void application_startup(UiEvent *event, void *data) { |
105 |
121 // global list |
|
122 UiContext *global = ui_global_context(); |
|
123 menu_list = ui_list_new(global, "menulist"); |
|
124 ui_list_append(menu_list, "menu list item 1"); |
|
125 ui_list_append(menu_list, "menu list item 2"); |
|
126 ui_list_append(menu_list, "menu list item 3"); |
|
127 |
|
128 |
|
129 |
106 UiObject *obj = ui_window("Test", NULL); |
130 UiObject *obj = ui_window("Test", NULL); |
107 |
131 |
108 MyDocument *doc = create_doc(); |
132 MyDocument *doc = create_doc(); |
109 ui_attach_document(obj->ctx, doc); |
133 ui_attach_document(obj->ctx, doc); |
110 |
134 |
169 ui_toolbar_item("Test4", .label = "Test 4", .onclick = action_toolbar_button); |
193 ui_toolbar_item("Test4", .label = "Test 4", .onclick = action_toolbar_button); |
170 ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button); |
194 ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button); |
171 ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button); |
195 ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button); |
172 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button); |
196 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button); |
173 ui_toolbar_menu("Menu", .label = "Menu") { |
197 ui_toolbar_menu("Menu", .label = "Menu") { |
174 ui_menuitem("Secondary Test", NULL, NULL); |
198 ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL); |
175 ui_menu("Secondary Sub") { |
199 ui_menu("Secondary Sub") { |
176 ui_menuitem("Secondary subitem", NULL, NULL); |
200 ui_menuitem("Secondary subitem", NULL, NULL); |
177 } |
201 } |
|
202 ui_menu_itemlist(.varname = "menulist", .onselect=action_menu_list); |
|
203 ui_menuitem("last", .onclick = action_add_menu_item); |
178 } |
204 } |
179 |
205 |
180 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT); |
206 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT); |
181 ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT); |
207 ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT); |
182 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT); |
208 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT); |