From 773ef01f1490f0884836a9d08f75938eb8742c8e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 21 May 2015 21:22:17 +0300 Subject: Add parent window field to all widgets. --- src/gui/widgets/basiccontainer.cpp | 3 +++ src/gui/widgets/widget.cpp | 1 + src/gui/widgets/widget.h | 8 ++++++++ 3 files changed, 12 insertions(+) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index 64cb650cd..271d11925 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -250,6 +250,7 @@ void BasicContainer::add(Widget *const widget) widget->setFocusHandler(mInternalFocusHandler); widget->setParent(this); + widget->setWindow(getWindow()); widget->addDeathListener(this); } @@ -261,6 +262,7 @@ void BasicContainer::remove(Widget* widget) { mWidgets.erase(iter); widget->setFocusHandler(nullptr); + widget->setWindow(nullptr); widget->setParent(nullptr); widget->removeDeathListener(this); break; @@ -282,6 +284,7 @@ void BasicContainer::clear() { Widget *const widget = *iter; widget->setFocusHandler(nullptr); + widget->setWindow(nullptr); widget->setParent(nullptr); widget->removeDeathListener(this); } diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index 667f88655..70aac5aa2 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -96,6 +96,7 @@ Widget::Widget(const Widget2 *const widget) : mFocusHandler(nullptr), mInternalFocusHandler(nullptr), mParent(nullptr), + mWindow(nullptr), mCurrentFont(nullptr), mFrameSize(0), mFocusable(false), diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 8191754e5..f1db2b481 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -199,6 +199,9 @@ class Widget notfinal : public Widget2 Widget* getParent() const A_WARN_UNUSED { return mParent; } + Widget* getWindow() const A_WARN_UNUSED + { return mWindow; } + /** * Sets the width of the widget. * @@ -666,6 +669,9 @@ class Widget notfinal : public Widget2 virtual void setParent(Widget* parent) { mParent = parent; } + virtual void setWindow(Widget* window) + { mWindow = window; } + /** * Gets the font set for the widget. If no font has been set, * the global font will be returned. If no global font has been set, @@ -1193,6 +1199,8 @@ class Widget notfinal : public Widget2 */ Widget* mParent; + Widget* mWindow; + /** * Holds the font used by the widget. */ -- cgit v1.2.3-70-g09d2