summaryrefslogtreecommitdiff
path: root/src/gui/windowcontainer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-11 16:15:10 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-11 16:15:10 +0000
commitcaeba363798727f75972ce6b8625fd9754bee903 (patch)
tree619fbff5801278d5b4f98413e354ea73a87f34bc /src/gui/windowcontainer.cpp
parent24bf86763cdba47e9a88124a3394882667169185 (diff)
downloadmana-caeba363798727f75972ce6b8625fd9754bee903.tar.gz
mana-caeba363798727f75972ce6b8625fd9754bee903.tar.bz2
mana-caeba363798727f75972ce6b8625fd9754bee903.tar.xz
mana-caeba363798727f75972ce6b8625fd9754bee903.zip
Implemented parent relationship for Window class and converted more ok dialogs
to the OkDialog class.
Diffstat (limited to 'src/gui/windowcontainer.cpp')
-rw-r--r--src/gui/windowcontainer.cpp49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/gui/windowcontainer.cpp b/src/gui/windowcontainer.cpp
index c9ce6eff..3367b5f4 100644
--- a/src/gui/windowcontainer.cpp
+++ b/src/gui/windowcontainer.cpp
@@ -23,10 +23,11 @@
#include <iostream>
#include "windowcontainer.h"
+#include "window.h"
WindowContainer::WindowContainer():
mouseDown(false),
- modalWidget(NULL)
+ modalWindow(NULL)
{
}
@@ -84,7 +85,7 @@ void WindowContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
}
if (mWidgetWithMouse && !mWidgetWithMouse->hasFocus() &&
- (!modalWidget || modalWidget == mWidgetWithMouse)) {
+ (!modalWindow || (gcn::Widget*)modalWindow == mWidgetWithMouse)) {
gcn::MouseInput mi = mouseInput;
mi.x -= mWidgetWithMouse->getX();
mi.y -= mWidgetWithMouse->getY();
@@ -96,44 +97,66 @@ void WindowContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
}
}
-void WindowContainer::add(gcn::Widget *widget, bool modal)
+void WindowContainer::add(gcn::Widget *widget)
{
gcn::Container::add(widget);
+}
+
+void WindowContainer::add(Window *window, bool modal)
+{
+ gcn::Container::add(window);
if (modal) {
- setModalWidget(widget);
+ setModalWindow(window);
}
}
void WindowContainer::remove(gcn::Widget *widget)
{
- if (modalWidget == widget) {
- modalWidget = NULL;
+ if (modalWindow == widget) {
+ setModalWindow(NULL);
}
gcn::Container::remove(widget);
}
void WindowContainer::_announceDeath(gcn::Widget *widget)
{
- if (modalWidget == widget) {
- modalWidget = NULL;
+ if (modalWindow == widget) {
+ setModalWindow(NULL);
}
gcn::Container::_announceDeath(widget);
}
void WindowContainer::clear()
{
- modalWidget = NULL;
+ modalWindow = NULL;
gcn::Container::clear();
}
-void WindowContainer::setModalWidget(gcn::Widget *widget)
+void WindowContainer::setModalWindow(Window *window)
{
- modalWidget = widget;
+ if (modalWindow != window) {
+ if (!window) {
+ // Removing modal window, at this point there must be a modal
+ // window set.
+ Window *modalParent = modalWindow->getParentWindow();
+ if (modalParent && modalParent->isModal()) {
+ // Return modality to parent.
+ modalWindow = modalParent;
+ return;
+ }
+ }
+ else if (modalWindow && window->getParentWindow() != modalWindow) {
+ // Adding a modal window, but failed sanity check.
+ std::cerr << "Error: existing modal window not parent.\n";
+ return;
+ }
+ modalWindow = window;
+ }
}
-gcn::Widget *WindowContainer::getModalWidget()
+gcn::Widget *WindowContainer::getModalWindow()
{
- return modalWidget;
+ return modalWindow;
}
void WindowContainer::scheduleDelete(gcn::Widget *widget)