summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
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;
+ }
+}