summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-08-28 00:01:38 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-08-28 00:01:38 +0000
commit55786731e0517efdc123d4e8245b2aa94fa55cbe (patch)
tree17d64454f3daeb9f55241e8c9a95b5671f2da023 /src/gui/window.cpp
parent76291862ce0e26040f251bc4764539d8ff6634a0 (diff)
downloadmana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.gz
mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.bz2
mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.xz
mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.zip
Made buy dialog resizable and added a WindowListener class for listening for
window resize and move events.
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 8cacd23e..650016cb 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -220,6 +220,8 @@ void Window::setWidth(int width)
{
mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x);
}
+
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
}
void Window::setHeight(int height)
@@ -230,6 +232,8 @@ void Window::setHeight(int height)
{
mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y);
}
+
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
}
void Window::setDimension(const gcn::Rectangle &dimension)
@@ -241,9 +245,30 @@ void Window::setDimension(const gcn::Rectangle &dimension)
mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x);
mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y);
}
+
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
+}
+
+void Window::setPosition(int x, int y)
+{
+ gcn::Window::setPosition(x, y);
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
+}
+
+void Window::setX(int x)
+{
+ gcn::Window::setX(x);
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
+}
+
+void Window::setY(int y)
+{
+ gcn::Window::setY(y);
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
}
-void Window::setLocationRelativeTo(gcn::Widget* widget)
+void Window::setLocationRelativeTo(gcn::Widget *widget)
{
int wx, wy;
int x, y;
@@ -561,3 +586,21 @@ int Window::getResizeHandles(gcn::MouseEvent &event)
return resizeHandles;
}
+
+void Window::fireWindowEvent(const WindowEvent &event)
+{
+ WindowListeners::iterator i_end = mListeners.end();
+ WindowListeners::iterator i = mListeners.begin();
+
+ switch (event.getType())
+ {
+ case WindowEvent::WINDOW_MOVED:
+ for (; i != i_end; ++i)
+ { (*i)->windowMoved(event); }
+ break;
+ case WindowEvent::WINDOW_RESIZED:
+ for (; i != i_end; ++i)
+ { (*i)->windowResized(event); }
+ break;
+ }
+}