application/main.c

changeset 965
5d4419042d9b
parent 955
ea9a999b4fc8
child 966
e411ed7c5f10
equal deleted inserted replaced
964:c563220d9aea 965:5d4419042d9b
195 UiList *srclist1; 195 UiList *srclist1;
196 UiList *srclist2; 196 UiList *srclist2;
197 UiList *items; 197 UiList *items;
198 UiGeneric *web; 198 UiGeneric *web;
199 UiString *list_input; 199 UiString *list_input;
200 UiString *list_new_col;
200 UiList *list11; 201 UiList *list11;
201 UiString *link; 202 UiString *link;
202 UiString *link_label; 203 UiString *link_label;
203 UiString *link_uri; 204 UiString *link_uri;
204 UiList *submenulist; 205 UiList *submenulist;
206
207 UiModel *model;
205 } MyDocument; 208 } MyDocument;
206 209
207 MyDocument *doc1; 210 MyDocument *doc1;
208 MyDocument *doc2; 211 MyDocument *doc2;
209 212
347 ui_list_append(doc->items, "Item 3"); 350 ui_list_append(doc->items, "Item 3");
348 351
349 doc->web = ui_generic_new(docctx, NULL); 352 doc->web = ui_generic_new(docctx, NULL);
350 353
351 doc->list_input = ui_string_new(docctx, "list_input"); 354 doc->list_input = ui_string_new(docctx, "list_input");
355 doc->list_new_col = ui_string_new(docctx, NULL);
352 356
353 doc->list11 = ui_list_new(docctx, "list11"); 357 doc->list11 = ui_list_new(docctx, "list11");
354 ui_list_append(doc->list11, "Item 1"); 358 ui_list_append(doc->list11, "Item 1");
355 ui_list_append(doc->list11, "Item 2"); 359 ui_list_append(doc->list11, "Item 2");
356 ui_list_append(doc->list11, "Item 3"); 360 ui_list_append(doc->list11, "Item 3");
469 473
470 UiMenuBuilder *menubuilder; 474 UiMenuBuilder *menubuilder;
471 UiMenuBuilder *sourcelist_menu; 475 UiMenuBuilder *sourcelist_menu;
472 476
473 void* table_getvalue(void *row, int col) { 477 void* table_getvalue(void *row, int col) {
478 return "test";
474 switch(col) { 479 switch(col) {
475 case 0: return ui_foldericon(16); 480 case 0: return ui_foldericon(16);
476 case 1: return row; 481 case 1: return row;
477 case 2: return (void*)(intptr_t)1234; 482 case 2: return (void*)(intptr_t)1234;
478 case 3: return ui_foldericon(16); 483 case 3: return ui_foldericon(16);
566 cxListInsert(list2, 1, strdup(newvalue)); 571 cxListInsert(list2, 1, strdup(newvalue));
567 572
568 doc->list2->update(doc->list2, 1); 573 doc->list2->update(doc->list2, 1);
569 } 574 }
570 575
576 static void action_add_col(UiEvent *event, void *userdata) {
577 MyDocument *doc = event->document;
578
579 char *colname = ui_get(doc->list_new_col);
580 ui_model_add_column(doc->model, UI_STRING, colname, 200);
581 }
582
571 static void action_list_selection(UiEvent *event, void *userdata) { 583 static void action_list_selection(UiEvent *event, void *userdata) {
572 UiListSelection *sel = event->eventdata; 584 UiListSelection *sel = event->eventdata;
573 printf("list selection[%d]\n", sel->count); 585 printf("list selection[%d]\n", sel->count);
574 for(int i=0;i<sel->count;i++) { 586 for(int i=0;i<sel->count;i++) {
575 printf("[%d]: %d\n", i, sel->rows[i]); 587 printf("[%d]: %d\n", i, sel->rows[i]);
693 } 705 }
694 ui_newline(obj); 706 ui_newline(obj);
695 } 707 }
696 } 708 }
697 ui_tab(obj, "Tab 1") { 709 ui_tab(obj, "Tab 1") {
698 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); 710 //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);
711 UiModel *model = ui_model(obj->ctx, UI_STRING, "Col", -1);
699 model->columnsize[0] = -1; 712 model->columnsize[0] = -1;
713 doc->model = model;
700 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE, 714 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE,
701 .getvalue = table_getvalue, .getstyle = table_getstyle, .onsave = list_save, 715 .getvalue = table_getvalue, .getstyle = table_getstyle, .onsave = list_save,
702 .onactivate = action_table_activate, .onactivatedata = "activate", 716 .onactivate = action_table_activate, .onactivatedata = "activate",
703 .onselection = action_table_activate, .onselectiondata = "selection"); 717 .onselection = action_table_activate, .onselectiondata = "selection");
704 ui_hbox(obj, .fill = FALSE) { 718 ui_hbox(obj, .fill = FALSE, .columnspacing = 4) {
705 ui_textfield(obj, .value = doc->list_input); 719 ui_textfield(obj, .value = doc->list_input);
706 ui_button(obj, .label = "Update List Item 1", .onclick = action_update_list); 720 ui_button(obj, .label = "Update List Item 1", .onclick = action_update_list);
721 ui_label(obj, .label = "Column Name");
722 ui_textfield(obj, .value = doc->list_new_col);
723 ui_button(obj, .label = "Add Column", .onclick = action_add_col);
707 } 724 }
708 } 725 }
709 ui_tab(obj, "Tab 2") { 726 ui_tab(obj, "Tab 2") {
710 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); 727 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread);
711 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); 728 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread);

mercurial