From 89694323abffb1c73c85d49460991b3e6f20f098 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 23 May 2015 22:11:54 +0300 Subject: Move window variable from widget class to widget2 class. --- src/gui/widgets/basiccontainer.cpp | 1 - src/gui/widgets/popup.cpp | 2 ++ src/gui/widgets/popup.h | 2 +- src/gui/widgets/widget.cpp | 1 - src/gui/widgets/widget.h | 8 -------- src/gui/widgets/widget2.h | 14 ++++++++++++++ src/gui/widgets/window.cpp | 2 ++ src/gui/widgets/window.h | 2 +- 8 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index 271d11925..2ab185a61 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -250,7 +250,6 @@ void BasicContainer::add(Widget *const widget) widget->setFocusHandler(mInternalFocusHandler); widget->setParent(this); - widget->setWindow(getWindow()); widget->addDeathListener(this); } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index a69c7a654..7383ac94b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -53,6 +53,8 @@ Popup::Popup(const std::string &name, { logger->log("Popup::Popup(\"%s\")", name.c_str()); + mWindow = this; + addWidgetListener(this); if (skin == "") diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 1d5bf0492..f39a92ec0 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -172,7 +172,7 @@ class Popup notfinal : public Container, { return mVisible; } virtual void postInit() - { mInit = true; mWindow = this; } + { mInit = true; } protected: int mPadding; /**< Holds the padding of the popup. */ diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index cbf301b27..f6f3854f4 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -96,7 +96,6 @@ 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 f1db2b481..8191754e5 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -199,9 +199,6 @@ 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. * @@ -669,9 +666,6 @@ 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, @@ -1199,8 +1193,6 @@ class Widget notfinal : public Widget2 */ Widget* mParent; - Widget* mWindow; - /** * Holds the font used by the widget. */ diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index c8ee90406..2fdb8b12b 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -23,6 +23,8 @@ #include "gui/theme.h" +class Widget; + class Widget2 notfinal { public: @@ -76,15 +78,27 @@ class Widget2 notfinal mForegroundColor2 = color; } + Widget* getWindow() const A_WARN_UNUSED + { + return mWindow; + } + + virtual void setWindow(Widget *const window) + { + mWindow = window; + } + protected: explicit Widget2(const Widget2 *const widget) : mPaletteOffset(widget ? widget->mPaletteOffset : 0), + mWindow(widget ? widget->getWindow() : nullptr), mForegroundColor2() { checkPalette(); } int mPaletteOffset; + Widget *mWindow; Color mForegroundColor2; }; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 53bf92cc0..657fbcd88 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -155,6 +155,8 @@ Window::Window(const std::string &caption, { logger->log("Window::Window(\"%s\")", caption.c_str()); + mWindow = this; + windowInstances++; // mFrameSize = 1; diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 90d0ade38..83f88f726 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -286,7 +286,7 @@ class Window notfinal : public BasicContainer2, { mSaveVisible = save; } virtual void postInit() - { mInit = true; mWindow = this; } + { mInit = true; } /** * Returns the parent window. -- cgit v1.2.3-70-g09d2