summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-22 15:43:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-22 15:43:12 +0300
commit4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06 (patch)
tree22b6f851e3ac90590828761a79e91fe1512c2adf
parent2c110bf45eb53807378bbd2abf70268aa0c2197f (diff)
downloadmv-4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06.tar.gz
mv-4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06.tar.bz2
mv-4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06.tar.xz
mv-4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06.zip
Move Widget into gui/widgets directory.
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/events/actionevent.h7
-rw-r--r--src/events/event.h11
-rw-r--r--src/events/inputguievent.h2
-rw-r--r--src/events/keyevent.h7
-rw-r--r--src/events/mouseevent.h5
-rw-r--r--src/events/selectionevent.h7
-rw-r--r--src/gui/base/basiccontainer.hpp2
-rw-r--r--src/gui/base/gui.cpp2
-rw-r--r--src/gui/base/gui.hpp3
-rw-r--r--src/gui/base/widget.cpp679
-rw-r--r--src/gui/base/widget.hpp1231
-rw-r--r--src/gui/base/widgets/button.cpp4
-rw-r--r--src/gui/base/widgets/button.hpp2
-rw-r--r--src/gui/base/widgets/checkbox.cpp4
-rw-r--r--src/gui/base/widgets/checkbox.hpp2
-rw-r--r--src/gui/base/widgets/label.cpp4
-rw-r--r--src/gui/base/widgets/label.hpp2
-rw-r--r--src/gui/base/widgets/listbox.cpp4
-rw-r--r--src/gui/base/widgets/listbox.hpp2
-rw-r--r--src/gui/base/widgets/radiobutton.cpp4
-rw-r--r--src/gui/base/widgets/radiobutton.hpp2
-rw-r--r--src/gui/base/widgets/slider.cpp4
-rw-r--r--src/gui/base/widgets/slider.hpp2
-rw-r--r--src/gui/base/widgets/textbox.cpp4
-rw-r--r--src/gui/base/widgets/textbox.hpp2
-rw-r--r--src/gui/base/widgets/textfield.cpp4
-rw-r--r--src/gui/base/widgets/textfield.hpp2
-rw-r--r--src/gui/focushandler.cpp56
-rw-r--r--src/gui/focushandler.h68
-rw-r--r--src/gui/gui.cpp22
-rw-r--r--src/gui/gui.h6
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp2
-rw-r--r--src/gui/widgets/browserbox.h5
-rw-r--r--src/gui/widgets/browserbox_unittest.cc2
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/container.h2
-rw-r--r--src/gui/widgets/emotepage.cpp2
-rw-r--r--src/gui/widgets/emotepage.h4
-rw-r--r--src/gui/widgets/flowcontainer.cpp2
-rw-r--r--src/gui/widgets/flowcontainer.h2
-rw-r--r--src/gui/widgets/guitable.cpp30
-rw-r--r--src/gui/widgets/guitable.h12
-rw-r--r--src/gui/widgets/horizontcontainer.cpp4
-rw-r--r--src/gui/widgets/horizontcontainer.h4
-rw-r--r--src/gui/widgets/icon.cpp4
-rw-r--r--src/gui/widgets/icon.h4
-rw-r--r--src/gui/widgets/itemcontainer.cpp4
-rw-r--r--src/gui/widgets/itemcontainer.h4
-rw-r--r--src/gui/widgets/layout.cpp4
-rw-r--r--src/gui/widgets/layout.h11
-rw-r--r--src/gui/widgets/layouthelper.cpp2
-rw-r--r--src/gui/widgets/layouthelper.h2
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/popup.h2
-rw-r--r--src/gui/widgets/popuplist.cpp2
-rw-r--r--src/gui/widgets/progressbar.cpp2
-rw-r--r--src/gui/widgets/progressbar.h4
-rw-r--r--src/gui/widgets/progressindicator.cpp2
-rw-r--r--src/gui/widgets/progressindicator.h4
-rw-r--r--src/gui/widgets/radiogroup.cpp2
-rw-r--r--src/gui/widgets/radiogroup.h6
-rw-r--r--src/gui/widgets/scrollarea.cpp10
-rw-r--r--src/gui/widgets/scrollarea.h2
-rw-r--r--src/gui/widgets/setupitem.cpp2
-rw-r--r--src/gui/widgets/setupitem.h10
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/shortcutcontainer.h5
-rw-r--r--src/gui/widgets/tabbedarea.cpp34
-rw-r--r--src/gui/widgets/tabbedarea.h16
-rw-r--r--src/gui/widgets/tablemodel.cpp8
-rw-r--r--src/gui/widgets/tablemodel.h13
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp6
-rw-r--r--src/gui/widgets/tabstrip.cpp4
-rw-r--r--src/gui/widgets/tabstrip.h6
-rw-r--r--src/gui/widgets/textbox.cpp4
-rw-r--r--src/gui/widgets/textpreview.cpp2
-rw-r--r--src/gui/widgets/textpreview.h4
-rw-r--r--src/gui/widgets/vertcontainer.cpp6
-rw-r--r--src/gui/widgets/vertcontainer.h6
-rw-r--r--src/gui/widgets/widget.cpp676
-rw-r--r--src/gui/widgets/widget.h1228
-rw-r--r--src/gui/widgets/widgetgroup.cpp2
-rw-r--r--src/gui/widgets/widgetgroup.h2
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/widgets/window.h6
-rw-r--r--src/gui/widgets/windowcontainer.cpp6
-rw-r--r--src/gui/widgets/windowcontainer.h8
-rw-r--r--src/gui/windows/botcheckerwindow.cpp8
-rw-r--r--src/gui/windows/charselectdialog.cpp2
-rw-r--r--src/gui/windows/chatwindow.cpp2
-rw-r--r--src/gui/windows/inventorywindow.cpp2
-rw-r--r--src/gui/windows/socialwindow.cpp2
96 files changed, 2185 insertions, 2207 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 69304d442..cfab9cccb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -783,7 +783,7 @@ SET(SRCS
events/selectionevent.h
listeners/selectionlistener.h
utils/sdlpixel.h
- gui/base/widget.hpp
+ gui/widgets/widget.h
listeners/widgetlistener.h
gui/base/widgets/button.hpp
gui/base/widgets/checkbox.hpp
@@ -802,7 +802,7 @@ SET(SRCS
gui/base/gui.cpp
input/key.cpp
gui/rectangle.cpp
- gui/base/widget.cpp
+ gui/widgets/widget.cpp
gui/base/widgets/button.cpp
gui/base/widgets/checkbox.cpp
gui/base/widgets/container.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b03f22f0..eba67d244 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -169,7 +169,7 @@ manaplus_SOURCES += events/actionevent.h \
events/selectionevent.h \
listeners/selectionlistener.h \
utils/sdlpixel.h \
- gui/base/widget.hpp \
+ gui/widgets/widget.h \
listeners/widgetlistener.h \
gui/base/widgets/button.hpp \
gui/base/widgets/checkbox.hpp \
@@ -188,7 +188,7 @@ manaplus_SOURCES += events/actionevent.h \
gui/base/gui.cpp \
input/key.cpp \
gui/rectangle.cpp \
- gui/base/widget.cpp \
+ gui/widgets/widget.cpp \
gui/base/widgets/button.cpp \
gui/base/widgets/checkbox.cpp \
gui/base/widgets/container.cpp \
diff --git a/src/events/actionevent.h b/src/events/actionevent.h
index 3164955e6..25f936cdd 100644
--- a/src/events/actionevent.h
+++ b/src/events/actionevent.h
@@ -70,10 +70,7 @@
#include "localconsts.h"
-namespace GCN
-{
- class Widget;
-}
+class Widget;
/**
* Represents an action event. An action event is an event
@@ -106,7 +103,7 @@ class ActionEvent final : public Event
* @param source The source widget of the event.
* @param id An identifier of the event.
*/
- ActionEvent(gcn::Widget *const source, const std::string &id) :
+ ActionEvent(Widget *const source, const std::string &id) :
Event(source),
mId(id)
{
diff --git a/src/events/event.h b/src/events/event.h
index b71d0edd4..63ccb207d 100644
--- a/src/events/event.h
+++ b/src/events/event.h
@@ -66,10 +66,7 @@
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
-}
+class Widget;
/**
* Base class for all events. All events in Guichan should
@@ -86,7 +83,7 @@ class Event
*
* @param source The source widget of the event.
*/
- explicit Event(gcn::Widget *const source) :
+ explicit Event(Widget *const source) :
mSource(source)
{ }
@@ -104,14 +101,14 @@ class Event
*
* @return The source widget of the event.
*/
- gcn::Widget* getSource() const A_WARN_UNUSED
+ Widget* getSource() const A_WARN_UNUSED
{ return mSource; }
protected:
/**
* Holds the source widget of the event.
*/
- gcn::Widget* mSource;
+ Widget* mSource;
};
#endif // EVENTS_EVENT_H
diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h
index 8523959ed..2e5136ea2 100644
--- a/src/events/inputguievent.h
+++ b/src/events/inputguievent.h
@@ -84,7 +84,7 @@ class InputGuiEvent: public Event
* @param isAltPressed True if alt is pressed, false otherwise.
* @param isMetaPressed True if meta is pressed, false otherwise.
*/
- InputGuiEvent(gcn::Widget *const source,
+ InputGuiEvent(Widget *const source,
const bool shiftPressed,
const bool controlPressed,
const bool altPressed,
diff --git a/src/events/keyevent.h b/src/events/keyevent.h
index 6ca3d87d8..360d229d7 100644
--- a/src/events/keyevent.h
+++ b/src/events/keyevent.h
@@ -69,10 +69,7 @@
#include <string>
-namespace gcn
-{
- class Widget;
-}
+class Widget;
/**
* Represents a key event.
@@ -102,7 +99,7 @@ class KeyEvent: public InputGuiEvent
* false otherwise.
* @param key The key of the event.
*/
- KeyEvent(gcn::Widget *const source,
+ KeyEvent(Widget *const source,
const bool shiftPressed,
const bool controlPressed,
const bool altPressed,
diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h
index fc8088341..a717980f9 100644
--- a/src/events/mouseevent.h
+++ b/src/events/mouseevent.h
@@ -69,9 +69,10 @@
namespace gcn
{
class Gui;
- class Widget;
}
+class Widget;
+
/**
* Represents a mouse event.
*
@@ -96,7 +97,7 @@ class MouseEvent: public InputGuiEvent
* @param clickCount The number of clicks generated with the same button.
* It's set to zero if another button is used.
*/
- MouseEvent(gcn::Widget *const source,
+ MouseEvent(Widget *const source,
const bool shiftPressed,
const bool controlPressed,
const bool altPressed,
diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h
index b2e91e04f..927b66f77 100644
--- a/src/events/selectionevent.h
+++ b/src/events/selectionevent.h
@@ -68,10 +68,7 @@
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
-}
+class Widget;
/**
* Represents a selection event.
@@ -87,7 +84,7 @@ class SelectionEvent final: public Event
*
* @param source source The widget of the selection event.
*/
- explicit SelectionEvent(gcn::Widget *const source) :
+ explicit SelectionEvent(Widget *const source) :
Event(source)
{ }
diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp
index fd28ef7b6..6d30db100 100644
--- a/src/gui/base/basiccontainer.hpp
+++ b/src/gui/base/basiccontainer.hpp
@@ -66,7 +66,7 @@
#include <vector>
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "listeners/deathlistener.h"
diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp
index d5b23e960..8985ec062 100644
--- a/src/gui/base/gui.cpp
+++ b/src/gui/base/gui.cpp
@@ -67,7 +67,7 @@
#include "gui/base/gui.hpp"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "gui/focushandler.h"
diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp
index 8c4ac4db0..4ea923400 100644
--- a/src/gui/base/gui.hpp
+++ b/src/gui/base/gui.hpp
@@ -76,11 +76,10 @@ class KeyEvent;
class KeyListener;
class MouseInput;
class SDLInput;
+class Widget;
namespace gcn
{
- class Widget;
-
// The following comment will appear in the doxygen main page.
/**
* @mainpage
diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp
deleted file mode 100644
index 692ea479c..000000000
--- a/src/gui/base/widget.cpp
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * 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/base/widget.hpp"
-
-#include "events/actionevent.h"
-
-#include "events/event.h"
-
-#include "gui/focushandler.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/deathlistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-namespace gcn
-{
- Font* Widget::mGlobalFont = nullptr;
- std::list<Widget*> Widget::mWidgets;
- std::set<Widget*> Widget::mWidgetsSet;
-
- Widget::Widget(const Widget2 *const widget) :
- Widget2(widget),
- mMouseListeners(),
- mKeyListeners(),
- mActionListeners(),
- mDeathListeners(),
- mFocusListeners(),
- mWidgetListeners(),
- mForegroundColor(0x000000),
- mBackgroundColor(0xffffff),
- mBaseColor(0x808090),
- mSelectionColor(0xc3d9ff),
- mFocusHandler(nullptr),
- mInternalFocusHandler(nullptr),
- mParent(nullptr),
- mDimension(),
- mFrameSize(0),
- mActionEventId(),
- mFocusable(false),
- mVisible(true),
- mTabIn(true),
- mTabOut(true),
- mEnabled(true),
- mId(),
- mCurrentFont(nullptr)
- {
- mWidgets.push_back(this);
- mWidgetsSet.insert(this);
- }
-
- Widget::~Widget()
- {
- for (DeathListenerIterator iter = mDeathListeners.begin();
- iter != mDeathListeners.end();
- ++iter)
- {
- Event event(this);
- (*iter)->death(event);
- }
-
- _setFocusHandler(nullptr);
-
- mWidgets.remove(this);
- mWidgetsSet.erase(this);
- }
-
- void Widget::drawFrame(Graphics* graphics)
- {
- BLOCK_START("Widget::drawFrame")
- const Color &faceColor = getBaseColor();
- Color highlightColor = faceColor + Color(0x303030);
- Color shadowColor = faceColor - Color(0x303030);
- const int alpha = getBaseColor().a;
- const int width = getWidth() + getFrameSize() * 2 - 1;
- const int height = getHeight() + getFrameSize() * 2 - 1;
- highlightColor.a = alpha;
- shadowColor.a = alpha;
-
- for (unsigned int i = 0; i < getFrameSize(); ++i)
- {
- graphics->setColor(shadowColor);
- graphics->drawLine(i, i, width - i, i);
- graphics->drawLine(i, i + 1, i, height - i - 1);
- graphics->setColor(highlightColor);
- graphics->drawLine(width - i, i + 1, width - i, height - i);
- graphics->drawLine(i, height - i, width - i - 1, height - i);
- }
- BLOCK_END("Widget::drawFrame")
- }
-
- void Widget::_setParent(Widget* parent)
- {
- mParent = parent;
- }
-
- void Widget::setWidth(int width)
- {
- Rectangle newDimension = mDimension;
- newDimension.width = width;
-
- setDimension(newDimension);
- }
-
- void Widget::setHeight(int height)
- {
- Rectangle newDimension = mDimension;
- newDimension.height = height;
-
- setDimension(newDimension);
- }
-
- void Widget::setX(int x)
- {
- Rectangle newDimension = mDimension;
- newDimension.x = x;
-
- setDimension(newDimension);
- }
-
- void Widget::setY(int y)
- {
- Rectangle newDimension = mDimension;
- newDimension.y = y;
-
- setDimension(newDimension);
- }
-
- void Widget::setPosition(int x, int y)
- {
- Rectangle newDimension = mDimension;
- newDimension.x = x;
- newDimension.y = y;
-
- setDimension(newDimension);
- }
-
- void Widget::setDimension(const Rectangle& dimension)
- {
- const Rectangle oldDimension = mDimension;
- mDimension = dimension;
-
- if (mDimension.width != oldDimension.width
- || mDimension.height != oldDimension.height)
- {
- distributeResizedEvent();
- }
-
- if (mDimension.x != oldDimension.x
- || mDimension.y != oldDimension.y)
- {
- distributeMovedEvent();
- }
- }
-
- void Widget::setFrameSize(unsigned int frameSize)
- {
- mFrameSize = frameSize;
- }
-
- unsigned int Widget::getFrameSize() const
- {
- return mFrameSize;
- }
-
- const Rectangle& Widget::getDimension() const
- {
- return mDimension;
- }
-
- const std::string& Widget::getActionEventId() const
- {
- return mActionEventId;
- }
-
- void Widget::setActionEventId(const std::string& actionEventId)
- {
- mActionEventId = actionEventId;
- }
-
- bool Widget::isFocused() const
- {
- if (!mFocusHandler)
- return false;
-
- return (mFocusHandler->isFocused(this));
- }
-
- void Widget::setFocusable(bool focusable)
- {
- if (!focusable && isFocused())
- {
- mFocusHandler->focusNone();
- }
-
- mFocusable = focusable;
- }
-
- bool Widget::isFocusable() const
- {
- return mFocusable && isVisible() && isEnabled();
- }
-
- void Widget::requestFocus()
- {
- if (!mFocusHandler)
- return;
-
- if (isFocusable())
- mFocusHandler->requestFocus(this);
- }
-
- void Widget::requestMoveToTop()
- {
- if (mParent)
- mParent->moveToTop(this);
- }
-
- void Widget::requestMoveToBottom()
- {
- if (mParent)
- mParent->moveToBottom(this);
- }
-
- void Widget::setVisible(bool visible)
- {
- if (!visible && isFocused())
- mFocusHandler->focusNone();
-
- if (visible)
- distributeShownEvent();
- else
- distributeHiddenEvent();
-
- mVisible = visible;
- }
-
- void Widget::setBaseColor(const Color& color)
- {
- mBaseColor = color;
- }
-
- const Color& Widget::getBaseColor() const
- {
- return mBaseColor;
- }
-
- void Widget::setForegroundColor(const Color& color)
- {
- mForegroundColor = color;
- }
-
- const Color& Widget::getForegroundColor() const
- {
- return mForegroundColor;
- }
-
- void Widget::setBackgroundColor(const Color& color)
- {
- mBackgroundColor = color;
- }
-
- const Color& Widget::getBackgroundColor() const
- {
- return mBackgroundColor;
- }
-
- void Widget::setSelectionColor(const Color& color)
- {
- mSelectionColor = color;
- }
-
- const Color& Widget::getSelectionColor() const
- {
- return mSelectionColor;
- }
-
- void Widget::_setFocusHandler(FocusHandler* focusHandler)
- {
- if (mFocusHandler)
- {
- releaseModalFocus();
- mFocusHandler->remove(this);
- }
-
- if (focusHandler)
- focusHandler->add(this);
-
- mFocusHandler = focusHandler;
- }
-
- FocusHandler* Widget::_getFocusHandler()
- {
- return mFocusHandler;
- }
-
- void Widget::addActionListener(ActionListener* actionListener)
- {
- mActionListeners.push_back(actionListener);
- }
-
- void Widget::removeActionListener(ActionListener* actionListener)
- {
- mActionListeners.remove(actionListener);
- }
-
- void Widget::addDeathListener(DeathListener* deathListener)
- {
- mDeathListeners.push_back(deathListener);
- }
-
- void Widget::removeDeathListener(DeathListener* deathListener)
- {
- mDeathListeners.remove(deathListener);
- }
-
- void Widget::addKeyListener(KeyListener* keyListener)
- {
- mKeyListeners.push_back(keyListener);
- }
-
- void Widget::removeKeyListener(KeyListener* keyListener)
- {
- mKeyListeners.remove(keyListener);
- }
-
- void Widget::addFocusListener(FocusListener* focusListener)
- {
- mFocusListeners.push_back(focusListener);
- }
-
- void Widget::removeFocusListener(FocusListener* focusListener)
- {
- mFocusListeners.remove(focusListener);
- }
-
- void Widget::addMouseListener(MouseListener* mouseListener)
- {
- mMouseListeners.push_back(mouseListener);
- }
-
- void Widget::removeMouseListener(MouseListener* mouseListener)
- {
- mMouseListeners.remove(mouseListener);
- }
-
- void Widget::addWidgetListener(WidgetListener* widgetListener)
- {
- mWidgetListeners.push_back(widgetListener);
- }
-
- void Widget::removeWidgetListener(WidgetListener* widgetListener)
- {
- mWidgetListeners.remove(widgetListener);
- }
-
- void Widget::getAbsolutePosition(int& x, int& y) const
- {
- if (!mParent)
- {
- x = mDimension.x;
- y = mDimension.y;
- return;
- }
-
- int parentX;
- int parentY;
-
- mParent->getAbsolutePosition(parentX, parentY);
-
- const Rectangle &rect = mParent->getChildrenArea();
- x = parentX + mDimension.x + rect.x;
- y = parentY + mDimension.y + rect.y;
- }
-
- Font* Widget::getFont() const
- {
- if (!mCurrentFont)
- return mGlobalFont;
- return mCurrentFont;
- }
-
- void Widget::setGlobalFont(Font* font)
- {
- mGlobalFont = font;
-
- for (std::list<Widget*>::const_iterator iter = mWidgets.begin();
- iter != mWidgets.end(); ++iter)
- {
- if (!(*iter)->mCurrentFont)
- (*iter)->fontChanged();
- }
- }
-
- void Widget::setFont(Font* font)
- {
- mCurrentFont = font;
- fontChanged();
- }
-
- bool Widget::widgetExists(const Widget* widget)
- {
- return mWidgetsSet.find(const_cast<Widget*>(widget))
- != mWidgetsSet.end();
- }
-
- bool Widget::isTabInEnabled() const
- {
- return mTabIn;
- }
-
- void Widget::setTabInEnabled(bool enabled)
- {
- mTabIn = enabled;
- }
-
- bool Widget::isTabOutEnabled() const
- {
- return mTabOut;
- }
-
- void Widget::setTabOutEnabled(bool enabled)
- {
- mTabOut = enabled;
- }
-
- void Widget::setSize(int width, int height)
- {
- Rectangle newDimension = mDimension;
- newDimension.width = width;
- newDimension.height = height;
-
- setDimension(newDimension);
- }
-
- void Widget::setEnabled(bool enabled)
- {
- mEnabled = enabled;
- }
-
- bool Widget::isEnabled() const
- {
- return mEnabled && isVisible();
- }
-
- void Widget::requestModalFocus()
- {
- if (!mFocusHandler)
- return;
-
- mFocusHandler->requestModalFocus(this);
- }
-
- void Widget::requestModalMouseInputFocus()
- {
- if (!mFocusHandler)
- return;
-
- mFocusHandler->requestModalMouseInputFocus(this);
- }
-
- void Widget::releaseModalFocus()
- {
- if (!mFocusHandler)
- return;
-
- mFocusHandler->releaseModalFocus(this);
- }
-
- void Widget::releaseModalMouseInputFocus()
- {
- if (!mFocusHandler)
- return;
-
- mFocusHandler->releaseModalMouseInputFocus(this);
- }
-
- bool Widget::isModalFocused() const
- {
- if (!mFocusHandler)
- return false;
-
- if (mParent)
- {
- return (mFocusHandler->getModalFocused() == this)
- || mParent->isModalFocused();
- }
-
- return mFocusHandler->getModalFocused() == this;
- }
-
- bool Widget::isModalMouseInputFocused() const
- {
- if (!mFocusHandler)
- return false;
-
- if (mParent)
- {
- return (mFocusHandler->getModalMouseInputFocused() == this)
- || mParent->isModalMouseInputFocused();
- }
-
- return mFocusHandler->getModalMouseInputFocused() == this;
- }
-
- Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED)
- {
- return nullptr;
- }
-
- const std::list<MouseListener*>& Widget::_getMouseListeners()
- {
- return mMouseListeners;
- }
-
- const std::list<KeyListener*>& Widget::_getKeyListeners()
- {
- return mKeyListeners;
- }
-
- const std::list<FocusListener*>& Widget::_getFocusListeners()
- {
- return mFocusListeners;
- }
-
- Rectangle Widget::getChildrenArea()
- {
- return Rectangle(0, 0, 0, 0);
- }
-
- FocusHandler* Widget::_getInternalFocusHandler()
- {
- return mInternalFocusHandler;
- }
-
- void Widget::setInternalFocusHandler(FocusHandler* focusHandler)
- {
- mInternalFocusHandler = focusHandler;
- }
-
- void Widget::setId(const std::string& id)
- {
- mId = id;
- }
-
- const std::string& Widget::getId()
- {
- return mId;
- }
-
- void Widget::distributeResizedEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++ iter)
- {
- Event event(this);
- (*iter)->widgetResized(event);
- }
- }
-
- void Widget::distributeMovedEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++ iter)
- {
- Event event(this);
- (*iter)->widgetMoved(event);
- }
- }
-
- void Widget::distributeHiddenEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++ iter)
- {
- Event event(this);
- (*iter)->widgetHidden(event);
- }
- }
-
- void Widget::distributeActionEvent()
- {
- for (ActionListenerIterator iter = mActionListeners.begin();
- iter != mActionListeners.end();
- ++iter)
- {
- ActionEvent actionEvent(this, mActionEventId);
- (*iter)->action(actionEvent);
- }
- }
-
- void Widget::distributeShownEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++iter)
- {
- Event event(this);
- (*iter)->widgetShown(event);
- }
- }
-
- void Widget::showPart(Rectangle rectangle)
- {
- if (mParent)
- mParent->showWidgetPart(this, rectangle);
- }
-} // namespace gcn
diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp
deleted file mode 100644
index a180cbd12..000000000
--- a/src/gui/base/widget.hpp
+++ /dev/null
@@ -1,1231 +0,0 @@
-/*
- * 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 GCN_WIDGET_HPP
-#define GCN_WIDGET_HPP
-
-#include <list>
-#include <set>
-#include <string>
-
-#include "gui/color.h"
-#include "gui/rectangle.h"
-
-#include "gui/widgets/widget2.h"
-
-#include "localconsts.h"
-
-class ActionListener;
-class DeathListener;
-class FocusHandler;
-class FocusListener;
-class Font;
-class Graphics;
-class KeyListener;
-class MouseListener;
-class WidgetListener;
-
-namespace gcn
-{
- /**
- * Abstract class for widgets of Guichan. It contains basic functions
- * every widget should have.
- *
- * NOTE: Functions begining with underscore "_" should not
- * be overloaded unless you know what you are doing
- *
- * @author Olof Naessén
- * @author Per Larsson.
- * @since 0.1.0
- */
- class Widget : public Widget2
- {
- public:
- /**
- * Constructor. Resets member variables. Noteable, a widget is not
- * focusable as default, therefore, widgets that are supposed to be
- * focusable should overide this default in their own constructor.
- */
- explicit Widget(const Widget2 *const widget);
-
- A_DELETE_COPY(Widget)
-
- /**
- * Default destructor.
- */
- virtual ~Widget();
-
- /**
- * Draws the widget. It is called by the parent widget when it is time
- * for the widget to draw itself. The graphics object is set up so
- * that all drawing is relative to the widget, i.e coordinate (0,0) is
- * the top left corner of the widget. It is not possible to draw
- * outside of a widget's dimension.
- *
- * @param graphics aA graphics object to draw with.
- * @since 0.1.0
- */
- virtual void draw(Graphics* graphics) = 0;
-
- /**
- * Called when a widget is given a chance to draw a frame around itself.
- * The frame is not considered a part of the widget, it only allows a frame
- * to be drawn around the widget, thus a frame will never be included when
- * calculating if a widget should receive events from user input. Also
- * a widget's frame will never be included when calculating a widget's
- * position.
- *
- * The size of the frame is calculated using the widget's frame size.
- * If a widget has a frame size of 10 pixels than the area the drawFrame
- * function can draw to will be the size of the widget with an additional
- * extension of 10 pixels in each direction.
- *
- * An example when drawFrame is a useful function is if a widget needs
- * a glow around itself.
- *
- * @param graphics A graphics object to draw with.
- * @see setFrameSize, getFrameSize
- * @since 0.8.0
- */
- virtual void drawFrame(Graphics* graphics);
-
- /**
- * Sets the size of the widget's frame. The frame is not considered a part of
- * the widget, it only allows a frame to be drawn around the widget, thus a frame
- * will never be included when calculating if a widget should receive events
- * from user input. Also a widget's frame will never be included when calculating
- * a widget's position.
- *
- * A frame size of 0 means that the widget has no frame. The default frame size
- * is 0.
- *
- * @param frameSize The size of the widget's frame.
- * @see getFrameSize, drawFrame
- * @since 0.8.0
- */
- void setFrameSize(unsigned int frameSize);
-
- /**
- * Gets the size of the widget's frame. The frame is not considered a part of
- * the widget, it only allows a frame to be drawn around the widget, thus a frame
- * will never be included when calculating if a widget should receive events
- * from user input. Also a widget's frame will never be included when calculating
- * a widget's position.
- *
- * A frame size of 0 means that the widget has no frame. The default frame size
- * is 0.
- *
- * @return The size of the widget's frame.
- * @see setFrameSize, drawFrame
- * @since 0.8.0
- */
- unsigned int getFrameSize() const A_WARN_UNUSED;
-
- /**
- * Called for all widgets in the gui each time Gui::logic is called.
- * You can do logic stuff here like playing an animation.
- *
- * @see Gui::logic
- * @since 0.1.0
- */
- virtual void logic()
- { }
-
- /**
- * Gets the widget's parent container.
- *
- * @return The widget's parent container. NULL if the widget
- * has no parent.
- * @since 0.1.0
- */
- virtual Widget* getParent() const A_WARN_UNUSED
- { return mParent; }
-
- /**
- * Sets the width of the widget.
- *
- * @param width The width of the widget.
- * @see getWidth, setHeight, getHeight, setSize,
- * setDimension, getDimensi
- * @since 0.1.0
- */
- void setWidth(int width);
-
- /**
- * Gets the width of the widget.
- *
- * @return The width of the widget.
- * @see setWidth, setHeight, getHeight, setSize,
- * setDimension, getDimension
- * @since 0.1.0
- */
- int getWidth() const A_WARN_UNUSED
- { return mDimension.width; }
-
- /**
- * Sets the height of the widget.
- *
- * @param height The height of the widget.
- * @see getHeight, setWidth, getWidth, setSize,
- * setDimension, getDimension
- * @since 0.1.0
- */
- void setHeight(int height);
-
- /**
- * Gets the height of the widget.
- *
- * @return The height of the widget.
- * @see setHeight, setWidth, getWidth, setSize,
- * setDimension, getDimension
- * @since 0.1.0
- */
- int getHeight() const A_WARN_UNUSED
- { return mDimension.height; }
-
- /**
- * Sets the size of the widget.
- *
- * @param width The width of the widget.
- * @param height The height of the widget.
- * @see setWidth, setHeight, getWidth, getHeight,
- * setDimension, getDimension
- * @since 0.1.0
- */
- void setSize(int width, int height);
-
- /**
- * Sets the x coordinate of the widget. The coordinate is
- * relateive to the widget's parent.
- *
- * @param x The x coordinate of the widget.
- * @see getX, setY, getY, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- void setX(int x);
-
- /**
- * Gets the x coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @return The x coordinate of the widget.
- * @see setX, setY, getY, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- int getX() const A_WARN_UNUSED
- { return mDimension.x; }
-
- /**
- * Sets the y coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @param y The y coordinate of the widget.
- * @see setY, setX, getX, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- void setY(int y);
-
- /**
- * Gets the y coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @return The y coordinate of the widget.
- * @see setY, setX, getX, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- int getY() const A_WARN_UNUSED
- { return mDimension.y; }
-
- /**
- * Sets position of the widget. The position is relative
- * to the widget's parent.
- *
- * @param x The x coordinate of the widget.
- * @param y The y coordinate of the widget.
- * @see setX, getX, setY, getY, setDimension, getDimension
- * @since 0.1.0
- */
- void setPosition(int x, int y);
-
- /**
- * Sets the dimension of the widget. The dimension is
- * relative to the widget's parent.
- *
- * @param dimension The dimension of the widget.
- * @see getDimension, setX, getX, setY, getY, setPosition
- * @since 0.1.0
- */
- void setDimension(const Rectangle& dimension);
-
- /**
- * Gets the dimension of the widget. The dimension is
- * relative to the widget's parent.
- *
- * @return The dimension of the widget.
- * @see getDimension, setX, getX, setY, getY, setPosition
- * @since 0.1.0
- */
- const Rectangle& getDimension() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to be fosusable, or not.
- *
- * @param focusable True if the widget should be focusable,
- * false otherwise.
- * @see isFocusable
- * @since 0.1.0
- */
- void setFocusable(bool focusable);
-
- /**
- * Checks if a widget is focsable.
- *
- * @return True if the widget should be focusable, false otherwise.
- * @see setFocusable
- * @since 0.1.0
- */
- bool isFocusable() const A_WARN_UNUSED;
-
- /**
- * Checks if the widget is focused.
- *
- * @return True if the widget is focused, false otherwise.
- * @since 0.1.0
- */
- virtual bool isFocused() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to enabled, or not. A disabled
- * widget will never recieve mouse or key events.
- *
- * @param enabled True if widget should be enabled,
- * false otherwise.
- * @see isEnabled
- * @since 0.1.0
- */
- void setEnabled(bool enabled);
-
- /**
- * Checks if the widget is enabled. A disabled
- * widget will never recieve mouse or key events.
- *
- * @return True if widget is enabled, false otherwise.
- * @see setEnabled
- * @since 0.1.0
- */
- bool isEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to be visible, or not.
- *
- * @param visible True if widget should be visible, false otherwise.
- * @see isVisible
- * @since 0.1.0
- */
- void setVisible(bool visible);
-
- /**
- * Checks if the widget is visible.
- *
- * @return True if widget is be visible, false otherwise.
- * @see setVisible
- * @since 0.1.0
- */
- bool isVisible() const A_WARN_UNUSED
- { return mVisible && (!mParent || mParent->isVisible()); }
-
- /**
- * Sets the base color of the widget.
- *
- * @param color The baseground color.
- * @see getBaseColor
- * @since 0.1.0
- */
- void setBaseColor(const Color& color);
-
- /**
- * Gets the base color.
- *
- * @return The base color.
- * @see setBaseColor
- * @since 0.1.0
- */
- const Color& getBaseColor() const A_WARN_UNUSED;
-
- /**
- * Sets the foreground color.
- *
- * @param color The foreground color.
- * @see getForegroundColor
- * @since 0.1.0
- */
- void setForegroundColor(const Color& color);
-
- /**
- * Gets the foreground color.
- *
- * @see setForegroundColor
- * @since 0.1.0
- */
- const Color& getForegroundColor() const A_WARN_UNUSED;
-
- /**
- * Sets the background color.
- *
- * @param color The background Color.
- * @see setBackgroundColor
- * @since 0.1.0
- */
- void setBackgroundColor(const Color& color);
-
- /**
- * Gets the background color.
- *
- * @see setBackgroundColor
- * @since 0.1.0
- */
- const Color& getBackgroundColor() const A_WARN_UNUSED;
-
- /**
- * Sets the selection color.
- *
- * @param color The selection color.
- * @see getSelectionColor
- * @since 0.6.0
- */
- void setSelectionColor(const Color& color);
-
- /**
- * Gets the selection color.
- *
- * @return The selection color.
- * @see setSelectionColor
- * @since 0.6.0
- */
- const Color& getSelectionColor() const A_WARN_UNUSED;
-
- /**
- * Requests focus for the widget. A widget will only recieve focus
- * if it is focusable.
- */
- virtual void requestFocus();
-
- /**
- * Requests a move to the top in the parent widget.
- */
- virtual void requestMoveToTop();
-
- /**
- * Requests a move to the bottom in the parent widget.
- */
- virtual void requestMoveToBottom();
-
- /**
- * Sets the focus handler to be used.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @param focusHandler The focus handler to use.
- * @see _getFocusHandler
- * @since 0.1.0
- */
- virtual void _setFocusHandler(FocusHandler* focusHandler);
-
- /**
- * Gets the focus handler used.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @return The focus handler used.
- * @see _setFocusHandler
- * @since 0.1.0
- */
- virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED;
-
- /**
- * Adds an action listener to the widget. When an action event
- * is fired by the widget the action listeners of the widget
- * will get notified.
- *
- * @param actionListener The action listener to add.
- * @see removeActionListener
- * @since 0.1.0
- */
- void addActionListener(ActionListener* actionListener);
-
- /**
- * Removes an added action listener from the widget.
- *
- * @param actionListener The action listener to remove.
- * @see addActionListener
- * @since 0.1.0
- */
- void removeActionListener(ActionListener* actionListener);
-
- /**
- * Adds a death listener to the widget. When a death event is
- * fired by the widget the death listeners of the widget will
- * get notified.
- *
- * @param deathListener The death listener to add.
- * @see removeDeathListener
- * @since 0.1.0
- */
- void addDeathListener(DeathListener* deathListener);
-
- /**
- * Removes an added death listener from the widget.
- *
- * @param deathListener The death listener to remove.
- * @see addDeathListener
- * @since 0.1.0
- */
- void removeDeathListener(DeathListener* deathListener);
-
- /**
- * Adds a mouse listener to the widget. When a mouse event is
- * fired by the widget the mouse listeners of the widget will
- * get notified.
- *
- * @param mouseListener The mouse listener to add.
- * @see removeMouseListener
- * @since 0.1.0
- */
- void addMouseListener(MouseListener* mouseListener);
-
- /**
- * Removes an added mouse listener from the widget.
- *
- * @param mouseListener The mouse listener to remove.
- * @see addMouseListener
- * @since 0.1.0
- */
- void removeMouseListener(MouseListener* mouseListener);
-
- /**
- * Adds a key listener to the widget. When a key event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param keyListener The key listener to add.
- * @see removeKeyListener
- * @since 0.1.0
- */
- void addKeyListener(KeyListener* keyListener);
-
- /**
- * Removes an added key listener from the widget.
- *
- * @param keyListener The key listener to remove.
- * @see addKeyListener
- * @since 0.1.0
- */
- void removeKeyListener(KeyListener* keyListener);
-
- /**
- * Adds a focus listener to the widget. When a focus event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param focusListener The focus listener to add.
- * @see removeFocusListener
- * @since 0.7.0
- */
- void addFocusListener(FocusListener* focusListener);
-
- /**
- * Removes an added focus listener from the widget.
- *
- * @param focusListener The focus listener to remove.
- * @see addFocusListener
- * @since 0.7.0
- */
- void removeFocusListener(FocusListener* focusListener);
-
- /**
- * Adds a widget listener to the widget. When a widget event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param widgetListener The widget listener to add.
- * @see removeWidgetListener
- * @since 0.8.0
- */
- void addWidgetListener(WidgetListener* widgetListener);
-
- /**
- * Removes an added widget listener from the widget.
- *
- * @param widgetListener The widget listener to remove.
- * @see addWidgetListener
- * @since 0.8.0
- */
- void removeWidgetListener(WidgetListener* widgetListener);
-
- /**
- * Sets the action event identifier of the widget. The identifier is
- * used to be able to identify which action has occured.
- *
- * NOTE: An action event identifier should not be used to identify a
- * certain widget but rather a certain event in your application.
- * Several widgets can have the same action event identifer.
- *
- * @param actionEventId The action event identifier.
- * @see getActionEventId
- * @since 0.6.0
- */
- void setActionEventId(const std::string& actionEventId);
-
- /**
- * Gets the action event identifier of the widget.
- *
- * @return The action event identifier of the widget.
- * @see setActionEventId
- * @since 0.6.0
- */
- const std::string& getActionEventId() const;
-
- /**
- * Gets the absolute position on the screen for the widget.
- *
- * @param x The absolute x coordinate will be stored in this parameter.
- * @param y The absolute y coordinate will be stored in this parameter.
- * @since 0.1.0
- */
- virtual void getAbsolutePosition(int& x, int& y) const;
-
- /**
- * Sets the parent of the widget. A parent must be a BasicContainer.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @param parent The parent of the widget.
- * @see getParent
- * @since 0.1.0
- */
- virtual void _setParent(Widget* parent);
-
- /**
- * Gets the font set for the widget. If no font has been set,
- * the global font will be returned. If no global font has been set,
- * the default font will be returend.
- *
- * @return The font set for the widget.
- * @see setFont, setGlobalFont
- * @since 0.1.0
- */
- Font *getFont() const A_WARN_UNUSED;
-
- /**
- * Sets the global font to be used by default for all widgets.
- *
- * @param font The global font.
- * @see getGlobalFont
- * @since 0.1.0
- */
- static void setGlobalFont(Font* font);
-
- /**
- * Sets the font for the widget. If NULL is passed, the global font
- * will be used.
- *
- * @param font The font to set for the widget.
- * @see getFont
- * @since 0.1.0
- */
- void setFont(Font* font);
-
- /**
- * Called when the font has changed. If the change is global,
- * this function will only be called if the widget doesn't have a
- * font already set.
- *
- * @since 0.1.0
- */
- virtual void fontChanged()
- { }
-
- /**
- * Checks if a widget exists or not, that is if it still exists
- * an instance of the object.
- *
- * @param widget The widget to check.
- * @return True if an instance of the widget exists, false otherwise.
- * @since 0.1.0
- */
- static bool widgetExists(const Widget* widget) A_WARN_UNUSED;
-
- /**
- * Checks if tab in is enabled. Tab in means that you can set focus
- * to this widget by pressing the tab button. If tab in is disabled
- * then the focus handler will skip this widget and focus the next
- * in its focus order.
- *
- * @return True if tab in is enabled, false otherwise.
- * @see setTabInEnabled
- * @since 0.1.0
- */
- bool isTabInEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets tab in enabled, or not. Tab in means that you can set focus
- * to this widget by pressing the tab button. If tab in is disabled
- * then the FocusHandler will skip this widget and focus the next
- * in its focus order.
- *
- * @param enabled True if tab in should be enabled, false otherwise.
- * @see isTabInEnabled
- * @since 0.1.0
- */
- void setTabInEnabled(bool enabled);
-
- /**
- * Checks if tab out is enabled. Tab out means that you can lose
- * focus to this widget by pressing the tab button. If tab out is
- * disabled then the FocusHandler ignores tabbing and focus will
- * stay with this widget.
- *
- * @return True if tab out is enabled, false otherwise.
- * @see setTabOutEnabled
- * @since 0.1.0
- */
- bool isTabOutEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets tab out enabled. Tab out means that you can lose
- * focus to this widget by pressing the tab button. If tab out is
- * disabled then the FocusHandler ignores tabbing and focus will
- * stay with this widget.
- *
- * @param enabled True if tab out should be enabled, false otherwise.
- * @see isTabOutEnabled
- * @since 0.1.0
- */
- void setTabOutEnabled(bool enabled);
-
- /**
- * Requests modal focus. When a widget has modal focus, only that
- * widget and it's children may recieve input.
- *
- * @throws Exception if another widget already has modal focus.
- * @see releaseModalFocus, isModalFocused
- * @since 0.4.0
- */
- virtual void requestModalFocus();
-
- /**
- * Requests modal mouse input focus. When a widget has modal input focus
- * that widget will be the only widget receiving input even if the input
- * occurs outside of the widget and no matter what the input is.
- *
- * @throws Exception if another widget already has modal focus.
- * @see releaseModalMouseInputFocus, isModalMouseInputFocused
- * @since 0.6.0
- */
- virtual void requestModalMouseInputFocus();
-
- /**
- * Releases modal focus. Modal focus will only be released if the
- * widget has modal focus.
- *
- * @see requestModalFocus, isModalFocused
- * @since 0.4.0
- */
- virtual void releaseModalFocus();
-
- /**
- * Releases modal mouse input focus. Modal mouse input focus will only
- * be released if the widget has modal mouse input focus.
- *
- * @see requestModalMouseInputFocus, isModalMouseInputFocused
- * @since 0.6.0
- */
- virtual void releaseModalMouseInputFocus();
-
- /**
- * Checks if the widget or it's parent has modal focus.
- *
- * @return True if the widget has modal focus, false otherwise.
- * @see requestModalFocus, releaseModalFocus
- * @since 0.8.0
- */
- virtual bool isModalFocused() const A_WARN_UNUSED;
-
- /**
- * Checks if the widget or it's parent has modal mouse input focus.
- *
- * @return True if the widget has modal mouse input focus, false
- * otherwise.
- * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
- * @since 0.8.0
- */
- virtual bool isModalMouseInputFocused() const A_WARN_UNUSED;
-
- /**
- * Gets a widget from a certain position in the widget.
- * This function is used to decide which gets mouse input,
- * thus it can be overloaded to change that behaviour.
- *
- * NOTE: This always returns NULL if the widget is not
- * a container.
- *
- * @param x The x coordinate of the widget to get.
- * @param y The y coordinate of the widget to get.
- * @return The widget at the specified coodinate, NULL
- * if no widget is found.
- * @since 0.6.0
- */
- virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED;
-
- /**
- * Gets the mouse listeners of the widget.
- *
- * @return The mouse listeners of the widget.
- * @since 0.6.0
- */
- virtual const std::list<MouseListener*>& _getMouseListeners()
- A_WARN_UNUSED;
-
- /**
- * Gets the key listeners of the widget.
- *
- * @return The key listeners of the widget.
- * @since 0.6.0
- */
- virtual const std::list<KeyListener*>& _getKeyListeners()
- A_WARN_UNUSED;
-
- /**
- * Gets the focus listeners of the widget.
- *
- * @return The focus listeners of the widget.
- * @since 0.7.0
- */
- virtual const std::list<FocusListener*>& _getFocusListeners()
- A_WARN_UNUSED;
-
- /**
- * Gets the area of the widget occupied by the widget's children.
- * By default this method returns an empty rectangle as not all
- * widgets are containers. If you want to make a container this
- * method should return the area where the children resides. This
- * method is used when drawing children of a widget when computing
- * clip rectangles for the children.
- *
- * An example of a widget that overloads this method is ScrollArea.
- * A ScrollArea has a view of its contant and that view is the
- * children area. The size of a ScrollArea's children area might
- * vary depending on if the scroll bars of the ScrollArea is shown
- * or not.
- *
- * @return The area of the widget occupied by the widget's children.
- * @see BasicContainer
- * @see BasicContainer::getChildrenArea
- * @see BasicContainer::drawChildren
- * @since 0.1.0
- */
- virtual Rectangle getChildrenArea() A_WARN_UNUSED;
-
- /**
- * Gets the internal focus handler used.
- *
- * @return the internalFocusHandler used. If no internal focus handler
- * is used, NULL will be returned.
- * @see setInternalFocusHandler
- * @since 0.1.0
- */
- virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED;
-
- /**
- * Sets the internal focus handler. An internal focus handler is
- * needed if both a widget in the widget and the widget itself
- * should be foucsed at the same time.
- *
- * @param focusHandler The internal focus handler to be used.
- * @see getInternalFocusHandler
- * @since 0.1.0
- */
- void setInternalFocusHandler(FocusHandler* internalFocusHandler);
-
- /**
- * Moves a widget to the top of this widget. The moved widget will be
- * drawn above all other widgets in this widget.
- *
- * @param widget The widget to move to the top.
- * @see moveToBottom
- * @since 0.1.0
- */
- virtual void moveToTop(Widget* widget A_UNUSED)
- { }
-
- /**
- * Moves a widget in this widget to the bottom of this widget.
- * The moved widget will be drawn below all other widgets in this widget.
- *
- * @param widget The widget to move to the bottom.
- * @see moveToTop
- * @since 0.1.0
- */
- virtual void moveToBottom(Widget* widget A_UNUSED)
- { }
-
- /**
- * Focuses the next widget in the widget.
- *
- * @see moveToBottom
- * @since 0.1.0
- */
- virtual void focusNext()
- { }
-
- /**
- * Focuses the previous widget in the widget.
- *
- * @see moveToBottom
- * @since 0.1.0
- */
- virtual void focusPrevious()
- { }
-
- /**
- * Tries to show a specific part of a widget by moving it. Used if the
- * widget should act as a container.
- *
- * @param widget The target widget.
- * @param area The area to show.
- * @since 0.1.0
- */
- virtual void showWidgetPart(Widget* widget A_UNUSED,
- Rectangle area A_UNUSED)
- { }
-
- /**
- * Sets an id of a widget. An id can be useful if a widget needs to be
- * identified in a container. For example, if widgets are created by an
- * XML document, a certain widget can be retrieved given that the widget
- * has an id.
- *
- * @param id The id to set to the widget.
- * @see getId, BasicContainer::findWidgetById
- * @since 0.8.0
- */
- void setId(const std::string& id);
-
- /**
- * Gets the id of a widget. An id can be useful if a widget needs to be
- * identified in a container. For example, if widgets are created by an
- * XML document, a certain widget can be retrieved given that the widget
- * has an id.
- *
- * @param id The id to set to the widget.
- * @see setId, BasicContainer::findWidgetById
- * @since 0.8.0
- */
- const std::string& getId() A_WARN_UNUSED;
-
- /**
- * Shows a certain part of a widget in the widget's parent.
- * Used when widgets want a specific part to be visible in
- * its parent. An example is a TextArea that wants a specific
- * part of its text to be visible when a TextArea is a child
- * of a ScrollArea.
- *
- * @param rectangle The rectangle to be shown.
- * @since 0.8.0
- */
- virtual void showPart(Rectangle rectangle);
-
- protected:
- /**
- * Distributes an action event to all action listeners
- * of the widget.
- *
- * @since 0.8.0
- */
- void distributeActionEvent();
-
- /**
- * Distributes resized events to all of the widget's listeners.
- *
- * @since 0.8.0
- */
- void distributeResizedEvent();
-
- /**
- * Distributes moved events to all of the widget's listeners.
- *
- * @since 0.8.0
- */
- void distributeMovedEvent();
-
- /**
- * Distributes hidden events to all of the widget's listeners.
- *
- * @since 0.8.0
- * @author Olof Naessén
- */
- void distributeHiddenEvent();
-
- /**
- * Distributes shown events to all of the widget's listeners.
- *
- * @since 0.8.0
- * @author Olof Naessén
- */
- void distributeShownEvent();
-
- /**
- * Typdef.
- */
- typedef std::list<MouseListener*> MouseListenerList;
-
- /**
- * Typdef.
- */
- typedef MouseListenerList::iterator MouseListenerIterator;
-
- /**
- * Holds the mouse listeners of the widget.
- */
- MouseListenerList mMouseListeners;
-
- /**
- * Typdef.
- */
- typedef std::list<KeyListener*> KeyListenerList;
-
- /**
- * Holds the key listeners of the widget.
- */
- KeyListenerList mKeyListeners;
-
- /**
- * Typdef.
- */
- typedef KeyListenerList::iterator KeyListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<ActionListener*> ActionListenerList;
-
- /**
- * Holds the action listeners of the widget.
- */
- ActionListenerList mActionListeners;
-
- /**
- * Typdef.
- */
- typedef ActionListenerList::iterator ActionListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<DeathListener*> DeathListenerList;
-
- /**
- * Holds the death listeners of the widget.
- */
- DeathListenerList mDeathListeners;
-
- /**
- * Typdef.
- */
- typedef DeathListenerList::iterator DeathListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<FocusListener*> FocusListenerList;
-
- /**
- * Holds the focus listeners of the widget.
- */
- FocusListenerList mFocusListeners;
-
- /**
- * Typdef.
- */
- typedef FocusListenerList::iterator FocusListenerIterator;
-
- typedef std::list<WidgetListener*> WidgetListenerList;
-
- /**
- * Holds the widget listeners of the widget.
- */
- WidgetListenerList mWidgetListeners;
-
- /**
- * Typdef.
- */
- typedef WidgetListenerList::iterator WidgetListenerIterator;
-
- /**
- * Holds the foreground color of the widget.
- */
- Color mForegroundColor;
-
- /**
- * Holds the background color of the widget.
- */
- Color mBackgroundColor;
-
- /**
- * Holds the base color of the widget.
- */
- Color mBaseColor;
-
- /**
- * Holds the selection color of the widget.
- */
- Color mSelectionColor;
-
- /**
- * Holds the focus handler used by the widget.
- */
- FocusHandler* mFocusHandler;
-
- /**
- * Holds the focus handler used by the widget. NULL
- * if no internal focus handler is used.
- */
- FocusHandler* mInternalFocusHandler;
-
- /**
- * Holds the parent of the widget. NULL if the widget
- * has no parent.
- */
- Widget* mParent;
-
- /**
- * Holds the dimension of the widget.
- */
- Rectangle mDimension;
-
- /**
- * Holds the frame size of the widget.
- */
- unsigned int mFrameSize;
-
- /**
- * Holds the action event of the widget.
- */
- std::string mActionEventId;
-
- /**
- * True if the widget focusable, false otherwise.
- */
- bool mFocusable;
-
- /**
- * True if the widget visible, false otherwise.
- */
- bool mVisible;
-
- /**
- * True if the widget has tab in enabled, false otherwise.
- */
- bool mTabIn;
-
- /**
- * True if the widget has tab in enabled, false otherwise.
- */
- bool mTabOut;
-
- /**
- * True if the widget is enabled, false otherwise.
- */
- bool mEnabled;
-
- /**
- * Holds the id of the widget.
- */
- std::string mId;
-
- /**
- * Holds the font used by the widget.
- */
- Font* mCurrentFont;
-
- /**
- * Holds the global font used by the widget.
- */
- static Font* mGlobalFont;
-
- /**
- * Holds a list of all instances of widgets.
- */
- static std::list<Widget*> mWidgets;
-
- static std::set<Widget*> mWidgetsSet;
- };
-} // namespace gcn
-
-#endif // end GCN_WIDGET_HPP
diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp
index 5187c625b..2d6afa672 100644
--- a/src/gui/base/widgets/button.cpp
+++ b/src/gui/base/widgets/button.cpp
@@ -76,7 +76,7 @@
namespace gcn
{
Button::Button(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
FocusListener(),
@@ -98,7 +98,7 @@ namespace gcn
Button::Button(const Widget2 *const widget,
const std::string& caption) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
FocusListener(),
diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp
index fea175362..99e5db4f4 100644
--- a/src/gui/base/widgets/button.hpp
+++ b/src/gui/base/widgets/button.hpp
@@ -70,7 +70,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp
index a5ec72dfa..476fb3c6b 100644
--- a/src/gui/base/widgets/checkbox.cpp
+++ b/src/gui/base/widgets/checkbox.cpp
@@ -73,7 +73,7 @@ namespace gcn
{
CheckBox::CheckBox(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mSelected(false),
@@ -87,7 +87,7 @@ namespace gcn
CheckBox::CheckBox(const Widget2 *const widget,
const std::string &caption,
bool selected) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mSelected(selected),
diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp
index c79ccaff9..6fcb04767 100644
--- a/src/gui/base/widgets/checkbox.hpp
+++ b/src/gui/base/widgets/checkbox.hpp
@@ -69,7 +69,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
namespace gcn
{
diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp
index 84ba87d84..d2293a957 100644
--- a/src/gui/base/widgets/label.cpp
+++ b/src/gui/base/widgets/label.cpp
@@ -76,7 +76,7 @@
namespace gcn
{
Label::Label(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
mCaption(),
mAlignment(Graphics::LEFT)
{
@@ -84,7 +84,7 @@ namespace gcn
Label::Label(const Widget2 *const widget,
const std::string& caption) :
- gcn::Widget(widget),
+ Widget(widget),
mCaption(caption),
mAlignment(Graphics::LEFT)
{
diff --git a/src/gui/base/widgets/label.hpp b/src/gui/base/widgets/label.hpp
index 399e4202a..fd0d54f8e 100644
--- a/src/gui/base/widgets/label.hpp
+++ b/src/gui/base/widgets/label.hpp
@@ -66,7 +66,7 @@
#include <string>
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp
index 765878834..9aca373b9 100644
--- a/src/gui/base/widgets/listbox.cpp
+++ b/src/gui/base/widgets/listbox.cpp
@@ -78,7 +78,7 @@
namespace gcn
{
ListBox::ListBox(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mSelected(-1),
@@ -95,7 +95,7 @@ namespace gcn
ListBox::ListBox(const Widget2 *const widget,
ListModel *listModel) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mSelected(-1),
diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp
index c46aca6ae..4046f5ddf 100644
--- a/src/gui/base/widgets/listbox.hpp
+++ b/src/gui/base/widgets/listbox.hpp
@@ -66,7 +66,7 @@
#include <list>
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp
index e17b9f776..f9d68555a 100644
--- a/src/gui/base/widgets/radiobutton.cpp
+++ b/src/gui/base/widgets/radiobutton.cpp
@@ -74,7 +74,7 @@ namespace gcn
RadioButton::GroupMap RadioButton::mGroupMap;
RadioButton::RadioButton(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mSelected(false),
@@ -92,7 +92,7 @@ namespace gcn
const std::string &caption,
const std::string &group,
bool selected) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mSelected(false),
diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp
index f4bfd53fa..a86a4eed3 100644
--- a/src/gui/base/widgets/radiobutton.hpp
+++ b/src/gui/base/widgets/radiobutton.hpp
@@ -70,7 +70,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
namespace gcn
{
diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp
index 4e9df0341..40c73ceb5 100644
--- a/src/gui/base/widgets/slider.cpp
+++ b/src/gui/base/widgets/slider.cpp
@@ -73,7 +73,7 @@ namespace gcn
{
Slider::Slider(const Widget2 *const widget,
const double scaleEnd) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mDragged(false),
@@ -94,7 +94,7 @@ namespace gcn
Slider::Slider(const Widget2 *const widget,
const double scaleStart,
const double scaleEnd) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mDragged(false),
diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp
index f29ad5950..9d5adc6d8 100644
--- a/src/gui/base/widgets/slider.hpp
+++ b/src/gui/base/widgets/slider.hpp
@@ -67,7 +67,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
namespace gcn
{
diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp
index bb22a6f46..04b506c59 100644
--- a/src/gui/base/widgets/textbox.cpp
+++ b/src/gui/base/widgets/textbox.cpp
@@ -76,7 +76,7 @@
namespace gcn
{
TextBox::TextBox(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mTextRows(),
@@ -95,7 +95,7 @@ namespace gcn
TextBox::TextBox(const Widget2 *const widget,
const std::string& text) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mTextRows(),
diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp
index 151af8c00..148b4f007 100644
--- a/src/gui/base/widgets/textbox.hpp
+++ b/src/gui/base/widgets/textbox.hpp
@@ -70,7 +70,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
namespace gcn
{
diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp
index ddcbec1b4..c2cead500 100644
--- a/src/gui/base/widgets/textfield.cpp
+++ b/src/gui/base/widgets/textfield.cpp
@@ -74,7 +74,7 @@
namespace gcn
{
TextField::TextField(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mText(),
@@ -89,7 +89,7 @@ namespace gcn
TextField::TextField(const Widget2 *const widget,
const std::string& text) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mText(text),
diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp
index aa5f210c5..e9df238ba 100644
--- a/src/gui/base/widgets/textfield.hpp
+++ b/src/gui/base/widgets/textfield.hpp
@@ -67,7 +67,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include <string>
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
index 0d45b6432..928b3b72e 100644
--- a/src/gui/focushandler.cpp
+++ b/src/gui/focushandler.cpp
@@ -87,7 +87,7 @@ FocusHandler::FocusHandler() :
{
}
-void FocusHandler::requestModalFocus(gcn::Widget *widget)
+void FocusHandler::requestModalFocus(Widget *widget)
{
/* If there is another widget with modal focus, remove its modal focus
* and put it on the modal widget stack.
@@ -103,7 +103,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget)
focusNone();
}
-void FocusHandler::releaseModalFocus(gcn::Widget *widget)
+void FocusHandler::releaseModalFocus(Widget *widget)
{
mModalStack.remove(widget);
@@ -123,7 +123,7 @@ void FocusHandler::releaseModalFocus(gcn::Widget *widget)
}
}
-void FocusHandler::remove(gcn::Widget *widget)
+void FocusHandler::remove(Widget *widget)
{
releaseModalFocus(widget);
@@ -217,7 +217,7 @@ void FocusHandler::tabNext()
if (focusedWidget == focused)
return;
- const gcn::Widget *const widget = mWidgets.at(focusedWidget);
+ const Widget *const widget = mWidgets.at(focusedWidget);
if (widget->isFocusable() && widget->isTabInEnabled() &&
(!mModalFocusedWidget || widget->isModalFocused()))
{
@@ -288,7 +288,7 @@ void FocusHandler::tabPrevious()
if (focusedWidget == focused)
return;
- const gcn::Widget *const widget = mWidgets.at(focusedWidget);
+ const Widget *const widget = mWidgets.at(focusedWidget);
if (widget->isFocusable() && widget->isTabInEnabled() &&
(!mModalFocusedWidget || widget->isModalFocused()))
{
@@ -317,7 +317,7 @@ void FocusHandler::checkForWindow() const
{
if (mFocusedWidget)
{
- gcn::Widget *widget = mFocusedWidget->getParent();
+ Widget *widget = mFocusedWidget->getParent();
while (widget)
{
@@ -339,7 +339,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
if (gui)
gui->distributeGlobalFocusGainedEvent(focusEvent);
- gcn::Widget *const sourceWidget = focusEvent.getSource();
+ Widget *const sourceWidget = focusEvent.getSource();
std::list<FocusListener*> focusListeners
= sourceWidget->_getFocusListeners();
@@ -354,7 +354,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
}
}
-void FocusHandler::requestFocus(gcn::Widget* widget)
+void FocusHandler::requestFocus(Widget* widget)
{
if (!widget || widget == mFocusedWidget)
return;
@@ -373,7 +373,7 @@ void FocusHandler::requestFocus(gcn::Widget* widget)
if (toBeFocusedIndex < 0)
return;
- gcn::Widget *const oldFocused = mFocusedWidget;
+ Widget *const oldFocused = mFocusedWidget;
if (oldFocused != widget)
{
@@ -390,7 +390,7 @@ void FocusHandler::requestFocus(gcn::Widget* widget)
}
}
-void FocusHandler::requestModalMouseInputFocus(gcn::Widget* widget)
+void FocusHandler::requestModalMouseInputFocus(Widget* widget)
{
if (mModalMouseInputFocusedWidget
&& mModalMouseInputFocusedWidget != widget)
@@ -401,23 +401,23 @@ void FocusHandler::requestModalMouseInputFocus(gcn::Widget* widget)
mModalMouseInputFocusedWidget = widget;
}
-void FocusHandler::releaseModalMouseInputFocus(gcn::Widget* widget)
+void FocusHandler::releaseModalMouseInputFocus(Widget* widget)
{
if (mModalMouseInputFocusedWidget == widget)
mModalMouseInputFocusedWidget = nullptr;
}
-gcn::Widget* FocusHandler::getFocused() const
+Widget* FocusHandler::getFocused() const
{
return mFocusedWidget;
}
-gcn::Widget* FocusHandler::getModalFocused() const
+Widget* FocusHandler::getModalFocused() const
{
return mModalFocusedWidget;
}
-gcn::Widget* FocusHandler::getModalMouseInputFocused() const
+Widget* FocusHandler::getModalMouseInputFocused() const
{
return mModalMouseInputFocusedWidget;
}
@@ -527,12 +527,12 @@ void FocusHandler::focusPrevious()
}
}
-bool FocusHandler::isFocused(const gcn::Widget* widget) const
+bool FocusHandler::isFocused(const Widget* widget) const
{
return mFocusedWidget == widget;
}
-void FocusHandler::add(gcn::Widget* widget)
+void FocusHandler::add(Widget* widget)
{
mWidgets.push_back(widget);
}
@@ -541,7 +541,7 @@ void FocusHandler::focusNone()
{
if (mFocusedWidget)
{
- gcn::Widget *const focused = mFocusedWidget;
+ Widget *const focused = mFocusedWidget;
mFocusedWidget = nullptr;
Event focusEvent(focused);
@@ -551,7 +551,7 @@ void FocusHandler::focusNone()
void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
{
- gcn::Widget *const sourceWidget = focusEvent.getSource();
+ Widget *const sourceWidget = focusEvent.getSource();
std::list<FocusListener*> focusListeners
= sourceWidget->_getFocusListeners();
@@ -566,52 +566,52 @@ void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
}
}
-gcn::Widget* FocusHandler::getDraggedWidget()
+Widget* FocusHandler::getDraggedWidget()
{
return mDraggedWidget;
}
-void FocusHandler::setDraggedWidget(gcn::Widget* draggedWidget)
+void FocusHandler::setDraggedWidget(Widget* draggedWidget)
{
mDraggedWidget = draggedWidget;
}
-gcn::Widget* FocusHandler::getLastWidgetWithMouse()
+Widget* FocusHandler::getLastWidgetWithMouse()
{
return mLastWidgetWithMouse;
}
-void FocusHandler::setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse)
+void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse)
{
mLastWidgetWithMouse = lastWidgetWithMouse;
}
-gcn::Widget* FocusHandler::getLastWidgetWithModalFocus()
+Widget* FocusHandler::getLastWidgetWithModalFocus()
{
return mLastWidgetWithModalFocus;
}
-void FocusHandler::setLastWidgetWithModalFocus(gcn::Widget* widget)
+void FocusHandler::setLastWidgetWithModalFocus(Widget* widget)
{
mLastWidgetWithModalFocus = widget;
}
-gcn::Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus()
+Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus()
{
return mLastWidgetWithModalMouseInputFocus;
}
-void FocusHandler::setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget)
+void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget)
{
mLastWidgetWithModalMouseInputFocus = widget;
}
-gcn::Widget* FocusHandler::getLastWidgetPressed()
+Widget* FocusHandler::getLastWidgetPressed()
{
return mLastWidgetPressed;
}
-void FocusHandler::setLastWidgetPressed(gcn::Widget* lastWidgetPressed)
+void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed)
{
mLastWidgetPressed = lastWidgetPressed;
}
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h
index c8885ef2c..ed3a08e98 100644
--- a/src/gui/focushandler.h
+++ b/src/gui/focushandler.h
@@ -74,11 +74,7 @@
#include "localconsts.h"
class Event;
-
-namespace gcn
-{
- class Widget;
-}
+class Widget;
/**
* The focus handler. This focus handler does exactly the same as the Guichan
@@ -101,7 +97,7 @@ class FocusHandler final
* @param widget The widget to request focus for.
* @see isFocused, Widget::requestFocus
*/
- void requestFocus(gcn::Widget* widget);
+ void requestFocus(Widget* widget);
/**
* Requests modal focus for a widget. Focus will only be granted
@@ -112,7 +108,7 @@ class FocusHandler final
* @throws Exception when another widget already has modal focus.
* @see releaseModalFocus, Widget::requestModalFocus
*/
- void requestModalFocus(gcn::Widget* widget);
+ void requestModalFocus(Widget* widget);
/**
* Requests modal mouse input focus for a widget. Focus will only
@@ -129,7 +125,7 @@ class FocusHandler final
* focus.
* @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus
*/
- void requestModalMouseInputFocus(gcn::Widget* widget);
+ void requestModalMouseInputFocus(Widget* widget);
/**
* Releases modal focus if the widget has modal focus.
@@ -138,7 +134,7 @@ class FocusHandler final
* @param widget The widget to release modal focus for.
* @see reuqestModalFocus, Widget::releaseModalFocus
*/
- void releaseModalFocus(gcn::Widget* widget);
+ void releaseModalFocus(Widget* widget);
/**
* Releases modal mouse input focus if the widget has modal mouse input
@@ -148,7 +144,7 @@ class FocusHandler final
* @param widget the widget to release modal mouse input focus for.
* @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus
*/
- void releaseModalMouseInputFocus(gcn::Widget* widget);
+ void releaseModalMouseInputFocus(Widget* widget);
/**
* Checks if a widget is focused.
@@ -157,14 +153,14 @@ class FocusHandler final
* @return True if the widget is focused, false otherwise.
* @see Widget::isFocused
*/
- bool isFocused(const gcn::Widget* widget) const;
+ bool isFocused(const Widget* widget) const;
/**
* Gets the widget with focus.
*
* @return The widget with focus. NULL if no widget has focus.
*/
- gcn::Widget* getFocused() const A_WARN_UNUSED;
+ Widget* getFocused() const A_WARN_UNUSED;
/**
* Gets the widget with modal focus.
@@ -172,7 +168,7 @@ class FocusHandler final
* @return The widget with modal focus. NULL if no widget has
* modal focus.
*/
- gcn::Widget* getModalFocused() const A_WARN_UNUSED;
+ Widget* getModalFocused() const A_WARN_UNUSED;
/**
* Gets the widget with modal mouse input focus.
@@ -180,7 +176,7 @@ class FocusHandler final
* @return The widget with modal mouse input focus. NULL if
* no widget has modal mouse input focus.
*/
- gcn::Widget* getModalMouseInputFocused() const A_WARN_UNUSED;
+ Widget* getModalMouseInputFocused() const A_WARN_UNUSED;
/**
* Focuses the next widget added to a conainer.
@@ -208,7 +204,7 @@ class FocusHandler final
* @param widget The widget to add.
* @see remove
*/
- void add(gcn::Widget* widget);
+ void add(Widget* widget);
/**
* Removes a widget from the focus handler.
@@ -216,7 +212,7 @@ class FocusHandler final
* @param widget The widget to remove.
* @see add
*/
- void remove(gcn::Widget* widget);
+ void remove(Widget* widget);
/**
* Focuses nothing. A focus event will also be sent to the
@@ -247,7 +243,7 @@ class FocusHandler final
* @return the widget being dragged.
* @see setDraggedWidget
*/
- gcn::Widget* getDraggedWidget() A_WARN_UNUSED;
+ Widget* getDraggedWidget() A_WARN_UNUSED;
/**
* Sets the widget being dragged. Used by the Gui class to
@@ -256,7 +252,7 @@ class FocusHandler final
* @param draggedWidget The widget being dragged.
* @see getDraggedWidget
*/
- void setDraggedWidget(gcn::Widget* draggedWidget);
+ void setDraggedWidget(Widget* draggedWidget);
/**
* Gets the last widget with the mouse. Used by the Gui class
@@ -265,7 +261,7 @@ class FocusHandler final
* @return The last widget with the mouse.
* @see setLastWidgetWithMouse
*/
- gcn::Widget* getLastWidgetWithMouse() A_WARN_UNUSED;
+ Widget* getLastWidgetWithMouse() A_WARN_UNUSED;
/**
* Sets the last widget with the mouse. Used by the Gui class
@@ -274,7 +270,7 @@ class FocusHandler final
* @param lastWidgetWithMouse The last widget with the mouse.
* @see getLastWidgetWithMouse
*/
- void setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse);
+ void setLastWidgetWithMouse(Widget* lastWidgetWithMouse);
/**
* Gets the last widget with modal focus.
@@ -282,7 +278,7 @@ class FocusHandler final
* @return The last widget with modal focus.
* @see setLastWidgetWithModalFocus
*/
- gcn::Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED;
+ Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED;
/**
* Sets the last widget with modal focus.
@@ -290,7 +286,7 @@ class FocusHandler final
* @param widget The last widget with modal focus.
* @see getLastWidgetWithModalFocus
*/
- void setLastWidgetWithModalFocus(gcn::Widget* widget);
+ void setLastWidgetWithModalFocus(Widget* widget);
/**
* Gets the last widget with modal mouse input focus.
@@ -298,7 +294,7 @@ class FocusHandler final
* @return The last widget with modal mouse input focus.
* @see setLastWidgetWithModalMouseInputFocus
*/
- gcn::Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED;
+ Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED;
/**
* Sets the last widget with modal mouse input focus.
@@ -306,7 +302,7 @@ class FocusHandler final
* @param widget The last widget with modal mouse input focus.
* @see getLastWidgetWithModalMouseInputFocus
*/
- void setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget);
+ void setLastWidgetWithModalMouseInputFocus(Widget* widget);
/**
* Gets the last widget pressed. Used by the Gui class to keep track
@@ -315,7 +311,7 @@ class FocusHandler final
* @return The last widget pressed.
* @see setLastWidgetPressed
*/
- gcn::Widget* getLastWidgetPressed() A_WARN_UNUSED;
+ Widget* getLastWidgetPressed() A_WARN_UNUSED;
/**
* Sets the last widget pressed. Used by the Gui class to keep track
@@ -324,7 +320,7 @@ class FocusHandler final
* @param lastWidgetPressed The last widget pressed.
* @see getLastWidgetPressed
*/
- void setLastWidgetPressed(gcn::Widget* lastWidgetPressed);
+ void setLastWidgetPressed(Widget* lastWidgetPressed);
private:
/**
@@ -352,7 +348,7 @@ class FocusHandler final
/**
* Typedef.
*/
- typedef std::vector<gcn::Widget*> WidgetVector;
+ typedef std::vector<Widget*> WidgetVector;
/**
* Typedef.
@@ -368,50 +364,50 @@ class FocusHandler final
/**
* Holds the focused widget. NULL if no widget has focus.
*/
- gcn::Widget* mFocusedWidget;
+ Widget* mFocusedWidget;
/**
* Holds the modal focused widget. NULL if no widget has
* modal focused.
*/
- gcn::Widget* mModalFocusedWidget;
+ Widget* mModalFocusedWidget;
/**
* Holds the modal mouse input focused widget. NULL if no widget
* is being dragged.
*/
- gcn::Widget* mModalMouseInputFocusedWidget;
+ Widget* mModalMouseInputFocusedWidget;
/**
* Holds the dragged widget. NULL if no widget is
* being dragged.
*/
- gcn::Widget* mDraggedWidget;
+ Widget* mDraggedWidget;
/**
* Holds the last widget with the mouse.
*/
- gcn::Widget* mLastWidgetWithMouse;
+ Widget* mLastWidgetWithMouse;
/**
* Holds the last widget with modal focus.
*/
- gcn::Widget* mLastWidgetWithModalFocus;
+ Widget* mLastWidgetWithModalFocus;
/**
* Holds the last widget with modal mouse input focus.
*/
- gcn::Widget* mLastWidgetWithModalMouseInputFocus;
+ Widget* mLastWidgetWithModalMouseInputFocus;
/**
* Holds the last widget pressed.
*/
- gcn::Widget* mLastWidgetPressed;
+ Widget* mLastWidgetPressed;
/**
* Stack of widgets that have requested modal forcus.
*/
- std::list<gcn::Widget*> mModalStack;
+ std::list<Widget*> mModalStack;
};
#endif // GUI_FOCUSHANDLER_H
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index fdaa299af..07aca0c81 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -223,7 +223,7 @@ void Gui::postInit(Graphics *const graphics)
mNpcFont = new Font(fontFile, npcFontSize);
- gcn::Widget::setGlobalFont(mGuiFont);
+ Widget::setGlobalFont(mGuiFont);
// Initialize mouse cursor and listen for changes to the option
setUseCustomCursor(config.getBoolValue("customcursor"));
@@ -538,7 +538,7 @@ void Gui::handleMousePressed(const MouseInput &mouseInput)
const unsigned int button = mouseInput.getButton();
const int timeStamp = mouseInput.getTimeStamp();
- gcn::Widget *sourceWidget = getMouseEventSource(x, y);
+ Widget *sourceWidget = getMouseEventSource(x, y);
if (mFocusHandler->getDraggedWidget())
sourceWidget = mFocusHandler->getDraggedWidget();
@@ -601,14 +601,14 @@ void Gui::updateFonts()
mNpcFont->loadFont(fontFile, npcFontSize);
}
-void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
+void Gui::distributeMouseEvent(Widget* source, int type, int button,
int x, int y, bool force,
bool toSourceOnly)
{
if (!source || !mFocusHandler)
return;
- gcn::Widget* widget = source;
+ Widget* widget = source;
if (!force && mFocusHandler->getModalFocused() != nullptr
&& !widget->isModalFocused())
@@ -626,12 +626,12 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
mAltPressed, mMetaPressed, type, button,
x, y, mClickCount);
- gcn::Widget* parent = source;
+ Widget* parent = source;
while (parent)
{
// If the widget has been removed due to input
// cancel the distribution.
- if (!gcn::Widget::widgetExists(widget))
+ if (!Widget::widgetExists(widget))
break;
parent = widget->getParent();
@@ -691,7 +691,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
break;
}
- const gcn::Widget *const swap = widget;
+ const Widget *const swap = widget;
widget = parent;
parent = swap->getParent();
@@ -740,7 +740,7 @@ MouseEvent *Gui::createMouseEvent(Window *const widget)
mouseX - x, mouseY - y, mClickCount);
}
-void Gui::getAbsolutePosition(gcn::Widget *restrict widget,
+void Gui::getAbsolutePosition(Widget *restrict widget,
int &restrict x, int &restrict y)
{
x = 0;
@@ -806,7 +806,7 @@ void Gui::handleMouseInput()
void Gui::handleMouseReleased(const MouseInput &mouseInput)
{
- gcn::Widget *sourceWidget = getMouseEventSource(
+ Widget *sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
int sourceWidgetX, sourceWidgetY;
@@ -815,7 +815,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
mFocusHandler->setLastWidgetPressed(nullptr);
- gcn::Widget *oldWidget = sourceWidget;
+ Widget *oldWidget = sourceWidget;
sourceWidget = mFocusHandler->getDraggedWidget();
if (oldWidget != sourceWidget)
{
@@ -876,7 +876,7 @@ void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent)
}
}
-void Gui::removeDragged(gcn::Widget *widget)
+void Gui::removeDragged(Widget *widget)
{
if (!mFocusHandler)
return;
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 232d47a22..4038bbec4 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -148,7 +148,7 @@ class Gui final : public gcn::Gui
MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED;
- static void getAbsolutePosition(gcn::Widget *restrict widget,
+ static void getAbsolutePosition(Widget *restrict widget,
int &restrict x,
int &restrict y);
@@ -158,7 +158,7 @@ class Gui final : public gcn::Gui
void distributeGlobalFocusGainedEvent(const Event &focusEvent);
- void removeDragged(gcn::Widget *widget);
+ void removeDragged(Widget *widget);
int getLastMouseX() const
{ return mLastMouseX; }
@@ -177,7 +177,7 @@ class Gui final : public gcn::Gui
void handleMouseInput();
- void distributeMouseEvent(gcn::Widget* source, int type, int button,
+ void distributeMouseEvent(Widget* source, int type, int button,
int x, int y, bool force = false,
bool toSourceOnly = false);
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 4300f4ea8..46b6ea20f 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -103,7 +103,7 @@ void AvatarListBox::draw(Graphics *graphics)
Font *const font = getFont();
const int fontHeight = getFont()->getHeight();
- const gcn::Widget *const parent = mParent;
+ const Widget *const parent = mParent;
const std::string name = player_node->getName();
// Draw the list elements
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 6e506eeeb..cfc26da0e 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -52,7 +52,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
const unsigned int mode,
const bool opaque,
const std::string &skin) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
mTextRows(),
mTextRowLinksCount(),
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index a33c69698..8202fa548 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -25,7 +25,8 @@
#define GUI_WIDGETS_BROWSERBOX_H
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+
+#include "gui/widgets/widget.h"
#include <list>
#include <vector>
@@ -100,7 +101,7 @@ class LinePart final
* A simple browser box able to handle links and forward events to the
* parent conteiner.
*/
-class BrowserBox final : public gcn::Widget,
+class BrowserBox final : public Widget,
public MouseListener
{
public:
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc
index 7bf674037..2acc5f5d3 100644
--- a/src/gui/widgets/browserbox_unittest.cc
+++ b/src/gui/widgets/browserbox_unittest.cc
@@ -51,7 +51,7 @@ TEST(browserbox, test1)
logger = new Logger();
imageHelper = new SDLImageHelper();
Theme *theme = Theme::instance();
- gcn::Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/"
+ Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/"
"ttf-dejavu/DejaVuSans-Oblique.ttf", 18));
BrowserBox *box = new BrowserBox(nullptr, BrowserBox::AUTO_WRAP, true, "");
box->setWidth(100);
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index 2d8aad965..93d74dc8d 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -45,7 +45,7 @@ void Container::removeControls()
delete mWidgets.front();
}
-bool Container::safeRemove(gcn::Widget *const widget)
+bool Container::safeRemove(Widget *const widget)
{
for (WidgetListConstIterator iter = mWidgets.begin();
iter != mWidgets.end(); ++iter)
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 36d7cce86..17d6b2af4 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -41,7 +41,7 @@ class Container : public gcn::Container
virtual ~Container();
- bool safeRemove(gcn::Widget *const widget);
+ bool safeRemove(Widget *const widget);
void removeControls();
};
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 1ebcb4841..2aff81955 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -34,7 +34,7 @@ namespace
} // namespace
EmotePage::EmotePage(const Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
WidgetListener(),
mEmotes(ResourceManager::getInstance()->getImageSet(
diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h
index 8a508bd26..2ce50f1fc 100644
--- a/src/gui/widgets/emotepage.h
+++ b/src/gui/widgets/emotepage.h
@@ -24,11 +24,11 @@
#include "listeners/mouselistener.h"
#include "listeners/widgetlistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "localconsts.h"
-class EmotePage final : public gcn::Widget,
+class EmotePage final : public Widget,
public MouseListener,
public WidgetListener
{
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 06fb731c4..e9b5c1e0c 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -86,7 +86,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
}
}
-void FlowContainer::add(gcn::Widget *widget)
+void FlowContainer::add(Widget *widget)
{
if (!widget)
return;
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
index 8e96204ae..7266bb06a 100644
--- a/src/gui/widgets/flowcontainer.h
+++ b/src/gui/widgets/flowcontainer.h
@@ -64,7 +64,7 @@ class FlowContainer final : public Container,
int getBoxHeight() const A_WARN_UNUSED
{ return mBoxHeight; }
- void add(gcn::Widget *widget) override final;
+ void add(Widget *widget) override final;
private:
int mBoxWidth;
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 7bd920046..98e7e5f23 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -44,7 +44,7 @@ class GuiTableActionListener final : public ActionListener
{
public:
GuiTableActionListener(GuiTable *restrict _table,
- gcn::Widget *restrict _widget,
+ Widget *restrict _widget,
int _row, int _column);
A_DELETE_COPY(GuiTableActionListener)
@@ -57,12 +57,12 @@ protected:
GuiTable *mTable;
int mRow;
int mColumn;
- gcn::Widget *mWidget;
+ Widget *mWidget;
};
GuiTableActionListener::GuiTableActionListener(GuiTable *restrict table,
- gcn::Widget *restrict widget,
+ Widget *restrict widget,
int row, int column) :
ActionListener(),
mTable(table),
@@ -96,7 +96,7 @@ void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED)
GuiTable::GuiTable(const Widget2 *const widget,
TableModel *const initial_model,
const bool opacity) :
- gcn::Widget(widget),
+ Widget(widget),
MouseListener(),
KeyListener(),
mModel(nullptr),
@@ -282,7 +282,7 @@ void GuiTable::installActionListeners()
{
for (int column = 0; column < columns; ++column)
{
- gcn::Widget *const widget = mModel->getElementAt(row, column);
+ Widget *const widget = mModel->getElementAt(row, column);
if (widget)
{
mActionListeners.push_back(new GuiTableActionListener(
@@ -347,7 +347,7 @@ void GuiTable::draw(Graphics* graphics)
for (unsigned c = first_column; c + 1 <= last_column1; ++c)
{
- gcn::Widget *const widget = mModel->getElementAt(r, c);
+ Widget *const widget = mModel->getElementAt(r, c);
const int cWidth = getColumnWidth(c);
if (widget)
{
@@ -401,15 +401,15 @@ void GuiTable::draw(Graphics* graphics)
BLOCK_END("GuiTable::draw")
}
-void GuiTable::moveToTop(gcn::Widget *widget)
+void GuiTable::moveToTop(Widget *widget)
{
- gcn::Widget::moveToTop(widget);
+ Widget::moveToTop(widget);
mTopWidget = widget;
}
-void GuiTable::moveToBottom(gcn::Widget *widget)
+void GuiTable::moveToBottom(Widget *widget)
{
- gcn::Widget::moveToBottom(widget);
+ Widget::moveToBottom(widget);
if (widget == mTopWidget)
mTopWidget = nullptr;
}
@@ -532,7 +532,7 @@ void GuiTable::modelUpdated(const bool completed)
}
}
-gcn::Widget *GuiTable::getWidgetAt(int x, int y)
+Widget *GuiTable::getWidgetAt(int x, int y)
{
const int row = getRowForY(y);
const int column = getColumnForX(x);
@@ -542,7 +542,7 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y)
if (mModel && row > -1 && column > -1)
{
- gcn::Widget *const w = mModel->getElementAt(row, column);
+ Widget *const w = mModel->getElementAt(row, column);
if (w && w->isFocusable())
return w;
else
@@ -595,7 +595,7 @@ void GuiTable::_setFocusHandler(FocusHandler* focusHandler)
if (!mModel || !focusHandler)
return;
- gcn::Widget::_setFocusHandler(focusHandler);
+ Widget::_setFocusHandler(focusHandler);
const int rows = mModel->getRows();
const int cols = mModel->getColumns();
@@ -603,7 +603,7 @@ void GuiTable::_setFocusHandler(FocusHandler* focusHandler)
{
for (int c = 0; c < cols ; ++c)
{
- gcn::Widget *const w = mModel->getElementAt(r, c);
+ Widget *const w = mModel->getElementAt(r, c);
if (w)
w->_setFocusHandler(focusHandler);
}
@@ -614,5 +614,5 @@ void GuiTable::requestFocus()
{
if (!mFocusHandler)
return;
- gcn::Widget::requestFocus();
+ Widget::requestFocus();
}
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
index 055c6c5f2..23185a903 100644
--- a/src/gui/widgets/guitable.h
+++ b/src/gui/widgets/guitable.h
@@ -30,7 +30,7 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include <vector>
@@ -45,7 +45,7 @@ class GuiTableActionListener;
*
* \ingroup GUI
*/
-class GuiTable final : public gcn::Widget,
+class GuiTable final : public Widget,
public MouseListener,
public KeyListener,
public TableModelListener
@@ -114,11 +114,11 @@ public:
// Inherited from Widget
void draw(Graphics* graphics) override final;
- gcn::Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED;
+ Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED;
- void moveToTop(gcn::Widget *child) override final;
+ void moveToTop(Widget *child) override final;
- void moveToBottom(gcn::Widget *child) override final;
+ void moveToBottom(Widget *child) override final;
void _setFocusHandler(FocusHandler* focusHandler) override final;
@@ -180,7 +180,7 @@ private:
TableModel *mModel;
/** If someone moves a fresh widget to the top, we must display it. */
- gcn::Widget *mTopWidget;
+ Widget *mTopWidget;
/** Vector for compactness; used as a list in practice. */
std::vector<GuiTableActionListener *> mActionListeners;
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index 5d0e14903..8e3be9662 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -36,12 +36,12 @@ HorizontContainer::HorizontContainer(const Widget2 *const widget,
addWidgetListener(this);
}
-void HorizontContainer::add(gcn::Widget *widget)
+void HorizontContainer::add(Widget *widget)
{
add(widget, mSpacing);
}
-void HorizontContainer::add(gcn::Widget *const widget, const int spacing)
+void HorizontContainer::add(Widget *const widget, const int spacing)
{
if (!widget)
return;
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 9a873272c..bef3d0b00 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -43,9 +43,9 @@ class HorizontContainer final : public Container,
A_DELETE_COPY(HorizontContainer)
- void add(gcn::Widget *widget) override final;
+ void add(Widget *widget) override final;
- void add(gcn::Widget *const widget, const int spacing);
+ void add(Widget *const widget, const int spacing);
void clear() override;
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 73c0db76c..53be9ef91 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -31,7 +31,7 @@
Icon::Icon(const Widget2 *const widget,
const std::string &file) :
- gcn::Widget(widget),
+ Widget(widget),
mImage(ResourceManager::getInstance()->getImage(file))
{
if (mImage)
@@ -43,7 +43,7 @@ Icon::Icon(const Widget2 *const widget,
Icon::Icon(const Widget2 *const widget,
Image *const image) :
- gcn::Widget(widget),
+ Widget(widget),
mImage(image)
{
if (mImage)
diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h
index dffdb8e8c..1e015f8e6 100644
--- a/src/gui/widgets/icon.h
+++ b/src/gui/widgets/icon.h
@@ -23,7 +23,7 @@
#ifndef GUI_WIDGETS_ICON_H
#define GUI_WIDGETS_ICON_H
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "localconsts.h"
@@ -34,7 +34,7 @@ class Image;
*
* \ingroup GUI
*/
-class Icon final : public gcn::Widget
+class Icon final : public Widget
{
public:
/**
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 85f020af4..0ea3adef1 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -158,7 +158,7 @@ namespace
ItemContainer::ItemContainer(const Widget2 *const widget,
Inventory *const inventory,
const bool forceQuantity) :
- gcn::Widget(widget),
+ Widget(widget),
KeyListener(),
MouseListener(),
WidgetListener(),
@@ -226,7 +226,7 @@ ItemContainer::~ItemContainer()
void ItemContainer::logic()
{
BLOCK_START("ItemContainer::logic")
- gcn::Widget::logic();
+ Widget::logic();
if (!mInventory)
{
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 32daa459b..f7bc44849 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -27,7 +27,7 @@
#include "listeners/mouselistener.h"
#include "listeners/widgetlistener.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include <list>
@@ -44,7 +44,7 @@ class SelectionListener;
*
* \ingroup GUI
*/
-class ItemContainer final : public gcn::Widget,
+class ItemContainer final : public Widget,
public KeyListener,
public MouseListener,
public WidgetListener
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 4132741e4..2af27a21c 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -36,7 +36,7 @@ ContainerPlacer ContainerPlacer::at(const int x, const int y)
}
LayoutCell &ContainerPlacer::operator()
- (const int x, const int y, gcn::Widget *const wg, const int w, const int h)
+ (const int x, const int y, Widget *const wg, const int w, const int h)
{
mContainer->add(wg);
return mCell->place(wg, x, y, w, h);
@@ -203,7 +203,7 @@ void LayoutArray::extend(const int x, const int y, const int w, const int h)
cell.mExtent[1] = h;
}
-LayoutCell &LayoutArray::place(gcn::Widget *const widget, const int x,
+LayoutCell &LayoutArray::place(Widget *const widget, const int x,
const int y, const int w, const int h)
{
LayoutCell &cell = at(x, y, w, h);
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 85998d8e7..288c282a0 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -32,9 +32,10 @@ class LayoutCell;
namespace gcn
{
class Container;
- class Widget;
}
+class Widget;
+
/**
* This class is a helper for adding widgets to nested tables in a window.
*/
@@ -61,7 +62,7 @@ class ContainerPlacer final
* Adds the given widget to the container and places it in the layout.
* @see LayoutArray::place
*/
- LayoutCell &operator()(const int x, const int y, gcn::Widget *const wg,
+ LayoutCell &operator()(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
private:
@@ -94,7 +95,7 @@ class LayoutArray final
* @note When @a w is 1, the width of column @a x is reset to zero if
* it was AUTO_DEF. Similarly for @a h.
*/
- LayoutCell &place(gcn::Widget *const widget, const int x, const int y,
+ LayoutCell &place(Widget *const widget, const int x, const int y,
const int w = 1, const int h = 1);
/**
@@ -220,7 +221,7 @@ class LayoutCell
/**
* @see LayoutArray::place
*/
- LayoutCell &place(gcn::Widget *wg, int x, int y, int w = 1, int h = 1)
+ LayoutCell &place(Widget *wg, int x, int y, int w = 1, int h = 1)
{ return getArray().place(wg, x, y, w, h); }
/**
@@ -298,7 +299,7 @@ class LayoutCell
union
{
- gcn::Widget *mWidget;
+ Widget *mWidget;
LayoutArray *mArray;
};
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index e4b931c92..83e6d050a 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -45,7 +45,7 @@ const Layout &LayoutHelper::getLayout() const
}
LayoutCell &LayoutHelper::place(const int x, const int y,
- gcn::Widget *const wg,
+ Widget *const wg,
const int w, const int h)
{
mContainer->add(wg);
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index d5a94e656..32e3d9e34 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -67,7 +67,7 @@ class LayoutHelper final : public WidgetListener
/**
* Adds a widget to the container and sets it at given cell.
*/
- LayoutCell &place(const int x, const int y, gcn::Widget *const wg,
+ LayoutCell &place(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
/**
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 76eb3707a..9a0a38013 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -148,7 +148,7 @@ void Popup::setContentSize(int width, int height)
mRedraw = true;
}
-void Popup::setLocationRelativeTo(const gcn::Widget *const widget)
+void Popup::setLocationRelativeTo(const Widget *const widget)
{
if (!widget)
return;
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index d1709a328..3c8947fce 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -86,7 +86,7 @@ class Popup : public Container,
/**
* Sets the location relative to the given widget.
*/
- void setLocationRelativeTo(const gcn::Widget *const widget);
+ void setLocationRelativeTo(const Widget *const widget);
void mouseMoved(MouseEvent &event) override;
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index 133cbd2ca..8ad4bd0c4 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -156,7 +156,7 @@ void PopupList::mouseReleased(MouseEvent& mouseEvent)
void PopupList::focusGained(const Event& event)
{
- const gcn::Widget *const source = event.getSource();
+ const Widget *const source = event.getSource();
if (!mVisible || source == this || source == mListBox
|| source == mScrollArea || source == mDropDown)
{
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index db199a714..1a1b8dc0e 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -40,7 +40,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
const int backColor,
const std::string &skin,
const std::string &skinFill):
- gcn::Widget(widget),
+ Widget(widget),
WidgetListener(),
mFillRect(),
mSkin(nullptr),
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index a4862882e..fef9bf11d 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -23,7 +23,7 @@
#ifndef GUI_WIDGETS_PROGRESSBAR_H
#define GUI_WIDGETS_PROGRESSBAR_H
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "listeners/widgetlistener.h"
@@ -39,7 +39,7 @@ class Skin;
*
* \ingroup GUI
*/
-class ProgressBar final : public gcn::Widget,
+class ProgressBar final : public Widget,
public WidgetListener
{
public:
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index f5b295ec8..8e86417bd 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -31,7 +31,7 @@
#include "debug.h"
ProgressIndicator::ProgressIndicator(Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
mIndicator(nullptr)
{
ImageSet *const images = Theme::getImageSetFromTheme(
diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h
index e62e7ec90..447c3d4e4 100644
--- a/src/gui/widgets/progressindicator.h
+++ b/src/gui/widgets/progressindicator.h
@@ -22,7 +22,7 @@
#ifndef GUI_WIDGETS_PROGRESSINDICATOR_H
#define GUI_WIDGETS_PROGRESSINDICATOR_H
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "localconsts.h"
@@ -32,7 +32,7 @@ class SimpleAnimation;
* A widget that indicates progress. Suitable to use instead of a progress bar
* in cases where it is unknown how long something is going to take.
*/
-class ProgressIndicator final : public gcn::Widget
+class ProgressIndicator final : public Widget
{
public:
explicit ProgressIndicator(Widget2 *const widget);
diff --git a/src/gui/widgets/radiogroup.cpp b/src/gui/widgets/radiogroup.cpp
index d2f130c1b..9bb4f40c5 100644
--- a/src/gui/widgets/radiogroup.cpp
+++ b/src/gui/widgets/radiogroup.cpp
@@ -31,7 +31,7 @@ RadioGroup::RadioGroup(const Widget2 *const widget,
{
}
-gcn::Widget *RadioGroup::createWidget(const std::string &text) const
+Widget *RadioGroup::createWidget(const std::string &text) const
{
RadioButton *const widget = new RadioButton(
this, text, mGroup, mCount == 0);
diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h
index d0bf18532..b553c629a 100644
--- a/src/gui/widgets/radiogroup.h
+++ b/src/gui/widgets/radiogroup.h
@@ -23,7 +23,7 @@
#include "gui/widgets/widgetgroup.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
class RadioGroup final : public WidgetGroup
{
@@ -35,8 +35,8 @@ class RadioGroup final : public WidgetGroup
A_DELETE_COPY(RadioGroup)
- gcn::Widget *createWidget(const std::string &name)
- const override final A_WARN_UNUSED;
+ Widget *createWidget(const std::string &name)
+ const override final A_WARN_UNUSED;
};
#endif // GUI_WIDGETS_RADIOGROUP_H
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index b508e2dd4..2ca851254 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -50,7 +50,7 @@ static std::string const buttonFiles[2] =
};
ScrollArea::ScrollArea(Widget2 *const widget2,
- gcn::Widget *const widget,
+ Widget *const widget,
const bool opaque,
const std::string &skin) :
gcn::ScrollArea(widget2, widget),
@@ -179,7 +179,7 @@ void ScrollArea::logic()
}
gcn::ScrollArea::logic();
- gcn::Widget *const content = getContent();
+ Widget *const content = getContent();
// When no scrollbar in a certain direction, adapt content size to match
// the content dimension exactly.
@@ -656,7 +656,7 @@ void ScrollArea::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
const unsigned int frameSize = 2 * mFrameSize;
- gcn::Widget *const content = getContent();
+ Widget *const content = getContent();
if (content)
{
content->setSize(mDimension.width - frameSize,
@@ -900,7 +900,7 @@ Rectangle ScrollArea::getVerticalMarkerDimension()
int height;
const int h2 = mShowButtons
? mScrollbarWidth : mMarkerSize / 2;
- const gcn::Widget *content;
+ const Widget *content;
if (!mWidgets.empty())
content = *mWidgets.begin();
else
@@ -958,7 +958,7 @@ Rectangle ScrollArea::getHorizontalMarkerDimension()
int width;
const int w2 = mShowButtons
? mScrollbarWidth : mMarkerSize / 2;
- const gcn::Widget *content;
+ const Widget *content;
if (!mWidgets.empty())
content = *mWidgets.begin();
else
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index e5c9ffb79..a6081e506 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -51,7 +51,7 @@ class ScrollArea final : public gcn::ScrollArea,
* @param content the initial content to show in the scroll area
*/
ScrollArea(Widget2 *const widget2,
- gcn::Widget *const widget,
+ Widget *const widget,
const bool opaque = true,
const std::string &skin = "");
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 1f5d48d06..3e40b902e 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -191,7 +191,7 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED)
{
}
-void SetupItem::fixFirstItemSize(gcn::Widget *const widget)
+void SetupItem::fixFirstItemSize(Widget *const widget)
{
const int maxSize = mParent->getPreferredFirstItemSize();
if (widget->getWidth() < maxSize)
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index 502d85d21..18e838cdf 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -70,10 +70,10 @@ class SetupItem : public ActionListener,
virtual void toWidget() = 0;
- void setWidget(gcn::Widget *widget)
+ void setWidget(Widget *widget)
{ mWidget = widget; }
- gcn::Widget *getWidget() const A_WARN_UNUSED
+ Widget *getWidget() const A_WARN_UNUSED
{ return mWidget; }
Configuration *getConfig() const A_WARN_UNUSED;
@@ -95,7 +95,7 @@ class SetupItem : public ActionListener,
bool isMainConfig() const A_WARN_UNUSED
{ return mMainConfig; }
- void fixFirstItemSize(gcn::Widget *const widget);
+ void fixFirstItemSize(Widget *const widget);
virtual void rereadValue();
@@ -138,9 +138,9 @@ class SetupItem : public ActionListener,
std::string mDefault;
- gcn::Widget *mWidget;
+ Widget *mWidget;
- std::list<gcn::Widget*> mTempWidgets;
+ std::list<Widget*> mTempWidgets;
int mValueType;
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index a8acb3f5f..a7e166da3 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -31,7 +31,7 @@
float ShortcutContainer::mAlpha = 1.0;
ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
- gcn::Widget(widget),
+ Widget(widget),
WidgetListener(),
MouseListener(),
mBackgroundImg(nullptr),
diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h
index 115298081..81392097b 100644
--- a/src/gui/widgets/shortcutcontainer.h
+++ b/src/gui/widgets/shortcutcontainer.h
@@ -23,8 +23,9 @@
#ifndef GUI_WIDGETS_SHORTCUTCONTAINER_H
#define GUI_WIDGETS_SHORTCUTCONTAINER_H
+#include "gui/widgets/widget.h"
+
#include "listeners/mouselistener.h"
-#include "gui/base/widget.hpp"
#include "listeners/widgetlistener.h"
class Image;
@@ -35,7 +36,7 @@ class ImageCollection;
*
* \ingroup GUI
*/
-class ShortcutContainer : public gcn::Widget,
+class ShortcutContainer : public Widget,
public WidgetListener,
public MouseListener
{
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index ce2c02886..7f58a061e 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -197,7 +197,7 @@ void TabbedArea::draw(Graphics *graphics)
BLOCK_END("TabbedArea::draw")
}
-gcn::Widget *TabbedArea::getWidget(const std::string &name) const
+Widget *TabbedArea::getWidget(const std::string &name) const
{
TabContainer::const_iterator itr = mTabs.begin();
const TabContainer::const_iterator itr_end = mTabs.end();
@@ -212,7 +212,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const
return nullptr;
}
-gcn::Widget *TabbedArea::getCurrentWidget() const
+Widget *TabbedArea::getCurrentWidget() const
{
const Tab *const tab = getSelectedTab();
@@ -223,7 +223,7 @@ gcn::Widget *TabbedArea::getCurrentWidget() const
}
void TabbedArea::addTab(Tab *const tab,
- gcn::Widget *const widget)
+ Widget *const widget)
{
if (!tab || !widget)
return;
@@ -232,7 +232,7 @@ void TabbedArea::addTab(Tab *const tab,
tab->addActionListener(this);
mTabContainer->add(tab);
- mTabs.push_back(std::pair<Tab*, gcn::Widget*>(tab, widget));
+ mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
if (!mSelectedTab)
setSelectedTab(tab);
@@ -248,14 +248,14 @@ void TabbedArea::addTab(Tab *const tab,
updateArrowEnableState();
}
-void TabbedArea::adjustWidget(gcn::Widget *const widget) const
+void TabbedArea::adjustWidget(Widget *const widget) const
{
const int frameSize = 2 * mFrameSize;
widget->setSize(getWidth() - frameSize,
getHeight() - frameSize - mTabContainer->getHeight());
}
-void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget)
+void TabbedArea::addTab(const std::string &caption, Widget *const widget)
{
Tab *const tab = new Tab(this);
tab->setCaption(caption);
@@ -264,7 +264,7 @@ void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget)
addTab(tab, widget);
}
-void TabbedArea::addTab(Image *const image, gcn::Widget *const widget)
+void TabbedArea::addTab(Image *const image, Widget *const widget)
{
Tab *const tab = new Tab(this);
tab->setImage(image);
@@ -375,7 +375,7 @@ void TabbedArea::mousePressed(MouseEvent &mouseEvent)
if (mouseEvent.getButton() == MouseEvent::LEFT)
{
- gcn::Widget *const widget = mTabContainer->getWidgetAt(
+ Widget *const widget = mTabContainer->getWidgetAt(
mouseEvent.getX(), mouseEvent.getY());
Tab *const tab = dynamic_cast<Tab *const>(widget);
@@ -449,7 +449,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
const int height = h1 - frameSize
- mWidgetContainer->getY() - widgetFrameSize;
- gcn::Widget *const w = getCurrentWidget();
+ Widget *const w = getCurrentWidget();
if (w)
{
ScrollArea *const scr = dynamic_cast<ScrollArea *const>(w);
@@ -545,7 +545,7 @@ void TabbedArea::adjustSize()
mWidgetContainer->setPosition(0, maxTabHeight);
mWidgetContainer->setSize(width, height - maxTabHeight);
- gcn::Widget *const w = getCurrentWidget();
+ Widget *const w = getCurrentWidget();
if (w)
{
const int wFrameSize = w->getFrameSize();
@@ -605,7 +605,7 @@ void TabbedArea::adjustTabPositions()
void TabbedArea::action(const ActionEvent& actionEvent)
{
- gcn::Widget *const source = actionEvent.getSource();
+ Widget *const source = actionEvent.getSource();
Tab *const tab = dynamic_cast<Tab *const>(source);
if (tab)
@@ -677,7 +677,7 @@ Tab *TabbedArea::getTabByIndex(const int index) const
return static_cast<Tab*>(mTabs[index].first);
}
-gcn::Widget *TabbedArea::getWidgetByIndex(const int index) const
+Widget *TabbedArea::getWidgetByIndex(const int index) const
{
if (index < 0 || index >= static_cast<int>(mTabs.size()))
return nullptr;
@@ -694,7 +694,7 @@ void TabbedArea::removeAll(const bool del)
{
const int idx = getNumberOfTabs() - 1;
Tab *tab = mTabs[idx].first;
- gcn::Widget *widget = mTabs[idx].second;
+ Widget *widget = mTabs[idx].second;
removeTab(tab);
if (del)
{
@@ -706,25 +706,25 @@ void TabbedArea::removeAll(const bool del)
void TabbedArea::setWidth(int width)
{
- gcn::Widget::setWidth(width);
+ Widget::setWidth(width);
adjustSize();
}
void TabbedArea::setHeight(int height)
{
- gcn::Widget::setHeight(height);
+ Widget::setHeight(height);
adjustSize();
}
void TabbedArea::setSize(int width, int height)
{
- gcn::Widget::setSize(width, height);
+ Widget::setSize(width, height);
adjustSize();
}
void TabbedArea::setDimension(const Rectangle &dimension)
{
- gcn::Widget::setDimension(dimension);
+ Widget::setDimension(dimension);
adjustSize();
}
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 2affd7368..0ad4fbbe6 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -118,17 +118,17 @@ class TabbedArea final : public ActionListener,
Tab *getTabByIndex(const int index) const A_WARN_UNUSED;
- gcn::Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED;
+ Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED;
/**
* Returns the widget with the tab that has specified caption
*/
- gcn::Widget *getWidget(const std::string &name) const A_WARN_UNUSED;
+ Widget *getWidget(const std::string &name) const A_WARN_UNUSED;
/**
* Returns the widget for the current tab
*/
- gcn::Widget *getCurrentWidget() const A_WARN_UNUSED;
+ Widget *getCurrentWidget() const A_WARN_UNUSED;
/**
* Add a tab. Overridden since it needs to size the widget.
@@ -136,11 +136,11 @@ class TabbedArea final : public ActionListener,
* @param tab The tab widget for the tab.
* @param widget The widget to view when the tab is selected.
*/
- void addTab(Tab *const tab, gcn::Widget *const widget);
+ void addTab(Tab *const tab, Widget *const widget);
- void addTab(const std::string &caption, gcn::Widget *const widget);
+ void addTab(const std::string &caption, Widget *const widget);
- void addTab(Image *const image, gcn::Widget *const widget);
+ void addTab(Image *const image, Widget *const widget);
bool isTabSelected(const unsigned int index) const A_WARN_UNUSED;
@@ -229,14 +229,14 @@ class TabbedArea final : public ActionListener,
void setResizeHeight(bool b)
{ mResizeHeight = b; }
- void adjustWidget(gcn::Widget *const widget) const;
+ void adjustWidget(Widget *const widget) const;
void selectNextTab();
void selectPrevTab();
private:
- typedef std::vector <std::pair<Tab*, gcn::Widget*> > TabContainer;
+ typedef std::vector <std::pair<Tab*, Widget*> > TabContainer;
/** The tab arrows */
Button *mArrowButton[2];
diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp
index 7b6b8048e..82b249d0f 100644
--- a/src/gui/widgets/tablemodel.cpp
+++ b/src/gui/widgets/tablemodel.cpp
@@ -24,7 +24,7 @@
#include "utils/dtor.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "debug.h"
@@ -89,7 +89,7 @@ void StaticTableModel::resize()
}
void StaticTableModel::set(const int row, const int column,
- gcn::Widget *const widget)
+ Widget *const widget)
{
if (!widget || row >= mRows || row < 0
|| column >= mColumns || column < 0)
@@ -119,8 +119,8 @@ void StaticTableModel::set(const int row, const int column,
signalAfterUpdate();
}
-gcn::Widget *StaticTableModel::getElementAt(const int row,
- const int column) const
+Widget *StaticTableModel::getElementAt(const int row,
+ const int column) const
{
return mTableModel[WIDGET_AT(row, column)];
}
diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h
index 1273c6873..48bd336af 100644
--- a/src/gui/widgets/tablemodel.h
+++ b/src/gui/widgets/tablemodel.h
@@ -28,10 +28,7 @@
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
-}
+class Widget;
class TableModelListener
{
@@ -83,7 +80,7 @@ public:
/**
* Retrieves the widget stored at the specified location within the table.
*/
- virtual gcn::Widget *getElementAt(const int row, const int column)
+ virtual Widget *getElementAt(const int row, const int column)
const A_WARN_UNUSED = 0;
virtual void installListener(TableModelListener *const listener);
@@ -125,7 +122,7 @@ public:
* The model is resized to accomodate the widget's width and height,
* unless column width / row height have been fixed.
*/
- void set(const int row, const int column, gcn::Widget *const widget);
+ void set(const int row, const int column, Widget *const widget);
/**
* Fixes the column width for a given column; this overrides dynamic width
@@ -153,14 +150,14 @@ public:
int getWidth() const A_WARN_UNUSED;
int getHeight() const A_WARN_UNUSED;
int getColumnWidth(const int index) const override final A_WARN_UNUSED;
- gcn::Widget *getElementAt(const int row,
+ Widget *getElementAt(const int row,
const int column) const
override final A_WARN_UNUSED;
protected:
int mRows, mColumns;
int mHeight;
- std::vector<gcn::Widget *> mTableModel;
+ std::vector<Widget *> mTableModel;
std::vector<int> mWidths;
};
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index aa1180cef..e2e66c6fc 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -104,7 +104,7 @@ Setup_Joystick::~Setup_Joystick()
void Setup_Joystick::action(const ActionEvent &event)
{
- const gcn::Widget *const source = event.getSource();
+ const Widget *const source = event.getSource();
if (source == mJoystickEnabled)
{
setTempEnabled(mJoystickEnabled->isSelected());
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index 30e1c96bd..dd08d437b 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -165,7 +165,7 @@ public:
player_names->size()); r < sz; ++r)
{
const std::string name = (*player_names)[r];
- gcn::Widget *const widget = new Label(this, name);
+ Widget *const widget = new Label(this, name);
mWidgets.push_back(widget);
DropDown *const choicebox = new DropDown(this, mListModel);
@@ -186,7 +186,7 @@ public:
}
- gcn::Widget *getElementAt(int row, int column) const override final
+ Widget *getElementAt(int row, int column) const override final
{
return mWidgets[WIDGET_AT(row, column)];
}
@@ -209,7 +209,7 @@ public:
protected:
StringVect *mPlayers;
- std::vector<gcn::Widget *> mWidgets;
+ std::vector<Widget *> mWidgets;
PlayerRelationListModel *mListModel;
};
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 4a72d7ccd..57520afce 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -39,7 +39,7 @@ TabStrip::TabStrip(const Widget2 *const widget,
{
}
-gcn::Widget *TabStrip::createWidget(const std::string &text) const
+Widget *TabStrip::createWidget(const std::string &text) const
{
Button *const widget = new Button(this);
widget->setStick(true);
@@ -55,7 +55,7 @@ void TabStrip::action(const ActionEvent &event)
WidgetGroup::action(event);
if (event.getSource())
{
- gcn::Widget *const widget = event.getSource();
+ Widget *const widget = event.getSource();
if (static_cast<Button*>(widget)->isPressed2())
{
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h
index 57a178ff0..b2dfc99e2 100644
--- a/src/gui/widgets/tabstrip.h
+++ b/src/gui/widgets/tabstrip.h
@@ -23,7 +23,7 @@
#include "gui/widgets/widgetgroup.h"
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
class TabStrip final : public WidgetGroup
{
@@ -39,8 +39,8 @@ class TabStrip final : public WidgetGroup
A_DELETE_COPY(TabStrip)
- gcn::Widget *createWidget(const std::string &name)
- const override final A_WARN_UNUSED;
+ Widget *createWidget(const std::string &name)
+ const override final A_WARN_UNUSED;
void action(const ActionEvent &event) override final;
};
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 59e61f8d2..6fce77641 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -292,7 +292,7 @@ void TextBox::keyPressed(KeyEvent& keyEvent)
case Input::KEY_GUI_PAGE_UP:
{
- gcn::Widget *const par = getParent();
+ Widget *const par = getParent();
if (par)
{
@@ -308,7 +308,7 @@ void TextBox::keyPressed(KeyEvent& keyEvent)
case Input::KEY_GUI_PAGE_DOWN:
{
- gcn::Widget *const par = getParent();
+ Widget *const par = getParent();
if (par)
{
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 0676dec25..3772f3bbc 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -35,7 +35,7 @@ Skin *TextPreview::mSkin = nullptr;
TextPreview::TextPreview(const Widget2 *const widget,
const std::string &text) :
- gcn::Widget(widget),
+ Widget(widget),
mFont(gui->getFont()),
mText(text),
mTextColor(&getThemeColor(Theme::TEXT)),
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index 31768fa66..5a09e1148 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -23,14 +23,14 @@
#ifndef GUI_WIDGETS_TEXTPREVIEW_H
#define GUI_WIDGETS_TEXTPREVIEW_H
-#include "gui/base/widget.hpp"
+#include "gui/widgets/widget.h"
#include "localconsts.h"
/**
* Preview widget for particle colors, etc.
*/
-class TextPreview final : public gcn::Widget
+class TextPreview final : public Widget
{
public:
TextPreview(const Widget2 *const widget,
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index 9d596d620..b86aa3e5f 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -40,12 +40,12 @@ VertContainer::VertContainer(const Widget2 *const widget,
addWidgetListener(this);
}
-void VertContainer::add1(gcn::Widget *const widget, const int spacing)
+void VertContainer::add1(Widget *const widget, const int spacing)
{
add2(widget, mResizable, spacing);
}
-void VertContainer::add2(gcn::Widget *const widget, const bool resizable,
+void VertContainer::add2(Widget *const widget, const bool resizable,
const int spacing)
{
if (!widget)
@@ -82,6 +82,6 @@ void VertContainer::clear()
void VertContainer::widgetResized(const Event &event A_UNUSED)
{
- FOR_EACH (std::vector<gcn::Widget*>::const_iterator, it, mResizableWidgets)
+ FOR_EACH (std::vector<Widget*>::const_iterator, it, mResizableWidgets)
(*it)->setWidth(getWidth());
}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
index 5fb212b48..05ba2e32f 100644
--- a/src/gui/widgets/vertcontainer.h
+++ b/src/gui/widgets/vertcontainer.h
@@ -46,17 +46,17 @@ class VertContainer final : public Container,
A_DELETE_COPY(VertContainer)
- void add2(gcn::Widget *const widget, const bool resizable,
+ void add2(Widget *const widget, const bool resizable,
const int spacing = -1);
- void add1(gcn::Widget *const widget, const int spacing = -1);
+ void add1(Widget *const widget, const int spacing = -1);
void clear();
void widgetResized(const Event &event) override final;
private:
- std::vector<gcn::Widget*> mResizableWidgets;
+ std::vector<Widget*> mResizableWidgets;
int mVerticalItemSize;
int mCount;
int mNextY;
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
new file mode 100644
index 000000000..f93107bc5
--- /dev/null
+++ b/src/gui/widgets/widget.cpp
@@ -0,0 +1,676 @@
+/*
+ * 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/widget.h"
+
+#include "events/actionevent.h"
+
+#include "events/event.h"
+
+#include "gui/focushandler.h"
+
+#include "listeners/actionlistener.h"
+#include "listeners/deathlistener.h"
+#include "listeners/widgetlistener.h"
+
+#include "render/graphics.h"
+
+#include "debug.h"
+
+Font* Widget::mGlobalFont = nullptr;
+std::list<Widget*> Widget::mWidgets;
+std::set<Widget*> Widget::mWidgetsSet;
+
+Widget::Widget(const Widget2 *const widget) :
+ Widget2(widget),
+ mMouseListeners(),
+ mKeyListeners(),
+ mActionListeners(),
+ mDeathListeners(),
+ mFocusListeners(),
+ mWidgetListeners(),
+ mForegroundColor(0x000000),
+ mBackgroundColor(0xffffff),
+ mBaseColor(0x808090),
+ mSelectionColor(0xc3d9ff),
+ mFocusHandler(nullptr),
+ mInternalFocusHandler(nullptr),
+ mParent(nullptr),
+ mDimension(),
+ mFrameSize(0),
+ mActionEventId(),
+ mFocusable(false),
+ mVisible(true),
+ mTabIn(true),
+ mTabOut(true),
+ mEnabled(true),
+ mId(),
+ mCurrentFont(nullptr)
+{
+ mWidgets.push_back(this);
+ mWidgetsSet.insert(this);
+}
+
+Widget::~Widget()
+{
+ for (DeathListenerIterator iter = mDeathListeners.begin();
+ iter != mDeathListeners.end();
+ ++iter)
+ {
+ Event event(this);
+ (*iter)->death(event);
+ }
+
+ _setFocusHandler(nullptr);
+
+ mWidgets.remove(this);
+ mWidgetsSet.erase(this);
+}
+
+void Widget::drawFrame(Graphics* graphics)
+{
+ BLOCK_START("Widget::drawFrame")
+ const Color &faceColor = getBaseColor();
+ Color highlightColor = faceColor + Color(0x303030);
+ Color shadowColor = faceColor - Color(0x303030);
+ const int alpha = getBaseColor().a;
+ const int width = getWidth() + getFrameSize() * 2 - 1;
+ const int height = getHeight() + getFrameSize() * 2 - 1;
+ highlightColor.a = alpha;
+ shadowColor.a = alpha;
+
+ for (unsigned int i = 0; i < getFrameSize(); ++i)
+ {
+ graphics->setColor(shadowColor);
+ graphics->drawLine(i, i, width - i, i);
+ graphics->drawLine(i, i + 1, i, height - i - 1);
+ graphics->setColor(highlightColor);
+ graphics->drawLine(width - i, i + 1, width - i, height - i);
+ graphics->drawLine(i, height - i, width - i - 1, height - i);
+ }
+ BLOCK_END("Widget::drawFrame")
+}
+
+void Widget::_setParent(Widget* parent)
+{
+ mParent = parent;
+}
+
+void Widget::setWidth(int width)
+{
+ Rectangle newDimension = mDimension;
+ newDimension.width = width;
+
+ setDimension(newDimension);
+}
+
+void Widget::setHeight(int height)
+{
+ Rectangle newDimension = mDimension;
+ newDimension.height = height;
+
+ setDimension(newDimension);
+}
+
+void Widget::setX(int x)
+{
+ Rectangle newDimension = mDimension;
+ newDimension.x = x;
+
+ setDimension(newDimension);
+}
+
+void Widget::setY(int y)
+{
+ Rectangle newDimension = mDimension;
+ newDimension.y = y;
+
+ setDimension(newDimension);
+}
+
+void Widget::setPosition(int x, int y)
+{
+ Rectangle newDimension = mDimension;
+ newDimension.x = x;
+ newDimension.y = y;
+
+ setDimension(newDimension);
+}
+
+void Widget::setDimension(const Rectangle& dimension)
+{
+ const Rectangle oldDimension = mDimension;
+ mDimension = dimension;
+
+ if (mDimension.width != oldDimension.width
+ || mDimension.height != oldDimension.height)
+ {
+ distributeResizedEvent();
+ }
+
+ if (mDimension.x != oldDimension.x
+ || mDimension.y != oldDimension.y)
+ {
+ distributeMovedEvent();
+ }
+}
+
+void Widget::setFrameSize(unsigned int frameSize)
+{
+ mFrameSize = frameSize;
+}
+
+unsigned int Widget::getFrameSize() const
+{
+ return mFrameSize;
+}
+
+const Rectangle& Widget::getDimension() const
+{
+ return mDimension;
+}
+
+const std::string& Widget::getActionEventId() const
+{
+ return mActionEventId;
+}
+
+void Widget::setActionEventId(const std::string& actionEventId)
+{
+ mActionEventId = actionEventId;
+}
+
+bool Widget::isFocused() const
+{
+ if (!mFocusHandler)
+ return false;
+
+ return (mFocusHandler->isFocused(this));
+}
+
+void Widget::setFocusable(bool focusable)
+{
+ if (!focusable && isFocused())
+ {
+ mFocusHandler->focusNone();
+ }
+
+ mFocusable = focusable;
+}
+
+bool Widget::isFocusable() const
+{
+ return mFocusable && isVisible() && isEnabled();
+}
+
+void Widget::requestFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ if (isFocusable())
+ mFocusHandler->requestFocus(this);
+}
+
+void Widget::requestMoveToTop()
+{
+ if (mParent)
+ mParent->moveToTop(this);
+}
+
+void Widget::requestMoveToBottom()
+{
+ if (mParent)
+ mParent->moveToBottom(this);
+}
+
+void Widget::setVisible(bool visible)
+{
+ if (!visible && isFocused())
+ mFocusHandler->focusNone();
+
+ if (visible)
+ distributeShownEvent();
+ else
+ distributeHiddenEvent();
+
+ mVisible = visible;
+}
+
+void Widget::setBaseColor(const Color& color)
+{
+ mBaseColor = color;
+}
+
+const Color& Widget::getBaseColor() const
+{
+ return mBaseColor;
+}
+
+void Widget::setForegroundColor(const Color& color)
+{
+ mForegroundColor = color;
+}
+
+const Color& Widget::getForegroundColor() const
+{
+ return mForegroundColor;
+}
+
+void Widget::setBackgroundColor(const Color& color)
+{
+ mBackgroundColor = color;
+}
+
+const Color& Widget::getBackgroundColor() const
+{
+ return mBackgroundColor;
+}
+
+void Widget::setSelectionColor(const Color& color)
+{
+ mSelectionColor = color;
+}
+
+const Color& Widget::getSelectionColor() const
+{
+ return mSelectionColor;
+}
+
+void Widget::_setFocusHandler(FocusHandler* focusHandler)
+{
+ if (mFocusHandler)
+ {
+ releaseModalFocus();
+ mFocusHandler->remove(this);
+ }
+
+ if (focusHandler)
+ focusHandler->add(this);
+
+ mFocusHandler = focusHandler;
+}
+
+FocusHandler* Widget::_getFocusHandler()
+{
+ return mFocusHandler;
+}
+
+void Widget::addActionListener(ActionListener* actionListener)
+{
+ mActionListeners.push_back(actionListener);
+}
+
+void Widget::removeActionListener(ActionListener* actionListener)
+{
+ mActionListeners.remove(actionListener);
+}
+
+void Widget::addDeathListener(DeathListener* deathListener)
+{
+ mDeathListeners.push_back(deathListener);
+}
+
+void Widget::removeDeathListener(DeathListener* deathListener)
+{
+ mDeathListeners.remove(deathListener);
+}
+
+void Widget::addKeyListener(KeyListener* keyListener)
+{
+ mKeyListeners.push_back(keyListener);
+}
+
+void Widget::removeKeyListener(KeyListener* keyListener)
+{
+ mKeyListeners.remove(keyListener);
+}
+
+void Widget::addFocusListener(FocusListener* focusListener)
+{
+ mFocusListeners.push_back(focusListener);
+}
+
+void Widget::removeFocusListener(FocusListener* focusListener)
+{
+ mFocusListeners.remove(focusListener);
+}
+
+void Widget::addMouseListener(MouseListener* mouseListener)
+{
+ mMouseListeners.push_back(mouseListener);
+}
+
+void Widget::removeMouseListener(MouseListener* mouseListener)
+{
+ mMouseListeners.remove(mouseListener);
+}
+
+void Widget::addWidgetListener(WidgetListener* widgetListener)
+{
+ mWidgetListeners.push_back(widgetListener);
+}
+
+void Widget::removeWidgetListener(WidgetListener* widgetListener)
+{
+ mWidgetListeners.remove(widgetListener);
+}
+
+void Widget::getAbsolutePosition(int& x, int& y) const
+{
+ if (!mParent)
+ {
+ x = mDimension.x;
+ y = mDimension.y;
+ return;
+ }
+
+ int parentX;
+ int parentY;
+
+ mParent->getAbsolutePosition(parentX, parentY);
+
+ const Rectangle &rect = mParent->getChildrenArea();
+ x = parentX + mDimension.x + rect.x;
+ y = parentY + mDimension.y + rect.y;
+}
+
+Font* Widget::getFont() const
+{
+ if (!mCurrentFont)
+ return mGlobalFont;
+ return mCurrentFont;
+}
+
+void Widget::setGlobalFont(Font* font)
+{
+ mGlobalFont = font;
+
+ for (std::list<Widget*>::const_iterator iter = mWidgets.begin();
+ iter != mWidgets.end(); ++iter)
+ {
+ if (!(*iter)->mCurrentFont)
+ (*iter)->fontChanged();
+ }
+}
+
+void Widget::setFont(Font* font)
+{
+ mCurrentFont = font;
+ fontChanged();
+}
+
+bool Widget::widgetExists(const Widget* widget)
+{
+ return mWidgetsSet.find(const_cast<Widget*>(widget))
+ != mWidgetsSet.end();
+}
+
+bool Widget::isTabInEnabled() const
+{
+ return mTabIn;
+}
+
+void Widget::setTabInEnabled(bool enabled)
+{
+ mTabIn = enabled;
+}
+
+bool Widget::isTabOutEnabled() const
+{
+ return mTabOut;
+}
+
+void Widget::setTabOutEnabled(bool enabled)
+{
+ mTabOut = enabled;
+}
+
+void Widget::setSize(int width, int height)
+{
+ Rectangle newDimension = mDimension;
+ newDimension.width = width;
+ newDimension.height = height;
+
+ setDimension(newDimension);
+}
+
+void Widget::setEnabled(bool enabled)
+{
+ mEnabled = enabled;
+}
+
+bool Widget::isEnabled() const
+{
+ return mEnabled && isVisible();
+}
+
+void Widget::requestModalFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->requestModalFocus(this);
+}
+
+void Widget::requestModalMouseInputFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->requestModalMouseInputFocus(this);
+}
+
+void Widget::releaseModalFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->releaseModalFocus(this);
+}
+
+void Widget::releaseModalMouseInputFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->releaseModalMouseInputFocus(this);
+}
+
+bool Widget::isModalFocused() const
+{
+ if (!mFocusHandler)
+ return false;
+
+ if (mParent)
+ {
+ return (mFocusHandler->getModalFocused() == this)
+ || mParent->isModalFocused();
+ }
+
+ return mFocusHandler->getModalFocused() == this;
+}
+
+bool Widget::isModalMouseInputFocused() const
+{
+ if (!mFocusHandler)
+ return false;
+
+ if (mParent)
+ {
+ return (mFocusHandler->getModalMouseInputFocused() == this)
+ || mParent->isModalMouseInputFocused();
+ }
+
+ return mFocusHandler->getModalMouseInputFocused() == this;
+}
+
+Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED)
+{
+ return nullptr;
+}
+
+const std::list<MouseListener*>& Widget::_getMouseListeners()
+{
+ return mMouseListeners;
+}
+
+const std::list<KeyListener*>& Widget::_getKeyListeners()
+{
+ return mKeyListeners;
+}
+
+const std::list<FocusListener*>& Widget::_getFocusListeners()
+{
+ return mFocusListeners;
+}
+
+Rectangle Widget::getChildrenArea()
+{
+ return Rectangle(0, 0, 0, 0);
+}
+
+FocusHandler* Widget::_getInternalFocusHandler()
+{
+ return mInternalFocusHandler;
+}
+
+void Widget::setInternalFocusHandler(FocusHandler* focusHandler)
+{
+ mInternalFocusHandler = focusHandler;
+}
+
+void Widget::setId(const std::string& id)
+{
+ mId = id;
+}
+
+const std::string& Widget::getId()
+{
+ return mId;
+}
+
+void Widget::distributeResizedEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++ iter)
+ {
+ Event event(this);
+ (*iter)->widgetResized(event);
+ }
+}
+
+void Widget::distributeMovedEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++ iter)
+ {
+ Event event(this);
+ (*iter)->widgetMoved(event);
+ }
+}
+
+void Widget::distributeHiddenEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++ iter)
+ {
+ Event event(this);
+ (*iter)->widgetHidden(event);
+ }
+}
+
+void Widget::distributeActionEvent()
+{
+ for (ActionListenerIterator iter = mActionListeners.begin();
+ iter != mActionListeners.end();
+ ++iter)
+ {
+ ActionEvent actionEvent(this, mActionEventId);
+ (*iter)->action(actionEvent);
+ }
+}
+
+void Widget::distributeShownEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++iter)
+ {
+ Event event(this);
+ (*iter)->widgetShown(event);
+ }
+}
+
+void Widget::showPart(Rectangle rectangle)
+{
+ if (mParent)
+ mParent->showWidgetPart(this, rectangle);
+}
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
new file mode 100644
index 000000000..08f1456b0
--- /dev/null
+++ b/src/gui/widgets/widget.h
@@ -0,0 +1,1228 @@
+/*
+ * 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_WIDGET_H
+#define GUI_WIDGETS_WIDGET_H
+
+#include <list>
+#include <set>
+#include <string>
+
+#include "gui/color.h"
+#include "gui/rectangle.h"
+
+#include "gui/widgets/widget2.h"
+
+#include "localconsts.h"
+
+class ActionListener;
+class DeathListener;
+class FocusHandler;
+class FocusListener;
+class Font;
+class Graphics;
+class KeyListener;
+class MouseListener;
+class WidgetListener;
+
+/**
+ * Abstract class for widgets of Guichan. It contains basic functions
+ * every widget should have.
+ *
+ * NOTE: Functions begining with underscore "_" should not
+ * be overloaded unless you know what you are doing
+ *
+ * @author Olof Naessén
+ * @author Per Larsson.
+ * @since 0.1.0
+ */
+class Widget : public Widget2
+{
+ public:
+ /**
+ * Constructor. Resets member variables. Noteable, a widget is not
+ * focusable as default, therefore, widgets that are supposed to be
+ * focusable should overide this default in their own constructor.
+ */
+ explicit Widget(const Widget2 *const widget);
+
+ A_DELETE_COPY(Widget)
+
+ /**
+ * Default destructor.
+ */
+ virtual ~Widget();
+
+ /**
+ * Draws the widget. It is called by the parent widget when it is time
+ * for the widget to draw itself. The graphics object is set up so
+ * that all drawing is relative to the widget, i.e coordinate (0,0) is
+ * the top left corner of the widget. It is not possible to draw
+ * outside of a widget's dimension.
+ *
+ * @param graphics aA graphics object to draw with.
+ * @since 0.1.0
+ */
+ virtual void draw(Graphics* graphics) = 0;
+
+ /**
+ * Called when a widget is given a chance to draw a frame around itself.
+ * The frame is not considered a part of the widget, it only allows a frame
+ * to be drawn around the widget, thus a frame will never be included when
+ * calculating if a widget should receive events from user input. Also
+ * a widget's frame will never be included when calculating a widget's
+ * position.
+ *
+ * The size of the frame is calculated using the widget's frame size.
+ * If a widget has a frame size of 10 pixels than the area the drawFrame
+ * function can draw to will be the size of the widget with an additional
+ * extension of 10 pixels in each direction.
+ *
+ * An example when drawFrame is a useful function is if a widget needs
+ * a glow around itself.
+ *
+ * @param graphics A graphics object to draw with.
+ * @see setFrameSize, getFrameSize
+ * @since 0.8.0
+ */
+ virtual void drawFrame(Graphics* graphics);
+
+ /**
+ * Sets the size of the widget's frame. The frame is not considered a part of
+ * the widget, it only allows a frame to be drawn around the widget, thus a frame
+ * will never be included when calculating if a widget should receive events
+ * from user input. Also a widget's frame will never be included when calculating
+ * a widget's position.
+ *
+ * A frame size of 0 means that the widget has no frame. The default frame size
+ * is 0.
+ *
+ * @param frameSize The size of the widget's frame.
+ * @see getFrameSize, drawFrame
+ * @since 0.8.0
+ */
+ void setFrameSize(unsigned int frameSize);
+
+ /**
+ * Gets the size of the widget's frame. The frame is not considered a part of
+ * the widget, it only allows a frame to be drawn around the widget, thus a frame
+ * will never be included when calculating if a widget should receive events
+ * from user input. Also a widget's frame will never be included when calculating
+ * a widget's position.
+ *
+ * A frame size of 0 means that the widget has no frame. The default frame size
+ * is 0.
+ *
+ * @return The size of the widget's frame.
+ * @see setFrameSize, drawFrame
+ * @since 0.8.0
+ */
+ unsigned int getFrameSize() const A_WARN_UNUSED;
+
+ /**
+ * Called for all widgets in the gui each time Gui::logic is called.
+ * You can do logic stuff here like playing an animation.
+ *
+ * @see Gui::logic
+ * @since 0.1.0
+ */
+ virtual void logic()
+ { }
+
+ /**
+ * Gets the widget's parent container.
+ *
+ * @return The widget's parent container. NULL if the widget
+ * has no parent.
+ * @since 0.1.0
+ */
+ virtual Widget* getParent() const A_WARN_UNUSED
+ { return mParent; }
+
+ /**
+ * Sets the width of the widget.
+ *
+ * @param width The width of the widget.
+ * @see getWidth, setHeight, getHeight, setSize,
+ * setDimension, getDimensi
+ * @since 0.1.0
+ */
+ void setWidth(int width);
+
+ /**
+ * Gets the width of the widget.
+ *
+ * @return The width of the widget.
+ * @see setWidth, setHeight, getHeight, setSize,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getWidth() const A_WARN_UNUSED
+ { return mDimension.width; }
+
+ /**
+ * Sets the height of the widget.
+ *
+ * @param height The height of the widget.
+ * @see getHeight, setWidth, getWidth, setSize,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setHeight(int height);
+
+ /**
+ * Gets the height of the widget.
+ *
+ * @return The height of the widget.
+ * @see setHeight, setWidth, getWidth, setSize,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getHeight() const A_WARN_UNUSED
+ { return mDimension.height; }
+
+ /**
+ * Sets the size of the widget.
+ *
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @see setWidth, setHeight, getWidth, getHeight,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setSize(int width, int height);
+
+ /**
+ * Sets the x coordinate of the widget. The coordinate is
+ * relateive to the widget's parent.
+ *
+ * @param x The x coordinate of the widget.
+ * @see getX, setY, getY, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setX(int x);
+
+ /**
+ * Gets the x coordinate of the widget. The coordinate is
+ * relative to the widget's parent.
+ *
+ * @return The x coordinate of the widget.
+ * @see setX, setY, getY, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getX() const A_WARN_UNUSED
+ { return mDimension.x; }
+
+ /**
+ * Sets the y coordinate of the widget. The coordinate is
+ * relative to the widget's parent.
+ *
+ * @param y The y coordinate of the widget.
+ * @see setY, setX, getX, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setY(int y);
+
+ /**
+ * Gets the y coordinate of the widget. The coordinate is
+ * relative to the widget's parent.
+ *
+ * @return The y coordinate of the widget.
+ * @see setY, setX, getX, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getY() const A_WARN_UNUSED
+ { return mDimension.y; }
+
+ /**
+ * Sets position of the widget. The position is relative
+ * to the widget's parent.
+ *
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @see setX, getX, setY, getY, setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setPosition(int x, int y);
+
+ /**
+ * Sets the dimension of the widget. The dimension is
+ * relative to the widget's parent.
+ *
+ * @param dimension The dimension of the widget.
+ * @see getDimension, setX, getX, setY, getY, setPosition
+ * @since 0.1.0
+ */
+ void setDimension(const Rectangle& dimension);
+
+ /**
+ * Gets the dimension of the widget. The dimension is
+ * relative to the widget's parent.
+ *
+ * @return The dimension of the widget.
+ * @see getDimension, setX, getX, setY, getY, setPosition
+ * @since 0.1.0
+ */
+ const Rectangle& getDimension() const A_WARN_UNUSED;
+
+ /**
+ * Sets the widget to be fosusable, or not.
+ *
+ * @param focusable True if the widget should be focusable,
+ * false otherwise.
+ * @see isFocusable
+ * @since 0.1.0
+ */
+ void setFocusable(bool focusable);
+
+ /**
+ * Checks if a widget is focsable.
+ *
+ * @return True if the widget should be focusable, false otherwise.
+ * @see setFocusable
+ * @since 0.1.0
+ */
+ bool isFocusable() const A_WARN_UNUSED;
+
+ /**
+ * Checks if the widget is focused.
+ *
+ * @return True if the widget is focused, false otherwise.
+ * @since 0.1.0
+ */
+ virtual bool isFocused() const A_WARN_UNUSED;
+
+ /**
+ * Sets the widget to enabled, or not. A disabled
+ * widget will never recieve mouse or key events.
+ *
+ * @param enabled True if widget should be enabled,
+ * false otherwise.
+ * @see isEnabled
+ * @since 0.1.0
+ */
+ void setEnabled(bool enabled);
+
+ /**
+ * Checks if the widget is enabled. A disabled
+ * widget will never recieve mouse or key events.
+ *
+ * @return True if widget is enabled, false otherwise.
+ * @see setEnabled
+ * @since 0.1.0
+ */
+ bool isEnabled() const A_WARN_UNUSED;
+
+ /**
+ * Sets the widget to be visible, or not.
+ *
+ * @param visible True if widget should be visible, false otherwise.
+ * @see isVisible
+ * @since 0.1.0
+ */
+ void setVisible(bool visible);
+
+ /**
+ * Checks if the widget is visible.
+ *
+ * @return True if widget is be visible, false otherwise.
+ * @see setVisible
+ * @since 0.1.0
+ */
+ bool isVisible() const A_WARN_UNUSED
+ { return mVisible && (!mParent || mParent->isVisible()); }
+
+ /**
+ * Sets the base color of the widget.
+ *
+ * @param color The baseground color.
+ * @see getBaseColor
+ * @since 0.1.0
+ */
+ void setBaseColor(const Color& color);
+
+ /**
+ * Gets the base color.
+ *
+ * @return The base color.
+ * @see setBaseColor
+ * @since 0.1.0
+ */
+ const Color& getBaseColor() const A_WARN_UNUSED;
+
+ /**
+ * Sets the foreground color.
+ *
+ * @param color The foreground color.
+ * @see getForegroundColor
+ * @since 0.1.0
+ */
+ void setForegroundColor(const Color& color);
+
+ /**
+ * Gets the foreground color.
+ *
+ * @see setForegroundColor
+ * @since 0.1.0
+ */
+ const Color& getForegroundColor() const A_WARN_UNUSED;
+
+ /**
+ * Sets the background color.
+ *
+ * @param color The background Color.
+ * @see setBackgroundColor
+ * @since 0.1.0
+ */
+ void setBackgroundColor(const Color& color);
+
+ /**
+ * Gets the background color.
+ *
+ * @see setBackgroundColor
+ * @since 0.1.0
+ */
+ const Color& getBackgroundColor() const A_WARN_UNUSED;
+
+ /**
+ * Sets the selection color.
+ *
+ * @param color The selection color.
+ * @see getSelectionColor
+ * @since 0.6.0
+ */
+ void setSelectionColor(const Color& color);
+
+ /**
+ * Gets the selection color.
+ *
+ * @return The selection color.
+ * @see setSelectionColor
+ * @since 0.6.0
+ */
+ const Color& getSelectionColor() const A_WARN_UNUSED;
+
+ /**
+ * Requests focus for the widget. A widget will only recieve focus
+ * if it is focusable.
+ */
+ virtual void requestFocus();
+
+ /**
+ * Requests a move to the top in the parent widget.
+ */
+ virtual void requestMoveToTop();
+
+ /**
+ * Requests a move to the bottom in the parent widget.
+ */
+ virtual void requestMoveToBottom();
+
+ /**
+ * Sets the focus handler to be used.
+ *
+ * WARNING: This function is used internally and should not
+ * be called or overloaded unless you know what you
+ * are doing.
+ *
+ * @param focusHandler The focus handler to use.
+ * @see _getFocusHandler
+ * @since 0.1.0
+ */
+ virtual void _setFocusHandler(FocusHandler* focusHandler);
+
+ /**
+ * Gets the focus handler used.
+ *
+ * WARNING: This function is used internally and should not
+ * be called or overloaded unless you know what you
+ * are doing.
+ *
+ * @return The focus handler used.
+ * @see _setFocusHandler
+ * @since 0.1.0
+ */
+ virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED;
+
+ /**
+ * Adds an action listener to the widget. When an action event
+ * is fired by the widget the action listeners of the widget
+ * will get notified.
+ *
+ * @param actionListener The action listener to add.
+ * @see removeActionListener
+ * @since 0.1.0
+ */
+ void addActionListener(ActionListener* actionListener);
+
+ /**
+ * Removes an added action listener from the widget.
+ *
+ * @param actionListener The action listener to remove.
+ * @see addActionListener
+ * @since 0.1.0
+ */
+ void removeActionListener(ActionListener* actionListener);
+
+ /**
+ * Adds a death listener to the widget. When a death event is
+ * fired by the widget the death listeners of the widget will
+ * get notified.
+ *
+ * @param deathListener The death listener to add.
+ * @see removeDeathListener
+ * @since 0.1.0
+ */
+ void addDeathListener(DeathListener* deathListener);
+
+ /**
+ * Removes an added death listener from the widget.
+ *
+ * @param deathListener The death listener to remove.
+ * @see addDeathListener
+ * @since 0.1.0
+ */
+ void removeDeathListener(DeathListener* deathListener);
+
+ /**
+ * Adds a mouse listener to the widget. When a mouse event is
+ * fired by the widget the mouse listeners of the widget will
+ * get notified.
+ *
+ * @param mouseListener The mouse listener to add.
+ * @see removeMouseListener
+ * @since 0.1.0
+ */
+ void addMouseListener(MouseListener* mouseListener);
+
+ /**
+ * Removes an added mouse listener from the widget.
+ *
+ * @param mouseListener The mouse listener to remove.
+ * @see addMouseListener
+ * @since 0.1.0
+ */
+ void removeMouseListener(MouseListener* mouseListener);
+
+ /**
+ * Adds a key listener to the widget. When a key event is
+ * fired by the widget the key listeners of the widget will
+ * get notified.
+ *
+ * @param keyListener The key listener to add.
+ * @see removeKeyListener
+ * @since 0.1.0
+ */
+ void addKeyListener(KeyListener* keyListener);
+
+ /**
+ * Removes an added key listener from the widget.
+ *
+ * @param keyListener The key listener to remove.
+ * @see addKeyListener
+ * @since 0.1.0
+ */
+ void removeKeyListener(KeyListener* keyListener);
+
+ /**
+ * Adds a focus listener to the widget. When a focus event is
+ * fired by the widget the key listeners of the widget will
+ * get notified.
+ *
+ * @param focusListener The focus listener to add.
+ * @see removeFocusListener
+ * @since 0.7.0
+ */
+ void addFocusListener(FocusListener* focusListener);
+
+ /**
+ * Removes an added focus listener from the widget.
+ *
+ * @param focusListener The focus listener to remove.
+ * @see addFocusListener
+ * @since 0.7.0
+ */
+ void removeFocusListener(FocusListener* focusListener);
+
+ /**
+ * Adds a widget listener to the widget. When a widget event is
+ * fired by the widget the key listeners of the widget will
+ * get notified.
+ *
+ * @param widgetListener The widget listener to add.
+ * @see removeWidgetListener
+ * @since 0.8.0
+ */
+ void addWidgetListener(WidgetListener* widgetListener);
+
+ /**
+ * Removes an added widget listener from the widget.
+ *
+ * @param widgetListener The widget listener to remove.
+ * @see addWidgetListener
+ * @since 0.8.0
+ */
+ void removeWidgetListener(WidgetListener* widgetListener);
+
+ /**
+ * Sets the action event identifier of the widget. The identifier is
+ * used to be able to identify which action has occured.
+ *
+ * NOTE: An action event identifier should not be used to identify a
+ * certain widget but rather a certain event in your application.
+ * Several widgets can have the same action event identifer.
+ *
+ * @param actionEventId The action event identifier.
+ * @see getActionEventId
+ * @since 0.6.0
+ */
+ void setActionEventId(const std::string& actionEventId);
+
+ /**
+ * Gets the action event identifier of the widget.
+ *
+ * @return The action event identifier of the widget.
+ * @see setActionEventId
+ * @since 0.6.0
+ */
+ const std::string& getActionEventId() const;
+
+ /**
+ * Gets the absolute position on the screen for the widget.
+ *
+ * @param x The absolute x coordinate will be stored in this parameter.
+ * @param y The absolute y coordinate will be stored in this parameter.
+ * @since 0.1.0
+ */
+ virtual void getAbsolutePosition(int& x, int& y) const;
+
+ /**
+ * Sets the parent of the widget. A parent must be a BasicContainer.
+ *
+ * WARNING: This function is used internally and should not
+ * be called or overloaded unless you know what you
+ * are doing.
+ *
+ * @param parent The parent of the widget.
+ * @see getParent
+ * @since 0.1.0
+ */
+ virtual void _setParent(Widget* parent);
+
+ /**
+ * Gets the font set for the widget. If no font has been set,
+ * the global font will be returned. If no global font has been set,
+ * the default font will be returend.
+ *
+ * @return The font set for the widget.
+ * @see setFont, setGlobalFont
+ * @since 0.1.0
+ */
+ Font *getFont() const A_WARN_UNUSED;
+
+ /**
+ * Sets the global font to be used by default for all widgets.
+ *
+ * @param font The global font.
+ * @see getGlobalFont
+ * @since 0.1.0
+ */
+ static void setGlobalFont(Font* font);
+
+ /**
+ * Sets the font for the widget. If NULL is passed, the global font
+ * will be used.
+ *
+ * @param font The font to set for the widget.
+ * @see getFont
+ * @since 0.1.0
+ */
+ void setFont(Font* font);
+
+ /**
+ * Called when the font has changed. If the change is global,
+ * this function will only be called if the widget doesn't have a
+ * font already set.
+ *
+ * @since 0.1.0
+ */
+ virtual void fontChanged()
+ { }
+
+ /**
+ * Checks if a widget exists or not, that is if it still exists
+ * an instance of the object.
+ *
+ * @param widget The widget to check.
+ * @return True if an instance of the widget exists, false otherwise.
+ * @since 0.1.0
+ */
+ static bool widgetExists(const Widget* widget) A_WARN_UNUSED;
+
+ /**
+ * Checks if tab in is enabled. Tab in means that you can set focus
+ * to this widget by pressing the tab button. If tab in is disabled
+ * then the focus handler will skip this widget and focus the next
+ * in its focus order.
+ *
+ * @return True if tab in is enabled, false otherwise.
+ * @see setTabInEnabled
+ * @since 0.1.0
+ */
+ bool isTabInEnabled() const A_WARN_UNUSED;
+
+ /**
+ * Sets tab in enabled, or not. Tab in means that you can set focus
+ * to this widget by pressing the tab button. If tab in is disabled
+ * then the FocusHandler will skip this widget and focus the next
+ * in its focus order.
+ *
+ * @param enabled True if tab in should be enabled, false otherwise.
+ * @see isTabInEnabled
+ * @since 0.1.0
+ */
+ void setTabInEnabled(bool enabled);
+
+ /**
+ * Checks if tab out is enabled. Tab out means that you can lose
+ * focus to this widget by pressing the tab button. If tab out is
+ * disabled then the FocusHandler ignores tabbing and focus will
+ * stay with this widget.
+ *
+ * @return True if tab out is enabled, false otherwise.
+ * @see setTabOutEnabled
+ * @since 0.1.0
+ */
+ bool isTabOutEnabled() const A_WARN_UNUSED;
+
+ /**
+ * Sets tab out enabled. Tab out means that you can lose
+ * focus to this widget by pressing the tab button. If tab out is
+ * disabled then the FocusHandler ignores tabbing and focus will
+ * stay with this widget.
+ *
+ * @param enabled True if tab out should be enabled, false otherwise.
+ * @see isTabOutEnabled
+ * @since 0.1.0
+ */
+ void setTabOutEnabled(bool enabled);
+
+ /**
+ * Requests modal focus. When a widget has modal focus, only that
+ * widget and it's children may recieve input.
+ *
+ * @throws Exception if another widget already has modal focus.
+ * @see releaseModalFocus, isModalFocused
+ * @since 0.4.0
+ */
+ virtual void requestModalFocus();
+
+ /**
+ * Requests modal mouse input focus. When a widget has modal input focus
+ * that widget will be the only widget receiving input even if the input
+ * occurs outside of the widget and no matter what the input is.
+ *
+ * @throws Exception if another widget already has modal focus.
+ * @see releaseModalMouseInputFocus, isModalMouseInputFocused
+ * @since 0.6.0
+ */
+ virtual void requestModalMouseInputFocus();
+
+ /**
+ * Releases modal focus. Modal focus will only be released if the
+ * widget has modal focus.
+ *
+ * @see requestModalFocus, isModalFocused
+ * @since 0.4.0
+ */
+ virtual void releaseModalFocus();
+
+ /**
+ * Releases modal mouse input focus. Modal mouse input focus will only
+ * be released if the widget has modal mouse input focus.
+ *
+ * @see requestModalMouseInputFocus, isModalMouseInputFocused
+ * @since 0.6.0
+ */
+ virtual void releaseModalMouseInputFocus();
+
+ /**
+ * Checks if the widget or it's parent has modal focus.
+ *
+ * @return True if the widget has modal focus, false otherwise.
+ * @see requestModalFocus, releaseModalFocus
+ * @since 0.8.0
+ */
+ virtual bool isModalFocused() const A_WARN_UNUSED;
+
+ /**
+ * Checks if the widget or it's parent has modal mouse input focus.
+ *
+ * @return True if the widget has modal mouse input focus, false
+ * otherwise.
+ * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
+ * @since 0.8.0
+ */
+ virtual bool isModalMouseInputFocused() const A_WARN_UNUSED;
+
+ /**
+ * Gets a widget from a certain position in the widget.
+ * This function is used to decide which gets mouse input,
+ * thus it can be overloaded to change that behaviour.
+ *
+ * NOTE: This always returns NULL if the widget is not
+ * a container.
+ *
+ * @param x The x coordinate of the widget to get.
+ * @param y The y coordinate of the widget to get.
+ * @return The widget at the specified coodinate, NULL
+ * if no widget is found.
+ * @since 0.6.0
+ */
+ virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED;
+
+ /**
+ * Gets the mouse listeners of the widget.
+ *
+ * @return The mouse listeners of the widget.
+ * @since 0.6.0
+ */
+ virtual const std::list<MouseListener*>& _getMouseListeners()
+ A_WARN_UNUSED;
+
+ /**
+ * Gets the key listeners of the widget.
+ *
+ * @return The key listeners of the widget.
+ * @since 0.6.0
+ */
+ virtual const std::list<KeyListener*>& _getKeyListeners()
+ A_WARN_UNUSED;
+
+ /**
+ * Gets the focus listeners of the widget.
+ *
+ * @return The focus listeners of the widget.
+ * @since 0.7.0
+ */
+ virtual const std::list<FocusListener*>& _getFocusListeners()
+ A_WARN_UNUSED;
+
+ /**
+ * Gets the area of the widget occupied by the widget's children.
+ * By default this method returns an empty rectangle as not all
+ * widgets are containers. If you want to make a container this
+ * method should return the area where the children resides. This
+ * method is used when drawing children of a widget when computing
+ * clip rectangles for the children.
+ *
+ * An example of a widget that overloads this method is ScrollArea.
+ * A ScrollArea has a view of its contant and that view is the
+ * children area. The size of a ScrollArea's children area might
+ * vary depending on if the scroll bars of the ScrollArea is shown
+ * or not.
+ *
+ * @return The area of the widget occupied by the widget's children.
+ * @see BasicContainer
+ * @see BasicContainer::getChildrenArea
+ * @see BasicContainer::drawChildren
+ * @since 0.1.0
+ */
+ virtual Rectangle getChildrenArea() A_WARN_UNUSED;
+
+ /**
+ * Gets the internal focus handler used.
+ *
+ * @return the internalFocusHandler used. If no internal focus handler
+ * is used, NULL will be returned.
+ * @see setInternalFocusHandler
+ * @since 0.1.0
+ */
+ virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED;
+
+ /**
+ * Sets the internal focus handler. An internal focus handler is
+ * needed if both a widget in the widget and the widget itself
+ * should be foucsed at the same time.
+ *
+ * @param focusHandler The internal focus handler to be used.
+ * @see getInternalFocusHandler
+ * @since 0.1.0
+ */
+ void setInternalFocusHandler(FocusHandler* internalFocusHandler);
+
+ /**
+ * Moves a widget to the top of this widget. The moved widget will be
+ * drawn above all other widgets in this widget.
+ *
+ * @param widget The widget to move to the top.
+ * @see moveToBottom
+ * @since 0.1.0
+ */
+ virtual void moveToTop(Widget* widget A_UNUSED)
+ { }
+
+ /**
+ * Moves a widget in this widget to the bottom of this widget.
+ * The moved widget will be drawn below all other widgets in this widget.
+ *
+ * @param widget The widget to move to the bottom.
+ * @see moveToTop
+ * @since 0.1.0
+ */
+ virtual void moveToBottom(Widget* widget A_UNUSED)
+ { }
+
+ /**
+ * Focuses the next widget in the widget.
+ *
+ * @see moveToBottom
+ * @since 0.1.0
+ */
+ virtual void focusNext()
+ { }
+
+ /**
+ * Focuses the previous widget in the widget.
+ *
+ * @see moveToBottom
+ * @since 0.1.0
+ */
+ virtual void focusPrevious()
+ { }
+
+ /**
+ * Tries to show a specific part of a widget by moving it. Used if the
+ * widget should act as a container.
+ *
+ * @param widget The target widget.
+ * @param area The area to show.
+ * @since 0.1.0
+ */
+ virtual void showWidgetPart(Widget* widget A_UNUSED,
+ Rectangle area A_UNUSED)
+ { }
+
+ /**
+ * Sets an id of a widget. An id can be useful if a widget needs to be
+ * identified in a container. For example, if widgets are created by an
+ * XML document, a certain widget can be retrieved given that the widget
+ * has an id.
+ *
+ * @param id The id to set to the widget.
+ * @see getId, BasicContainer::findWidgetById
+ * @since 0.8.0
+ */
+ void setId(const std::string& id);
+
+ /**
+ * Gets the id of a widget. An id can be useful if a widget needs to be
+ * identified in a container. For example, if widgets are created by an
+ * XML document, a certain widget can be retrieved given that the widget
+ * has an id.
+ *
+ * @param id The id to set to the widget.
+ * @see setId, BasicContainer::findWidgetById
+ * @since 0.8.0
+ */
+ const std::string& getId() A_WARN_UNUSED;
+
+ /**
+ * Shows a certain part of a widget in the widget's parent.
+ * Used when widgets want a specific part to be visible in
+ * its parent. An example is a TextArea that wants a specific
+ * part of its text to be visible when a TextArea is a child
+ * of a ScrollArea.
+ *
+ * @param rectangle The rectangle to be shown.
+ * @since 0.8.0
+ */
+ virtual void showPart(Rectangle rectangle);
+
+ protected:
+ /**
+ * Distributes an action event to all action listeners
+ * of the widget.
+ *
+ * @since 0.8.0
+ */
+ void distributeActionEvent();
+
+ /**
+ * Distributes resized events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ */
+ void distributeResizedEvent();
+
+ /**
+ * Distributes moved events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ */
+ void distributeMovedEvent();
+
+ /**
+ * Distributes hidden events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ * @author Olof Naessén
+ */
+ void distributeHiddenEvent();
+
+ /**
+ * Distributes shown events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ * @author Olof Naessén
+ */
+ void distributeShownEvent();
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<MouseListener*> MouseListenerList;
+
+ /**
+ * Typdef.
+ */
+ typedef MouseListenerList::iterator MouseListenerIterator;
+
+ /**
+ * Holds the mouse listeners of the widget.
+ */
+ MouseListenerList mMouseListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<KeyListener*> KeyListenerList;
+
+ /**
+ * Holds the key listeners of the widget.
+ */
+ KeyListenerList mKeyListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef KeyListenerList::iterator KeyListenerIterator;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<ActionListener*> ActionListenerList;
+
+ /**
+ * Holds the action listeners of the widget.
+ */
+ ActionListenerList mActionListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef ActionListenerList::iterator ActionListenerIterator;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<DeathListener*> DeathListenerList;
+
+ /**
+ * Holds the death listeners of the widget.
+ */
+ DeathListenerList mDeathListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef DeathListenerList::iterator DeathListenerIterator;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<FocusListener*> FocusListenerList;
+
+ /**
+ * Holds the focus listeners of the widget.
+ */
+ FocusListenerList mFocusListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef FocusListenerList::iterator FocusListenerIterator;
+
+ typedef std::list<WidgetListener*> WidgetListenerList;
+
+ /**
+ * Holds the widget listeners of the widget.
+ */
+ WidgetListenerList mWidgetListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef WidgetListenerList::iterator WidgetListenerIterator;
+
+ /**
+ * Holds the foreground color of the widget.
+ */
+ Color mForegroundColor;
+
+ /**
+ * Holds the background color of the widget.
+ */
+ Color mBackgroundColor;
+
+ /**
+ * Holds the base color of the widget.
+ */
+ Color mBaseColor;
+
+ /**
+ * Holds the selection color of the widget.
+ */
+ Color mSelectionColor;
+
+ /**
+ * Holds the focus handler used by the widget.
+ */
+ FocusHandler* mFocusHandler;
+
+ /**
+ * Holds the focus handler used by the widget. NULL
+ * if no internal focus handler is used.
+ */
+ FocusHandler* mInternalFocusHandler;
+
+ /**
+ * Holds the parent of the widget. NULL if the widget
+ * has no parent.
+ */
+ Widget* mParent;
+
+ /**
+ * Holds the dimension of the widget.
+ */
+ Rectangle mDimension;
+
+ /**
+ * Holds the frame size of the widget.
+ */
+ unsigned int mFrameSize;
+
+ /**
+ * Holds the action event of the widget.
+ */
+ std::string mActionEventId;
+
+ /**
+ * True if the widget focusable, false otherwise.
+ */
+ bool mFocusable;
+
+ /**
+ * True if the widget visible, false otherwise.
+ */
+ bool mVisible;
+
+ /**
+ * True if the widget has tab in enabled, false otherwise.
+ */
+ bool mTabIn;
+
+ /**
+ * True if the widget has tab in enabled, false otherwise.
+ */
+ bool mTabOut;
+
+ /**
+ * True if the widget is enabled, false otherwise.
+ */
+ bool mEnabled;
+
+ /**
+ * Holds the id of the widget.
+ */
+ std::string mId;
+
+ /**
+ * Holds the font used by the widget.
+ */
+ Font* mCurrentFont;
+
+ /**
+ * Holds the global font used by the widget.
+ */
+ static Font* mGlobalFont;
+
+ /**
+ * Holds a list of all instances of widgets.
+ */
+ static std::list<Widget*> mWidgets;
+
+ static std::set<Widget*> mWidgetsSet;
+};
+
+#endif // GUI_WIDGETS_WIDGET_H
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
index 4a0065ca8..07c4df43c 100644
--- a/src/gui/widgets/widgetgroup.cpp
+++ b/src/gui/widgets/widgetgroup.cpp
@@ -67,7 +67,7 @@ void WidgetGroup::action(const ActionEvent &event)
}
}
-void WidgetGroup::add(gcn::Widget *const widget, const int spacing)
+void WidgetGroup::add(Widget *const widget, const int spacing)
{
if (!widget)
return;
diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h
index 37523fcdc..051234cda 100644
--- a/src/gui/widgets/widgetgroup.h
+++ b/src/gui/widgets/widgetgroup.h
@@ -42,7 +42,7 @@ class WidgetGroup : public Container,
void action(const ActionEvent &event) override;
- virtual void add(gcn::Widget *const widget,
+ virtual void add(Widget *const widget,
const int spacing);
virtual void clear();
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index cccb1cdc7..8388ae64e 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -343,7 +343,7 @@ void Window::setContentSize(int width, int height)
setSize(width, height);
}
-void Window::setLocationRelativeTo(const gcn::Widget *const widget)
+void Window::setLocationRelativeTo(const Widget *const widget)
{
if (!widget)
return;
@@ -360,7 +360,7 @@ void Window::setLocationRelativeTo(const gcn::Widget *const widget)
- mDimension.height) / 2 - y));
}
-void Window::setLocationHorisontallyRelativeTo(const gcn::Widget *const widget)
+void Window::setLocationHorisontallyRelativeTo(const Widget *const widget)
{
if (!widget)
return;
@@ -1165,7 +1165,7 @@ void Window::clearLayout()
}
}
-LayoutCell &Window::place(const int x, const int y, gcn::Widget *const wg,
+LayoutCell &Window::place(const int x, const int y, Widget *const wg,
const int w, const int h)
{
add(wg);
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 10c9123be..50babfce4 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -87,12 +87,12 @@ class Window : public gcn::Window,
/**
* Sets the location relative to the given widget.
*/
- void setLocationRelativeTo(const gcn::Widget *const widget);
+ void setLocationRelativeTo(const Widget *const widget);
/**
* Sets the location relative to the given widget (only horisontally)
*/
- void setLocationHorisontallyRelativeTo(const gcn::Widget
+ void setLocationHorisontallyRelativeTo(const Widget
*const widget);
/**
@@ -370,7 +370,7 @@ class Window : public gcn::Window,
/**
* Adds a widget to the window and sets it at given cell.
*/
- LayoutCell &place(const int x, const int y, gcn::Widget *const wg,
+ LayoutCell &place(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
/**
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 5adde3cae..a9b556410 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -42,7 +42,7 @@ void WindowContainer::slowLogic()
mDeathList.clear();
}
-void WindowContainer::scheduleDelete(gcn::Widget *const widget)
+void WindowContainer::scheduleDelete(Widget *const widget)
{
if (widget)
mDeathList.push_back(widget);
@@ -58,8 +58,8 @@ void WindowContainer::adjustAfterResize(const int oldScreenWidth,
}
}
-void WindowContainer::moveWidgetAfter(gcn::Widget *const after,
- gcn::Widget *const widget)
+void WindowContainer::moveWidgetAfter(Widget *const after,
+ Widget *const widget)
{
const WidgetListIterator widgetIter = std::find(
mWidgets.begin(), mWidgets.end(), widget);
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
index d940a4e91..a822fadb5 100644
--- a/src/gui/widgets/windowcontainer.h
+++ b/src/gui/widgets/windowcontainer.h
@@ -44,7 +44,7 @@ class WindowContainer : public Container
* Schedule a widget for deletion. It will be deleted at the start of
* the next logic update.
*/
- void scheduleDelete(gcn::Widget *const widget);
+ void scheduleDelete(Widget *const widget);
/**
* Ensures that all visible windows are on the screen after the screen
@@ -53,8 +53,8 @@ class WindowContainer : public Container
void adjustAfterResize(const int oldScreenWidth,
const int oldScreenHeight);
- void moveWidgetAfter(gcn::Widget *const before,
- gcn::Widget *const widget);
+ void moveWidgetAfter(Widget *const before,
+ Widget *const widget);
#ifdef USE_PROFILER
void draw(Graphics* graphics);
@@ -64,7 +64,7 @@ class WindowContainer : public Container
/**
* List of widgets that are scheduled to be deleted.
*/
- typedef std::vector<gcn::Widget*> Widgets;
+ typedef std::vector<Widget*> Widgets;
typedef Widgets::iterator WidgetIterator;
Widgets mDeathList;
};
diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp
index 3bdebff71..d1fc0e7bd 100644
--- a/src/gui/windows/botcheckerwindow.cpp
+++ b/src/gui/windows/botcheckerwindow.cpp
@@ -125,7 +125,7 @@ public:
continue;
const Being *const player = mPlayers.at(r);
- gcn::Widget *widget = new Label(this, player->getName());
+ Widget *widget = new Label(this, player->getName());
mWidgets.push_back(widget);
@@ -235,14 +235,14 @@ public:
{
}
- gcn::Widget *getElementAt(const int row, const int column) const
+ Widget *getElementAt(const int row, const int column) const
{
return mWidgets[WIDGET_AT(row, column)];
}
void freeWidgets()
{
- for (std::vector<gcn::Widget *>::const_iterator it = mWidgets.begin();
+ for (std::vector<Widget *>::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
{
delete *it;
@@ -253,7 +253,7 @@ public:
protected:
std::vector<Being*> mPlayers;
- std::vector<gcn::Widget*> mWidgets;
+ std::vector<Widget*> mWidgets;
};
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 12a78ce10..d67c15bf0 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -210,7 +210,7 @@ void CharSelectDialog::postInit()
void CharSelectDialog::action(const ActionEvent &event)
{
// Check if a button of a character was pressed
- const gcn::Widget *const sourceParent = event.getSource()->getParent();
+ const Widget *const sourceParent = event.getSource()->getParent();
int selected = -1;
for (unsigned int i = 0, sz = static_cast<unsigned int>(
mCharacterEntries.size()); i < sz; ++i)
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 1754ca0bf..acd4c50bd 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -424,7 +424,7 @@ void ChatWindow::adjustTabSize()
const ChatTab *const tab = getFocused();
if (tab)
{
- gcn::Widget *const content = tab->mScrollArea;
+ Widget *const content = tab->mScrollArea;
if (content)
{
const int contentFrame2 = 2 * content->getFrameSize();
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index bd6719df9..0b0e6c6de 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -593,7 +593,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
void InventoryWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- const gcn::Widget *const src = event.getSource();
+ const Widget *const src = event.getSource();
if (src == mSlotsBar || src == mWeightBar)
{
const int x = event.getX();
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 86b4b9ba3..3dbfa566d 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -1261,7 +1261,7 @@ public:
setVisible(false);
}
- void show(gcn::Widget *parent)
+ void show(Widget *parent)
{
if (!parent)
return;