summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-07 13:18:09 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-07 13:18:09 +0300
commitd2b06398ce43e1ad46078571b41d05df7c1d344b (patch)
treefa9aa0948a09ddd760da07a466abbaedf1cf0179 /src/gui/widgets
parenta7258e25d06f90b10dee8281a65d239c89e5094c (diff)
downloadmanaverse-d2b06398ce43e1ad46078571b41d05df7c1d344b.tar.gz
manaverse-d2b06398ce43e1ad46078571b41d05df7c1d344b.tar.bz2
manaverse-d2b06398ce43e1ad46078571b41d05df7c1d344b.tar.xz
manaverse-d2b06398ce43e1ad46078571b41d05df7c1d344b.zip
Rename exguichan container into basiccontainer2.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/basiccontainer2.cpp131
-rw-r--r--src/gui/widgets/basiccontainer2.h174
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/container.h4
-rw-r--r--src/gui/widgets/layout.cpp2
-rw-r--r--src/gui/widgets/layout.h11
-rw-r--r--src/gui/widgets/layouthelper.cpp4
-rw-r--r--src/gui/widgets/layouthelper.h4
-rw-r--r--src/gui/widgets/tabbedarea.cpp6
-rw-r--r--src/gui/widgets/tabbedarea.h6
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/widgets/window.h4
12 files changed, 327 insertions, 27 deletions
diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp
new file mode 100644
index 000000000..5a34ee0dc
--- /dev/null
+++ b/src/gui/widgets/basiccontainer2.cpp
@@ -0,0 +1,131 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * For comments regarding functions please see the header file.
+ */
+
+#include "gui/widgets/basiccontainer2.h"
+
+#include "render/graphics.h"
+
+#include "debug.h"
+
+BasicContainer2::BasicContainer2(const Widget2 *const widget) :
+ BasicContainer(widget),
+ mOpaque(true)
+{
+}
+
+BasicContainer2::~BasicContainer2()
+{
+}
+
+void BasicContainer2::draw(Graphics* graphics)
+{
+ BLOCK_START("BasicContainer2::draw")
+ if (isOpaque())
+ {
+ graphics->setColor(getBaseColor());
+ graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight()));
+ }
+
+ drawChildren(graphics);
+ BLOCK_END("BasicContainer2::draw")
+}
+
+void BasicContainer2::setOpaque(bool opaque)
+{
+ mOpaque = opaque;
+}
+
+bool BasicContainer2::isOpaque() const
+{
+ return mOpaque;
+}
+
+void BasicContainer2::add(Widget* widget)
+{
+ BasicContainer::add(widget);
+}
+
+void BasicContainer2::add(Widget* widget, int x, int y)
+{
+ widget->setPosition(x, y);
+ BasicContainer::add(widget);
+}
+
+void BasicContainer2::remove(Widget* widget)
+{
+ BasicContainer::remove(widget);
+}
+
+void BasicContainer2::clear()
+{
+ BasicContainer::clear();
+}
+
+Widget* BasicContainer2::findWidgetById(const std::string &id)
+{
+ return BasicContainer::findWidgetById(id);
+}
diff --git a/src/gui/widgets/basiccontainer2.h b/src/gui/widgets/basiccontainer2.h
new file mode 100644
index 000000000..16078016f
--- /dev/null
+++ b/src/gui/widgets/basiccontainer2.h
@@ -0,0 +1,174 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GUI_WIDGETS_BASICCONTAINER2_HPP
+#define GUI_WIDGETS_BASICCONTAINER2_HPP
+
+#include "gui/widgets/basiccontainer.h"
+
+/**
+ * An implementation of a container able to contain other widgets. A widget's
+ * position in the container is relative to the container itself and not the screen.
+ * A container is the most common widget to use as the Gui's top widget as makes the Gui
+ * able to contain more than one widget.
+ *
+ * @see Gui::setTop
+ */
+class BasicContainer2: public BasicContainer
+{
+ public:
+ /**
+ * Constructor. A container is opauqe as default, if you want a
+ * none opaque container call setQpaque(false).
+ *
+ * @see setOpaque, isOpaque
+ */
+ explicit BasicContainer2(const Widget2 *const widget);
+
+ /**
+ * Destructor.
+ */
+ virtual ~BasicContainer2();
+
+ /**
+ * Sets the container to be opaque or not. If the container
+ * is opaque its background will be drawn, if it's not opaque
+ * its background will not be drawn, and thus making the container
+ * completely transparent.
+ *
+ * NOTE: This is not the same as to set visibility. A non visible
+ * container will not itself nor will it draw its content.
+ *
+ * @param opaque True if the container should be opaque, false otherwise.
+ * @see isOpaque
+ */
+ void setOpaque(bool opaque);
+
+ /**
+ * Checks if the container is opaque or not.
+ *
+ * @return True if the container is opaque, false otherwise.
+ * @see setOpaque
+ */
+ bool isOpaque() const;
+
+ /**
+ * Adds a widget to the container.
+ *
+ * @param widget The widget to add.
+ * @see remove, clear
+ */
+ virtual void add(Widget* widget);
+
+ /**
+ * Adds a widget to the container and also specifies the widget's
+ * position in the container. The position is relative to the container
+ * and not relative to the screen.
+ *
+ * @param widget The widget to add.
+ * @param x The x coordinate for the widget.
+ * @param y The y coordinate for the widget.
+ * @see remove, clear
+ */
+ virtual void add(Widget* widget, int x, int y);
+
+ /**
+ * Removes a widget from the Container.
+ *
+ * @param widget The widget to remove.
+ * @throws Exception when the widget has not been added to the
+ * container.
+ * @see add, clear
+ */
+ virtual void remove(Widget* widget);
+
+ /**
+ * Clears the container of all widgets.
+ *
+ * @see add, remove
+ */
+ virtual void clear();
+
+ /**
+ * Finds a widget given an id.
+ *
+ * @param id The id to find a widget by.
+ * @return A widget with a corrosponding id, NULL if no widget
+ * is found.
+ * @see Widget::setId
+ */
+ virtual Widget* findWidgetById(const std::string &id);
+
+
+ // Inherited from Widget
+
+ virtual void draw(Graphics* graphics);
+
+ protected:
+ /**
+ * True if the container is opaque, false otherwise.
+ */
+ bool mOpaque;
+};
+
+#endif // GUI_WIDGETS_BASICCONTAINER2_HPP
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index 93d74dc8d..52d11c4e8 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -27,7 +27,7 @@
#include "debug.h"
Container::Container(const Widget2 *const widget) :
- gcn::Container(widget)
+ BasicContainer2(widget)
{
setOpaque(false);
}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 17d6b2af4..262d7327a 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -23,7 +23,7 @@
#ifndef GUI_WIDGETS_CONTAINER_H
#define GUI_WIDGETS_CONTAINER_H
-#include "gui/base/widgets/container.hpp"
+#include "gui/widgets/basiccontainer2.h"
/**
* A widget container.
@@ -34,7 +34,7 @@
*
* This container is also non-opaque by default.
*/
-class Container : public gcn::Container
+class Container : public BasicContainer2
{
public:
explicit Container(const Widget2 *const widget);
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 24722510b..668334fd5 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -24,7 +24,7 @@
#include "logger.h"
-#include "gui/base/widgets/container.hpp"
+#include "gui/widgets/basiccontainer2.h"
#include <cassert>
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 288c282a0..27af0840d 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -27,13 +27,8 @@
#include <vector>
+class BasicContainer2;
class LayoutCell;
-
-namespace gcn
-{
- class Container;
-}
-
class Widget;
/**
@@ -42,7 +37,7 @@ class Widget;
class ContainerPlacer final
{
public:
- explicit ContainerPlacer(gcn::Container *c = nullptr,
+ explicit ContainerPlacer(BasicContainer2 *c = nullptr,
LayoutCell *lc = nullptr) :
mContainer(c), mCell(lc)
{}
@@ -66,7 +61,7 @@ class ContainerPlacer final
const int w = 1, const int h = 1);
private:
- gcn::Container *mContainer;
+ BasicContainer2 *mContainer;
LayoutCell *mCell;
};
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index c225c7543..a8cf28bea 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -22,11 +22,11 @@
#include "gui/widgets/layouthelper.h"
-#include "gui/base/widgets/container.hpp"
+#include "gui/widgets/basiccontainer2.h"
#include "debug.h"
-LayoutHelper::LayoutHelper(gcn::Container *const container) :
+LayoutHelper::LayoutHelper(BasicContainer2 *const container) :
WidgetListener(),
mLayout(),
mContainer(container)
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index 32e3d9e34..78e34f419 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -38,7 +38,7 @@ class LayoutHelper final : public WidgetListener
/**
* Constructor.
*/
- explicit LayoutHelper(gcn::Container *const container);
+ explicit LayoutHelper(BasicContainer2 *const container);
A_DELETE_COPY(LayoutHelper)
@@ -82,7 +82,7 @@ class LayoutHelper final : public WidgetListener
private:
Layout mLayout; /**< Layout handler */
- gcn::Container *mContainer; /**< Managed container */
+ BasicContainer2 *mContainer; /**< Managed container */
};
#endif // GUI_WIDGETS_LAYOUTHELPER_H
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 5d125cadd..c075cbc62 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -75,7 +75,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabs/tab.h"
-#include "gui/base/widgets/container.hpp"
+#include "gui/widgets/basiccontainer2.h"
#include "debug.h"
@@ -86,8 +86,8 @@ TabbedArea::TabbedArea(const Widget2 *const widget) :
MouseListener(),
WidgetListener(),
mSelectedTab(nullptr),
- mTabContainer(new gcn::Container(widget)),
- mWidgetContainer(new gcn::Container(widget)),
+ mTabContainer(new BasicContainer2(widget)),
+ mWidgetContainer(new BasicContainer2(widget)),
mTabsToDelete(),
mTabs(),
mTabsWidth(0),
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 11f3a46d3..0e7a032f0 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -70,7 +70,7 @@
#include "listeners/mouselistener.h"
#include "listeners/widgetlistener.h"
-#include "gui/base/widgets/container.hpp"
+#include "gui/widgets/basiccontainer2.h"
#include "listeners/actionlistener.h"
@@ -251,8 +251,8 @@ class TabbedArea final : public ActionListener,
void updateTabsWidth();
Tab* mSelectedTab;
- gcn::Container* mTabContainer;
- gcn::Container* mWidgetContainer;
+ BasicContainer2* mTabContainer;
+ BasicContainer2* mWidgetContainer;
std::vector<Tab*> mTabsToDelete;
TabContainer mTabs;
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index ec83af9a8..5a636013b 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -91,7 +91,7 @@ int Window::mouseResize = 0;
Window::Window(const std::string &caption, const bool modal,
Window *const parent, std::string skin) :
- gcn::Container(nullptr),
+ BasicContainer2(nullptr),
MouseListener(),
WidgetListener(),
mCaption(caption),
@@ -668,9 +668,9 @@ void Window::setVisible(const bool visible, const bool forceSticky)
mResizeHandles = 0;
if (mStickyButtonLock)
- gcn::Container::setVisible(visible);
+ BasicContainer2::setVisible(visible);
else
- gcn::Container::setVisible((!forceSticky && mSticky) || visible);
+ BasicContainer2::setVisible((!forceSticky && mSticky) || visible);
if (visible)
{
if (mPlayVisibleSound)
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 6369990bb..3a9bf2157 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -71,7 +71,7 @@
#include "listeners/mouselistener.h"
#include "listeners/widgetlistener.h"
-#include "gui/base/widgets/container.hpp"
+#include "gui/widgets/basiccontainer2.h"
#include "localconsts.h"
@@ -88,7 +88,7 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Window : public gcn::Container,
+class Window : public BasicContainer2,
public MouseListener,
private WidgetListener
{