Changes in uspace/app/uidemo/uidemo.c [9a07ee3:80d4aea] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r9a07ee3 r80d4aea 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 44 44 #include <ui/image.h> 45 45 #include <ui/label.h> 46 #include <ui/list.h> 46 #include <ui/menubar.h> 47 #include <ui/menuentry.h> 47 48 #include <ui/menu.h> 48 #include <ui/menubar.h>49 #include <ui/menudd.h>50 #include <ui/menuentry.h>51 49 #include <ui/msgdialog.h> 52 50 #include <ui/pbutton.h> 53 51 #include <ui/promptdialog.h> 54 52 #include <ui/resource.h> 55 #include <ui/selectdialog.h>56 #include <ui/tab.h>57 #include <ui/tabset.h>58 53 #include <ui/ui.h> 59 54 #include <ui/window.h> … … 92 87 }; 93 88 94 static void scrollbar_up(ui_scrollbar_t *, void *);95 static void scrollbar_down(ui_scrollbar_t *, void *);96 static void scrollbar_page_up(ui_scrollbar_t *, void *);97 static void scrollbar_page_down(ui_scrollbar_t *, void *);98 static void scrollbar_moved(ui_scrollbar_t *, void *, gfx_coord_t);99 100 static ui_scrollbar_cb_t scrollbar_cb = {101 .up = scrollbar_up,102 .down = scrollbar_down,103 .page_up = scrollbar_page_up,104 .page_down = scrollbar_page_down,105 .moved = scrollbar_moved106 };107 108 89 static void uidemo_file_load(ui_menu_entry_t *, void *); 109 90 static void uidemo_file_message(ui_menu_entry_t *, void *); 110 static void uidemo_file_confirmation(ui_menu_entry_t *, void *);111 91 static void uidemo_file_exit(ui_menu_entry_t *, void *); 112 92 static void uidemo_edit_modify(ui_menu_entry_t *, void *); 113 static void uidemo_edit_insert_character(ui_menu_entry_t *, void *);114 93 115 94 static void file_dialog_bok(ui_file_dialog_t *, void *, const char *); … … 131 110 .bcancel = prompt_dialog_bcancel, 132 111 .close = prompt_dialog_close 133 };134 135 static void select_dialog_bok(ui_select_dialog_t *, void *, void *);136 static void select_dialog_bcancel(ui_select_dialog_t *, void *);137 static void select_dialog_close(ui_select_dialog_t *, void *);138 139 static ui_select_dialog_cb_t select_dialog_cb = {140 .bok = select_dialog_bok,141 .bcancel = select_dialog_bcancel,142 .close = select_dialog_close143 112 }; 144 113 … … 246 215 } 247 216 248 /** Scrollbar up button pressed. 249 * 250 * @param scrollbar Scrollbar 251 * @param arg Argument (demo) 252 */ 253 static void scrollbar_up(ui_scrollbar_t *scrollbar, void *arg) 254 { 255 gfx_coord_t pos; 256 257 pos = ui_scrollbar_get_pos(scrollbar); 258 ui_scrollbar_set_pos(scrollbar, pos - 1); 259 260 pos = ui_scrollbar_get_pos(scrollbar); 261 scrollbar_moved(scrollbar, arg, pos); 262 } 263 264 /** Scrollbar down button pressed. 265 * 266 * @param scrollbar Scrollbar 267 * @param arg Argument (demo) 268 */ 269 static void scrollbar_down(ui_scrollbar_t *scrollbar, void *arg) 270 { 271 gfx_coord_t pos; 272 273 pos = ui_scrollbar_get_pos(scrollbar); 274 ui_scrollbar_set_pos(scrollbar, pos + 1); 275 276 pos = ui_scrollbar_get_pos(scrollbar); 277 scrollbar_moved(scrollbar, arg, pos); 278 } 279 280 /** Scrollbar page up event. 281 * 282 * @param scrollbar Scrollbar 283 * @param arg Argument (demo) 284 */ 285 static void scrollbar_page_up(ui_scrollbar_t *scrollbar, void *arg) 286 { 287 gfx_coord_t pos; 288 289 pos = ui_scrollbar_get_pos(scrollbar); 290 ui_scrollbar_set_pos(scrollbar, pos - 291 ui_scrollbar_trough_length(scrollbar) / 4); 292 293 pos = ui_scrollbar_get_pos(scrollbar); 294 scrollbar_moved(scrollbar, arg, pos); 295 } 296 297 /** Scrollbar page down event. 298 * 299 * @param scrollbar Scrollbar 300 * @param arg Argument (demo) 301 */ 302 static void scrollbar_page_down(ui_scrollbar_t *scrollbar, void *arg) 303 { 304 gfx_coord_t pos; 305 306 pos = ui_scrollbar_get_pos(scrollbar); 307 ui_scrollbar_set_pos(scrollbar, pos + 308 ui_scrollbar_trough_length(scrollbar) / 4); 309 310 pos = ui_scrollbar_get_pos(scrollbar); 311 scrollbar_moved(scrollbar, arg, pos); 312 } 313 314 /** Scrollbar was moved. 315 * 316 * @param scrollbar Scrollbar 317 * @param arg Argument (demo) 318 * @param pos Position 319 */ 320 static void scrollbar_moved(ui_scrollbar_t *scrollbar, void *arg, 321 gfx_coord_t pos) 322 { 323 ui_demo_t *demo = (ui_demo_t *) arg; 324 char *str; 325 errno_t rc; 326 int rv; 327 328 rv = asprintf(&str, "Scrollbar: %d of %d", (int) pos, 329 ui_scrollbar_move_length(scrollbar)); 330 if (rv < 0) { 331 printf("Out of memory.\n"); 332 return; 333 } 334 335 rc = ui_entry_set_text(demo->entry, str); 336 if (rc != EOK) 337 printf("Error changing entry text.\n"); 338 (void) ui_entry_paint(demo->entry); 339 340 free(str); 341 } 342 343 /** Display a message window with OK button. 217 /** Display a message window. 344 218 * 345 219 * @param demo UI demo … … 416 290 } 417 291 418 /** File / Confirmation menu entry selected.419 *420 * @param mentry Menu entry421 * @param arg Argument (demo)422 */423 static void uidemo_file_confirmation(ui_menu_entry_t *mentry, void *arg)424 {425 ui_demo_t *demo = (ui_demo_t *) arg;426 ui_msg_dialog_params_t mdparams;427 ui_msg_dialog_t *dialog;428 errno_t rc;429 430 ui_msg_dialog_params_init(&mdparams);431 mdparams.caption = "Confirmation";432 mdparams.text = "This will not actually do anything. Proceed?";433 mdparams.choice = umdc_ok_cancel;434 435 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog);436 if (rc != EOK) {437 printf("Error creating message dialog.\n");438 return;439 }440 441 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo);442 }443 444 292 /** File / Exit menu entry selected. 445 293 * … … 472 320 rc = ui_prompt_dialog_create(demo->ui, &pdparams, &dialog); 473 321 if (rc != EOK) { 474 printf("Error creating promptdialog.\n");322 printf("Error creating message dialog.\n"); 475 323 return; 476 324 } 477 325 478 326 ui_prompt_dialog_set_cb(dialog, &prompt_dialog_cb, demo); 479 }480 481 /** Edit / Insert Character menu entry selected.482 *483 * @param mentry Menu entry484 * @param arg Argument (demo)485 */486 static void uidemo_edit_insert_character(ui_menu_entry_t *mentry, void *arg)487 {488 ui_demo_t *demo = (ui_demo_t *) arg;489 ui_select_dialog_params_t sdparams;490 ui_select_dialog_t *dialog;491 ui_list_entry_attr_t attr;492 errno_t rc;493 494 ui_select_dialog_params_init(&sdparams);495 sdparams.caption = "Insert Character";496 sdparams.prompt = "Select character to insert";497 498 rc = ui_select_dialog_create(demo->ui, &sdparams, &dialog);499 if (rc != EOK) {500 printf("Error creating select dialog.\n");501 return;502 }503 504 ui_list_entry_attr_init(&attr);505 attr.caption = "Dollar sign ($)";506 attr.arg = (void *)'$';507 rc = ui_select_dialog_append(dialog, &attr);508 if (rc != EOK) {509 printf("Error appending entry to list.\n");510 return;511 }512 513 ui_list_entry_attr_init(&attr);514 attr.caption = "Hash sign (#)";515 attr.arg = (void *)'#';516 rc = ui_select_dialog_append(dialog, &attr);517 if (rc != EOK) {518 printf("Error appending entry to list.\n");519 return;520 }521 522 ui_list_entry_attr_init(&attr);523 attr.caption = "Question mark (?)";524 attr.arg = (void *)'?';525 rc = ui_select_dialog_append(dialog, &attr);526 if (rc != EOK) {527 printf("Error appending entry to list.\n");528 return;529 }530 531 ui_select_dialog_set_cb(dialog, &select_dialog_cb, demo);532 533 (void) ui_select_dialog_paint(dialog);534 327 } 535 328 … … 620 413 /** Prompt dialog cancel button press. 621 414 * 622 * @param dialog Promptdialog415 * @param dialog File dialog 623 416 * @param arg Argument (ui_demo_t *) 624 417 */ … … 633 426 /** Prompt dialog close request. 634 427 * 635 * @param dialog Promptdialog428 * @param dialog File dialog 636 429 * @param arg Argument (ui_demo_t *) 637 430 */ … … 642 435 (void) demo; 643 436 ui_prompt_dialog_destroy(dialog); 644 }645 646 /** Select dialog OK button press.647 *648 * @param dialog Select dialog649 * @param arg Argument (ui_demo_t *)650 * @param text Submitted text651 */652 static void select_dialog_bok(ui_select_dialog_t *dialog, void *arg,653 void *earg)654 {655 ui_demo_t *demo = (ui_demo_t *) arg;656 char str[2];657 658 ui_select_dialog_destroy(dialog);659 str[0] = (char)(intptr_t)earg;660 str[1] = '\0';661 (void) ui_entry_insert_str(demo->entry, str);662 }663 664 /** Select dialog cancel button press.665 *666 * @param dialog Select dialog667 * @param arg Argument (ui_demo_t *)668 */669 static void select_dialog_bcancel(ui_select_dialog_t *dialog, void *arg)670 {671 ui_demo_t *demo = (ui_demo_t *) arg;672 673 (void) demo;674 ui_select_dialog_destroy(dialog);675 }676 677 /** Select dialog close request.678 *679 * @param dialog Select dialog680 * @param arg Argument (ui_demo_t *)681 */682 static void select_dialog_close(ui_select_dialog_t *dialog, void *arg)683 {684 ui_demo_t *demo = (ui_demo_t *) arg;685 686 (void) demo;687 ui_select_dialog_destroy(dialog);688 437 } 689 438 … … 737 486 ui_menu_entry_t *mexit; 738 487 ui_menu_entry_t *mmodify; 739 ui_menu_entry_t *minsert_char;740 488 ui_menu_entry_t *mabout; 741 ui_list_entry_attr_t eattr;742 489 errno_t rc; 743 490 … … 753 500 ui_wnd_params_init(¶ms); 754 501 params.caption = "UI Demo"; 755 params.style |= ui_wds_ maximize_btn | ui_wds_resizable;502 params.style |= ui_wds_resizable; 756 503 757 504 /* FIXME: Auto layout */ … … 759 506 params.rect.p0.x = 0; 760 507 params.rect.p0.y = 0; 761 params.rect.p1.x = 4 6;762 params.rect.p1.y = 2 5;508 params.rect.p1.x = 44; 509 params.rect.p1.y = 21; 763 510 } else { 764 511 params.rect.p0.x = 0; 765 512 params.rect.p0.y = 0; 766 params.rect.p1.x = 255; 767 params.rect.p1.y = 410; 768 } 769 770 /* Only allow making the window larger */ 771 gfx_rect_dims(¶ms.rect, ¶ms.min_size); 513 params.rect.p1.x = 220; 514 params.rect.p1.y = 350; 515 } 772 516 773 517 rc = ui_window_create(ui, ¶ms, &window); … … 795 539 } 796 540 797 rc = ui_menu_ dd_create(demo.mbar, "~F~ile", NULL, &demo.mfile);798 if (rc != EOK) { 799 printf("Error creating menu.\n"); 800 return rc; 801 } 802 803 rc = ui_menu_entry_create(demo.mfile, " ~M~essage", "", &mmsg);541 rc = ui_menu_create(demo.mbar, "File", &demo.mfile); 542 if (rc != EOK) { 543 printf("Error creating menu.\n"); 544 return rc; 545 } 546 547 rc = ui_menu_entry_create(demo.mfile, "Message", "", &mmsg); 804 548 if (rc != EOK) { 805 549 printf("Error creating menu.\n"); … … 809 553 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo); 810 554 811 rc = ui_menu_entry_create(demo.mfile, "~C~onfirmation", "", &mmsg); 812 if (rc != EOK) { 813 printf("Error creating menu.\n"); 814 return rc; 815 } 816 817 ui_menu_entry_set_cb(mmsg, uidemo_file_confirmation, (void *) &demo); 818 819 rc = ui_menu_entry_create(demo.mfile, "~L~oad", "", &mload); 555 rc = ui_menu_entry_create(demo.mfile, "Load", "", &mload); 820 556 if (rc != EOK) { 821 557 printf("Error creating menu.\n"); … … 825 561 ui_menu_entry_set_cb(mload, uidemo_file_load, (void *) &demo); 826 562 827 rc = ui_menu_entry_create(demo.mfile, "~F~oo", "Ctrl-Alt-Del", &mfoo); 828 if (rc != EOK) { 829 printf("Error creating menu.\n"); 830 return rc; 831 } 832 833 rc = ui_menu_entry_create(demo.mfile, "~B~ar", "", &mbar); 834 if (rc != EOK) { 835 printf("Error creating menu.\n"); 836 return rc; 837 } 838 839 rc = ui_menu_entry_create(demo.mfile, "F~o~obar", "", &mfoobar); 840 if (rc != EOK) { 841 printf("Error creating menu.\n"); 842 return rc; 843 } 844 845 ui_menu_entry_set_disabled(mfoobar, true); 563 rc = ui_menu_entry_create(demo.mfile, "Foo", "Ctrl-Alt-Del", &mfoo); 564 if (rc != EOK) { 565 printf("Error creating menu.\n"); 566 return rc; 567 } 568 569 rc = ui_menu_entry_create(demo.mfile, "Bar", "", &mbar); 570 if (rc != EOK) { 571 printf("Error creating menu.\n"); 572 return rc; 573 } 574 575 rc = ui_menu_entry_create(demo.mfile, "Foobar", "", &mfoobar); 576 if (rc != EOK) { 577 printf("Error creating menu.\n"); 578 return rc; 579 } 846 580 847 581 rc = ui_menu_entry_sep_create(demo.mfile, &msep); … … 851 585 } 852 586 853 rc = ui_menu_entry_create(demo.mfile, "E ~x~it", "Alt-F4", &mexit);587 rc = ui_menu_entry_create(demo.mfile, "Exit", "Alt-F4", &mexit); 854 588 if (rc != EOK) { 855 589 printf("Error creating menu.\n"); … … 859 593 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo); 860 594 861 rc = ui_menu_ dd_create(demo.mbar, "~E~dit", NULL, &demo.medit);862 if (rc != EOK) { 863 printf("Error creating menu.\n"); 864 return rc; 865 } 866 867 rc = ui_menu_entry_create(demo.medit, " ~M~odify", "", &mmodify);595 rc = ui_menu_create(demo.mbar, "Edit", &demo.medit); 596 if (rc != EOK) { 597 printf("Error creating menu.\n"); 598 return rc; 599 } 600 601 rc = ui_menu_entry_create(demo.medit, "Modify", "", &mmodify); 868 602 if (rc != EOK) { 869 603 printf("Error creating menu.\n"); … … 873 607 ui_menu_entry_set_cb(mmodify, uidemo_edit_modify, (void *) &demo); 874 608 875 rc = ui_menu_entry_create(demo.medit, "~I~nsert Character", 876 "", &minsert_char); 877 if (rc != EOK) { 878 printf("Error creating menu.\n"); 879 return rc; 880 } 881 882 ui_menu_entry_set_cb(minsert_char, uidemo_edit_insert_character, 883 (void *) &demo); 884 885 rc = ui_menu_dd_create(demo.mbar, "~P~references", NULL, 886 &demo.mpreferences); 887 if (rc != EOK) { 888 printf("Error creating menu.\n"); 889 return rc; 890 } 891 892 rc = ui_menu_dd_create(demo.mbar, "~H~elp", NULL, &demo.mhelp); 893 if (rc != EOK) { 894 printf("Error creating menu.\n"); 895 return rc; 896 } 897 898 rc = ui_menu_entry_create(demo.mhelp, "~A~bout", "Ctrl-H, F1", &mabout); 609 rc = ui_menu_create(demo.mbar, "Preferences", &demo.mpreferences); 610 if (rc != EOK) { 611 printf("Error creating menu.\n"); 612 return rc; 613 } 614 615 rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp); 616 if (rc != EOK) { 617 printf("Error creating menu.\n"); 618 return rc; 619 } 620 621 rc = ui_menu_entry_create(demo.mhelp, "About", "Ctrl-H, F1", &mabout); 899 622 if (rc != EOK) { 900 623 printf("Error creating menu.\n"); … … 911 634 rect.p0.x = 4; 912 635 rect.p0.y = 30; 913 rect.p1.x = 2 51;636 rect.p1.x = 216; 914 637 rect.p1.y = 52; 915 638 } 916 917 639 ui_menu_bar_set_rect(demo.mbar, &rect); 918 640 … … 923 645 } 924 646 925 rc = ui_ tab_set_create(ui_res, &demo.tabset);926 if (rc != EOK) { 927 printf("Error creating tab set.\n");647 rc = ui_entry_create(window, "", &demo.entry); 648 if (rc != EOK) { 649 printf("Error creating entry.\n"); 928 650 return rc; 929 651 } … … 932 654 if (ui_is_textmode(ui)) { 933 655 rect.p0.x = 2; 934 rect.p0.y = 2;935 rect.p1.x = 4 4;936 rect.p1.y = 24;937 } else { 938 rect.p0.x = 8;656 rect.p0.y = 3; 657 rect.p1.x = 42; 658 rect.p1.y = 4; 659 } else { 660 rect.p0.x = 15; 939 661 rect.p0.y = 53; 940 rect.p1.x = 250;941 rect.p1.y = 405;942 }943 944 ui_tab_set_set_rect(demo.tabset, &rect);945 946 rc = ui_tab_create(demo.tabset, "Basic", &demo.tbasic);947 if (rc != EOK) {948 printf("Error creating tab.\n");949 return rc;950 }951 952 rc = ui_tab_create(demo.tabset, "Lists", &demo.tlists);953 if (rc != EOK) {954 printf("Error creating tab.\n");955 return rc;956 }957 958 rc = ui_fixed_add(demo.fixed, ui_tab_set_ctl(demo.tabset));959 if (rc != EOK) {960 printf("Error adding control to layout.\n");961 return rc;962 }963 964 rc = ui_fixed_create(&demo.bfixed);965 if (rc != EOK) {966 printf("Error creating fixed layout.\n");967 return rc;968 }969 970 rc = ui_entry_create(window, "", &demo.entry);971 if (rc != EOK) {972 printf("Error creating entry.\n");973 return rc;974 }975 976 /* FIXME: Auto layout */977 if (ui_is_textmode(ui)) {978 rect.p0.x = 4;979 rect.p0.y = 5;980 rect.p1.x = 41;981 rect.p1.y = 6;982 } else {983 rect.p0.x = 15;984 rect.p0.y = 88;985 662 rect.p1.x = 205; 986 rect.p1.y = 113;663 rect.p1.y = 78; 987 664 } 988 665 … … 990 667 ui_entry_set_halign(demo.entry, gfx_halign_center); 991 668 992 rc = ui_fixed_add(demo. bfixed, ui_entry_ctl(demo.entry));669 rc = ui_fixed_add(demo.fixed, ui_entry_ctl(demo.entry)); 993 670 if (rc != EOK) { 994 671 printf("Error adding control to layout.\n"); … … 1004 681 /* FIXME: Auto layout */ 1005 682 if (ui_is_textmode(ui)) { 1006 rect.p0.x = 4;1007 rect.p0.y = 7;1008 rect.p1.x = 4 1;1009 rect.p1.y = 8;683 rect.p0.x = 2; 684 rect.p0.y = 5; 685 rect.p1.x = 42; 686 rect.p1.y = 6; 1010 687 } else { 1011 688 rect.p0.x = 60; 1012 rect.p0.y = 123;689 rect.p0.y = 88; 1013 690 rect.p1.x = 160; 1014 rect.p1.y = 1 36;691 rect.p1.y = 101; 1015 692 } 1016 693 … … 1018 695 ui_label_set_halign(demo.label, gfx_halign_center); 1019 696 1020 rc = ui_fixed_add(demo. bfixed, ui_label_ctl(demo.label));697 rc = ui_fixed_add(demo.fixed, ui_label_ctl(demo.label)); 1021 698 if (rc != EOK) { 1022 699 printf("Error adding control to layout.\n"); … … 1034 711 /* FIXME: Auto layout */ 1035 712 if (ui_is_textmode(ui)) { 1036 rect.p0.x = 4;1037 rect.p0.y = 9;1038 rect.p1.x = 1 5;1039 rect.p1.y = 10;713 rect.p0.x = 2; 714 rect.p0.y = 7; 715 rect.p1.x = 12; 716 rect.p1.y = 8; 1040 717 } else { 1041 718 rect.p0.x = 15; 1042 rect.p0.y = 1 46;719 rect.p0.y = 111; 1043 720 rect.p1.x = 105; 1044 rect.p1.y = 1 74;721 rect.p1.y = 139; 1045 722 } 1046 723 … … 1049 726 ui_pbutton_set_default(demo.pb1, true); 1050 727 1051 rc = ui_fixed_add(demo. bfixed, ui_pbutton_ctl(demo.pb1));728 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb1)); 1052 729 if (rc != EOK) { 1053 730 printf("Error adding control to layout.\n"); … … 1064 741 1065 742 if (ui_is_textmode(ui)) { 1066 rect.p0.x = 3 0;1067 rect.p0.y = 9;1068 rect.p1.x = 4 1;1069 rect.p1.y = 10;743 rect.p0.x = 32; 744 rect.p0.y = 7; 745 rect.p1.x = 42; 746 rect.p1.y = 8; 1070 747 } else { 1071 748 rect.p0.x = 115; 1072 rect.p0.y = 1 46;749 rect.p0.y = 111; 1073 750 rect.p1.x = 205; 1074 rect.p1.y = 1 74;751 rect.p1.y = 139; 1075 752 } 1076 753 1077 754 ui_pbutton_set_rect(demo.pb2, &rect); 1078 755 1079 rc = ui_fixed_add(demo. bfixed, ui_pbutton_ctl(demo.pb2));756 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb2)); 1080 757 if (rc != EOK) { 1081 758 printf("Error adding control to layout.\n"); … … 1087 764 bparams.rect.p0.x = 0; 1088 765 bparams.rect.p0.y = 0; 1089 bparams.rect.p1.x = 37;766 bparams.rect.p1.x = 40; 1090 767 bparams.rect.p1.y = 2; 1091 768 } else { … … 1111 788 1112 789 if (ui_is_textmode(ui)) { 1113 off.x = 4;1114 off.y = 11;790 off.x = 2; 791 off.y = 9; 1115 792 } else { 1116 793 off.x = 15; 1117 off.y = 1 90;794 off.y = 155; 1118 795 } 1119 796 … … 1129 806 ui_image_set_rect(demo.image, &rect); 1130 807 1131 rc = ui_fixed_add(demo. bfixed, ui_image_ctl(demo.image));808 rc = ui_fixed_add(demo.fixed, ui_image_ctl(demo.image)); 1132 809 if (rc != EOK) { 1133 810 printf("Error adding control to layout.\n"); … … 1145 822 /* FIXME: Auto layout */ 1146 823 if (ui_is_textmode(ui)) { 1147 rect.p0.x = 4;1148 rect.p0.y = 1 4;1149 rect.p1.x = 1 4;1150 rect.p1.y = 1 5;824 rect.p0.x = 2; 825 rect.p0.y = 12; 826 rect.p1.x = 12; 827 rect.p1.y = 13; 1151 828 } else { 1152 829 rect.p0.x = 15; 1153 rect.p0.y = 225;830 rect.p0.y = 190; 1154 831 rect.p1.x = 140; 1155 rect.p1.y = 2 45;832 rect.p1.y = 210; 1156 833 } 1157 834 1158 835 ui_checkbox_set_rect(demo.checkbox, &rect); 1159 836 1160 rc = ui_fixed_add(demo. bfixed, ui_checkbox_ctl(demo.checkbox));837 rc = ui_fixed_add(demo.fixed, ui_checkbox_ctl(demo.checkbox)); 1161 838 if (rc != EOK) { 1162 839 printf("Error adding control to layout.\n"); … … 1182 859 /* FIXME: Auto layout */ 1183 860 if (ui_is_textmode(ui)) { 1184 rect.p0.x = 4;1185 rect.p0.y = 1 6;1186 rect.p1.x = 1 4;1187 rect.p1.y = 1 7;861 rect.p0.x = 2; 862 rect.p0.y = 14; 863 rect.p1.x = 12; 864 rect.p1.y = 15; 1188 865 } else { 1189 866 rect.p0.x = 15; 1190 rect.p0.y = 2 55;867 rect.p0.y = 220; 1191 868 rect.p1.x = 140; 1192 rect.p1.y = 2 75;869 rect.p1.y = 240; 1193 870 } 1194 871 ui_rbutton_set_rect(demo.rbleft, &rect); 1195 872 1196 rc = ui_fixed_add(demo. bfixed, ui_rbutton_ctl(demo.rbleft));873 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbleft)); 1197 874 if (rc != EOK) { 1198 875 printf("Error adding control to layout.\n"); … … 1209 886 /* FIXME: Auto layout */ 1210 887 if (ui_is_textmode(ui)) { 1211 rect.p0.x = 4;1212 rect.p0.y = 1 7;1213 rect.p1.x = 1 4;1214 rect.p1.y = 1 8;888 rect.p0.x = 2; 889 rect.p0.y = 15; 890 rect.p1.x = 12; 891 rect.p1.y = 16; 1215 892 } else { 1216 893 rect.p0.x = 15; 1217 rect.p0.y = 2 85;894 rect.p0.y = 250; 1218 895 rect.p1.x = 140; 1219 rect.p1.y = 305;896 rect.p1.y = 270; 1220 897 } 1221 898 ui_rbutton_set_rect(demo.rbcenter, &rect); 1222 899 ui_rbutton_select(demo.rbcenter); 1223 900 1224 rc = ui_fixed_add(demo. bfixed, ui_rbutton_ctl(demo.rbcenter));901 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbcenter)); 1225 902 if (rc != EOK) { 1226 903 printf("Error adding control to layout.\n"); … … 1237 914 /* FIXME: Auto layout */ 1238 915 if (ui_is_textmode(ui)) { 1239 rect.p0.x = 4; 916 rect.p0.x = 2; 917 rect.p0.y = 16; 918 rect.p1.x = 12; 919 rect.p1.y = 17; 920 } else { 921 rect.p0.x = 15; 922 rect.p0.y = 280; 923 rect.p1.x = 140; 924 rect.p1.y = 300; 925 } 926 ui_rbutton_set_rect(demo.rbright, &rect); 927 928 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbright)); 929 if (rc != EOK) { 930 printf("Error adding control to layout.\n"); 931 return rc; 932 } 933 934 rc = ui_slider_create(ui_res, "Slide!", &demo.slider); 935 if (rc != EOK) { 936 printf("Error creating button.\n"); 937 return rc; 938 } 939 940 ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo); 941 942 /* FIXME: Auto layout */ 943 if (ui_is_textmode(ui)) { 944 rect.p0.x = 2; 1240 945 rect.p0.y = 18; 1241 rect.p1.x = 1 4;946 rect.p1.x = 12; 1242 947 rect.p1.y = 19; 1243 948 } else { 1244 949 rect.p0.x = 15; 1245 rect.p0.y = 315; 1246 rect.p1.x = 140; 1247 rect.p1.y = 335; 1248 } 1249 ui_rbutton_set_rect(demo.rbright, &rect); 1250 1251 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbright)); 950 rect.p0.y = 310; 951 rect.p1.x = 130; 952 rect.p1.y = 330; 953 } 954 955 ui_slider_set_rect(demo.slider, &rect); 956 957 rc = ui_fixed_add(demo.fixed, ui_slider_ctl(demo.slider)); 1252 958 if (rc != EOK) { 1253 959 printf("Error adding control to layout.\n"); 1254 960 return rc; 1255 961 } 1256 1257 rc = ui_slider_create(ui_res, &demo.slider);1258 if (rc != EOK) {1259 printf("Error creating button.\n");1260 return rc;1261 }1262 1263 ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo);1264 1265 /* FIXME: Auto layout */1266 if (ui_is_textmode(ui)) {1267 rect.p0.x = 4;1268 rect.p0.y = 20;1269 rect.p1.x = 32;1270 rect.p1.y = 21;1271 } else {1272 rect.p0.x = 15;1273 rect.p0.y = 345;1274 rect.p1.x = 130;1275 rect.p1.y = 365;1276 }1277 1278 ui_slider_set_rect(demo.slider, &rect);1279 1280 rc = ui_fixed_add(demo.bfixed, ui_slider_ctl(demo.slider));1281 if (rc != EOK) {1282 printf("Error adding control to layout.\n");1283 return rc;1284 }1285 1286 rc = ui_scrollbar_create(ui, window, ui_sbd_horiz, &demo.hscrollbar);1287 if (rc != EOK) {1288 printf("Error creating scrollbar.\n");1289 return rc;1290 }1291 1292 ui_scrollbar_set_cb(demo.hscrollbar, &scrollbar_cb, (void *) &demo);1293 1294 /* FIXME: Auto layout */1295 if (ui_is_textmode(ui)) {1296 rect.p0.x = 4;1297 rect.p0.y = 22;1298 rect.p1.x = 42;1299 rect.p1.y = 23;1300 } else {1301 rect.p0.x = 15;1302 rect.p0.y = 375;1303 rect.p1.x = 220;1304 rect.p1.y = 398;1305 }1306 1307 ui_scrollbar_set_rect(demo.hscrollbar, &rect);1308 1309 ui_scrollbar_set_thumb_length(demo.hscrollbar,1310 ui_scrollbar_trough_length(demo.hscrollbar) / 4);1311 1312 rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.hscrollbar));1313 if (rc != EOK) {1314 printf("Error adding control to layout.\n");1315 return rc;1316 }1317 1318 rc = ui_scrollbar_create(ui, window, ui_sbd_vert, &demo.vscrollbar);1319 if (rc != EOK) {1320 printf("Error creating button.\n");1321 return rc;1322 }1323 1324 ui_scrollbar_set_cb(demo.vscrollbar, &scrollbar_cb, (void *) &demo);1325 1326 /* FIXME: Auto layout */1327 if (ui_is_textmode(ui)) {1328 rect.p0.x = 42;1329 rect.p0.y = 5;1330 rect.p1.x = 43;1331 rect.p1.y = 22;1332 } else {1333 rect.p0.x = 220;1334 rect.p0.y = 88;1335 rect.p1.x = 243;1336 rect.p1.y = 375;1337 }1338 1339 ui_scrollbar_set_rect(demo.vscrollbar, &rect);1340 1341 ui_scrollbar_set_thumb_length(demo.vscrollbar,1342 ui_scrollbar_trough_length(demo.vscrollbar) / 4);1343 1344 rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.vscrollbar));1345 if (rc != EOK) {1346 printf("Error adding control to layout.\n");1347 return rc;1348 }1349 1350 ui_tab_add(demo.tbasic, ui_fixed_ctl(demo.bfixed));1351 1352 rc = ui_fixed_create(&demo.lfixed);1353 if (rc != EOK) {1354 printf("Error creating fixed layout.\n");1355 return rc;1356 }1357 1358 rc = ui_list_create(window, false, &demo.list);1359 if (rc != EOK) {1360 printf("Error creating list.\n");1361 return rc;1362 }1363 1364 ui_list_entry_attr_init(&eattr);1365 1366 eattr.caption = "One";1367 rc = ui_list_entry_append(demo.list, &eattr, NULL);1368 if (rc != EOK) {1369 printf("Error adding list entry.\n");1370 return rc;1371 }1372 1373 eattr.caption = "Two";1374 rc = ui_list_entry_append(demo.list, &eattr, NULL);1375 if (rc != EOK) {1376 printf("Error adding list entry.\n");1377 return rc;1378 }1379 1380 eattr.caption = "Three";1381 rc = ui_list_entry_append(demo.list, &eattr, NULL);1382 if (rc != EOK) {1383 printf("Error adding list entry.\n");1384 return rc;1385 }1386 1387 eattr.caption = "Four";1388 rc = ui_list_entry_append(demo.list, &eattr, NULL);1389 if (rc != EOK) {1390 printf("Error adding list entry.\n");1391 return rc;1392 }1393 1394 eattr.caption = "Five";1395 rc = ui_list_entry_append(demo.list, &eattr, NULL);1396 if (rc != EOK) {1397 printf("Error adding list entry.\n");1398 return rc;1399 }1400 1401 eattr.caption = "Six";1402 rc = ui_list_entry_append(demo.list, &eattr, NULL);1403 if (rc != EOK) {1404 printf("Error adding list entry.\n");1405 return rc;1406 }1407 1408 /* FIXME: Auto layout */1409 if (ui_is_textmode(ui)) {1410 rect.p0.x = 4;1411 rect.p0.y = 5;1412 rect.p1.x = 41;1413 rect.p1.y = 10;1414 } else {1415 rect.p0.x = 15;1416 rect.p0.y = 88;1417 rect.p1.x = 245;1418 rect.p1.y = 173;1419 }1420 1421 ui_list_set_rect(demo.list, &rect);1422 1423 rc = ui_fixed_add(demo.lfixed, ui_list_ctl(demo.list));1424 if (rc != EOK) {1425 printf("Error adding control to layout.\n");1426 return rc;1427 }1428 1429 ui_tab_add(demo.tlists, ui_fixed_ctl(demo.lfixed));1430 962 1431 963 ui_window_add(window, ui_fixed_ctl(demo.fixed)); … … 1487 1019 int main(int argc, char *argv[]) 1488 1020 { 1489 const char *display_spec = UI_ ANY_DEFAULT;1021 const char *display_spec = UI_DISPLAY_DEFAULT; 1490 1022 errno_t rc; 1491 1023 int i;
Note:
See TracChangeset
for help on using the changeset viewer.