aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index bbb8b06ee6..17098df6ea 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -45,6 +45,7 @@ Widget::Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip)
Widget::Widget(GuiObject *boss, const Common::String &name, const char *tooltip)
: GuiObject(name), _type(0), _boss(boss), _tooltip(tooltip),
_id(0), _flags(0), _hasFocus(false), _state(ThemeEngine::kStateDisabled) {
+ reflowLayout();
init();
}
@@ -341,6 +342,13 @@ ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Co
_type = kButtonWidget;
}
+void ButtonWidget::getMinSize(int &minWidth, int &minHeight) {
+ const Graphics::Font &font = g_gui.getFont(_font);
+
+ minWidth = font.getStringWidth(_label);
+ minHeight = font.getFontHeight();
+}
+
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
if (isEnabled() && _duringPress && x >= 0 && x < _w && y >= 0 && y < _h) {
setUnpressedState();
@@ -476,6 +484,14 @@ void DropdownButtonWidget::reflowLayout() {
reset();
}
+void DropdownButtonWidget::getMinSize(int &minWidth, int &minHeight) {
+ ButtonWidget::getMinSize(minWidth, minHeight);
+
+ if (minWidth >= 0) {
+ minWidth += _dropdownWidth * 2;
+ }
+}
+
void DropdownButtonWidget::appendEntry(const Common::String &label, uint32 cmd) {
Entry e;
e.label = label;
@@ -838,12 +854,16 @@ void GraphicsWidget::drawWidget() {
#pragma mark -
-ContainerWidget::ContainerWidget(GuiObject *boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h) {
+ContainerWidget::ContainerWidget(GuiObject *boss, int x, int y, int w, int h) :
+ Widget(boss, x, y, w, h),
+ _backgroundType(ThemeEngine::kWidgetBackgroundBorder) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
_type = kContainerWidget;
}
-ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) : Widget(boss, name) {
+ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) :
+ Widget(boss, name),
+ _backgroundType(ThemeEngine::kWidgetBackgroundBorder) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
_type = kContainerWidget;
}
@@ -875,9 +895,12 @@ void ContainerWidget::removeWidget(Widget *widget) {
Widget::removeWidget(widget);
}
+void ContainerWidget::setBackgroundType(ThemeEngine::WidgetBackground backgroundType) {
+ _backgroundType = backgroundType;
+}
+
void ContainerWidget::drawWidget() {
- g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
- ThemeEngine::kWidgetBackgroundBorder);
+ g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, _backgroundType);
}
} // End of namespace GUI