271 |
271 |
272 void action_sourcelist_activate(UiEvent *event, void *userdata) { |
272 void action_sourcelist_activate(UiEvent *event, void *userdata) { |
273 printf("sourcelist %s index %d\n", event->eventdata, event->intval); |
273 printf("sourcelist %s index %d\n", event->eventdata, event->intval); |
274 } |
274 } |
275 |
275 |
|
276 void action_table_activate(UiEvent *event, void *userdata) { |
|
277 char *s = userdata; |
|
278 printf("table event: %s\n", s); |
|
279 UiListSelection *sel = event->eventdata; |
|
280 for(int i=0;i<sel->count;i++) { |
|
281 printf("%d\n", sel->rows[i]); |
|
282 } |
|
283 printf("\n"); |
|
284 } |
|
285 |
276 UiMenuBuilder *menubuilder; |
286 UiMenuBuilder *menubuilder; |
277 |
287 |
278 void* table_getvalue(void *row, int col) { |
288 void* table_getvalue(void *row, int col) { |
279 return row; |
289 switch(col) { |
|
290 case 0: return row; |
|
291 case 1: return (void*)(intptr_t)1234; |
|
292 case 2: return ui_foldericon(16); |
|
293 case 3: return ui_fileicon(16); |
|
294 case 4: return "file"; |
|
295 } |
|
296 return NULL; |
280 } |
297 } |
281 |
298 |
282 void sourcelist_getvalue(void *sublistdata, void *rowdata, int index, UiSubListItem *item) { |
299 void sourcelist_getvalue(void *sublistdata, void *rowdata, int index, UiSubListItem *item) { |
283 item->label = strdup(rowdata); |
300 item->label = strdup(rowdata); |
284 item->eventdata = sublistdata; |
301 item->eventdata = sublistdata; |
343 .sublists = UI_SUBLISTS(UI_SUBLIST(.varname = "srclist1", .header = "Header 1", .userdata = "Sublist1"), UI_SUBLIST(.varname = "srclist2", .header = "Header 2", .userdata = "Sublist2")), |
360 .sublists = UI_SUBLISTS(UI_SUBLIST(.varname = "srclist1", .header = "Header 1", .userdata = "Sublist1"), UI_SUBLIST(.varname = "srclist2", .header = "Header 2", .userdata = "Sublist2")), |
344 .onactivate = action_sourcelist_activate); |
361 .onactivate = action_sourcelist_activate); |
345 } |
362 } |
346 |
363 |
347 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { |
364 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { |
348 ui_tab(obj, "Tab 1") { |
365 ui_tab(obj, "Tab 0") { |
349 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { |
366 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { |
350 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); |
367 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); |
351 ui_togglebutton(obj, .label = "Toggle"); |
368 ui_togglebutton(obj, .label = "Toggle"); |
352 ui_checkbox(obj, .label = "My Checkbox"); |
369 ui_checkbox(obj, .label = "My Checkbox"); |
353 } |
370 } |
390 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio"); |
407 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio"); |
391 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio"); |
408 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio"); |
392 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); |
409 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); |
393 } |
410 } |
394 ui_newline(obj); |
411 ui_newline(obj); |
395 |
|
396 UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", -1); |
|
397 model->getvalue = table_getvalue; |
|
398 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .hexpand = TRUE, .contextmenu = menubuilder); |
|
399 } |
412 } |
|
413 } |
|
414 ui_tab(obj, "Tab 1") { |
|
415 UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", -1); |
|
416 model->getvalue = table_getvalue; |
|
417 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = UI_ON, .contextmenu = menubuilder, .multiselection = TRUE, |
|
418 .onactivate = action_table_activate, .onactivatedata = "activate", |
|
419 .onselection = action_table_activate, .onselectiondata = "selection"); |
400 } |
420 } |
401 ui_tab(obj, "Tab 2") { |
421 ui_tab(obj, "Tab 2") { |
402 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); |
422 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); |
403 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); |
423 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); |
404 ui_button(obj, .label = "Obj Ref", .onclick=action_button_ref); |
424 ui_button(obj, .label = "Obj Ref", .onclick=action_button_ref); |