Changeset 7020d1f in mainline for uspace/app/uidemo/uidemo.c
- Timestamp:
- 2021-02-01T10:53:48Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f14a900
- Parents:
- d70dc1c4
- git-author:
- Jiri Svoboda <jiri@…> (2020-01-31 16:53:25)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-02-01 10:53:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
rd70dc1c4 r7020d1f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 68 68 }; 69 69 70 static void rb_selected(ui_rbutton_group_t *, void *, void *); 71 72 static ui_rbutton_group_cb_t rbutton_group_cb = { 73 .selected = rb_selected 74 }; 75 70 76 /** Window close button was clicked. 71 77 * … … 126 132 } 127 133 134 /** Radio button was selected. 135 * 136 * @param rbgroup Radio button group 137 * @param garg Group argument (demo) 138 * @param barg Button argument 139 */ 140 static void rb_selected(ui_rbutton_group_t *rbgroup, void *garg, void *barg) 141 { 142 ui_demo_t *demo = (ui_demo_t *) garg; 143 const char *text = (const char *) barg; 144 errno_t rc; 145 146 rc = ui_entry_set_text(demo->entry, text); 147 if (rc != EOK) 148 printf("Error changing entry text.\n"); 149 (void) ui_entry_paint(demo->entry); 150 } 151 128 152 /** Run UI demo on display server. */ 129 153 static errno_t ui_demo(const char *display_spec) … … 153 177 params.rect.p0.y = 0; 154 178 params.rect.p1.x = 220; 155 params.rect.p1.y = 220;179 params.rect.p1.y = 330; 156 180 157 181 memset((void *) &demo, 0, sizeof(demo)); … … 307 331 308 332 rc = ui_fixed_add(demo.fixed, ui_checkbox_ctl(demo.checkbox)); 333 if (rc != EOK) { 334 printf("Error adding control to layout.\n"); 335 return rc; 336 } 337 338 rc = ui_rbutton_group_create(ui_res, &demo.rbgroup); 339 if (rc != EOK) { 340 printf("Error creating radio button group.\n"); 341 return rc; 342 } 343 344 rc = ui_rbutton_create(demo.rbgroup, "Option 1", (void *) "First", 345 &demo.rb1); 346 if (rc != EOK) { 347 printf("Error creating radio button.\n"); 348 return rc; 349 } 350 351 ui_rbutton_group_set_cb(demo.rbgroup, &rbutton_group_cb, 352 (void *) &demo); 353 354 rect.p0.x = 15; 355 rect.p0.y = 210; 356 rect.p1.x = 140; 357 rect.p1.y = 230; 358 ui_rbutton_set_rect(demo.rb1, &rect); 359 360 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb1)); 361 if (rc != EOK) { 362 printf("Error adding control to layout.\n"); 363 return rc; 364 } 365 366 rc = ui_rbutton_create(demo.rbgroup, "Option 2", (void *) "Second", 367 &demo.rb2); 368 if (rc != EOK) { 369 printf("Error creating radio button.\n"); 370 return rc; 371 } 372 373 rect.p0.x = 15; 374 rect.p0.y = 240; 375 rect.p1.x = 140; 376 rect.p1.y = 260; 377 ui_rbutton_set_rect(demo.rb2, &rect); 378 379 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb2)); 380 if (rc != EOK) { 381 printf("Error adding control to layout.\n"); 382 return rc; 383 } 384 385 rc = ui_rbutton_create(demo.rbgroup, "Option 3", (void *) "Third", 386 &demo.rb3); 387 if (rc != EOK) { 388 printf("Error creating radio button.\n"); 389 return rc; 390 } 391 392 rect.p0.x = 15; 393 rect.p0.y = 270; 394 rect.p1.x = 140; 395 rect.p1.y = 290; 396 ui_rbutton_set_rect(demo.rb3, &rect); 397 398 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb3)); 309 399 if (rc != EOK) { 310 400 printf("Error adding control to layout.\n");
Note:
See TracChangeset
for help on using the changeset viewer.