diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-04-08 11:55:53 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-04-08 11:55:53 +0000 |
commit | e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8 (patch) | |
tree | bb74c1c6b9bf63ceb94cee60b532838ff71b5899 | |
parent | 722538cb38196237c0d503e8c07b3408c17989bc (diff) | |
download | mana-client-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.tar.gz mana-client-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.tar.bz2 mana-client-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.tar.xz mana-client-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.zip |
Added window resizing.
-rw-r--r-- | src/gui/window.cpp | 40 | ||||
-rw-r--r-- | src/gui/window.h | 24 |
2 files changed, 61 insertions, 3 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index c24b50ab..ee2474ba 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -32,7 +32,10 @@ Window::Window(const std::string& caption, bool modal, Window *parent): gcn::Window(caption), parent(parent), snapSize(8), - modal(modal) + modal(modal), + minWinWidth(256), + minWinHeight(128), + isWinResizeable(false) { logger.log("Window::Window(\"%s\")", caption.c_str()); @@ -156,6 +159,26 @@ void Window::setContentSize(int width, int height) setContentHeight(height); } +void Window::setMinWidth(unsigned int width) +{ + minWinWidth = width; +} + +void Window::setMinHeight(unsigned int height) +{ + minWinHeight = height; +} + +void Window::setResizeable(bool r) +{ + isWinResizeable = r; +} + +bool Window::getResizeable() +{ + return isWinResizeable; +} + Window *Window::getParentWindow() { return parent; @@ -194,8 +217,19 @@ void Window::mouseMotion(int mx, int my) //if (y < snapSize) y = 0; //if (x + winWidth + snapSize > screen->w) x = screen->w - winWidth; //if (y + winHeight + snapSize > screen->h) y = screen->h - winHeight; - - setPosition(x, y); + + if (isWinResizeable && mx > getWidth() - 16) { + //resize + if (mx < minWinWidth) + mx = minWinWidth; + if (my < minWinHeight) + my = minWinHeight; + setWidth(mx); + setHeight(my); + } else { + //move + setPosition(x, y); + } } } diff --git a/src/gui/window.h b/src/gui/window.h index 972c58cd..33c7f5b8 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -50,6 +50,10 @@ class Window : public gcn::Window, public ConfigListener ImageRect border; /**< The window border */ + bool isWinResizeable; /**< Window can be resized */ + int minWinWidth; /**< Minimum window width */ + int minWinHeight; /**< Minimum window height */ + /** The window container windows add themselves to. */ static WindowContainer* windowContainer; @@ -117,6 +121,26 @@ class Window : public gcn::Window, public ConfigListener */ void setContentSize(int width, int height); + /** + * Sets whether of not the window can be resized + */ + void setResizeable(bool resize); + + /** + * Returns the current value of isResizable + */ + bool getResizeable(); + + /** + * Sets the minimum width of the window + */ + void setMinWidth(unsigned int width); + + /** + * Sets the minimum height of the window + */ + void setMinHeight(unsigned int height); + /** * Returns the parent window. * |