Changeset 0d1d0ea in mainline for uspace/lib/ui/src/paint.c
- Timestamp:
- 2022-03-31T14:37:31Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d68239a1
- Parents:
- 7ca7215
- git-author:
- Jiri Svoboda <jiri@…> (2022-03-30 17:37:11)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-03-31 14:37:31)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/paint.c
r7ca7215 r0d1d0ea 555 555 } 556 556 557 /** Fill rectangle with text character. 558 * 559 * @param resource UI resource 560 * @param rect Rectangle 561 * @param color Color 562 * @param gchar Character to fill with 563 * @return EOK on success or an error code 564 */ 565 errno_t ui_paint_text_rect(ui_resource_t *resource, gfx_rect_t *rect, 566 gfx_color_t *color, const char *gchar) 567 { 568 gfx_coord2_t pos; 569 gfx_text_fmt_t fmt; 570 gfx_rect_t srect; 571 gfx_coord_t w, i; 572 char *buf; 573 size_t gcharsz; 574 errno_t rc; 575 576 gfx_rect_points_sort(rect, &srect); 577 578 gfx_text_fmt_init(&fmt); 579 fmt.font = resource->font; 580 fmt.color = color; 581 fmt.halign = gfx_halign_left; 582 fmt.valign = gfx_valign_top; 583 584 w = srect.p1.x - srect.p0.x; 585 if (w == 0) 586 return EOK; 587 588 gcharsz = str_size(gchar); 589 590 buf = malloc(w * gcharsz + 1); 591 if (buf == NULL) 592 return ENOMEM; 593 594 for (i = 0; i < w; i++) 595 str_cpy(buf + i * gcharsz, (w - i) * gcharsz + 1, gchar); 596 buf[w * gcharsz] = '\0'; 597 598 pos.x = srect.p0.x; 599 for (pos.y = srect.p0.y; pos.y < srect.p1.y; pos.y++) { 600 rc = gfx_puttext(&pos, &fmt, buf); 601 if (rc != EOK) 602 goto error; 603 } 604 605 free(buf); 606 return EOK; 607 error: 608 free(buf); 609 return rc; 610 } 611 557 612 /** Initialize UI text formatting structure. 558 613 *
Note:
See TracChangeset
for help on using the changeset viewer.