From 55786731e0517efdc123d4e8245b2aa94fa55cbe Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 28 Aug 2007 00:01:38 +0000 Subject: Made buy dialog resizable and added a WindowListener class for listening for window resize and move events. --- src/gui/window.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src/gui/window.cpp') 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; + } +} -- cgit v1.2.3-70-g09d2