summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-08-16 10:11:33 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-08-16 10:11:33 +0000
commitf6fabeacc35b67ca0a44bf50cf6ca7d2378c289d (patch)
tree636fa896306452cd0ccbe9febdb855d29ddaf74f /src/gui
parent9e6c0ca8f20f5ba4cbfafe19938d0bb34d6ee031 (diff)
downloadmana-f6fabeacc35b67ca0a44bf50cf6ca7d2378c289d.tar.gz
mana-f6fabeacc35b67ca0a44bf50cf6ca7d2378c289d.tar.bz2
mana-f6fabeacc35b67ca0a44bf50cf6ca7d2378c289d.tar.xz
mana-f6fabeacc35b67ca0a44bf50cf6ca7d2378c289d.zip
Added a resize grip to resizable window, fixed some compiling errors.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/status.cpp2
-rw-r--r--src/gui/window.cpp33
-rw-r--r--src/gui/window.h9
-rw-r--r--src/gui/windowcontainer.h2
4 files changed, 37 insertions, 9 deletions
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 3c12fd42..eb20dcd5 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -131,6 +131,8 @@ StatusWindow::StatusWindow():
add(inventoryButton);
add(setupButton);
add(equipmentButton);
+
+ setResizable(true);
}
StatusWindow::~StatusWindow()
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 07b85ea5..67bd224f 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -21,10 +21,9 @@
* $Id$
*/
-#include "window.h"
-
#include <guichan/exception.hpp>
+#include "window.h"
#include "windowcontainer.h"
#include "../configuration.h"
@@ -39,6 +38,7 @@
WindowContainer *Window::windowContainer = NULL;
int Window::instances = 0;
ImageRect Window::border;
+Image *Window::resizeGrip;
Window::Window(const std::string& caption, bool modal, Window *parent):
gcn::Window(caption),
@@ -69,6 +69,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
border.grid[6] = dBorders->getSubImage(0, 15, 4, 4);
border.grid[7] = dBorders->getSubImage(4, 15, 3, 4);
border.grid[8] = dBorders->getSubImage(7, 15, 4, 4);
+ resizeGrip = resman->getImage("graphics/gui/resize.png");
dBorders->decRef();
}
@@ -138,6 +139,17 @@ void Window::draw(gcn::Graphics* graphics)
dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, getWidth(), getHeight(),
border);
+ // Draw grip
+ if (resizable)
+ {
+ dynamic_cast<Graphics*>(graphics)->drawImage(Window::resizeGrip,
+ x + getWidth() - 18,
+ y + getHeight() - 15);
+ }
+
+
+
+
// Draw title
if (title) {
graphics->setFont(getFont());
@@ -236,7 +248,7 @@ void Window::mousePress(int x, int y, int button)
// If the mouse is not inside the content, the press must have been on the
// border, and is a candidate for a resize.
if (getResizable() && button == 1 &&
- !getContentDimension().isPointInRect(x, y) &&
+ getGripDimension().isPointInRect(x, y) &&
!(mMouseDrag && y > (int)getPadding()))
{
mMouseResize = true;
@@ -244,10 +256,10 @@ void Window::mousePress(int x, int y, int button)
mMouseYOffset = y;
// Determine which borders are being dragged
- mLeftBorderDrag = (x < 10);
- mTopBorderDrag = (y < 10);
- mRightBorderDrag = (x >= getWidth() - 10);
- mBottomBorderDrag = (y >= getHeight() - 10);
+ mLeftBorderDrag = false;//(x < 10);
+ mTopBorderDrag = false;//(y < 10);*/
+ mRightBorderDrag = true;//(x >= getWidth() - 10);
+ mBottomBorderDrag = true;//(y >= getHeight() - 10);
}
}
@@ -410,3 +422,10 @@ void Window::optionChanged(const std::string &name)
}
}
}
+
+gcn::Rectangle Window::getGripDimension () {
+ int x, y;
+ getAbsolutePosition(x, y);
+ return gcn::Rectangle(getWidth() - 18, getHeight() - 15, getWidth(),
+ getHeight());
+}
diff --git a/src/gui/window.h b/src/gui/window.h
index 731b7e9d..e9567762 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -25,10 +25,13 @@
#define _TMW_WINDOW_H__
#include <guichan/widgets/window.hpp>
+#include <guichan/rectangle.hpp>
#include "../configlistener.h"
#include "../guichanfwd.h"
+#include "../resources/image.h"
+
class ImageRect;
class WindowContainer;
@@ -154,6 +157,11 @@ class Window : public gcn::Window, public ConfigListener
* Called when an config option changes.
*/
void optionChanged(const std::string &name);
+
+ /**
+ * The position of the resize grip
+ */
+ gcn::Rectangle getGripDimension();
protected:
gcn::Container *chrome; /**< Contained container */
@@ -179,6 +187,7 @@ class Window : public gcn::Window, public ConfigListener
static int instances; /**< Number of Window instances */
static ImageRect border; /**< The window border and background */
+ static Image *resizeGrip; /**< The grip to resize window */
};
#endif
diff --git a/src/gui/windowcontainer.h b/src/gui/windowcontainer.h
index f41a4a33..533e42e4 100644
--- a/src/gui/windowcontainer.h
+++ b/src/gui/windowcontainer.h
@@ -26,8 +26,6 @@
#include <guichan/widgets/container.hpp>
-class Window;
-
/**
* A window container. This container makes draggable windows possible.
*