484 |
484 |
485 #endif |
485 #endif |
486 |
486 |
487 #if defined(UI_COCOA) || defined(UI_MOTIF) |
487 #if defined(UI_COCOA) || defined(UI_MOTIF) |
488 |
488 |
|
489 static UiList *menulist; |
|
490 int items = 4; |
|
491 |
489 void action_button(UiEvent *event, void *data) { |
492 void action_button(UiEvent *event, void *data) { |
490 printf("action_button\n"); |
493 printf("action_button\n"); |
|
494 |
|
495 char *newitem = malloc(32); |
|
496 snprintf(newitem, 32, "Item %d", ++items); |
|
497 ui_list_append(menulist, newitem); |
|
498 ui_list_notify(menulist); |
491 } |
499 } |
492 |
500 |
493 typedef struct WData { |
501 typedef struct WData { |
494 UiString *path; |
502 UiString *path; |
495 } WData; |
503 } WData; |
496 |
504 |
|
505 |
|
506 |
497 void application_startup(UiEvent *event, void *data) { |
507 void application_startup(UiEvent *event, void *data) { |
|
508 |
|
509 menulist = ui_list_new(ui_global_context(), "menulist"); |
|
510 ui_list_append(menulist, "Item 1"); |
|
511 ui_list_append(menulist, "Item 2"); |
|
512 ui_list_append(menulist, "Item 3"); |
|
513 ui_list_append(menulist, "Item 4"); |
|
514 |
498 UiObject *obj = ui_window("Test", NULL); |
515 UiObject *obj = ui_window("Test", NULL); |
499 |
516 |
500 WData *wdata = ui_malloc(obj->ctx, sizeof(WData)); |
517 WData *wdata = ui_malloc(obj->ctx, sizeof(WData)); |
501 wdata->path = ui_string_new(obj->ctx, NULL); |
518 wdata->path = ui_string_new(obj->ctx, NULL); |
502 obj->window = wdata; |
519 obj->window = wdata; |
503 |
520 |
504 /* |
521 ui_button(obj, .label = "Add Item", .onclick = action_button); |
505 ui_grid(obj, .margin = 10) { |
|
506 ui_button(obj, .label = "Test Button", .onclick = action_button); |
|
507 ui_newline(obj); |
|
508 |
|
509 ui_togglebutton(obj, .label = "Togglebutton"); |
|
510 ui_togglebutton(obj, .label = "XY", .hfill = TRUE); |
|
511 ui_togglebutton(obj, .label = "AB", .hfill = TRUE); |
|
512 ui_togglebutton(obj, .label = "ZZ", .hexpand = TRUE, .hfill = TRUE); |
|
513 ui_newline(obj); |
|
514 |
|
515 ui_hbox(obj, .colspan = 4, .hfill = TRUE, .hexpand = TRUE) { |
|
516 ui_checkbox(obj, .label = "Checkbox", .enable_group = 123); |
|
517 ui_checkbox(obj, .label = "Checkbox Disabled", .groups = UI_GROUPS(123)); |
|
518 ui_button(obj, .label = "fill", .fill = UI_ON); |
|
519 } |
|
520 ui_newline(obj); |
|
521 |
|
522 |
|
523 |
|
524 ui_hbox(obj, .colspan = 4, .hfill = TRUE, .hexpand = TRUE) { |
|
525 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio"); |
|
526 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio"); |
|
527 ui_button(obj, .label = "fill", .hexpand = TRUE, .hfill = TRUE); |
|
528 } |
|
529 ui_newline(obj); |
|
530 |
|
531 |
|
532 ui_hbox(obj, .colspan = 4, .vexpand = TRUE, .vfill = TRUE) { |
|
533 ui_button(obj, .label = "F1----------------------A"); |
|
534 ui_button(obj, .label = "F2 test test test test test test test"); |
|
535 ui_button(obj, .label = "F312343543"); |
|
536 } |
|
537 |
|
538 |
|
539 } |
|
540 */ |
|
541 |
|
542 |
|
543 |
|
544 //ui_textfield(obj, .varname = "textfield"); |
|
545 //ui_textfield(obj, .varname = "textfield2"); |
|
546 ui_path_textfield(obj, .value = wdata->path, .hfill = TRUE, .hexpand = TRUE); |
|
547 |
|
548 ui_set(wdata->path, "/test/path/string"); |
|
549 |
|
550 |
522 |
551 ui_show(obj); |
523 ui_show(obj); |
552 } |
524 } |
553 |
525 |
554 void action_test(UiEvent *event, void *data) { |
526 void action_test(UiEvent *event, void *data) { |
562 // menu |
534 // menu |
563 ui_menu("File") { |
535 ui_menu("File") { |
564 ui_menuitem(.label = "Test 1", .onclick = action_test); |
536 ui_menuitem(.label = "Test 1", .onclick = action_test); |
565 ui_menuitem(.label = "Test 2", .onclick = action_test); |
537 ui_menuitem(.label = "Test 2", .onclick = action_test); |
566 ui_menuitem(.label = "Test 3", .onclick = action_test); |
538 ui_menuitem(.label = "Test 3", .onclick = action_test); |
|
539 ui_menuseparator(); |
567 ui_menu_toggleitem(.label = "Toggle 1"); |
540 ui_menu_toggleitem(.label = "Toggle 1"); |
568 ui_menu_toggleitem(.label = "Toggle 2"); |
541 ui_menu_toggleitem(.label = "Toggle 2"); |
|
542 ui_menuseparator(); |
569 ui_menu_radioitem(.label = "Radio 1", .varname = "menu_radio"); |
543 ui_menu_radioitem(.label = "Radio 1", .varname = "menu_radio"); |
570 ui_menu_radioitem(.label = "Radio 2", .varname = "menu_radio"); |
544 ui_menu_radioitem(.label = "Radio 2", .varname = "menu_radio"); |
571 ui_menu_radioitem(.label = "Radio 3", .varname = "menu_radio"); |
545 ui_menu_radioitem(.label = "Radio 3", .varname = "menu_radio"); |
572 ui_menu_radioitem(.label = "Radio 4", .varname = "menu_radio"); |
546 ui_menu_radioitem(.label = "Radio 4", .varname = "menu_radio"); |
|
547 ui_menuseparator(); |
|
548 ui_menu_itemlist(.varname = "menulist"); |
|
549 ui_menuseparator(); |
|
550 ui_menuitem(.label = "Quit"); |
573 } |
551 } |
574 |
552 |
575 ui_main(); |
553 ui_main(); |
576 return (EXIT_SUCCESS); |
554 return (EXIT_SUCCESS); |
577 } |
555 } |