19 #include <winpr/assert.h>
21 #include <rdtk/config.h>
23 #include "rdtk_font.h"
25 #include "rdtk_label.h"
27 int rdtk_label_draw(rdtkSurface* surface, uint16_t nXDst, uint16_t nYDst, uint16_t nWidth,
28 uint16_t nHeight, rdtkLabel* label,
const char* text, uint16_t hAlign,
33 uint16_t textWidth = 0;
34 uint16_t textHeight = 0;
36 WINPR_ASSERT(surface);
38 rdtkEngine* engine = surface->engine;
39 rdtkFont* font = engine->font;
41 rdtk_font_text_draw_size(font, &textWidth, &textHeight, text);
43 if ((textWidth > 0) && (textHeight > 0))
48 if (textWidth < nWidth)
49 offsetX = ((nWidth - textWidth) / 2);
51 if (textHeight < nHeight)
52 offsetY = ((nHeight - textHeight) / 2);
54 rdtk_font_draw_text(surface, nXDst + offsetX, nYDst + offsetY, font, text);
60 rdtkLabel* rdtk_label_new(rdtkEngine* engine)
63 rdtkLabel* label = (rdtkLabel*)calloc(1,
sizeof(rdtkLabel));
68 label->engine = engine;
73 void rdtk_label_free(rdtkLabel* label)
78 int rdtk_label_engine_init(rdtkEngine* engine)
83 engine->label = rdtk_label_new(engine);
89 int rdtk_label_engine_uninit(rdtkEngine* engine)
94 rdtk_label_free(engine->label);