summaryrefslogtreecommitdiff
path: root/src/gui/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/base')
-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
21 files changed, 27 insertions, 1938 deletions
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>