Changes in uspace/app/uidemo/uidemo.c [80d4aea:9a07ee3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r80d4aea r9a07ee3 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 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> 47 #include <ui/menu.h> 46 48 #include <ui/menubar.h> 49 #include <ui/menudd.h> 47 50 #include <ui/menuentry.h> 48 #include <ui/menu.h>49 51 #include <ui/msgdialog.h> 50 52 #include <ui/pbutton.h> 51 53 #include <ui/promptdialog.h> 52 54 #include <ui/resource.h> 55 #include <ui/selectdialog.h> 56 #include <ui/tab.h> 57 #include <ui/tabset.h> 53 58 #include <ui/ui.h> 54 59 #include <ui/window.h> … … 87 92 }; 88 93 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_moved 106 }; 107 89 108 static void uidemo_file_load(ui_menu_entry_t *, void *); 90 109 static void uidemo_file_message(ui_menu_entry_t *, void *); 110 static void uidemo_file_confirmation(ui_menu_entry_t *, void *); 91 111 static void uidemo_file_exit(ui_menu_entry_t *, void *); 92 112 static void uidemo_edit_modify(ui_menu_entry_t *, void *); 113 static void uidemo_edit_insert_character(ui_menu_entry_t *, void *); 93 114 94 115 static void file_dialog_bok(ui_file_dialog_t *, void *, const char *); … … 110 131 .bcancel = prompt_dialog_bcancel, 111 132 .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_close 112 143 }; 113 144 … … 215 246 } 216 247 217 /** Display a message window. 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. 218 344 * 219 345 * @param demo UI demo … … 290 416 } 291 417 418 /** File / Confirmation menu entry selected. 419 * 420 * @param mentry Menu entry 421 * @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 292 444 /** File / Exit menu entry selected. 293 445 * … … 320 472 rc = ui_prompt_dialog_create(demo->ui, &pdparams, &dialog); 321 473 if (rc != EOK) { 322 printf("Error creating messagedialog.\n");474 printf("Error creating prompt dialog.\n"); 323 475 return; 324 476 } 325 477 326 478 ui_prompt_dialog_set_cb(dialog, &prompt_dialog_cb, demo); 479 } 480 481 /** Edit / Insert Character menu entry selected. 482 * 483 * @param mentry Menu entry 484 * @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); 327 534 } 328 535 … … 413 620 /** Prompt dialog cancel button press. 414 621 * 415 * @param dialog Filedialog622 * @param dialog Prompt dialog 416 623 * @param arg Argument (ui_demo_t *) 417 624 */ … … 426 633 /** Prompt dialog close request. 427 634 * 428 * @param dialog Filedialog635 * @param dialog Prompt dialog 429 636 * @param arg Argument (ui_demo_t *) 430 637 */ … … 435 642 (void) demo; 436 643 ui_prompt_dialog_destroy(dialog); 644 } 645 646 /** Select dialog OK button press. 647 * 648 * @param dialog Select dialog 649 * @param arg Argument (ui_demo_t *) 650 * @param text Submitted text 651 */ 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 dialog 667 * @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 dialog 680 * @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); 437 688 } 438 689 … … 486 737 ui_menu_entry_t *mexit; 487 738 ui_menu_entry_t *mmodify; 739 ui_menu_entry_t *minsert_char; 488 740 ui_menu_entry_t *mabout; 741 ui_list_entry_attr_t eattr; 489 742 errno_t rc; 490 743 … … 500 753 ui_wnd_params_init(¶ms); 501 754 params.caption = "UI Demo"; 502 params.style |= ui_wds_ resizable;755 params.style |= ui_wds_maximize_btn | ui_wds_resizable; 503 756 504 757 /* FIXME: Auto layout */ … … 506 759 params.rect.p0.x = 0; 507 760 params.rect.p0.y = 0; 508 params.rect.p1.x = 4 4;509 params.rect.p1.y = 2 1;761 params.rect.p1.x = 46; 762 params.rect.p1.y = 25; 510 763 } else { 511 764 params.rect.p0.x = 0; 512 765 params.rect.p0.y = 0; 513 params.rect.p1.x = 220; 514 params.rect.p1.y = 350; 515 } 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); 516 772 517 773 rc = ui_window_create(ui, ¶ms, &window); … … 539 795 } 540 796 541 rc = ui_menu_ create(demo.mbar, "File", &demo.mfile);797 rc = ui_menu_dd_create(demo.mbar, "~F~ile", NULL, &demo.mfile); 542 798 if (rc != EOK) { 543 799 printf("Error creating menu.\n"); … … 545 801 } 546 802 547 rc = ui_menu_entry_create(demo.mfile, " Message", "", &mmsg);803 rc = ui_menu_entry_create(demo.mfile, "~M~essage", "", &mmsg); 548 804 if (rc != EOK) { 549 805 printf("Error creating menu.\n"); … … 553 809 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo); 554 810 555 rc = ui_menu_entry_create(demo.mfile, " Load", "", &mload);811 rc = ui_menu_entry_create(demo.mfile, "~C~onfirmation", "", &mmsg); 556 812 if (rc != EOK) { 557 813 printf("Error creating menu.\n"); … … 559 815 } 560 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); 820 if (rc != EOK) { 821 printf("Error creating menu.\n"); 822 return rc; 823 } 824 561 825 ui_menu_entry_set_cb(mload, uidemo_file_load, (void *) &demo); 562 826 563 rc = ui_menu_entry_create(demo.mfile, " Foo", "Ctrl-Alt-Del", &mfoo);827 rc = ui_menu_entry_create(demo.mfile, "~F~oo", "Ctrl-Alt-Del", &mfoo); 564 828 if (rc != EOK) { 565 829 printf("Error creating menu.\n"); … … 567 831 } 568 832 569 rc = ui_menu_entry_create(demo.mfile, " Bar", "", &mbar);833 rc = ui_menu_entry_create(demo.mfile, "~B~ar", "", &mbar); 570 834 if (rc != EOK) { 571 835 printf("Error creating menu.\n"); … … 573 837 } 574 838 575 rc = ui_menu_entry_create(demo.mfile, "F oobar", "", &mfoobar);839 rc = ui_menu_entry_create(demo.mfile, "F~o~obar", "", &mfoobar); 576 840 if (rc != EOK) { 577 841 printf("Error creating menu.\n"); … … 579 843 } 580 844 845 ui_menu_entry_set_disabled(mfoobar, true); 846 581 847 rc = ui_menu_entry_sep_create(demo.mfile, &msep); 582 848 if (rc != EOK) { … … 585 851 } 586 852 587 rc = ui_menu_entry_create(demo.mfile, "E xit", "Alt-F4", &mexit);853 rc = ui_menu_entry_create(demo.mfile, "E~x~it", "Alt-F4", &mexit); 588 854 if (rc != EOK) { 589 855 printf("Error creating menu.\n"); … … 593 859 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo); 594 860 595 rc = ui_menu_ create(demo.mbar, "Edit", &demo.medit);861 rc = ui_menu_dd_create(demo.mbar, "~E~dit", NULL, &demo.medit); 596 862 if (rc != EOK) { 597 863 printf("Error creating menu.\n"); … … 599 865 } 600 866 601 rc = ui_menu_entry_create(demo.medit, " Modify", "", &mmodify);867 rc = ui_menu_entry_create(demo.medit, "~M~odify", "", &mmodify); 602 868 if (rc != EOK) { 603 869 printf("Error creating menu.\n"); … … 607 873 ui_menu_entry_set_cb(mmodify, uidemo_edit_modify, (void *) &demo); 608 874 609 rc = ui_menu_create(demo.mbar, "Preferences", &demo.mpreferences); 875 rc = ui_menu_entry_create(demo.medit, "~I~nsert Character", 876 "", &minsert_char); 610 877 if (rc != EOK) { 611 878 printf("Error creating menu.\n"); … … 613 880 } 614 881 615 rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp); 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); 616 887 if (rc != EOK) { 617 888 printf("Error creating menu.\n"); … … 619 890 } 620 891 621 rc = ui_menu_entry_create(demo.mhelp, "About", "Ctrl-H, F1", &mabout); 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); 622 899 if (rc != EOK) { 623 900 printf("Error creating menu.\n"); … … 634 911 rect.p0.x = 4; 635 912 rect.p0.y = 30; 636 rect.p1.x = 2 16;913 rect.p1.x = 251; 637 914 rect.p1.y = 52; 638 915 } 916 639 917 ui_menu_bar_set_rect(demo.mbar, &rect); 640 918 … … 645 923 } 646 924 925 rc = ui_tab_set_create(ui_res, &demo.tabset); 926 if (rc != EOK) { 927 printf("Error creating tab set.\n"); 928 return rc; 929 } 930 931 /* FIXME: Auto layout */ 932 if (ui_is_textmode(ui)) { 933 rect.p0.x = 2; 934 rect.p0.y = 2; 935 rect.p1.x = 44; 936 rect.p1.y = 24; 937 } else { 938 rect.p0.x = 8; 939 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 647 970 rc = ui_entry_create(window, "", &demo.entry); 648 971 if (rc != EOK) { … … 653 976 /* FIXME: Auto layout */ 654 977 if (ui_is_textmode(ui)) { 655 rect.p0.x = 2;656 rect.p0.y = 3;657 rect.p1.x = 4 2;658 rect.p1.y = 4;978 rect.p0.x = 4; 979 rect.p0.y = 5; 980 rect.p1.x = 41; 981 rect.p1.y = 6; 659 982 } else { 660 983 rect.p0.x = 15; 661 rect.p0.y = 53;984 rect.p0.y = 88; 662 985 rect.p1.x = 205; 663 rect.p1.y = 78;986 rect.p1.y = 113; 664 987 } 665 988 … … 667 990 ui_entry_set_halign(demo.entry, gfx_halign_center); 668 991 669 rc = ui_fixed_add(demo. fixed, ui_entry_ctl(demo.entry));992 rc = ui_fixed_add(demo.bfixed, ui_entry_ctl(demo.entry)); 670 993 if (rc != EOK) { 671 994 printf("Error adding control to layout.\n"); … … 681 1004 /* FIXME: Auto layout */ 682 1005 if (ui_is_textmode(ui)) { 683 rect.p0.x = 2;684 rect.p0.y = 5;685 rect.p1.x = 4 2;686 rect.p1.y = 6;1006 rect.p0.x = 4; 1007 rect.p0.y = 7; 1008 rect.p1.x = 41; 1009 rect.p1.y = 8; 687 1010 } else { 688 1011 rect.p0.x = 60; 689 rect.p0.y = 88;1012 rect.p0.y = 123; 690 1013 rect.p1.x = 160; 691 rect.p1.y = 1 01;1014 rect.p1.y = 136; 692 1015 } 693 1016 … … 695 1018 ui_label_set_halign(demo.label, gfx_halign_center); 696 1019 697 rc = ui_fixed_add(demo. fixed, ui_label_ctl(demo.label));1020 rc = ui_fixed_add(demo.bfixed, ui_label_ctl(demo.label)); 698 1021 if (rc != EOK) { 699 1022 printf("Error adding control to layout.\n"); … … 711 1034 /* FIXME: Auto layout */ 712 1035 if (ui_is_textmode(ui)) { 713 rect.p0.x = 2;714 rect.p0.y = 7;715 rect.p1.x = 1 2;716 rect.p1.y = 8;1036 rect.p0.x = 4; 1037 rect.p0.y = 9; 1038 rect.p1.x = 15; 1039 rect.p1.y = 10; 717 1040 } else { 718 1041 rect.p0.x = 15; 719 rect.p0.y = 1 11;1042 rect.p0.y = 146; 720 1043 rect.p1.x = 105; 721 rect.p1.y = 1 39;1044 rect.p1.y = 174; 722 1045 } 723 1046 … … 726 1049 ui_pbutton_set_default(demo.pb1, true); 727 1050 728 rc = ui_fixed_add(demo. fixed, ui_pbutton_ctl(demo.pb1));1051 rc = ui_fixed_add(demo.bfixed, ui_pbutton_ctl(demo.pb1)); 729 1052 if (rc != EOK) { 730 1053 printf("Error adding control to layout.\n"); … … 741 1064 742 1065 if (ui_is_textmode(ui)) { 743 rect.p0.x = 3 2;744 rect.p0.y = 7;745 rect.p1.x = 4 2;746 rect.p1.y = 8;1066 rect.p0.x = 30; 1067 rect.p0.y = 9; 1068 rect.p1.x = 41; 1069 rect.p1.y = 10; 747 1070 } else { 748 1071 rect.p0.x = 115; 749 rect.p0.y = 1 11;1072 rect.p0.y = 146; 750 1073 rect.p1.x = 205; 751 rect.p1.y = 1 39;1074 rect.p1.y = 174; 752 1075 } 753 1076 754 1077 ui_pbutton_set_rect(demo.pb2, &rect); 755 1078 756 rc = ui_fixed_add(demo. fixed, ui_pbutton_ctl(demo.pb2));1079 rc = ui_fixed_add(demo.bfixed, ui_pbutton_ctl(demo.pb2)); 757 1080 if (rc != EOK) { 758 1081 printf("Error adding control to layout.\n"); … … 764 1087 bparams.rect.p0.x = 0; 765 1088 bparams.rect.p0.y = 0; 766 bparams.rect.p1.x = 40;1089 bparams.rect.p1.x = 37; 767 1090 bparams.rect.p1.y = 2; 768 1091 } else { … … 788 1111 789 1112 if (ui_is_textmode(ui)) { 790 off.x = 2;791 off.y = 9;1113 off.x = 4; 1114 off.y = 11; 792 1115 } else { 793 1116 off.x = 15; 794 off.y = 1 55;1117 off.y = 190; 795 1118 } 796 1119 … … 806 1129 ui_image_set_rect(demo.image, &rect); 807 1130 808 rc = ui_fixed_add(demo. fixed, ui_image_ctl(demo.image));1131 rc = ui_fixed_add(demo.bfixed, ui_image_ctl(demo.image)); 809 1132 if (rc != EOK) { 810 1133 printf("Error adding control to layout.\n"); … … 822 1145 /* FIXME: Auto layout */ 823 1146 if (ui_is_textmode(ui)) { 824 rect.p0.x = 2;825 rect.p0.y = 1 2;826 rect.p1.x = 1 2;827 rect.p1.y = 1 3;1147 rect.p0.x = 4; 1148 rect.p0.y = 14; 1149 rect.p1.x = 14; 1150 rect.p1.y = 15; 828 1151 } else { 829 1152 rect.p0.x = 15; 830 rect.p0.y = 190;1153 rect.p0.y = 225; 831 1154 rect.p1.x = 140; 832 rect.p1.y = 2 10;1155 rect.p1.y = 245; 833 1156 } 834 1157 835 1158 ui_checkbox_set_rect(demo.checkbox, &rect); 836 1159 837 rc = ui_fixed_add(demo. fixed, ui_checkbox_ctl(demo.checkbox));1160 rc = ui_fixed_add(demo.bfixed, ui_checkbox_ctl(demo.checkbox)); 838 1161 if (rc != EOK) { 839 1162 printf("Error adding control to layout.\n"); … … 859 1182 /* FIXME: Auto layout */ 860 1183 if (ui_is_textmode(ui)) { 861 rect.p0.x = 2;862 rect.p0.y = 1 4;863 rect.p1.x = 1 2;864 rect.p1.y = 1 5;1184 rect.p0.x = 4; 1185 rect.p0.y = 16; 1186 rect.p1.x = 14; 1187 rect.p1.y = 17; 865 1188 } else { 866 1189 rect.p0.x = 15; 867 rect.p0.y = 2 20;1190 rect.p0.y = 255; 868 1191 rect.p1.x = 140; 869 rect.p1.y = 2 40;1192 rect.p1.y = 275; 870 1193 } 871 1194 ui_rbutton_set_rect(demo.rbleft, &rect); 872 1195 873 rc = ui_fixed_add(demo. fixed, ui_rbutton_ctl(demo.rbleft));1196 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbleft)); 874 1197 if (rc != EOK) { 875 1198 printf("Error adding control to layout.\n"); … … 886 1209 /* FIXME: Auto layout */ 887 1210 if (ui_is_textmode(ui)) { 888 rect.p0.x = 2;889 rect.p0.y = 1 5;890 rect.p1.x = 1 2;891 rect.p1.y = 1 6;1211 rect.p0.x = 4; 1212 rect.p0.y = 17; 1213 rect.p1.x = 14; 1214 rect.p1.y = 18; 892 1215 } else { 893 1216 rect.p0.x = 15; 894 rect.p0.y = 2 50;1217 rect.p0.y = 285; 895 1218 rect.p1.x = 140; 896 rect.p1.y = 270;1219 rect.p1.y = 305; 897 1220 } 898 1221 ui_rbutton_set_rect(demo.rbcenter, &rect); 899 1222 ui_rbutton_select(demo.rbcenter); 900 1223 901 rc = ui_fixed_add(demo. fixed, ui_rbutton_ctl(demo.rbcenter));1224 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbcenter)); 902 1225 if (rc != EOK) { 903 1226 printf("Error adding control to layout.\n"); … … 914 1237 /* FIXME: Auto layout */ 915 1238 if (ui_is_textmode(ui)) { 916 rect.p0.x = 2;917 rect.p0.y = 1 6;918 rect.p1.x = 1 2;919 rect.p1.y = 1 7;1239 rect.p0.x = 4; 1240 rect.p0.y = 18; 1241 rect.p1.x = 14; 1242 rect.p1.y = 19; 920 1243 } else { 921 1244 rect.p0.x = 15; 922 rect.p0.y = 280;1245 rect.p0.y = 315; 923 1246 rect.p1.x = 140; 924 rect.p1.y = 3 00;1247 rect.p1.y = 335; 925 1248 } 926 1249 ui_rbutton_set_rect(demo.rbright, &rect); 927 1250 928 rc = ui_fixed_add(demo. fixed, ui_rbutton_ctl(demo.rbright));1251 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbright)); 929 1252 if (rc != EOK) { 930 1253 printf("Error adding control to layout.\n"); … … 932 1255 } 933 1256 934 rc = ui_slider_create(ui_res, "Slide!",&demo.slider);1257 rc = ui_slider_create(ui_res, &demo.slider); 935 1258 if (rc != EOK) { 936 1259 printf("Error creating button.\n"); … … 942 1265 /* FIXME: Auto layout */ 943 1266 if (ui_is_textmode(ui)) { 944 rect.p0.x = 2;945 rect.p0.y = 18;946 rect.p1.x = 12;947 rect.p1.y = 19;1267 rect.p0.x = 4; 1268 rect.p0.y = 20; 1269 rect.p1.x = 32; 1270 rect.p1.y = 21; 948 1271 } else { 949 1272 rect.p0.x = 15; 950 rect.p0.y = 3 10;1273 rect.p0.y = 345; 951 1274 rect.p1.x = 130; 952 rect.p1.y = 3 30;1275 rect.p1.y = 365; 953 1276 } 954 1277 955 1278 ui_slider_set_rect(demo.slider, &rect); 956 1279 957 rc = ui_fixed_add(demo. fixed, ui_slider_ctl(demo.slider));1280 rc = ui_fixed_add(demo.bfixed, ui_slider_ctl(demo.slider)); 958 1281 if (rc != EOK) { 959 1282 printf("Error adding control to layout.\n"); 960 1283 return rc; 961 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)); 962 1430 963 1431 ui_window_add(window, ui_fixed_ctl(demo.fixed)); … … 1019 1487 int main(int argc, char *argv[]) 1020 1488 { 1021 const char *display_spec = UI_ DISPLAY_DEFAULT;1489 const char *display_spec = UI_ANY_DEFAULT; 1022 1490 errno_t rc; 1023 1491 int i;
Note:
See TracChangeset
for help on using the changeset viewer.