INVERS flag removed and VCENTERED added

This commit is contained in:
Bertrand Songis
2020-06-18 12:15:23 +02:00
parent e4b6a87f28
commit d653eb4cb6
2 changed files with 12 additions and 5 deletions
+1 -1
View File
@@ -26,8 +26,8 @@
#define BLINK 0x01u
/* drawText flags */
#define INVERS 0x02u
#define LEFT 0x00u /* align left */
#define VCENTERED 0x02u /* align center vertically */
#define CENTERED 0x04u /* align center */
#define RIGHT 0x08u /* align right */
#define SHADOWED 0x80u /* black copy at +1 +1 */
+11 -4
View File
@@ -22,12 +22,19 @@
void StaticText::paint(BitmapBuffer * dc)
{
if (windowFlags & BUTTON_BACKGROUND)
if (windowFlags & BUTTON_BACKGROUND) {
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, DISABLE_COLOR);
}
coord_t x;
if (textFlags & CENTERED)
dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2, text.c_str(), textFlags);
x = rect.w / 2;
else if (textFlags & RIGHT)
dc->drawText(rect.w, FIELD_PADDING_TOP, text.c_str(), textFlags);
x = rect.w;
else
dc->drawText(0, 0 + FIELD_PADDING_TOP, text.c_str(), textFlags);
x = 0;
coord_t y = (textFlags & VCENTERED) ? (rect.h - getFontHeight(textFlags)) / 2 : FIELD_PADDING_TOP;
dc->drawText(x, y, text.c_str(), textFlags);
}