// widgetLabel.c — Label widget #include "widgetInternal.h" // ============================================================ // wgtLabel // ============================================================ WidgetT *wgtLabel(WidgetT *parent, const char *text) { WidgetT *w = widgetAlloc(parent, WidgetLabelE); if (w) { w->as.label.text = text; } return w; } // ============================================================ // widgetLabelCalcMinSize // ============================================================ void widgetLabelCalcMinSize(WidgetT *w, const BitmapFontT *font) { w->calcMinW = (int32_t)strlen(w->as.label.text) * font->charWidth; w->calcMinH = font->charHeight; } // ============================================================ // widgetLabelPaint // ============================================================ void widgetLabelPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors) { uint32_t fg = w->fgColor ? w->fgColor : colors->contentFg; uint32_t bg = w->bgColor ? w->bgColor : colors->contentBg; drawText(d, ops, font, w->x, w->y + (w->h - font->charHeight) / 2, w->as.label.text, fg, bg, false); }