aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/widget.cpp18
-rw-r--r--gui/widget.h4
2 files changed, 19 insertions, 3 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 865b011a77..e8a7d80183 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -111,7 +111,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h,
: Widget(boss, x, y, w, h), _align(align) {
_flags = WIDGET_ENABLED;
_type = kStaticTextWidget;
- setLabel(text);
+ _label = text;
}
void StaticTextWidget::setValue(int value) {
@@ -120,6 +120,22 @@ void StaticTextWidget::setValue(int value) {
_label = buf;
}
+void StaticTextWidget::setLabel(const String &label) {
+ _label = label;
+ // TODO: We should automatically redraw when the label is changed.
+ // The following doesn't quite work when we are using tabs, plus it
+ // is rather clumsy to force a full redraw for a single static text.
+ // However, as long as we do blending, it might be the only way.
+ //_boss->draw();
+}
+
+void StaticTextWidget::setAlign(TextAlignment align) {
+ _align = align;
+ // TODO: We should automatically redraw when the alignment is changed.
+ // See setLabel() for more insights.
+}
+
+
void StaticTextWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
gui->drawString(_label, _x, _y, _w, isEnabled() ? gui->_textcolor : gui->_color, _align);
diff --git a/gui/widget.h b/gui/widget.h
index 1ce9ba9285..3a97cab747 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -134,9 +134,9 @@ protected:
public:
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align);
void setValue(int value);
- void setLabel(const String &label) { _label = label; }
+ void setLabel(const String &label);
const String &getLabel() const { return _label; }
- void setAlign(TextAlignment align) { _align = align; }
+ void setAlign(TextAlignment align);
TextAlignment getAlign() const { return _align; }
protected: