From e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8 Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Fri, 8 Apr 2005 11:55:53 +0000 Subject: Added window resizing. --- src/gui/window.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src/gui/window.cpp') 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); + } } } -- cgit v1.2.3-70-g09d2