Changeset 5de71df in mainline
- Timestamp:
- 2021-07-28T18:22:58Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dbb42c9
- Parents:
- a106037
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
ra106037 r5de71df 96 96 }; 97 97 98 /** Horizontal alignment selected by each radio button */ 99 static const gfx_halign_t uidemo_halign[3] = { 100 gfx_halign_left, 101 gfx_halign_center, 102 gfx_halign_right 103 }; 104 98 105 /** Window close button was clicked. 99 106 * … … 139 146 { 140 147 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 } 148 149 ui_entry_set_read_only(demo->entry, enable); 154 150 } 155 151 … … 163 159 { 164 160 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"); 161 gfx_halign_t halign = *(gfx_halign_t *) barg; 162 163 ui_entry_set_halign(demo->entry, halign); 171 164 (void) ui_entry_paint(demo->entry); 172 165 } … … 578 571 } 579 572 580 rc = ui_checkbox_create(ui_res, " Check me", &demo.checkbox);573 rc = ui_checkbox_create(ui_res, "Read only", &demo.checkbox); 581 574 if (rc != EOK) { 582 575 printf("Error creating check box.\n"); … … 604 597 } 605 598 606 rc = ui_rbutton_create(demo.rbgroup, " Option 1", (void *) "First",607 &demo.rb 1);599 rc = ui_rbutton_create(demo.rbgroup, "Left", (void *) &uidemo_halign[0], 600 &demo.rbleft); 608 601 if (rc != EOK) { 609 602 printf("Error creating radio button.\n"); … … 618 611 rect.p1.x = 140; 619 612 rect.p1.y = 240; 620 ui_rbutton_set_rect(demo.rb 1, &rect);621 622 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb 1));623 if (rc != EOK) { 624 printf("Error adding control to layout.\n"); 625 return rc; 626 } 627 628 rc = ui_rbutton_create(demo.rbgroup, " Option 2", (void *) "Second",629 &demo.rb 2);613 ui_rbutton_set_rect(demo.rbleft, &rect); 614 615 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbleft)); 616 if (rc != EOK) { 617 printf("Error adding control to layout.\n"); 618 return rc; 619 } 620 621 rc = ui_rbutton_create(demo.rbgroup, "Center", (void *) &uidemo_halign[1], 622 &demo.rbcenter); 630 623 if (rc != EOK) { 631 624 printf("Error creating radio button.\n"); … … 637 630 rect.p1.x = 140; 638 631 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)); 642 if (rc != EOK) { 643 printf("Error adding control to layout.\n"); 644 return rc; 645 } 646 647 rc = ui_rbutton_create(demo.rbgroup, "Option 3", (void *) "Third", 648 &demo.rb3); 632 ui_rbutton_set_rect(demo.rbcenter, &rect); 633 ui_rbutton_select(demo.rbcenter); 634 635 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbcenter)); 636 if (rc != EOK) { 637 printf("Error adding control to layout.\n"); 638 return rc; 639 } 640 641 rc = ui_rbutton_create(demo.rbgroup, "Right", (void *) &uidemo_halign[2], 642 &demo.rbright); 649 643 if (rc != EOK) { 650 644 printf("Error creating radio button.\n"); … … 656 650 rect.p1.x = 140; 657 651 rect.p1.y = 300; 658 ui_rbutton_set_rect(demo.rb 3, &rect);659 660 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb 3));652 ui_rbutton_set_rect(demo.rbright, &rect); 653 654 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbright)); 661 655 if (rc != EOK) { 662 656 printf("Error adding control to layout.\n"); -
uspace/app/uidemo/uidemo.h
ra106037 r5de71df 67 67 ui_checkbox_t *checkbox; 68 68 ui_rbutton_group_t *rbgroup; 69 ui_rbutton_t *rb 1;70 ui_rbutton_t *rb 2;71 ui_rbutton_t *rb 3;69 ui_rbutton_t *rbleft; 70 ui_rbutton_t *rbcenter; 71 ui_rbutton_t *rbright; 72 72 ui_slider_t *slider; 73 73 } ui_demo_t; -
uspace/lib/ui/include/ui/rbutton.h
ra106037 r5de71df 61 61 extern void ui_rbutton_enter(ui_rbutton_t *); 62 62 extern void ui_rbutton_leave(ui_rbutton_t *); 63 extern void ui_rbutton_select(ui_rbutton_t *); 63 64 extern void ui_rbutton_selected(ui_rbutton_t *); 64 65 extern ui_evclaim_t ui_rbutton_pos_event(ui_rbutton_t *, pos_event_t *); -
uspace/lib/ui/src/rbutton.c
ra106037 r5de71df 316 316 void ui_rbutton_release(ui_rbutton_t *rbutton) 317 317 { 318 ui_rbutton_t *old_selected;319 320 318 if (!rbutton->held) 321 319 return; … … 325 323 if (rbutton->inside) { 326 324 /* Activate radio button */ 327 old_selected = rbutton->group->selected; 328 329 if (old_selected != rbutton) { 330 rbutton->group->selected = rbutton; 331 ui_rbutton_paint(old_selected); 332 } 333 334 /* Repaint and notify */ 335 (void) ui_rbutton_paint(rbutton); 336 337 if (old_selected != rbutton) 338 ui_rbutton_selected(rbutton); 325 ui_rbutton_select(rbutton); 339 326 } 340 327 } … … 368 355 } 369 356 370 /** Button was selected. 357 /** Select radio button. 358 * 359 * @param rbutton Radio button 360 */ 361 void ui_rbutton_select(ui_rbutton_t *rbutton) 362 { 363 ui_rbutton_t *old_selected; 364 365 old_selected = rbutton->group->selected; 366 367 if (old_selected != rbutton) { 368 rbutton->group->selected = rbutton; 369 ui_rbutton_paint(old_selected); 370 } 371 372 /* Repaint and notify */ 373 (void) ui_rbutton_paint(rbutton); 374 375 if (old_selected != rbutton) 376 ui_rbutton_selected(rbutton); 377 } 378 379 /** Notify that button was selected. 371 380 * 372 381 * @param rbutton Radio button
Note:
See TracChangeset
for help on using the changeset viewer.