summaryrefslogtreecommitdiff
path: root/src/gui/windowcontainer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-08 01:33:53 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-08 01:33:53 +0000
commitee416a5f3de03a689247a290077e7fdf451e1a23 (patch)
treef456df99f954919ac7a425606df51f010aa4ef2d /src/gui/windowcontainer.cpp
parent4070dda1560bc729c3e272f0a5c03d77391e2661 (diff)
downloadmana-ee416a5f3de03a689247a290077e7fdf451e1a23.tar.gz
mana-ee416a5f3de03a689247a290077e7fdf451e1a23.tar.bz2
mana-ee416a5f3de03a689247a290077e7fdf451e1a23.tar.xz
mana-ee416a5f3de03a689247a290077e7fdf451e1a23.zip
Well improved window container and window widgets a bit, and made a start
on support for modal dialogs. Still some issues to work out. Tell me if you experience something unsettling.
Diffstat (limited to 'src/gui/windowcontainer.cpp')
-rw-r--r--src/gui/windowcontainer.cpp75
1 files changed, 66 insertions, 9 deletions
diff --git a/src/gui/windowcontainer.cpp b/src/gui/windowcontainer.cpp
index 460b99e5..c9ce6eff 100644
--- a/src/gui/windowcontainer.cpp
+++ b/src/gui/windowcontainer.cpp
@@ -21,14 +21,26 @@
* $Id$
*/
+#include <iostream>
#include "windowcontainer.h"
WindowContainer::WindowContainer():
- gcn::Container(),
- mouseDown(false)
+ mouseDown(false),
+ modalWidget(NULL)
{
}
+void WindowContainer::logic()
+{
+ std::list<gcn::Widget*>::iterator i = deathList.begin();
+ while (i != deathList.end()) {
+ delete (*i);
+ i = deathList.erase(i);
+ }
+
+ gcn::Container::logic();
+}
+
void WindowContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
{
if (mouseInput.getType() == gcn::MouseInput::PRESS)
@@ -40,19 +52,18 @@ void WindowContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
mouseDown = false;
}
- /*
- * Make drag events not change widget with mouse. The Window instances
- * need this behaviour to be able to handle window dragging.
- */
+ // Make drag events not change widget with mouse. The Window instances
+ // need this behaviour to be able to handle window dragging.
if (!(mouseInput.getType() == gcn::MouseInput::MOTION && mouseDown))
{
Widget* tempWidgetWithMouse = NULL;
- WidgetIterator iter;
+ WidgetIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
{
if ((*iter)->getDimension().isPointInRect(
- mouseInput.x, mouseInput.y) && (*iter)->isVisible())
+ mouseInput.x, mouseInput.y) &&
+ (*iter)->isVisible())
{
tempWidgetWithMouse = (*iter);
}
@@ -72,7 +83,8 @@ void WindowContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
}
}
- if (mWidgetWithMouse && !mWidgetWithMouse->hasFocus()) {
+ if (mWidgetWithMouse && !mWidgetWithMouse->hasFocus() &&
+ (!modalWidget || modalWidget == mWidgetWithMouse)) {
gcn::MouseInput mi = mouseInput;
mi.x -= mWidgetWithMouse->getX();
mi.y -= mWidgetWithMouse->getY();
@@ -83,3 +95,48 @@ void WindowContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
gcn::Widget::_mouseInputMessage(mouseInput);
}
}
+
+void WindowContainer::add(gcn::Widget *widget, bool modal)
+{
+ gcn::Container::add(widget);
+ if (modal) {
+ setModalWidget(widget);
+ }
+}
+
+void WindowContainer::remove(gcn::Widget *widget)
+{
+ if (modalWidget == widget) {
+ modalWidget = NULL;
+ }
+ gcn::Container::remove(widget);
+}
+
+void WindowContainer::_announceDeath(gcn::Widget *widget)
+{
+ if (modalWidget == widget) {
+ modalWidget = NULL;
+ }
+ gcn::Container::_announceDeath(widget);
+}
+
+void WindowContainer::clear()
+{
+ modalWidget = NULL;
+ gcn::Container::clear();
+}
+
+void WindowContainer::setModalWidget(gcn::Widget *widget)
+{
+ modalWidget = widget;
+}
+
+gcn::Widget *WindowContainer::getModalWidget()
+{
+ return modalWidget;
+}
+
+void WindowContainer::scheduleDelete(gcn::Widget *widget)
+{
+ deathList.push_back(widget);
+}