aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2012-07-09 01:49:58 +0200
committerJohannes Schickel2012-07-09 02:18:22 +0200
commit0cf00ddfe2d985bdd00f5fb06ee5bfb2f8683831 (patch)
tree03a402b27ba82e4096d815477ae3499a1634e0ca /gui
parent049e61b4459fd6fdbcf29c5d0e29d35755de82e3 (diff)
downloadscummvm-rg350-0cf00ddfe2d985bdd00f5fb06ee5bfb2f8683831.tar.gz
scummvm-rg350-0cf00ddfe2d985bdd00f5fb06ee5bfb2f8683831.tar.bz2
scummvm-rg350-0cf00ddfe2d985bdd00f5fb06ee5bfb2f8683831.zip
GUI: Make container widget a bit more container like.
Now it is possible to add sub widgets to a ContainerWidget and allow for these to get events too.
Diffstat (limited to 'gui')
-rw-r--r--gui/widget.cpp20
-rw-r--r--gui/widget.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 3c26f1135b..4babce66fb 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -711,6 +711,26 @@ ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) :
_type = kContainerWidget;
}
+ContainerWidget::~ContainerWidget() {
+ // We also remove the widget from the boss to avoid segfaults, when the
+ // deleted widget is an active widget in the boss.
+ for (Widget *w = _firstWidget; w; w = w->next()) {
+ _boss->removeWidget(w);
+ }
+}
+
+Widget *ContainerWidget::findWidget(int x, int y) {
+ return findWidgetInChain(_firstWidget, x, y);
+}
+
+void ContainerWidget::removeWidget(Widget *widget) {
+ // We also remove the widget from the boss to avoid a reference to a
+ // widget not in the widget chain anymore.
+ _boss->removeWidget(widget);
+
+ Widget::removeWidget(widget);
+}
+
void ContainerWidget::drawWidget() {
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, ThemeEngine::kWidgetBackgroundBorder);
}
diff --git a/gui/widget.h b/gui/widget.h
index bcc9a3f6d3..6f710f302f 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -368,7 +368,10 @@ class ContainerWidget : public Widget {
public:
ContainerWidget(GuiObject *boss, int x, int y, int w, int h);
ContainerWidget(GuiObject *boss, const Common::String &name);
+ ~ContainerWidget();
+ virtual Widget *findWidget(int x, int y);
+ virtual void removeWidget(Widget *widget);
protected:
void drawWidget();
};