summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2005-04-08 11:55:53 +0000
committerAaron Marks <nymacro@gmail.com>2005-04-08 11:55:53 +0000
commite7c9e87c0ac4c66ac78aa1d03feaccc7533616e8 (patch)
treebb74c1c6b9bf63ceb94cee60b532838ff71b5899 /src/gui/window.cpp
parent722538cb38196237c0d503e8c07b3408c17989bc (diff)
downloadMana-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.tar.gz
Mana-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.tar.bz2
Mana-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.tar.xz
Mana-e7c9e87c0ac4c66ac78aa1d03feaccc7533616e8.zip
Added window resizing.
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp40
1 files changed, 37 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);
+ }
}
}