From dd79b36895a17b3da131197be66827e6809615f0 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Thu, 24 Aug 2006 09:33:33 +0000 Subject: Added support for sticky windows as discussed with doener. Patch by AHarrison --- src/gui/chat.cpp | 2 +- src/gui/window.cpp | 21 +++++++++++++++++++++ src/gui/window.h | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 77c44332..f188b90e 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -400,7 +400,7 @@ ChatWindow::setInputText(std::string input_str) void ChatWindow::setVisible(bool isVisible) { - Widget::setVisible(isVisible); + Window::setVisible(isVisible); /* * For whatever reason, if setVisible is called, the mTmpVisible effect diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 9edecfca..fe23c775 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -63,6 +63,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent): mModal(modal), mResizable(false), mMouseResize(false), + mSticky(false), mMinWinWidth(100), mMinWinHeight(28), mMaxWinWidth(INT_MAX), @@ -243,6 +244,26 @@ bool Window::isResizable() return mResizable; } +void Window::setSticky(bool sticky) +{ + mSticky = sticky; +} + +bool Window::isSticky() { + return mSticky; +} + +void Window::setVisible(bool visible) { + if(isSticky()) + { + gcn::Window::setVisible(true); + } + else + { + gcn::Window::setVisible(visible); + } +} + void Window::scheduleDelete() { windowContainer->scheduleDelete(this); diff --git a/src/gui/window.h b/src/gui/window.h index 42ce444c..51c876e3 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -133,6 +133,25 @@ class Window : public gcn::Window */ void setMaxHeight(unsigned int height); + /** + * Sets whether the window is sticky. + * A sticky window will not have its visibility set to false + * on a general setVisible(false) call. + */ + void setSticky(bool sticky); + + /** + * Returns whether the window is sticky. + */ + bool isSticky(); + + /** + * Overloads window setVisible by guichan to allow sticky window + * Handling + */ + + void setVisible(bool visible); + /** * Returns the parent window. * @@ -204,6 +223,7 @@ class Window : public gcn::Window bool mModal; /**< Window is modal */ bool mResizable; /**< Window can be resized */ bool mMouseResize; /**< Window is being resized */ + bool mSticky; /**< Window resists minimzation */ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ int mMaxWinWidth; /**< Maximum window width */ -- cgit v1.2.3-70-g09d2