Changes in uspace/app/uidemo/uidemo.c [a977e37:08499f0] in mainline
- File:
-
- 1 edited
-
uspace/app/uidemo/uidemo.c (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
ra977e37 r08499f0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 33 33 */ 34 34 35 #include <fibril_synch.h> 35 36 #include <gfx/bitmap.h> 36 37 #include <gfx/coord.h> … … 40 41 #include <str.h> 41 42 #include <ui/entry.h> 43 #include <ui/filedialog.h> 42 44 #include <ui/fixed.h> 43 45 #include <ui/image.h> 44 46 #include <ui/label.h> 47 #include <ui/list.h> 48 #include <ui/menu.h> 45 49 #include <ui/menubar.h> 50 #include <ui/menudd.h> 46 51 #include <ui/menuentry.h> 47 #include <ui/menu.h>48 52 #include <ui/msgdialog.h> 49 53 #include <ui/pbutton.h> 54 #include <ui/promptdialog.h> 50 55 #include <ui/resource.h> 56 #include <ui/selectdialog.h> 57 #include <ui/tab.h> 58 #include <ui/tabset.h> 51 59 #include <ui/ui.h> 52 60 #include <ui/window.h> 53 61 #include "uidemo.h" 54 62 63 enum { 64 scrollbar_update_interval_ms = 1000, 65 ui_demo_progress_step = 17 66 }; 67 55 68 static errno_t bitmap_moire(gfx_bitmap_t *, gfx_coord_t, gfx_coord_t); 56 69 … … 85 98 }; 86 99 100 static void scrollbar_up(ui_scrollbar_t *, void *); 101 static void scrollbar_down(ui_scrollbar_t *, void *); 102 static void scrollbar_page_up(ui_scrollbar_t *, void *); 103 static void scrollbar_page_down(ui_scrollbar_t *, void *); 104 static void scrollbar_moved(ui_scrollbar_t *, void *, gfx_coord_t); 105 106 static ui_scrollbar_cb_t scrollbar_cb = { 107 .up = scrollbar_up, 108 .down = scrollbar_down, 109 .page_up = scrollbar_page_up, 110 .page_down = scrollbar_page_down, 111 .moved = scrollbar_moved 112 }; 113 114 static void uidemo_file_load(ui_menu_entry_t *, void *); 87 115 static void uidemo_file_message(ui_menu_entry_t *, void *); 116 static void uidemo_file_confirmation(ui_menu_entry_t *, void *); 88 117 static void uidemo_file_exit(ui_menu_entry_t *, void *); 118 static void uidemo_edit_modify(ui_menu_entry_t *, void *); 119 static void uidemo_edit_insert_character(ui_menu_entry_t *, void *); 120 121 static void file_dialog_bok(ui_file_dialog_t *, void *, const char *); 122 static void file_dialog_bcancel(ui_file_dialog_t *, void *); 123 static void file_dialog_close(ui_file_dialog_t *, void *); 124 125 static ui_file_dialog_cb_t file_dialog_cb = { 126 .bok = file_dialog_bok, 127 .bcancel = file_dialog_bcancel, 128 .close = file_dialog_close 129 }; 130 131 static void prompt_dialog_bok(ui_prompt_dialog_t *, void *, const char *); 132 static void prompt_dialog_bcancel(ui_prompt_dialog_t *, void *); 133 static void prompt_dialog_close(ui_prompt_dialog_t *, void *); 134 135 static ui_prompt_dialog_cb_t prompt_dialog_cb = { 136 .bok = prompt_dialog_bok, 137 .bcancel = prompt_dialog_bcancel, 138 .close = prompt_dialog_close 139 }; 140 141 static void select_dialog_bok(ui_select_dialog_t *, void *, void *); 142 static void select_dialog_bcancel(ui_select_dialog_t *, void *); 143 static void select_dialog_close(ui_select_dialog_t *, void *); 144 145 static ui_select_dialog_cb_t select_dialog_cb = { 146 .bok = select_dialog_bok, 147 .bcancel = select_dialog_bcancel, 148 .close = select_dialog_close 149 }; 89 150 90 151 static void msg_dialog_button(ui_msg_dialog_t *, void *, unsigned); … … 96 157 }; 97 158 159 /** Horizontal alignment selected by each radio button */ 160 static const gfx_halign_t uidemo_halign[3] = { 161 gfx_halign_left, 162 gfx_halign_center, 163 gfx_halign_right 164 }; 165 98 166 /** Window close button was clicked. 99 167 * … … 122 190 if (rc != EOK) 123 191 printf("Error changing entry text.\n"); 124 (void) ui_entry_paint(demo->entry);125 192 } else { 126 193 rc = ui_entry_set_text(demo->entry, "Cancel pressed"); 127 194 if (rc != EOK) 128 195 printf("Error changing entry text.\n"); 129 (void) ui_entry_paint(demo->entry);130 196 } 131 197 } … … 139 205 { 140 206 ui_demo_t *demo = (ui_demo_t *) arg; 141 errno_t rc; 142 143 if (enable) { 144 rc = ui_entry_set_text(demo->entry, "Checked"); 145 if (rc != EOK) 146 printf("Error changing entry text.\n"); 147 (void) ui_entry_paint(demo->entry); 148 } else { 149 rc = ui_entry_set_text(demo->entry, "Unchecked"); 150 if (rc != EOK) 151 printf("Error changing entry text.\n"); 152 (void) ui_entry_paint(demo->entry); 153 } 207 208 ui_entry_set_read_only(demo->entry, enable); 154 209 } 155 210 … … 163 218 { 164 219 ui_demo_t *demo = (ui_demo_t *) garg; 165 const char *text = (const char *) barg; 166 errno_t rc; 167 168 rc = ui_entry_set_text(demo->entry, text); 169 if (rc != EOK) 170 printf("Error changing entry text.\n"); 220 gfx_halign_t halign = *(gfx_halign_t *) barg; 221 222 ui_entry_set_halign(demo->entry, halign); 171 223 (void) ui_entry_paint(demo->entry); 172 224 } … … 200 252 } 201 253 202 /** File/message menu entry selected.203 * 204 * @param mentry Menu entry254 /** Scrollbar up button pressed. 255 * 256 * @param scrollbar Scrollbar 205 257 * @param arg Argument (demo) 206 258 */ 207 static void uidemo_file_message(ui_menu_entry_t *mentry, void *arg) 208 { 209 ui_demo_t *demo = (ui_demo_t *) arg; 259 static void scrollbar_up(ui_scrollbar_t *scrollbar, void *arg) 260 { 261 gfx_coord_t pos; 262 263 pos = ui_scrollbar_get_pos(scrollbar); 264 ui_scrollbar_set_pos(scrollbar, pos - 1); 265 266 pos = ui_scrollbar_get_pos(scrollbar); 267 scrollbar_moved(scrollbar, arg, pos); 268 } 269 270 /** Scrollbar down button pressed. 271 * 272 * @param scrollbar Scrollbar 273 * @param arg Argument (demo) 274 */ 275 static void scrollbar_down(ui_scrollbar_t *scrollbar, void *arg) 276 { 277 gfx_coord_t pos; 278 279 pos = ui_scrollbar_get_pos(scrollbar); 280 ui_scrollbar_set_pos(scrollbar, pos + 1); 281 282 pos = ui_scrollbar_get_pos(scrollbar); 283 scrollbar_moved(scrollbar, arg, pos); 284 } 285 286 /** Scrollbar page up event. 287 * 288 * @param scrollbar Scrollbar 289 * @param arg Argument (demo) 290 */ 291 static void scrollbar_page_up(ui_scrollbar_t *scrollbar, void *arg) 292 { 293 gfx_coord_t pos; 294 295 pos = ui_scrollbar_get_pos(scrollbar); 296 ui_scrollbar_set_pos(scrollbar, pos - 297 ui_scrollbar_trough_length(scrollbar) / 4); 298 299 pos = ui_scrollbar_get_pos(scrollbar); 300 scrollbar_moved(scrollbar, arg, pos); 301 } 302 303 /** Scrollbar page down event. 304 * 305 * @param scrollbar Scrollbar 306 * @param arg Argument (demo) 307 */ 308 static void scrollbar_page_down(ui_scrollbar_t *scrollbar, void *arg) 309 { 310 gfx_coord_t pos; 311 312 pos = ui_scrollbar_get_pos(scrollbar); 313 ui_scrollbar_set_pos(scrollbar, pos + 314 ui_scrollbar_trough_length(scrollbar) / 4); 315 316 pos = ui_scrollbar_get_pos(scrollbar); 317 scrollbar_moved(scrollbar, arg, pos); 318 } 319 320 /** Scrollbar was moved. 321 * 322 * @param scrollbar Scrollbar 323 * @param arg Argument (demo) 324 * @param pos Position 325 */ 326 static void scrollbar_moved(ui_scrollbar_t *scrollbar, void *arg, 327 gfx_coord_t pos) 328 { 329 ui_demo_t *demo = (ui_demo_t *) arg; 330 char *str; 331 errno_t rc; 332 int rv; 333 334 rv = asprintf(&str, "Scrollbar: %d of %d", (int) pos, 335 ui_scrollbar_move_length(scrollbar)); 336 if (rv < 0) { 337 printf("Out of memory.\n"); 338 return; 339 } 340 341 rc = ui_entry_set_text(demo->entry, str); 342 if (rc != EOK) 343 printf("Error changing entry text.\n"); 344 (void) ui_entry_paint(demo->entry); 345 346 free(str); 347 } 348 349 /** Display a message window with OK button. 350 * 351 * @param demo UI demo 352 * @param caption Window caption 353 * @param text Message text 354 */ 355 static void uidemo_show_message(ui_demo_t *demo, const char *caption, 356 const char *text) 357 { 210 358 ui_msg_dialog_params_t mdparams; 211 359 ui_msg_dialog_t *dialog; … … 213 361 214 362 ui_msg_dialog_params_init(&mdparams); 363 mdparams.caption = caption; 364 mdparams.text = text; 365 366 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog); 367 if (rc != EOK) { 368 printf("Error creating message dialog.\n"); 369 return; 370 } 371 372 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo); 373 } 374 375 /** File / Load menu entry selected. 376 * 377 * @param mentry Menu entry 378 * @param arg Argument (demo) 379 */ 380 static void uidemo_file_load(ui_menu_entry_t *mentry, void *arg) 381 { 382 ui_demo_t *demo = (ui_demo_t *) arg; 383 ui_file_dialog_params_t fdparams; 384 ui_file_dialog_t *dialog; 385 errno_t rc; 386 387 ui_file_dialog_params_init(&fdparams); 388 fdparams.caption = "Load File"; 389 390 rc = ui_file_dialog_create(demo->ui, &fdparams, &dialog); 391 if (rc != EOK) { 392 printf("Error creating message dialog.\n"); 393 return; 394 } 395 396 ui_file_dialog_set_cb(dialog, &file_dialog_cb, demo); 397 } 398 399 /** File / Message menu entry selected. 400 * 401 * @param mentry Menu entry 402 * @param arg Argument (demo) 403 */ 404 static void uidemo_file_message(ui_menu_entry_t *mentry, void *arg) 405 { 406 ui_demo_t *demo = (ui_demo_t *) arg; 407 ui_msg_dialog_params_t mdparams; 408 ui_msg_dialog_t *dialog; 409 errno_t rc; 410 411 ui_msg_dialog_params_init(&mdparams); 215 412 mdparams.caption = "Message For You"; 216 413 mdparams.text = "Hello, world!"; … … 223 420 224 421 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo); 225 226 } 227 228 /** File/exit menu entry selected. 422 } 423 424 /** File / Confirmation menu entry selected. 229 425 * 230 426 * @param mentry Menu entry 231 427 * @param arg Argument (demo) 232 428 */ 429 static void uidemo_file_confirmation(ui_menu_entry_t *mentry, void *arg) 430 { 431 ui_demo_t *demo = (ui_demo_t *) arg; 432 ui_msg_dialog_params_t mdparams; 433 ui_msg_dialog_t *dialog; 434 errno_t rc; 435 436 ui_msg_dialog_params_init(&mdparams); 437 mdparams.caption = "Confirmation"; 438 mdparams.text = "This will not actually do anything. Proceed?"; 439 mdparams.choice = umdc_ok_cancel; 440 441 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog); 442 if (rc != EOK) { 443 printf("Error creating message dialog.\n"); 444 return; 445 } 446 447 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo); 448 } 449 450 /** File / Exit menu entry selected. 451 * 452 * @param mentry Menu entry 453 * @param arg Argument (demo) 454 */ 233 455 static void uidemo_file_exit(ui_menu_entry_t *mentry, void *arg) 234 456 { … … 236 458 237 459 ui_quit(demo->ui); 460 } 461 462 /** Edit / Modify menu entry selected. 463 * 464 * @param mentry Menu entry 465 * @param arg Argument (demo) 466 */ 467 static void uidemo_edit_modify(ui_menu_entry_t *mentry, void *arg) 468 { 469 ui_demo_t *demo = (ui_demo_t *) arg; 470 ui_prompt_dialog_params_t pdparams; 471 ui_prompt_dialog_t *dialog; 472 errno_t rc; 473 474 ui_prompt_dialog_params_init(&pdparams); 475 pdparams.caption = "Modify Entry Text"; 476 pdparams.prompt = "Enter New Text"; 477 478 rc = ui_prompt_dialog_create(demo->ui, &pdparams, &dialog); 479 if (rc != EOK) { 480 printf("Error creating prompt dialog.\n"); 481 return; 482 } 483 484 ui_prompt_dialog_set_cb(dialog, &prompt_dialog_cb, demo); 485 } 486 487 /** Edit / Insert Character menu entry selected. 488 * 489 * @param mentry Menu entry 490 * @param arg Argument (demo) 491 */ 492 static void uidemo_edit_insert_character(ui_menu_entry_t *mentry, void *arg) 493 { 494 ui_demo_t *demo = (ui_demo_t *) arg; 495 ui_select_dialog_params_t sdparams; 496 ui_select_dialog_t *dialog; 497 ui_list_entry_attr_t attr; 498 errno_t rc; 499 500 ui_select_dialog_params_init(&sdparams); 501 sdparams.caption = "Insert Character"; 502 sdparams.prompt = "Select character to insert"; 503 504 rc = ui_select_dialog_create(demo->ui, &sdparams, &dialog); 505 if (rc != EOK) { 506 printf("Error creating select dialog.\n"); 507 return; 508 } 509 510 ui_list_entry_attr_init(&attr); 511 attr.caption = "Dollar sign ($)"; 512 attr.arg = (void *)'$'; 513 rc = ui_select_dialog_append(dialog, &attr); 514 if (rc != EOK) { 515 printf("Error appending entry to list.\n"); 516 return; 517 } 518 519 ui_list_entry_attr_init(&attr); 520 attr.caption = "Hash sign (#)"; 521 attr.arg = (void *)'#'; 522 rc = ui_select_dialog_append(dialog, &attr); 523 if (rc != EOK) { 524 printf("Error appending entry to list.\n"); 525 return; 526 } 527 528 ui_list_entry_attr_init(&attr); 529 attr.caption = "Question mark (?)"; 530 attr.arg = (void *)'?'; 531 rc = ui_select_dialog_append(dialog, &attr); 532 if (rc != EOK) { 533 printf("Error appending entry to list.\n"); 534 return; 535 } 536 537 ui_select_dialog_set_cb(dialog, &select_dialog_cb, demo); 538 539 (void) ui_select_dialog_paint(dialog); 540 } 541 542 /** File dialog OK button press. 543 * 544 * @param dialog File dialog 545 * @param arg Argument (ui_demo_t *) 546 * @param fname File name 547 */ 548 static void file_dialog_bok(ui_file_dialog_t *dialog, void *arg, 549 const char *fname) 550 { 551 ui_demo_t *demo = (ui_demo_t *) arg; 552 char buf[128]; 553 char *p; 554 FILE *f; 555 556 ui_file_dialog_destroy(dialog); 557 558 f = fopen(fname, "rt"); 559 if (f == NULL) { 560 uidemo_show_message(demo, "Error", "Error opening file."); 561 return; 562 } 563 564 p = fgets(buf, sizeof(buf), f); 565 if (p == NULL) { 566 uidemo_show_message(demo, "Error", "Error reading file."); 567 fclose(f); 568 return; 569 } 570 571 /* Cut string off at the first non-printable character */ 572 p = buf; 573 while (*p != '\0') { 574 if (*p < ' ') { 575 *p = '\0'; 576 break; 577 } 578 ++p; 579 } 580 581 ui_entry_set_text(demo->entry, buf); 582 fclose(f); 583 } 584 585 /** File dialog cancel button press. 586 * 587 * @param dialog File dialog 588 * @param arg Argument (ui_demo_t *) 589 */ 590 static void file_dialog_bcancel(ui_file_dialog_t *dialog, void *arg) 591 { 592 ui_demo_t *demo = (ui_demo_t *) arg; 593 594 (void) demo; 595 ui_file_dialog_destroy(dialog); 596 } 597 598 /** File dialog close request. 599 * 600 * @param dialog File dialog 601 * @param arg Argument (ui_demo_t *) 602 */ 603 static void file_dialog_close(ui_file_dialog_t *dialog, void *arg) 604 { 605 ui_demo_t *demo = (ui_demo_t *) arg; 606 607 (void) demo; 608 ui_file_dialog_destroy(dialog); 609 } 610 611 /** Prompt dialog OK button press. 612 * 613 * @param dialog Prompt dialog 614 * @param arg Argument (ui_demo_t *) 615 * @param text Submitted text 616 */ 617 static void prompt_dialog_bok(ui_prompt_dialog_t *dialog, void *arg, 618 const char *text) 619 { 620 ui_demo_t *demo = (ui_demo_t *) arg; 621 622 ui_prompt_dialog_destroy(dialog); 623 ui_entry_set_text(demo->entry, text); 624 } 625 626 /** Prompt dialog cancel button press. 627 * 628 * @param dialog Prompt dialog 629 * @param arg Argument (ui_demo_t *) 630 */ 631 static void prompt_dialog_bcancel(ui_prompt_dialog_t *dialog, void *arg) 632 { 633 ui_demo_t *demo = (ui_demo_t *) arg; 634 635 (void) demo; 636 ui_prompt_dialog_destroy(dialog); 637 } 638 639 /** Prompt dialog close request. 640 * 641 * @param dialog Prompt dialog 642 * @param arg Argument (ui_demo_t *) 643 */ 644 static void prompt_dialog_close(ui_prompt_dialog_t *dialog, void *arg) 645 { 646 ui_demo_t *demo = (ui_demo_t *) arg; 647 648 (void) demo; 649 ui_prompt_dialog_destroy(dialog); 650 } 651 652 /** Select dialog OK button press. 653 * 654 * @param dialog Select dialog 655 * @param arg Argument (ui_demo_t *) 656 * @param text Submitted text 657 */ 658 static void select_dialog_bok(ui_select_dialog_t *dialog, void *arg, 659 void *earg) 660 { 661 ui_demo_t *demo = (ui_demo_t *) arg; 662 char str[2]; 663 664 ui_select_dialog_destroy(dialog); 665 str[0] = (char)(intptr_t)earg; 666 str[1] = '\0'; 667 (void) ui_entry_insert_str(demo->entry, str); 668 } 669 670 /** Select dialog cancel button press. 671 * 672 * @param dialog Select dialog 673 * @param arg Argument (ui_demo_t *) 674 */ 675 static void select_dialog_bcancel(ui_select_dialog_t *dialog, void *arg) 676 { 677 ui_demo_t *demo = (ui_demo_t *) arg; 678 679 (void) demo; 680 ui_select_dialog_destroy(dialog); 681 } 682 683 /** Select dialog close request. 684 * 685 * @param dialog Select dialog 686 * @param arg Argument (ui_demo_t *) 687 */ 688 static void select_dialog_close(ui_select_dialog_t *dialog, void *arg) 689 { 690 ui_demo_t *demo = (ui_demo_t *) arg; 691 692 (void) demo; 693 ui_select_dialog_destroy(dialog); 238 694 } 239 695 … … 264 720 (void) demo; 265 721 ui_msg_dialog_destroy(dialog); 722 } 723 724 static void ui_demo_timer_fun(void *arg) 725 { 726 ui_demo_t *demo = (ui_demo_t *) arg; 727 728 if (demo->progress_value < 100) { 729 demo->progress_value += ui_demo_progress_step; 730 if (demo->progress_value > 100) 731 demo->progress_value = 100; 732 } else { 733 demo->progress_value = 0; 734 } 735 736 ui_progress_set_value(demo->progress, demo->progress_value); 737 738 if (ui_tab_is_selected(demo->tbars)) { 739 ui_lock(demo->ui); 740 ui_progress_paint(demo->progress); 741 ui_unlock(demo->ui); 742 } 743 744 fibril_timer_set(demo->timer, 1000 * scrollbar_update_interval_ms, 745 ui_demo_timer_fun, (void *)demo); 266 746 } 267 747 … … 280 760 gfx_coord2_t off; 281 761 ui_menu_entry_t *mmsg; 762 ui_menu_entry_t *mload; 282 763 ui_menu_entry_t *mfoo; 283 764 ui_menu_entry_t *mbar; 284 765 ui_menu_entry_t *mfoobar; 766 ui_menu_entry_t *msep; 285 767 ui_menu_entry_t *mexit; 768 ui_menu_entry_t *mmodify; 769 ui_menu_entry_t *minsert_char; 286 770 ui_menu_entry_t *mabout; 771 ui_list_entry_attr_t eattr; 287 772 errno_t rc; 288 773 … … 298 783 ui_wnd_params_init(¶ms); 299 784 params.caption = "UI Demo"; 300 params.style |= ui_wds_ resizable;785 params.style |= ui_wds_maximize_btn | ui_wds_resizable; 301 786 302 787 /* FIXME: Auto layout */ … … 304 789 params.rect.p0.x = 0; 305 790 params.rect.p0.y = 0; 306 params.rect.p1.x = 80;791 params.rect.p1.x = 46; 307 792 params.rect.p1.y = 25; 308 793 } else { 309 794 params.rect.p0.x = 0; 310 795 params.rect.p0.y = 0; 311 params.rect.p1.x = 220; 312 params.rect.p1.y = 350; 313 } 796 params.rect.p1.x = 255; 797 params.rect.p1.y = 410; 798 } 799 800 /* Only allow making the window larger */ 801 gfx_rect_dims(¶ms.rect, ¶ms.min_size); 314 802 315 803 rc = ui_window_create(ui, ¶ms, &window); … … 337 825 } 338 826 339 rc = ui_menu_ create(demo.mbar, "File", &demo.mfile);827 rc = ui_menu_dd_create(demo.mbar, "~F~ile", NULL, &demo.mfile); 340 828 if (rc != EOK) { 341 829 printf("Error creating menu.\n"); … … 343 831 } 344 832 345 rc = ui_menu_entry_create(demo.mfile, " Message", "", &mmsg);833 rc = ui_menu_entry_create(demo.mfile, "~M~essage", "", &mmsg); 346 834 if (rc != EOK) { 347 835 printf("Error creating menu.\n"); … … 351 839 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo); 352 840 353 rc = ui_menu_entry_create(demo.mfile, " Foo", "Ctrl-Alt-Del", &mfoo);841 rc = ui_menu_entry_create(demo.mfile, "~C~onfirmation", "", &mmsg); 354 842 if (rc != EOK) { 355 843 printf("Error creating menu.\n"); … … 357 845 } 358 846 359 rc = ui_menu_entry_create(demo.mfile, "Bar", "", &mbar); 847 ui_menu_entry_set_cb(mmsg, uidemo_file_confirmation, (void *) &demo); 848 849 rc = ui_menu_entry_create(demo.mfile, "~L~oad", "", &mload); 360 850 if (rc != EOK) { 361 851 printf("Error creating menu.\n"); … … 363 853 } 364 854 365 rc = ui_menu_entry_create(demo.mfile, "Foobar", "", &mfoobar); 855 ui_menu_entry_set_cb(mload, uidemo_file_load, (void *) &demo); 856 857 rc = ui_menu_entry_create(demo.mfile, "~F~oo", "Ctrl-Alt-Del", &mfoo); 366 858 if (rc != EOK) { 367 859 printf("Error creating menu.\n"); … … 369 861 } 370 862 371 rc = ui_menu_entry_ sep_create(demo.mfile, &mexit);863 rc = ui_menu_entry_create(demo.mfile, "~B~ar", "", &mbar); 372 864 if (rc != EOK) { 373 865 printf("Error creating menu.\n"); … … 375 867 } 376 868 377 rc = ui_menu_entry_create(demo.mfile, " Exit", "Alt-F4", &mexit);869 rc = ui_menu_entry_create(demo.mfile, "F~o~obar", "", &mfoobar); 378 870 if (rc != EOK) { 379 871 printf("Error creating menu.\n"); … … 381 873 } 382 874 875 ui_menu_entry_set_disabled(mfoobar, true); 876 877 rc = ui_menu_entry_sep_create(demo.mfile, &msep); 878 if (rc != EOK) { 879 printf("Error creating menu.\n"); 880 return rc; 881 } 882 883 rc = ui_menu_entry_create(demo.mfile, "E~x~it", "Alt-F4", &mexit); 884 if (rc != EOK) { 885 printf("Error creating menu.\n"); 886 return rc; 887 } 888 383 889 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo); 384 890 385 rc = ui_menu_ create(demo.mbar, "Edit", &demo.medit);891 rc = ui_menu_dd_create(demo.mbar, "~E~dit", NULL, &demo.medit); 386 892 if (rc != EOK) { 387 893 printf("Error creating menu.\n"); … … 389 895 } 390 896 391 rc = ui_menu_ create(demo.mbar, "Preferences", &demo.mpreferences);897 rc = ui_menu_entry_create(demo.medit, "~M~odify", "", &mmodify); 392 898 if (rc != EOK) { 393 899 printf("Error creating menu.\n"); … … 395 901 } 396 902 397 rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp); 903 ui_menu_entry_set_cb(mmodify, uidemo_edit_modify, (void *) &demo); 904 905 rc = ui_menu_entry_create(demo.medit, "~I~nsert Character", 906 "", &minsert_char); 398 907 if (rc != EOK) { 399 908 printf("Error creating menu.\n"); … … 401 910 } 402 911 403 rc = ui_menu_entry_create(demo.mhelp, "About", "Ctrl-H, F1", &mabout); 912 ui_menu_entry_set_cb(minsert_char, uidemo_edit_insert_character, 913 (void *) &demo); 914 915 rc = ui_menu_dd_create(demo.mbar, "~P~references", NULL, 916 &demo.mpreferences); 404 917 if (rc != EOK) { 405 918 printf("Error creating menu.\n"); … … 407 920 } 408 921 922 rc = ui_menu_dd_create(demo.mbar, "~H~elp", NULL, &demo.mhelp); 923 if (rc != EOK) { 924 printf("Error creating menu.\n"); 925 return rc; 926 } 927 928 rc = ui_menu_entry_create(demo.mhelp, "~A~bout", "Ctrl-H, F1", &mabout); 929 if (rc != EOK) { 930 printf("Error creating menu.\n"); 931 return rc; 932 } 933 409 934 /* FIXME: Auto layout */ 410 935 if (ui_is_textmode(ui)) { 411 936 rect.p0.x = 1; 412 rect.p0.y = 2;413 rect.p1.x = 79;414 rect.p1.y = 3;937 rect.p0.y = 1; 938 rect.p1.x = 43; 939 rect.p1.y = 2; 415 940 } else { 416 941 rect.p0.x = 4; 417 942 rect.p0.y = 30; 418 rect.p1.x = 2 16;943 rect.p1.x = 251; 419 944 rect.p1.y = 52; 420 945 } 946 421 947 ui_menu_bar_set_rect(demo.mbar, &rect); 422 948 … … 427 953 } 428 954 955 rc = ui_tab_set_create(ui_res, &demo.tabset); 956 if (rc != EOK) { 957 printf("Error creating tab set.\n"); 958 return rc; 959 } 960 961 /* FIXME: Auto layout */ 962 if (ui_is_textmode(ui)) { 963 rect.p0.x = 2; 964 rect.p0.y = 2; 965 rect.p1.x = 44; 966 rect.p1.y = 24; 967 } else { 968 rect.p0.x = 8; 969 rect.p0.y = 53; 970 rect.p1.x = 250; 971 rect.p1.y = 405; 972 } 973 974 ui_tab_set_set_rect(demo.tabset, &rect); 975 976 rc = ui_tab_create(demo.tabset, "Basic", &demo.tbasic); 977 if (rc != EOK) { 978 printf("Error creating tab.\n"); 979 return rc; 980 } 981 982 rc = ui_tab_create(demo.tabset, "Lists", &demo.tlists); 983 if (rc != EOK) { 984 printf("Error creating tab.\n"); 985 return rc; 986 } 987 988 rc = ui_tab_create(demo.tabset, "Bars", &demo.tbars); 989 if (rc != EOK) { 990 printf("Error creating tab.\n"); 991 return rc; 992 } 993 994 rc = ui_fixed_add(demo.fixed, ui_tab_set_ctl(demo.tabset)); 995 if (rc != EOK) { 996 printf("Error adding control to layout.\n"); 997 return rc; 998 } 999 1000 rc = ui_fixed_create(&demo.bfixed); 1001 if (rc != EOK) { 1002 printf("Error creating fixed layout.\n"); 1003 return rc; 1004 } 1005 429 1006 rc = ui_entry_create(window, "", &demo.entry); 430 1007 if (rc != EOK) { … … 435 1012 /* FIXME: Auto layout */ 436 1013 if (ui_is_textmode(ui)) { 437 rect.p0.x = 20;438 rect.p0.y = 4;439 rect.p1.x = 60;440 rect.p1.y = 5;1014 rect.p0.x = 4; 1015 rect.p0.y = 5; 1016 rect.p1.x = 41; 1017 rect.p1.y = 6; 441 1018 } else { 442 1019 rect.p0.x = 15; 443 rect.p0.y = 53;1020 rect.p0.y = 88; 444 1021 rect.p1.x = 205; 445 rect.p1.y = 78;1022 rect.p1.y = 113; 446 1023 } 447 1024 … … 449 1026 ui_entry_set_halign(demo.entry, gfx_halign_center); 450 1027 451 rc = ui_fixed_add(demo. fixed, ui_entry_ctl(demo.entry));1028 rc = ui_fixed_add(demo.bfixed, ui_entry_ctl(demo.entry)); 452 1029 if (rc != EOK) { 453 1030 printf("Error adding control to layout.\n"); … … 463 1040 /* FIXME: Auto layout */ 464 1041 if (ui_is_textmode(ui)) { 465 rect.p0.x = 20;466 rect.p0.y = 6;467 rect.p1.x = 60;468 rect.p1.y = 7;1042 rect.p0.x = 4; 1043 rect.p0.y = 7; 1044 rect.p1.x = 41; 1045 rect.p1.y = 8; 469 1046 } else { 470 1047 rect.p0.x = 60; 471 rect.p0.y = 88;1048 rect.p0.y = 123; 472 1049 rect.p1.x = 160; 473 rect.p1.y = 1 01;1050 rect.p1.y = 136; 474 1051 } 475 1052 … … 477 1054 ui_label_set_halign(demo.label, gfx_halign_center); 478 1055 479 rc = ui_fixed_add(demo. fixed, ui_label_ctl(demo.label));1056 rc = ui_fixed_add(demo.bfixed, ui_label_ctl(demo.label)); 480 1057 if (rc != EOK) { 481 1058 printf("Error adding control to layout.\n"); … … 493 1070 /* FIXME: Auto layout */ 494 1071 if (ui_is_textmode(ui)) { 495 rect.p0.x = 20;496 rect.p0.y = 8;497 rect.p1.x = 30;498 rect.p1.y = 9;1072 rect.p0.x = 4; 1073 rect.p0.y = 9; 1074 rect.p1.x = 15; 1075 rect.p1.y = 10; 499 1076 } else { 500 1077 rect.p0.x = 15; 501 rect.p0.y = 1 11;1078 rect.p0.y = 146; 502 1079 rect.p1.x = 105; 503 rect.p1.y = 1 39;1080 rect.p1.y = 174; 504 1081 } 505 1082 … … 508 1085 ui_pbutton_set_default(demo.pb1, true); 509 1086 510 rc = ui_fixed_add(demo. fixed, ui_pbutton_ctl(demo.pb1));1087 rc = ui_fixed_add(demo.bfixed, ui_pbutton_ctl(demo.pb1)); 511 1088 if (rc != EOK) { 512 1089 printf("Error adding control to layout.\n"); … … 523 1100 524 1101 if (ui_is_textmode(ui)) { 525 rect.p0.x = 50;526 rect.p0.y = 8;527 rect.p1.x = 60;528 rect.p1.y = 9;1102 rect.p0.x = 30; 1103 rect.p0.y = 9; 1104 rect.p1.x = 41; 1105 rect.p1.y = 10; 529 1106 } else { 530 1107 rect.p0.x = 115; 531 rect.p0.y = 1 11;1108 rect.p0.y = 146; 532 1109 rect.p1.x = 205; 533 rect.p1.y = 1 39;1110 rect.p1.y = 174; 534 1111 } 535 1112 536 1113 ui_pbutton_set_rect(demo.pb2, &rect); 537 1114 538 rc = ui_fixed_add(demo. fixed, ui_pbutton_ctl(demo.pb2));1115 rc = ui_fixed_add(demo.bfixed, ui_pbutton_ctl(demo.pb2)); 539 1116 if (rc != EOK) { 540 1117 printf("Error adding control to layout.\n"); … … 543 1120 544 1121 gfx_bitmap_params_init(&bparams); 545 bparams.rect.p0.x = 0; 546 bparams.rect.p0.y = 0; 547 bparams.rect.p1.x = 188; 548 bparams.rect.p1.y = 24; 1122 if (ui_is_textmode(ui)) { 1123 bparams.rect.p0.x = 0; 1124 bparams.rect.p0.y = 0; 1125 bparams.rect.p1.x = 37; 1126 bparams.rect.p1.y = 2; 1127 } else { 1128 bparams.rect.p0.x = 0; 1129 bparams.rect.p0.y = 0; 1130 bparams.rect.p1.x = 188; 1131 bparams.rect.p1.y = 24; 1132 } 549 1133 550 1134 rc = gfx_bitmap_create(gc, &bparams, NULL, &bitmap); … … 562 1146 } 563 1147 564 off.x = 15; 565 off.y = 155; 1148 if (ui_is_textmode(ui)) { 1149 off.x = 4; 1150 off.y = 11; 1151 } else { 1152 off.x = 15; 1153 off.y = 190; 1154 } 1155 566 1156 gfx_rect_translate(&off, &bparams.rect, &rect); 567 1157 568 1158 /* Adjust for frame width (2 x 1 pixel) */ 569 rect.p1.x += 2; 570 rect.p1.y += 2; 1159 if (!ui_is_textmode(ui)) { 1160 ui_image_set_flags(demo.image, ui_imgf_frame); 1161 rect.p1.x += 2; 1162 rect.p1.y += 2; 1163 } 1164 571 1165 ui_image_set_rect(demo.image, &rect); 572 ui_image_set_flags(demo.image, ui_imgf_frame); 573 574 rc = ui_fixed_add(demo.fixed, ui_image_ctl(demo.image)); 1166 1167 rc = ui_fixed_add(demo.bfixed, ui_image_ctl(demo.image)); 575 1168 if (rc != EOK) { 576 1169 printf("Error adding control to layout.\n"); … … 578 1171 } 579 1172 580 rc = ui_checkbox_create(ui_res, " Check me", &demo.checkbox);1173 rc = ui_checkbox_create(ui_res, "Read only", &demo.checkbox); 581 1174 if (rc != EOK) { 582 1175 printf("Error creating check box.\n"); … … 586 1179 ui_checkbox_set_cb(demo.checkbox, &checkbox_cb, (void *) &demo); 587 1180 588 rect.p0.x = 15; 589 rect.p0.y = 190; 590 rect.p1.x = 140; 591 rect.p1.y = 210; 1181 /* FIXME: Auto layout */ 1182 if (ui_is_textmode(ui)) { 1183 rect.p0.x = 4; 1184 rect.p0.y = 14; 1185 rect.p1.x = 14; 1186 rect.p1.y = 15; 1187 } else { 1188 rect.p0.x = 15; 1189 rect.p0.y = 225; 1190 rect.p1.x = 140; 1191 rect.p1.y = 245; 1192 } 1193 592 1194 ui_checkbox_set_rect(demo.checkbox, &rect); 593 1195 594 rc = ui_fixed_add(demo. fixed, ui_checkbox_ctl(demo.checkbox));1196 rc = ui_fixed_add(demo.bfixed, ui_checkbox_ctl(demo.checkbox)); 595 1197 if (rc != EOK) { 596 1198 printf("Error adding control to layout.\n"); … … 604 1206 } 605 1207 606 rc = ui_rbutton_create(demo.rbgroup, " Option 1", (void *) "First",607 &demo.rb 1);1208 rc = ui_rbutton_create(demo.rbgroup, "Left", (void *) &uidemo_halign[0], 1209 &demo.rbleft); 608 1210 if (rc != EOK) { 609 1211 printf("Error creating radio button.\n"); … … 614 1216 (void *) &demo); 615 1217 616 rect.p0.x = 15; 617 rect.p0.y = 220; 618 rect.p1.x = 140; 619 rect.p1.y = 240; 620 ui_rbutton_set_rect(demo.rb1, &rect); 621 622 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb1)); 1218 /* FIXME: Auto layout */ 1219 if (ui_is_textmode(ui)) { 1220 rect.p0.x = 4; 1221 rect.p0.y = 16; 1222 rect.p1.x = 14; 1223 rect.p1.y = 17; 1224 } else { 1225 rect.p0.x = 15; 1226 rect.p0.y = 255; 1227 rect.p1.x = 140; 1228 rect.p1.y = 275; 1229 } 1230 ui_rbutton_set_rect(demo.rbleft, &rect); 1231 1232 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbleft)); 623 1233 if (rc != EOK) { 624 1234 printf("Error adding control to layout.\n"); … … 626 1236 } 627 1237 628 rc = ui_rbutton_create(demo.rbgroup, " Option 2", (void *) "Second",629 &demo.rb 2);1238 rc = ui_rbutton_create(demo.rbgroup, "Center", (void *) &uidemo_halign[1], 1239 &demo.rbcenter); 630 1240 if (rc != EOK) { 631 1241 printf("Error creating radio button.\n"); … … 633 1243 } 634 1244 635 rect.p0.x = 15; 636 rect.p0.y = 250; 637 rect.p1.x = 140; 638 rect.p1.y = 270; 639 ui_rbutton_set_rect(demo.rb2, &rect); 640 641 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb2)); 1245 /* FIXME: Auto layout */ 1246 if (ui_is_textmode(ui)) { 1247 rect.p0.x = 4; 1248 rect.p0.y = 17; 1249 rect.p1.x = 14; 1250 rect.p1.y = 18; 1251 } else { 1252 rect.p0.x = 15; 1253 rect.p0.y = 285; 1254 rect.p1.x = 140; 1255 rect.p1.y = 305; 1256 } 1257 ui_rbutton_set_rect(demo.rbcenter, &rect); 1258 ui_rbutton_select(demo.rbcenter); 1259 1260 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbcenter)); 642 1261 if (rc != EOK) { 643 1262 printf("Error adding control to layout.\n"); … … 645 1264 } 646 1265 647 rc = ui_rbutton_create(demo.rbgroup, " Option 3", (void *) "Third",648 &demo.rb 3);1266 rc = ui_rbutton_create(demo.rbgroup, "Right", (void *) &uidemo_halign[2], 1267 &demo.rbright); 649 1268 if (rc != EOK) { 650 1269 printf("Error creating radio button.\n"); … … 652 1271 } 653 1272 654 rect.p0.x = 15; 655 rect.p0.y = 280; 656 rect.p1.x = 140; 657 rect.p1.y = 300; 658 ui_rbutton_set_rect(demo.rb3, &rect); 659 660 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb3)); 1273 /* FIXME: Auto layout */ 1274 if (ui_is_textmode(ui)) { 1275 rect.p0.x = 4; 1276 rect.p0.y = 18; 1277 rect.p1.x = 14; 1278 rect.p1.y = 19; 1279 } else { 1280 rect.p0.x = 15; 1281 rect.p0.y = 315; 1282 rect.p1.x = 140; 1283 rect.p1.y = 335; 1284 } 1285 ui_rbutton_set_rect(demo.rbright, &rect); 1286 1287 rc = ui_fixed_add(demo.bfixed, ui_rbutton_ctl(demo.rbright)); 661 1288 if (rc != EOK) { 662 1289 printf("Error adding control to layout.\n"); … … 664 1291 } 665 1292 666 rc = ui_slider_create(ui_res, "Slide!",&demo.slider);1293 rc = ui_slider_create(ui_res, &demo.slider); 667 1294 if (rc != EOK) { 668 1295 printf("Error creating button.\n"); … … 672 1299 ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo); 673 1300 674 rect.p0.x = 15; 675 rect.p0.y = 310; 676 rect.p1.x = 130; 677 rect.p1.y = 330; 1301 /* FIXME: Auto layout */ 1302 if (ui_is_textmode(ui)) { 1303 rect.p0.x = 4; 1304 rect.p0.y = 20; 1305 rect.p1.x = 32; 1306 rect.p1.y = 21; 1307 } else { 1308 rect.p0.x = 15; 1309 rect.p0.y = 345; 1310 rect.p1.x = 130; 1311 rect.p1.y = 365; 1312 } 1313 678 1314 ui_slider_set_rect(demo.slider, &rect); 679 1315 680 rc = ui_fixed_add(demo. fixed, ui_slider_ctl(demo.slider));1316 rc = ui_fixed_add(demo.bfixed, ui_slider_ctl(demo.slider)); 681 1317 if (rc != EOK) { 682 1318 printf("Error adding control to layout.\n"); … … 684 1320 } 685 1321 1322 rc = ui_scrollbar_create(ui, window, ui_sbd_horiz, &demo.hscrollbar); 1323 if (rc != EOK) { 1324 printf("Error creating scrollbar.\n"); 1325 return rc; 1326 } 1327 1328 ui_scrollbar_set_cb(demo.hscrollbar, &scrollbar_cb, (void *) &demo); 1329 1330 /* FIXME: Auto layout */ 1331 if (ui_is_textmode(ui)) { 1332 rect.p0.x = 4; 1333 rect.p0.y = 22; 1334 rect.p1.x = 42; 1335 rect.p1.y = 23; 1336 } else { 1337 rect.p0.x = 15; 1338 rect.p0.y = 375; 1339 rect.p1.x = 220; 1340 rect.p1.y = 398; 1341 } 1342 1343 ui_scrollbar_set_rect(demo.hscrollbar, &rect); 1344 1345 ui_scrollbar_set_thumb_length(demo.hscrollbar, 1346 ui_scrollbar_trough_length(demo.hscrollbar) / 4); 1347 1348 rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.hscrollbar)); 1349 if (rc != EOK) { 1350 printf("Error adding control to layout.\n"); 1351 return rc; 1352 } 1353 1354 rc = ui_scrollbar_create(ui, window, ui_sbd_vert, &demo.vscrollbar); 1355 if (rc != EOK) { 1356 printf("Error creating button.\n"); 1357 return rc; 1358 } 1359 1360 ui_scrollbar_set_cb(demo.vscrollbar, &scrollbar_cb, (void *) &demo); 1361 1362 /* FIXME: Auto layout */ 1363 if (ui_is_textmode(ui)) { 1364 rect.p0.x = 42; 1365 rect.p0.y = 5; 1366 rect.p1.x = 43; 1367 rect.p1.y = 22; 1368 } else { 1369 rect.p0.x = 220; 1370 rect.p0.y = 88; 1371 rect.p1.x = 243; 1372 rect.p1.y = 375; 1373 } 1374 1375 ui_scrollbar_set_rect(demo.vscrollbar, &rect); 1376 1377 ui_scrollbar_set_thumb_length(demo.vscrollbar, 1378 ui_scrollbar_trough_length(demo.vscrollbar) / 4); 1379 1380 rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.vscrollbar)); 1381 if (rc != EOK) { 1382 printf("Error adding control to layout.\n"); 1383 return rc; 1384 } 1385 1386 ui_tab_add(demo.tbasic, ui_fixed_ctl(demo.bfixed)); 1387 1388 rc = ui_fixed_create(&demo.lfixed); 1389 if (rc != EOK) { 1390 printf("Error creating fixed layout.\n"); 1391 return rc; 1392 } 1393 1394 rc = ui_list_create(window, false, &demo.list); 1395 if (rc != EOK) { 1396 printf("Error creating list.\n"); 1397 return rc; 1398 } 1399 1400 ui_list_entry_attr_init(&eattr); 1401 1402 eattr.caption = "One"; 1403 rc = ui_list_entry_append(demo.list, &eattr, NULL); 1404 if (rc != EOK) { 1405 printf("Error adding list entry.\n"); 1406 return rc; 1407 } 1408 1409 eattr.caption = "Two"; 1410 rc = ui_list_entry_append(demo.list, &eattr, NULL); 1411 if (rc != EOK) { 1412 printf("Error adding list entry.\n"); 1413 return rc; 1414 } 1415 1416 eattr.caption = "Three"; 1417 rc = ui_list_entry_append(demo.list, &eattr, NULL); 1418 if (rc != EOK) { 1419 printf("Error adding list entry.\n"); 1420 return rc; 1421 } 1422 1423 eattr.caption = "Four"; 1424 rc = ui_list_entry_append(demo.list, &eattr, NULL); 1425 if (rc != EOK) { 1426 printf("Error adding list entry.\n"); 1427 return rc; 1428 } 1429 1430 eattr.caption = "Five"; 1431 rc = ui_list_entry_append(demo.list, &eattr, NULL); 1432 if (rc != EOK) { 1433 printf("Error adding list entry.\n"); 1434 return rc; 1435 } 1436 1437 eattr.caption = "Six"; 1438 rc = ui_list_entry_append(demo.list, &eattr, NULL); 1439 if (rc != EOK) { 1440 printf("Error adding list entry.\n"); 1441 return rc; 1442 } 1443 1444 /* FIXME: Auto layout */ 1445 if (ui_is_textmode(ui)) { 1446 rect.p0.x = 4; 1447 rect.p0.y = 5; 1448 rect.p1.x = 41; 1449 rect.p1.y = 10; 1450 } else { 1451 rect.p0.x = 15; 1452 rect.p0.y = 88; 1453 rect.p1.x = 245; 1454 rect.p1.y = 173; 1455 } 1456 1457 ui_list_set_rect(demo.list, &rect); 1458 1459 rc = ui_fixed_add(demo.lfixed, ui_list_ctl(demo.list)); 1460 if (rc != EOK) { 1461 printf("Error adding control to layout.\n"); 1462 return rc; 1463 } 1464 1465 ui_tab_add(demo.tlists, ui_fixed_ctl(demo.lfixed)); 1466 1467 rc = ui_fixed_create(&demo.bars_fixed); 1468 if (rc != EOK) { 1469 printf("Error creating fixed layout.\n"); 1470 return rc; 1471 } 1472 1473 rc = ui_progress_create(ui_res, 0, &demo.progress); 1474 if (rc != EOK) { 1475 printf("Error creating entry.\n"); 1476 return rc; 1477 } 1478 1479 /* FIXME: Auto layout */ 1480 if (ui_is_textmode(ui)) { 1481 rect.p0.x = 4; 1482 rect.p0.y = 5; 1483 rect.p1.x = 42; 1484 rect.p1.y = 6; 1485 } else { 1486 rect.p0.x = 15; 1487 rect.p0.y = 88; 1488 rect.p1.x = 243; 1489 rect.p1.y = 113; 1490 } 1491 1492 ui_progress_set_rect(demo.progress, &rect); 1493 1494 rc = ui_fixed_add(demo.bars_fixed, ui_progress_ctl(demo.progress)); 1495 if (rc != EOK) { 1496 printf("Error adding control to layout.\n"); 1497 return rc; 1498 } 1499 1500 ui_tab_add(demo.tbars, ui_fixed_ctl(demo.bars_fixed)); 1501 686 1502 ui_window_add(window, ui_fixed_ctl(demo.fixed)); 687 1503 1504 demo.timer = fibril_timer_create(NULL); 1505 if (demo.timer == NULL) { 1506 printf("Error creating timer.\n"); 1507 return ENOMEM; 1508 } 1509 1510 fibril_timer_set(demo.timer, 1000 * scrollbar_update_interval_ms, 1511 ui_demo_timer_fun, (void *)&demo); 1512 688 1513 rc = ui_window_paint(window); 689 1514 if (rc != EOK) { … … 693 1518 694 1519 ui_run(ui); 1520 1521 fibril_timer_clear(demo.timer); 1522 fibril_timer_destroy(demo.timer); 695 1523 696 1524 ui_window_destroy(window); … … 728 1556 k = i * i + j * j; 729 1557 pixelmap_put_pixel(&pixelmap, i, j, 730 PIXEL( 255, k, k, 255 - k));1558 PIXEL(0, k, k, 255 - k)); 731 1559 } 732 1560 } … … 742 1570 int main(int argc, char *argv[]) 743 1571 { 744 const char *display_spec = UI_ DISPLAY_DEFAULT;1572 const char *display_spec = UI_ANY_DEFAULT; 745 1573 errno_t rc; 746 1574 int i;
Note:
See TracChangeset
for help on using the changeset viewer.
