| 307 ui_textarea(obj, .varname="text"); |
307 ui_textarea(obj, .varname="text"); |
| 308 |
308 |
| 309 ui_show(obj); |
309 ui_show(obj); |
| 310 } |
310 } |
| 311 |
311 |
| |
312 void action_table_activate(UiEvent *event, void *data) { |
| |
313 printf("action: table activate\n"); |
| |
314 } |
| |
315 |
| |
316 void action_table_selection(UiEvent *event, void *data) { |
| |
317 printf("action: table selection\n"); |
| |
318 } |
| |
319 |
| 312 static void mydoc_action_save(UiEvent *event, void *data) { |
320 static void mydoc_action_save(UiEvent *event, void *data) { |
| 313 printf("mydoc action save\n"); |
321 printf("mydoc action save\n"); |
| 314 |
322 |
| 315 } |
323 } |
| 316 |
324 |
| 317 |
325 |
| 318 MyDocument* create_doc(void) { |
326 MyDocument* create_doc(void) { |
| 319 MyDocument *doc = ui_document_new(sizeof(MyDocument)); |
327 MyDocument *doc = ui_document_new(sizeof(MyDocument)); |
| 320 UiContext *docctx = ui_document_context(doc); |
328 UiContext *docctx = ui_document_context(doc); |
| |
329 ui_add_action(docctx, "table_activate", action_table_activate, NULL); |
| |
330 ui_add_action(docctx, "table_selection", action_table_selection, NULL); |
| |
331 |
| 321 ui_add_action(docctx, "save", mydoc_action_save, NULL); |
332 ui_add_action(docctx, "save", mydoc_action_save, NULL); |
| 322 doc->submenulist = ui_list_new(docctx, "sub_menulist"); |
333 doc->submenulist = ui_list_new(docctx, "sub_menulist"); |
| 323 ui_list_append(doc->submenulist, "Sub Menu List Item 1"); |
334 ui_list_append(doc->submenulist, "Sub Menu List Item 1"); |
| 324 ui_list_append(doc->submenulist, "Sub Menu List Item 2"); |
335 ui_list_append(doc->submenulist, "Sub Menu List Item 2"); |
| 325 ui_list_append(doc->submenulist, "Sub Menu List Item 3"); |
336 ui_list_append(doc->submenulist, "Sub Menu List Item 3"); |
| 468 if(eventdata->sublist_index == 1 && eventdata->row_index == 2) { |
479 if(eventdata->sublist_index == 1 && eventdata->row_index == 2) { |
| 469 ui_list_setselection(eventdata->list, 0); |
480 ui_list_setselection(eventdata->list, 0); |
| 470 } |
481 } |
| 471 } |
482 } |
| 472 |
483 |
| 473 void action_table_activate(UiEvent *event, void *userdata) { |
484 void table_activate(UiEvent *event, void *userdata) { |
| 474 char *s = userdata; |
485 char *s = userdata; |
| 475 printf("table event: %s\n", s); |
486 printf("table event: %s\n", s); |
| 476 UiListSelection *sel = event->eventdata; |
487 UiListSelection *sel = event->eventdata; |
| 477 for(int i=0;i<sel->count;i++) { |
488 for(int i=0;i<sel->count;i++) { |
| 478 printf("%d\n", sel->rows[i]); |
489 printf("%d\n", sel->rows[i]); |
| 760 UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", UI_STRING_EDITABLE, "edit6", UI_STRING_EDITABLE, "edit7", UI_BOOL_EDITABLE, "Check", -1); |
771 UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", UI_STRING_EDITABLE, "edit6", UI_STRING_EDITABLE, "edit7", UI_BOOL_EDITABLE, "Check", -1); |
| 761 model->columnsize[0] = -1; |
772 model->columnsize[0] = -1; |
| 762 doc->model = model; |
773 doc->model = model; |
| 763 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE, |
774 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE, |
| 764 .getvalue = table_getvalue, .getstyle = table_getstyle, .onsave = list_save, |
775 .getvalue = table_getvalue, .getstyle = table_getstyle, .onsave = list_save, |
| 765 .onactivate = action_table_activate, .onactivatedata = "activate", |
776 .onactivate = table_activate, .onactivatedata = "activate", .onactivate_action = "table_activate", |
| 766 .onselection = action_table_activate, .onselectiondata = "selection"); |
777 .onselection = table_activate, .onselectiondata = "selection", .onselection_action = "table_selection"); |
| 767 ui_hbox(obj, .fill = FALSE, .columnspacing = 4) { |
778 ui_hbox(obj, .fill = FALSE, .columnspacing = 4) { |
| 768 ui_textfield(obj, .value = doc->list_input); |
779 ui_textfield(obj, .value = doc->list_input); |
| 769 ui_button(obj, .label = "Update List Item 1", .onclick = action_update_list); |
780 ui_button(obj, .label = "Update List Item 1", .onclick = action_update_list); |
| 770 ui_label(obj, .label = "Column Name"); |
781 ui_label(obj, .label = "Column Name"); |
| 771 ui_textfield(obj, .value = doc->list_new_col); |
782 ui_textfield(obj, .value = doc->list_new_col); |