summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-03-01 15:47:15 -0700
committerJared Adams <jaxad0127@gmail.com>2010-03-01 17:26:24 -0700
commit67e678094b9fddd21fb3c690130e772937ab2746 (patch)
tree75b2ee140dcdc1e5be24f47f38ec724a47df7103 /src/gui/widgets
parent3acb148b6d5fe3b342e4397e2c7de020de6005ff (diff)
downloadmana-client-67e678094b9fddd21fb3c690130e772937ab2746.tar.gz
mana-client-67e678094b9fddd21fb3c690130e772937ab2746.tar.bz2
mana-client-67e678094b9fddd21fb3c690130e772937ab2746.tar.xz
mana-client-67e678094b9fddd21fb3c690130e772937ab2746.zip
Merge WindowContainer into Viewport and remove extra members
Reviewed-by: Chuck Miller
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/popup.cpp23
-rw-r--r--src/gui/widgets/popup.h8
-rw-r--r--src/gui/widgets/window.cpp21
-rw-r--r--src/gui/widgets/window.h6
-rw-r--r--src/gui/widgets/windowcontainer.cpp39
-rw-r--r--src/gui/widgets/windowcontainer.h59
6 files changed, 12 insertions, 144 deletions
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 970b21ec..1bfd7fd2 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -29,8 +29,6 @@
#include "gui/skin.h"
#include "gui/viewport.h"
-#include "gui/widgets/windowcontainer.h"
-
#include "resources/image.h"
#include <guichan/exception.hpp>
@@ -45,16 +43,16 @@ Popup::Popup(const std::string &name, const std::string &skin):
{
logger->log("Popup::Popup(\"%s\")", name.c_str());
- if (!windowContainer)
- throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
+ if (!viewport)
+ throw GCN_EXCEPTION("Popup::Popup(): no viewport set");
setPadding(3);
// Loads the skin
mSkin = SkinLoader::instance()->load(skin, mDefaultSkinPath);
- // Add this window to the window container
- windowContainer->add(this);
+ // Add this window to the viewport
+ viewport->add(this);
// Popups are invisible by default
setVisible(false);
@@ -69,11 +67,6 @@ Popup::~Popup()
mSkin->instances--;
}
-void Popup::setWindowContainer(WindowContainer *wc)
-{
- windowContainer = wc;
-}
-
void Popup::loadPopupConfiguration()
{
if (mPopupName.empty())
@@ -168,7 +161,7 @@ void Popup::setMaxHeight(int height)
void Popup::scheduleDelete()
{
- windowContainer->scheduleDelete(this);
+ viewport->scheduleDelete(this);
}
void Popup::position(int x, int y)
@@ -187,9 +180,3 @@ void Popup::position(int x, int y)
setVisible(true);
requestMoveToTop();
}
-
-void Popup::mouseMoved(gcn::MouseEvent &event)
-{
- if (viewport)
- viewport->hideBeingPopup();
-}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 5c9164f6..dfa9b2fa 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -31,7 +31,6 @@
#include <guichan/mouselistener.hpp>
class Skin;
-class WindowContainer;
/**
* A light version of the Window class. Particularly suited for popup type
@@ -65,11 +64,6 @@ class Popup : public Container, public gcn::MouseListener
~Popup();
/**
- * Sets the window container to be used by new popups.
- */
- static void setWindowContainer(WindowContainer *windowContainer);
-
- /**
* Changes the popup's skin to use the skin defined in the saved
* configuration file.
*/
@@ -96,8 +90,6 @@ class Popup : public Container, public gcn::MouseListener
*/
void setLocationRelativeTo(gcn::Widget *widget);
- void mouseMoved(gcn::MouseEvent &event);
-
/**
* Sets the minimum width of the popup.
*/
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 83c918cf..4d70df84 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -31,7 +31,6 @@
#include "gui/widgets/layout.h"
#include "gui/widgets/resizegrip.h"
-#include "gui/widgets/windowcontainer.h"
#include "resources/image.h"
@@ -63,8 +62,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
{
logger->log("Window::Window(\"%s\")", caption.c_str());
- if (!windowContainer)
- throw GCN_EXCEPTION("Window::Window(): no windowContainer set");
+ if (!viewport)
+ throw GCN_EXCEPTION("Window::Window(): no viewport set");
instances++;
@@ -75,8 +74,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
// Loads the skin
mSkin = SkinLoader::instance()->load(skin, mDefaultSkinPath);
- // Add this window to the window container
- windowContainer->add(this);
+ // Add this window to the viewport
+ viewport->add(this);
if (mModal)
{
@@ -88,6 +87,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
setVisible(false);
addWidgetListener(this);
+
+ setFocusable(true);
}
Window::~Window()
@@ -108,11 +109,6 @@ Window::~Window()
mSkin->instances--;
}
-void Window::setWindowContainer(WindowContainer *wc)
-{
- windowContainer = wc;
-}
-
void Window::draw(gcn::Graphics *graphics)
{
Graphics *g = static_cast<Graphics*>(graphics);
@@ -336,7 +332,7 @@ void Window::setVisible(bool visible, bool forceSticky)
void Window::scheduleDelete()
{
- windowContainer->scheduleDelete(this);
+ viewport->scheduleDelete(this);
}
void Window::mousePressed(gcn::MouseEvent &event)
@@ -431,9 +427,6 @@ void Window::mouseMoved(gcn::MouseEvent &event)
default:
gui->setCursorType(Gui::CURSOR_POINTER);
}
-
- if (viewport)
- viewport->hideBeingPopup();
}
void Window::mouseDragged(gcn::MouseEvent &event)
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index b72be9d4..3c458efe 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -34,7 +34,6 @@ class Layout;
class LayoutCell;
class ResizeGrip;
class Skin;
-class WindowContainer;
/**
* A window. This window can be dragged around and has a title bar. Windows are
@@ -65,11 +64,6 @@ class Window : public gcn::Window, gcn::WidgetListener
~Window();
/**
- * Sets the window container to be used by new windows.
- */
- static void setWindowContainer(WindowContainer *windowContainer);
-
- /**
* Draws the window.
*/
void draw(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
deleted file mode 100644
index 7d5ecd37..00000000
--- a/src/gui/widgets/windowcontainer.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "utils/dtor.h"
-
-WindowContainer *windowContainer = NULL;
-
-void WindowContainer::logic()
-{
- delete_all(mDeathList);
- mDeathList.clear();
-
- gcn::Container::logic();
-}
-
-void WindowContainer::scheduleDelete(gcn::Widget *widget)
-{
- mDeathList.push_back(widget);
-}
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
deleted file mode 100644
index 2ec65d15..00000000
--- a/src/gui/widgets/windowcontainer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef WINDOWCONTAINER_H
-#define WINDOWCONTAINER_H
-
-#include "gui/widgets/container.h"
-
-/**
- * A window container. This container adds functionality for more convenient
- * widget (windows in particular) destruction.
- *
- * \ingroup GUI
- */
-class WindowContainer : public Container
-{
- public:
- /**
- * Do GUI logic. This functions adds automatic deletion of objects that
- * volunteered to be deleted.
- */
- void logic();
-
- /**
- * Schedule a widget for deletion. It will be deleted at the start of
- * the next logic update.
- */
- void scheduleDelete(gcn::Widget *widget);
-
- private:
- /**
- * List of widgets that are scheduled to be deleted.
- */
- typedef std::list<gcn::Widget*> Widgets;
- typedef Widgets::iterator WidgetIterator;
- Widgets mDeathList;
-};
-
-extern WindowContainer *windowContainer;
-
-#endif