application/main.c

changeset 742
f63d8125fcbd
parent 738
0dbf92544d4f
child 745
a4ee36ff7147
equal deleted inserted replaced
741:b653d8296d12 742:f63d8125fcbd
432 } 432 }
433 ui_show(obj); 433 ui_show(obj);
434 } 434 }
435 435
436 void action_sourcelist_activate(UiEvent *event, void *userdata) { 436 void action_sourcelist_activate(UiEvent *event, void *userdata) {
437 printf("sourcelist %s index %d\n", event->eventdata, event->intval); 437 UiSubListEventData *eventdata = event->eventdata;
438 printf("sourcelist %s index %d\n", eventdata->row_data, event->intval);
438 } 439 }
439 440
440 void action_table_activate(UiEvent *event, void *userdata) { 441 void action_table_activate(UiEvent *event, void *userdata) {
441 char *s = userdata; 442 char *s = userdata;
442 printf("table event: %s\n", s); 443 printf("table event: %s\n", s);
449 450
450 UiMenuBuilder *menubuilder; 451 UiMenuBuilder *menubuilder;
451 452
452 void* table_getvalue(void *row, int col) { 453 void* table_getvalue(void *row, int col) {
453 switch(col) { 454 switch(col) {
454 case 0: return row; 455 case 0: return ui_foldericon(16);
455 case 1: return (void*)(intptr_t)1234; 456 case 1: return row;
456 case 2: return ui_foldericon(16); 457 case 2: return (void*)(intptr_t)1234;
457 case 3: return ui_fileicon(16); 458 case 3: return ui_foldericon(16);
458 case 4: return "file"; 459 case 4: return ui_fileicon(16);
460 case 5: return "file";
459 } 461 }
460 return NULL; 462 return NULL;
461 } 463 }
462 464
463 UiBool table_getstyle(UiList *list, void *elm, int row, int col, void *userdata, UiTextStyle *style) { 465 UiBool table_getstyle(UiList *list, void *elm, int row, int col, void *userdata, UiTextStyle *style) {
464 if(row < 2 && col != -1) { 466 if(row < 2 && col != -1) {
465 style->text_style = UI_TEXT_STYLE_BOLD; 467 style->text_style = UI_TEXT_STYLE_BOLD;
466 style->fg.blue = col == 0 ? 255 : 0; 468 style->fg.blue = col == 1 ? 255 : 0;
467 style->fg.green = col == 1 ? 255 : 0; 469 style->fg.green = col == 2 ? 255 : 0;
468 style->fg.red = col == 4 ? 255 : 0; 470 style->fg.red = col == 5 ? 255 : 0;
469 return TRUE; 471 return TRUE;
470 } 472 }
471 return FALSE; 473 return FALSE;
472 } 474 }
473 475
574 .getvalue = sourcelist_getvalue, 576 .getvalue = sourcelist_getvalue,
575 .sublists = UI_SUBLISTS(UI_SUBLIST(.varname = "srclist1", .header = "Header 1", .userdata = "Sublist1"), UI_SUBLIST(.varname = "srclist2", .header = "Header 2", .userdata = "Sublist2")), 577 .sublists = UI_SUBLISTS(UI_SUBLIST(.varname = "srclist1", .header = "Header 1", .userdata = "Sublist1"), UI_SUBLIST(.varname = "srclist2", .header = "Header 2", .userdata = "Sublist2")),
576 .onactivate = action_sourcelist_activate); 578 .onactivate = action_sourcelist_activate);
577 } 579 }
578 580
579 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { 581 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview", .fill = TRUE) {
580 ui_tab(obj, "Tab 0") { 582 ui_tab(obj, "Tab 0") {
581 ui_vbox(obj, .fill = FALSE, .margin = 15, .spacing = 15) { 583 ui_vbox(obj, .fill = FALSE, .margin = 15, .spacing = 15) {
582 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); 584 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
583 ui_togglebutton(obj, .label = "Toggle"); 585 ui_togglebutton(obj, .label = "Toggle");
584 ui_checkbox(obj, .label = "My Checkbox"); 586 ui_checkbox(obj, .label = "My Checkbox");
634 } 636 }
635 ui_newline(obj); 637 ui_newline(obj);
636 } 638 }
637 } 639 }
638 ui_tab(obj, "Tab 1") { 640 ui_tab(obj, "Tab 1") {
639 UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", -1); 641 UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", -1);
640 model->columnsize[0] = -1; 642 model->columnsize[0] = -1;
641 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE, 643 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE,
642 .getvalue = table_getvalue, .getstyle = table_getstyle, 644 .getvalue = table_getvalue, .getstyle = table_getstyle,
643 .onactivate = action_table_activate, .onactivatedata = "activate", 645 .onactivate = action_table_activate, .onactivatedata = "activate",
644 .onselection = action_table_activate, .onselectiondata = "selection"); 646 .onselection = action_table_activate, .onselectiondata = "selection");

mercurial