Changeset bfb055b in mainline for uspace/app/uidemo/uidemo.c
- Timestamp:
- 2021-03-27T22:52:09Z (4 years ago)
- Children:
- cd62879
- Parents:
- dbf1be5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
rdbf1be5 rbfb055b 43 43 #include <ui/image.h> 44 44 #include <ui/label.h> 45 #include <ui/menubar.h> 46 #include <ui/menuentry.h> 47 #include <ui/menu.h> 45 48 #include <ui/pbutton.h> 46 49 #include <ui/resource.h> … … 80 83 .moved = slider_moved 81 84 }; 85 86 static void uidemo_file_exit(ui_menu_entry_t *, void *); 82 87 83 88 /** Window close button was clicked. … … 185 190 } 186 191 192 /** File/exit menu entry selected. 193 * 194 * @param mentry Menu entry 195 * @param arg Argument (demo) 196 */ 197 static void uidemo_file_exit(ui_menu_entry_t *mentry, void *arg) 198 { 199 ui_demo_t *demo = (ui_demo_t *) arg; 200 201 ui_quit(demo->ui); 202 } 203 187 204 /** Run UI demo on display server. */ 188 205 static errno_t ui_demo(const char *display_spec) … … 198 215 gfx_bitmap_t *bitmap; 199 216 gfx_coord2_t off; 217 ui_menu_entry_t *mfoo; 218 ui_menu_entry_t *mbar; 219 ui_menu_entry_t *mfoobar; 220 ui_menu_entry_t *mexit; 221 ui_menu_entry_t *mabout; 200 222 errno_t rc; 201 223 … … 212 234 params.rect.p0.y = 0; 213 235 params.rect.p1.x = 220; 214 params.rect.p1.y = 3 40;236 params.rect.p1.y = 350; 215 237 216 238 memset((void *) &demo, 0, sizeof(demo)); … … 235 257 } 236 258 259 rc = ui_menu_bar_create(ui_res, &demo.mbar); 260 if (rc != EOK) { 261 printf("Error creating menu bar.\n"); 262 return rc; 263 } 264 265 rc = ui_menu_create(demo.mbar, "File", &demo.mfile); 266 if (rc != EOK) { 267 printf("Error creating menu.\n"); 268 return rc; 269 } 270 271 rc = ui_menu_entry_create(demo.mfile, "Foo", &mfoo); 272 if (rc != EOK) { 273 printf("Error creating menu.\n"); 274 return rc; 275 } 276 277 rc = ui_menu_entry_create(demo.mfile, "Bar", &mbar); 278 if (rc != EOK) { 279 printf("Error creating menu.\n"); 280 return rc; 281 } 282 283 rc = ui_menu_entry_create(demo.mfile, "Foobar", &mfoobar); 284 if (rc != EOK) { 285 printf("Error creating menu.\n"); 286 return rc; 287 } 288 289 rc = ui_menu_entry_create(demo.mfile, "Exit", &mexit); 290 if (rc != EOK) { 291 printf("Error creating menu.\n"); 292 return rc; 293 } 294 295 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo); 296 297 rc = ui_menu_create(demo.mbar, "Edit", &demo.medit); 298 if (rc != EOK) { 299 printf("Error creating menu.\n"); 300 return rc; 301 } 302 303 rc = ui_menu_create(demo.mbar, "Preferences", &demo.mpreferences); 304 if (rc != EOK) { 305 printf("Error creating menu.\n"); 306 return rc; 307 } 308 309 rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp); 310 if (rc != EOK) { 311 printf("Error creating menu.\n"); 312 return rc; 313 } 314 315 rc = ui_menu_entry_create(demo.mhelp, "About", &mabout); 316 if (rc != EOK) { 317 printf("Error creating menu.\n"); 318 return rc; 319 } 320 321 rect.p0.x = 4; 322 rect.p0.y = 30; 323 rect.p1.x = 216; 324 rect.p1.y = 52; 325 ui_menu_bar_set_rect(demo.mbar, &rect); 326 327 rc = ui_fixed_add(demo.fixed, ui_menu_bar_ctl(demo.mbar)); 328 if (rc != EOK) { 329 printf("Error adding control to layout.\n"); 330 return rc; 331 } 332 333 rc = ui_entry_create(ui_res, "", &demo.entry); 334 if (rc != EOK) { 335 printf("Error creating entry.\n"); 336 return rc; 337 } 338 339 rect.p0.x = 15; 340 rect.p0.y = 53; 341 rect.p1.x = 205; 342 rect.p1.y = 78; 343 ui_entry_set_rect(demo.entry, &rect); 344 ui_entry_set_halign(demo.entry, gfx_halign_center); 345 346 rc = ui_fixed_add(demo.fixed, ui_entry_ctl(demo.entry)); 347 if (rc != EOK) { 348 printf("Error adding control to layout.\n"); 349 return rc; 350 } 351 237 352 rc = ui_label_create(ui_res, "Text label", &demo.label); 238 353 if (rc != EOK) { … … 242 357 243 358 rect.p0.x = 60; 244 rect.p0.y = 37;359 rect.p0.y = 88; 245 360 rect.p1.x = 160; 246 rect.p1.y = 50;361 rect.p1.y = 101; 247 362 ui_label_set_rect(demo.label, &rect); 248 363 ui_label_set_halign(demo.label, gfx_halign_center); … … 263 378 264 379 rect.p0.x = 15; 265 rect.p0.y = 70;380 rect.p0.y = 111; 266 381 rect.p1.x = 105; 267 rect.p1.y = 98;382 rect.p1.y = 139; 268 383 ui_pbutton_set_rect(demo.pb1, &rect); 269 384 … … 285 400 286 401 rect.p0.x = 115; 287 rect.p0.y = 70;402 rect.p0.y = 111; 288 403 rect.p1.x = 205; 289 rect.p1.y = 98;404 rect.p1.y = 139; 290 405 ui_pbutton_set_rect(demo.pb2, &rect); 291 406 292 407 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb2)); 293 if (rc != EOK) {294 printf("Error adding control to layout.\n");295 return rc;296 }297 298 rc = ui_entry_create(ui_res, "", &demo.entry);299 if (rc != EOK) {300 printf("Error creating entry.\n");301 return rc;302 }303 304 rect.p0.x = 15;305 rect.p0.y = 110;306 rect.p1.x = 205;307 rect.p1.y = 135;308 ui_entry_set_rect(demo.entry, &rect);309 ui_entry_set_halign(demo.entry, gfx_halign_center);310 311 rc = ui_fixed_add(demo.fixed, ui_entry_ctl(demo.entry));312 408 if (rc != EOK) { 313 409 printf("Error adding control to layout.\n"); … … 336 432 337 433 off.x = 15; 338 off.y = 1 45;434 off.y = 155; 339 435 gfx_rect_translate(&off, &bparams.rect, &rect); 340 436 … … 360 456 361 457 rect.p0.x = 15; 362 rect.p0.y = 1 80;458 rect.p0.y = 190; 363 459 rect.p1.x = 140; 364 rect.p1.y = 2 00;460 rect.p1.y = 210; 365 461 ui_checkbox_set_rect(demo.checkbox, &rect); 366 462 … … 388 484 389 485 rect.p0.x = 15; 390 rect.p0.y = 2 10;486 rect.p0.y = 220; 391 487 rect.p1.x = 140; 392 rect.p1.y = 2 30;488 rect.p1.y = 240; 393 489 ui_rbutton_set_rect(demo.rb1, &rect); 394 490 … … 407 503 408 504 rect.p0.x = 15; 409 rect.p0.y = 2 40;505 rect.p0.y = 250; 410 506 rect.p1.x = 140; 411 rect.p1.y = 2 60;507 rect.p1.y = 270; 412 508 ui_rbutton_set_rect(demo.rb2, &rect); 413 509 … … 426 522 427 523 rect.p0.x = 15; 428 rect.p0.y = 2 70;524 rect.p0.y = 280; 429 525 rect.p1.x = 140; 430 rect.p1.y = 290;526 rect.p1.y = 300; 431 527 ui_rbutton_set_rect(demo.rb3, &rect); 432 528 … … 446 542 447 543 rect.p0.x = 15; 448 rect.p0.y = 3 00;544 rect.p0.y = 310; 449 545 rect.p1.x = 130; 450 rect.p1.y = 3 20;546 rect.p1.y = 330; 451 547 ui_slider_set_rect(demo.slider, &rect); 452 548
Note:
See TracChangeset
for help on using the changeset viewer.