From cde42202d69e178da73c698065deca54b24054fd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 18:07:17 +0300 Subject: move exguichan files into gui/base/ --- src/gui/gui.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/gui.h') diff --git a/src/gui/gui.h b/src/gui/gui.h index 5fddc7df7..4737c62fb 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -23,9 +23,9 @@ #ifndef GUI_GUI_H #define GUI_GUI_H -#include -#include -#include +#include "gui/base/color.hpp" +#include "gui/base/focuslistener.hpp" +#include "gui/base/gui.hpp" #include "localconsts.h" -- cgit v1.2.3-70-g09d2 From 01d93aedcc4d1632ff5915c3989a502ec31cd978 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 23:40:05 +0300 Subject: move focuslistener from base into listeners. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/focushandler.cpp | 3 +- src/gui/base/focuslistener.hpp | 119 ---------------------------------------- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 4 +- src/gui/base/widgets/button.hpp | 5 +- src/gui/gui.cpp | 4 +- src/gui/gui.h | 9 +-- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 7 ++- src/gui/widgets/popuplist.cpp | 2 +- src/gui/widgets/popuplist.h | 5 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textfield.h | 5 +- src/listeners/focuslistener.h | 116 +++++++++++++++++++++++++++++++++++++++ 16 files changed, 146 insertions(+), 143 deletions(-) delete mode 100644 src/gui/base/focuslistener.hpp create mode 100644 src/listeners/focuslistener.h (limited to 'src/gui/gui.h') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d68026c5d..324e65cac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -778,7 +778,7 @@ SET(SRCS gui/base/event.hpp gui/base/exception.hpp gui/base/focushandler.hpp - gui/base/focuslistener.hpp + listeners/focuslistener.h gui/base/font.hpp gui/base/gui.hpp gui/base/input.hpp diff --git a/src/Makefile.am b/src/Makefile.am index 7a74b3d17..da16e98d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -165,7 +165,7 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/event.hpp \ gui/base/exception.hpp \ gui/base/focushandler.hpp \ - gui/base/focuslistener.hpp \ + listeners/focuslistener.h \ gui/base/font.hpp \ gui/base/graphics.hpp \ gui/base/gui.hpp \ diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp index 6984d1fcd..ff149bf99 100644 --- a/src/gui/base/focushandler.cpp +++ b/src/gui/base/focushandler.cpp @@ -67,10 +67,11 @@ #include "gui/base/focushandler.hpp" -#include "gui/base/focuslistener.hpp" #include "gui/base/exception.hpp" #include "gui/base/widget.hpp" +#include "listeners/focuslistener.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/focuslistener.hpp b/src/gui/base/focuslistener.hpp deleted file mode 100644 index f6a7da5ea..000000000 --- a/src/gui/base/focuslistener.hpp +++ /dev/null @@ -1,119 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_FOCUSLISTENER_HPP -#define GCN_FOCUSLISTENER_HPP - -#include - -#include "gui/base/event.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for focus events from widgets. - * - * @see Widget::addFocusListener, Widget::removeFocusListener - * @author Olof Naessén - * @since 0.7.0 - */ - class FocusListener - { - public: - /** - * Destructor. - */ - virtual ~FocusListener() - { } - - /** - * Called when a widget gains focus. - * - * @param event Discribes the event. - */ - virtual void focusGained(const Event& event A_UNUSED) - { } - - /** - * Called when a widget loses focus. - * - * @param event Discribes the event. - */ - virtual void focusLost(const Event& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of FocusListener, - * therefore its constructor is protected. - */ - FocusListener() - { } - }; -} // namespace gcn - -#endif // end GCN_FOCUSLISTENER_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index b896ac1e9..a6dc2ed13 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -75,13 +75,13 @@ class ActionListener; class DeathListener; +class FocusListener; class Graphics; namespace gcn { class BasicContainer; class FocusHandler; - class FocusListener; class Font; class KeyInput; class KeyListener; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 3e699670a..82ff878a0 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -83,7 +83,7 @@ namespace gcn gcn::Widget(), gcn::MouseListener(), gcn::KeyListener(), - gcn::FocusListener(), + FocusListener(), mCaption(), mHasMouse(false), mKeyPressed(false), @@ -104,7 +104,7 @@ namespace gcn gcn::Widget(), gcn::MouseListener(), gcn::KeyListener(), - gcn::FocusListener(), + FocusListener(), mCaption(caption), mHasMouse(false), mKeyPressed(false), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index cd41a1b02..e2d6c0c8e 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -66,10 +66,11 @@ #include -#include "gui/base/focuslistener.hpp" +#include "listeners/focuslistener.h" #include "gui/base/keylistener.hpp" -#include "gui/base/mouseevent.hpp" #include "gui/base/mouselistener.hpp" + +#include "gui/base/mouseevent.hpp" #include "gui/base/widget.hpp" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 4da397a73..a398ca427 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -910,12 +910,12 @@ void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput) mFocusHandler->setDraggedWidget(nullptr); } -void Gui::addGlobalFocusListener(gcn::FocusListener* focusListener) +void Gui::addGlobalFocusListener(FocusListener* focusListener) { mFocusListeners.push_back(focusListener); } -void Gui::removeGlobalFocusListener(gcn::FocusListener* focusListener) +void Gui::removeGlobalFocusListener(FocusListener* focusListener) { mFocusListeners.remove(focusListener); } diff --git a/src/gui/gui.h b/src/gui/gui.h index 4737c62fb..544d9dd3d 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -24,9 +24,10 @@ #define GUI_GUI_H #include "gui/base/color.hpp" -#include "gui/base/focuslistener.hpp" #include "gui/base/gui.hpp" +#include "listeners/focuslistener.h" + #include "localconsts.h" class Graphics; @@ -151,9 +152,9 @@ class Gui final : public gcn::Gui int &restrict x, int &restrict y); - void addGlobalFocusListener(gcn::FocusListener* focusListener); + void addGlobalFocusListener(FocusListener* focusListener); - void removeGlobalFocusListener(gcn::FocusListener* focusListener); + void removeGlobalFocusListener(FocusListener* focusListener); void distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent); @@ -195,7 +196,7 @@ class Gui final : public gcn::Gui uint16_t mLastMouseRealX; uint16_t mLastMouseRealY; #endif - typedef std::list FocusListenerList; + typedef std::list FocusListenerList; typedef FocusListenerList::iterator FocusListenerIterator; FocusListenerList mFocusListeners; gcn::Color mForegroundColor; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 070afdbb5..0e9241f21 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -60,7 +60,7 @@ DropDown::DropDown(const Widget2 *const widget, gcn::BasicContainer(), gcn::KeyListener(), gcn::MouseListener(), - gcn::FocusListener(), + FocusListener(), gcn::SelectionListener(), Widget2(widget), mPopup(new PopupList(this, listModel, extended, modal)), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 0b6ada6dd..ca0743ae7 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -26,9 +26,10 @@ #include "gui/widgets/widget2.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/focuslistener.hpp" -#include "gui/base/keylistener.hpp" #include "gui/base/listmodel.hpp" + +#include "listeners/focuslistener.h" +#include "gui/base/keylistener.hpp" #include "gui/base/mouselistener.hpp" #include "gui/base/selectionlistener.hpp" @@ -54,7 +55,7 @@ class DropDown final : public ActionListener, public gcn::BasicContainer, public gcn::KeyListener, public gcn::MouseListener, - public gcn::FocusListener, + public FocusListener, public gcn::SelectionListener, public Widget2 { diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index f7f8afc66..b8e4dabb4 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -32,7 +32,7 @@ PopupList::PopupList(DropDown *const widget, gcn::ListModel *const listModel, bool extended, bool modal): Popup("PopupList", "popuplist.xml"), - gcn::FocusListener(), + FocusListener(), mListModel(listModel), mListBox(extended ? new ExtendedListBox( widget, listModel, "extendedlistbox.xml", 0) : diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index dfe93c0ae..454b5617c 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -23,7 +23,8 @@ #include "gui/widgets/popup.h" -#include "gui/base/focuslistener.hpp" +#include "listeners/focuslistener.h" + #include "gui/base/listmodel.hpp" #include "localconsts.h" @@ -33,7 +34,7 @@ class ListBox; class ScrollArea; class PopupList final : public Popup, - public gcn::FocusListener + public FocusListener { public: PopupList(DropDown *const widget, diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 692a5608e..22e9d42dd 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -57,7 +57,7 @@ TextField::TextField(const Widget2 *restrict const widget, const std::string &restrict eventId, const bool sendAlwaysEvents): gcn::TextField(text), - gcn::FocusListener(), + FocusListener(), Widget2(widget), mSendAlwaysEvents(sendAlwaysEvents), mCaretColor(&getThemeColor(Theme::CARET)), diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 80d022bb1..4545e9ff9 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -25,7 +25,8 @@ #include "gui/widgets/widget2.h" -#include "gui/base/focuslistener.hpp" +#include "listeners/focuslistener.h" + #include "gui/base/widgets/textfield.hpp" #include "localconsts.h" @@ -38,7 +39,7 @@ class PopupMenu; * \ingroup GUI */ class TextField : public gcn::TextField, - public gcn::FocusListener, + public FocusListener, public Widget2 { public: diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h new file mode 100644 index 000000000..1a6dd3fb2 --- /dev/null +++ b/src/listeners/focuslistener.h @@ -0,0 +1,116 @@ +/* + * 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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 LISTENERS_FOCUSLISTENER_HPP +#define LISTENERS_FOCUSLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for focus events from widgets. + * + * @see Widget::addFocusListener, Widget::removeFocusListener + * @author Olof Naessén + * @since 0.7.0 + */ +class FocusListener +{ + public: + /** + * Destructor. + */ + virtual ~FocusListener() + { } + + /** + * Called when a widget gains focus. + * + * @param event Discribes the event. + */ + virtual void focusGained(const gcn::Event &event A_UNUSED) + { } + + /** + * Called when a widget loses focus. + * + * @param event Discribes the event. + */ + virtual void focusLost(const gcn::Event &event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of FocusListener, + * therefore its constructor is protected. + */ + FocusListener() + { } +}; + +#endif // LISTENERS_FOCUSLISTENER_HPP -- cgit v1.2.3-70-g09d2 From 3ae82048ca8636ce03e71bdd4c11f60594cfc698 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 12:47:15 +0300 Subject: move event into events directory. --- src/CMakeLists.txt | 3 +- src/Makefile.am | 6 +- src/events/actionevent.h | 6 +- src/events/event.h | 117 +++++++++++++++++++++++++++++ src/gui/base/event.cpp | 87 --------------------- src/gui/base/event.hpp | 113 ---------------------------- src/gui/base/focushandler.hpp | 2 +- src/gui/base/inputevent.hpp | 2 +- src/gui/base/selectionevent.hpp | 2 +- src/gui/base/widget.cpp | 2 +- src/gui/focushandler.cpp | 2 +- src/gui/focushandler.h | 2 +- src/gui/gui.cpp | 2 +- src/gui/gui.h | 2 +- src/gui/widgets/button.cpp | 4 +- src/gui/widgets/button.h | 4 +- src/gui/widgets/characterdisplay.cpp | 2 +- src/gui/widgets/characterdisplay.h | 2 +- src/gui/widgets/desktop.cpp | 2 +- src/gui/widgets/desktop.h | 2 +- src/gui/widgets/dropshortcutcontainer.cpp | 2 +- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emotepage.cpp | 4 +- src/gui/widgets/emotepage.h | 4 +- src/gui/widgets/emoteshortcutcontainer.cpp | 2 +- src/gui/widgets/emoteshortcutcontainer.h | 2 +- src/gui/widgets/flowcontainer.cpp | 4 +- src/gui/widgets/flowcontainer.h | 2 +- src/gui/widgets/horizontcontainer.cpp | 2 +- src/gui/widgets/horizontcontainer.h | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 2 +- src/gui/widgets/itemshortcutcontainer.cpp | 2 +- src/gui/widgets/itemshortcutcontainer.h | 2 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/layouthelper.h | 2 +- src/gui/widgets/popup.cpp | 4 +- src/gui/widgets/popup.h | 4 +- src/gui/widgets/popuplist.cpp | 6 +- src/gui/widgets/popuplist.h | 6 +- src/gui/widgets/progressbar.cpp | 4 +- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/scrollarea.cpp | 4 +- src/gui/widgets/scrollarea.h | 4 +- src/gui/widgets/shortcutcontainer.cpp | 4 +- src/gui/widgets/shortcutcontainer.h | 4 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.h | 2 +- src/gui/widgets/tabbedarea.cpp | 8 +- src/gui/widgets/tabbedarea.h | 4 +- src/gui/widgets/tabs/setuptabscroll.cpp | 2 +- src/gui/widgets/tabs/setuptabscroll.h | 2 +- src/gui/widgets/tabs/tab.cpp | 4 +- src/gui/widgets/tabs/tab.h | 4 +- src/gui/widgets/textfield.cpp | 4 +- src/gui/widgets/textfield.h | 4 +- src/gui/widgets/vertcontainer.cpp | 2 +- src/gui/widgets/vertcontainer.h | 2 +- src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 2 +- src/gui/widgets/window.cpp | 8 +- src/gui/widgets/window.h | 6 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/charselectdialog.h | 2 +- src/gui/windows/chatwindow.cpp | 4 +- src/gui/windows/chatwindow.h | 2 +- src/gui/windows/debugwindow.cpp | 2 +- src/gui/windows/debugwindow.h | 2 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/emotewindow.cpp | 4 +- src/gui/windows/emotewindow.h | 4 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 6 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/setupwindow.cpp | 4 +- src/gui/windows/setupwindow.h | 2 +- src/gui/windows/shortcutwindow.cpp | 4 +- src/gui/windows/shortcutwindow.h | 4 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/skilldialog.h | 2 +- src/gui/windows/socialwindow.cpp | 4 +- src/gui/windows/socialwindow.h | 2 +- src/gui/windows/whoisonline.cpp | 4 +- src/gui/windows/whoisonline.h | 2 +- src/listeners/deathlistener.h | 4 +- src/listeners/focuslistener.h | 6 +- src/listeners/widgetlistener.h | 10 +-- 87 files changed, 252 insertions(+), 338 deletions(-) create mode 100644 src/events/event.h delete mode 100644 src/gui/base/event.cpp delete mode 100644 src/gui/base/event.hpp (limited to 'src/gui/gui.h') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 99d36e1ec..2a79f5839 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -775,7 +775,7 @@ SET(SRCS gui/base/cliprectangle.hpp gui/base/color.hpp listeners/deathlistener.h - gui/base/event.hpp + events/event.h gui/base/exception.hpp gui/base/focushandler.hpp listeners/focuslistener.h @@ -811,7 +811,6 @@ SET(SRCS gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp gui/base/color.cpp - gui/base/event.cpp gui/base/exception.cpp gui/base/focushandler.cpp gui/base/font.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 21c2fc0e9..8a731c17f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,6 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/event.cpp \ gui/base/exception.cpp \ gui/base/font.cpp \ gui/base/rectangle.cpp \ @@ -36,7 +35,7 @@ dyecmd_SOURCES = gui/base/cliprectangle.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ - gui/base/event.hpp \ + events/event.h \ gui/base/exception.hpp \ gui/base/font.hpp \ gui/base/rectangle.hpp \ @@ -161,7 +160,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ listeners/deathlistener.h \ - gui/base/event.hpp \ + events/event.h \ gui/base/exception.hpp \ gui/base/focushandler.hpp \ listeners/focuslistener.h \ @@ -198,7 +197,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/event.cpp \ gui/base/exception.cpp \ gui/base/focushandler.cpp \ gui/base/font.cpp \ diff --git a/src/events/actionevent.h b/src/events/actionevent.h index 77f945693..70ed0f398 100644 --- a/src/events/actionevent.h +++ b/src/events/actionevent.h @@ -64,7 +64,7 @@ #ifndef EVENTS_ACTIONEVENT_HPP #define EVENTS_ACTIONEVENT_HPP -#include "gui/base/event.hpp" +#include "events/event.h" #include @@ -97,7 +97,7 @@ namespace GCN * @author Olof Naessén * @since 0.6.0 */ -class ActionEvent final : public gcn::Event +class ActionEvent final : public Event { public: /** @@ -107,7 +107,7 @@ class ActionEvent final : public gcn::Event * @param id An identifier of the event. */ ActionEvent(gcn::Widget *const source, const std::string &id) : - gcn::Event(source), + Event(source), mId(id) { } diff --git a/src/events/event.h b/src/events/event.h new file mode 100644 index 000000000..d62dd672b --- /dev/null +++ b/src/events/event.h @@ -0,0 +1,117 @@ +/* + * 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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 EVENTS_EVENT_HPP +#define EVENTS_EVENT_HPP + +#include "localconsts.h" + +namespace gcn +{ + class Widget; +} + +/** + * Base class for all events. All events in Guichan should + * inherit from this class. + * + * @author Olof Naessén + * @since 0.6.0 + */ +class Event +{ + public: + /** + * Constructor. + * + * @param source The source widget of the event. + */ + explicit Event(gcn::Widget *const source) : + mSource(source) + { } + + A_DELETE_COPY(Event) + + /** + * Destructor. + */ + virtual ~Event() + { } + + /** + * Gets the source widget of the event. The function + * is used to tell which widget fired an event. + * + * @return The source widget of the event. + */ + gcn::Widget* getSource() const A_WARN_UNUSED + { return mSource; } + + protected: + /** + * Holds the source widget of the event. + */ + gcn::Widget* mSource; +}; + +#endif // EVENTS_EVENT_HPP diff --git a/src/gui/base/event.cpp b/src/gui/base/event.cpp deleted file mode 100644 index 359b780bf..000000000 --- a/src/gui/base/event.cpp +++ /dev/null @@ -1,87 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/event.hpp" - -#include "debug.h" - -namespace gcn -{ - Event::Event(Widget *const source) : - mSource(source) - { - } - - Event::~Event() - { - } - - Widget* Event::getSource() const - { - return mSource; - } -} // namespace gcn diff --git a/src/gui/base/event.hpp b/src/gui/base/event.hpp deleted file mode 100644 index 2a1f4ca4b..000000000 --- a/src/gui/base/event.hpp +++ /dev/null @@ -1,113 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_EVENT_HPP -#define GCN_EVENT_HPP - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Base class for all events. All events in Guichan should - * inherit from this class. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - */ - explicit Event(Widget *const source); - - A_DELETE_COPY(Event) - - /** - * Destructor. - */ - virtual ~Event(); - - /** - * Gets the source widget of the event. The function - * is used to tell which widget fired an event. - * - * @return The source widget of the event. - */ - Widget* getSource() const A_WARN_UNUSED; - - protected: - /** - * Holds the source widget of the event. - */ - Widget* mSource; - }; -} // namespace gcn - -#endif // end GCN_EVENT_HPP diff --git a/src/gui/base/focushandler.hpp b/src/gui/base/focushandler.hpp index aab3f2464..a5c1b14a1 100644 --- a/src/gui/base/focushandler.hpp +++ b/src/gui/base/focushandler.hpp @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" namespace gcn { diff --git a/src/gui/base/inputevent.hpp b/src/gui/base/inputevent.hpp index 166edf038..fab68e2a4 100644 --- a/src/gui/base/inputevent.hpp +++ b/src/gui/base/inputevent.hpp @@ -64,7 +64,7 @@ #ifndef GCN_INPUTEVENT_HPP #define GCN_INPUTEVENT_HPP -#include "gui/base/event.hpp" +#include "events/event.h" namespace gcn { diff --git a/src/gui/base/selectionevent.hpp b/src/gui/base/selectionevent.hpp index 543b3a9ad..5d05f015c 100644 --- a/src/gui/base/selectionevent.hpp +++ b/src/gui/base/selectionevent.hpp @@ -64,7 +64,7 @@ #ifndef GCN_SELECTIONEVENT_HPP #define GCN_SELECTIONEVENT_HPP -#include "gui/base/event.hpp" +#include "events/event.h" #include "localconsts.h" diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index de133ac09..6083fb35a 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -70,7 +70,7 @@ #include "events/actionevent.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/event.hpp" +#include "events/event.h" #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/keyinput.hpp" diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index cd780e12d..04cb3f555 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -103,7 +103,7 @@ void FocusHandler::checkForWindow() const } } -void FocusHandler::distributeFocusGainedEvent(const gcn::Event &focusEvent) +void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) { if (gui) gui->distributeGlobalFocusGainedEvent(focusEvent); diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index b051fe300..0e07625b7 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -71,7 +71,7 @@ class FocusHandler final : public gcn::FocusHandler void tabPrevious() override final; - void distributeFocusGainedEvent(const gcn::Event &focusEvent) + void distributeFocusGainedEvent(const Event &focusEvent) override final; private: diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index bced937c7..5d72c9dcb 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -920,7 +920,7 @@ void Gui::removeGlobalFocusListener(FocusListener* focusListener) mFocusListeners.remove(focusListener); } -void Gui::distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent) +void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent) { for (FocusListenerIterator iter = mFocusListeners.begin(); iter != mFocusListeners.end(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 544d9dd3d..1ec73e42f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -156,7 +156,7 @@ class Gui final : public gcn::Gui void removeGlobalFocusListener(FocusListener* focusListener); - void distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent); + void distributeGlobalFocusGainedEvent(const Event &focusEvent); void removeDragged(gcn::Widget *widget); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index ee984a18a..5478d8164 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -546,12 +546,12 @@ void Button::mouseReleased(gcn::MouseEvent& mouseEvent) } } -void Button::widgetResized(const gcn::Event &event A_UNUSED) +void Button::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void Button::widgetMoved(const gcn::Event &event A_UNUSED) +void Button::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 8f79755a8..7fd7e4a9a 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -132,9 +132,9 @@ class Button final : public gcn::Button, void setPressed(bool b) { mPressed = b; } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; void loadImage(const std::string &imageName); diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 21de10412..3f4a672f0 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -110,7 +110,7 @@ void CharacterDisplay::update() distributeResizedEvent(); } -void CharacterDisplay::widgetHidden(const gcn::Event &event A_UNUSED) +void CharacterDisplay::widgetHidden(const Event &event A_UNUSED) { mPopup->setVisible(false); } diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index 940dbe5c6..84a288ab0 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -73,7 +73,7 @@ class CharacterDisplay final : public Container, void setSelect(bool b) { mPlayerBox->setSelected(b); } - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 5874ee441..8e0496fea 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -98,7 +98,7 @@ void Desktop::reloadWallpaper() setBestFittingWallpaper(); } -void Desktop::widgetResized(const gcn::Event &event A_UNUSED) +void Desktop::widgetResized(const Event &event A_UNUSED) { setBestFittingWallpaper(); } diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 9e49ceb59..ad07b0ff8 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -60,7 +60,7 @@ class Desktop final : public Container, */ void reloadWallpaper(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void draw(Graphics *graphics) override final; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 9b37682fe..4b991bc34 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -308,7 +308,7 @@ void DropShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mItemPopup->setVisible(false); } -void DropShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void DropShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 6b7a9f151..26cbdffa7 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -67,7 +67,7 @@ class DropShortcutContainer final : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 091d699a7..e255afc30 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -139,12 +139,12 @@ void EmotePage::resetAction() mSelectedIndex = -1; } -void EmotePage::widgetResized(const gcn::Event &event A_UNUSED) +void EmotePage::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void EmotePage::widgetMoved(const gcn::Event &event A_UNUSED) +void EmotePage::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index afc950f79..cb6fd8711 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -48,9 +48,9 @@ class EmotePage final : public gcn::Widget, int getIndexFromGrid(const int x, const int y) const; - void widgetResized(const gcn::Event &event A_UNUSED) override final; + void widgetResized(const Event &event A_UNUSED) override final; - void widgetMoved(const gcn::Event &event A_UNUSED) override final; + void widgetMoved(const Event &event A_UNUSED) override final; void resetAction(); diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index dc25d9e5c..d00f01495 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -232,7 +232,7 @@ void EmoteShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mEmotePopup->setVisible(false); } -void EmoteShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void EmoteShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mEmotePopup) mEmotePopup->setVisible(false); diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index 62999207e..37ebe0cf9 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -74,7 +74,7 @@ class EmoteShortcutContainer final : public ShortcutContainer void mouseExited(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void setWidget2(const Widget2 *const widget) override final; diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index bfcd704d3..1c5961140 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -39,7 +39,7 @@ FlowContainer::FlowContainer(const Widget2 *const widget, mBoxHeight = 1; } -void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED) +void FlowContainer::widgetResized(const Event &event A_UNUSED) { if (getWidth() < mBoxWidth) { @@ -92,5 +92,5 @@ void FlowContainer::add(gcn::Widget *widget) Container::add(widget); widget->setSize(mBoxWidth, mBoxHeight); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index e2773d34c..a425e8465 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -55,7 +55,7 @@ class FlowContainer final : public Container, * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; int getBoxWidth() const A_WARN_UNUSED { return mBoxWidth; } diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index 77dff3232..b2fddfcae 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -58,6 +58,6 @@ void HorizontContainer::clear() mCount = 0; } -void HorizontContainer::widgetResized(const gcn::Event &event A_UNUSED) +void HorizontContainer::widgetResized(const Event &event A_UNUSED) { } diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index eb1f8c5aa..4f652df64 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -48,7 +48,7 @@ class HorizontContainer final : public Container, void clear() override; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; protected: int mSpacing; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 84934911c..2c9e9b731 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -618,7 +618,7 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mItemPopup->setVisible(false); } -void ItemContainer::widgetResized(const gcn::Event &event A_UNUSED) +void ItemContainer::widgetResized(const Event &event A_UNUSED) { mGridColumns = std::max(1, mDimension.width / mBoxWidth); adjustHeight(); diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 3d98d425b..ecb7b658e 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -96,7 +96,7 @@ class ItemContainer final : public gcn::Widget, void mouseExited(gcn::MouseEvent &event) override final; // WidgetListener - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; /** * Returns the selected item. diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 2438050d9..ef4d8ebfa 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -467,7 +467,7 @@ void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mSpellPopup->setVisible(false); } -void ItemShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index c2dbe93a3..5efda0433 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -68,7 +68,7 @@ class ItemShortcutContainer final : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 460810adf..066cabaf8 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -61,7 +61,7 @@ void LayoutHelper::reflowLayout(int w, int h) mContainer->setSize(w, h); } -void LayoutHelper::widgetResized(const gcn::Event &event A_UNUSED) +void LayoutHelper::widgetResized(const Event &event A_UNUSED) { const gcn::Rectangle area = mContainer->getChildrenArea(); int w = area.width; diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index bdd923560..d5a94e656 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -78,7 +78,7 @@ class LayoutHelper final : public WidgetListener /** * Called whenever the managed container changes size. */ - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; private: Layout mLayout; /**< Layout handler */ diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 9d34beaa7..7036968ad 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -244,12 +244,12 @@ void Popup::hide() mRedraw = true; } -void Popup::widgetResized(const gcn::Event &event A_UNUSED) +void Popup::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void Popup::widgetMoved(const gcn::Event &event A_UNUSED) +void Popup::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 25998e21d..e467783ef 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -164,9 +164,9 @@ class Popup : public Container, void hide(); - void widgetResized(const gcn::Event &event) override; + void widgetResized(const Event &event) override; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; bool isPopupVisible() const { return mVisible; } diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index b8e4dabb4..37dd6b1ec 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -90,7 +90,7 @@ void PopupList::show(int x, int y) requestModalFocus(); } -void PopupList::widgetResized(const gcn::Event &event) +void PopupList::widgetResized(const Event &event) { Popup::widgetResized(event); adjustSize(); @@ -154,7 +154,7 @@ void PopupList::mouseReleased(gcn::MouseEvent& mouseEvent) releaseModalFocus(); } -void PopupList::focusGained(const gcn::Event& event) +void PopupList::focusGained(const Event& event) { const gcn::Widget *const source = event.getSource(); if (!mVisible || source == this || source == mListBox @@ -170,7 +170,7 @@ void PopupList::focusGained(const gcn::Event& event) releaseModalFocus(); } -void PopupList::focusLost(const gcn::Event& event A_UNUSED) +void PopupList::focusLost(const Event& event A_UNUSED) { if (mDropDown) mDropDown->updateSelection(); diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index 454b5617c..31308fff8 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -49,7 +49,7 @@ class PopupList final : public Popup, void show(int x, int y); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void setSelected(int selected); @@ -62,9 +62,9 @@ class PopupList final : public Popup, void adjustSize(); - void focusGained(const gcn::Event& event A_UNUSED) override final; + void focusGained(const Event& event A_UNUSED) override final; - void focusLost(const gcn::Event& event A_UNUSED) override final; + void focusLost(const Event& event A_UNUSED) override final; void mousePressed(gcn::MouseEvent& mouseEvent) override final; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 415962310..b120e4289 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -283,12 +283,12 @@ void ProgressBar::render(Graphics *graphics) } } -void ProgressBar::widgetResized(const gcn::Event &event A_UNUSED) +void ProgressBar::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void ProgressBar::widgetMoved(const gcn::Event &event A_UNUSED) +void ProgressBar::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 2835a7ffc..86e314e16 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -132,9 +132,9 @@ class ProgressBar final : public gcn::Widget, */ void render(Graphics *graphics); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; void setPadding(unsigned int padding) { mPadding = padding; } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index e9e850b1c..73ff82be0 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -667,7 +667,7 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event A_UNUSED) mHasMouse = false; } -void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED) +void ScrollArea::widgetResized(const Event &event A_UNUSED) { mRedraw = true; const unsigned int frameSize = 2 * mFrameSize; @@ -679,7 +679,7 @@ void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED) } } -void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED) +void ScrollArea::widgetMoved(const Event& event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 69f567b02..7bf7e811c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -124,9 +124,9 @@ class ScrollArea final : public gcn::ScrollArea, void mouseDragged(gcn::MouseEvent &event) override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; gcn::Rectangle getVerticalBarDimension() const; diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 8b3507b8e..767a32974 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -53,7 +53,7 @@ ShortcutContainer::~ShortcutContainer() mVertexes = nullptr; } -void ShortcutContainer::widgetResized(const gcn::Event &event A_UNUSED) +void ShortcutContainer::widgetResized(const Event &event A_UNUSED) { mGridWidth = mDimension.width / mBoxWidth; @@ -116,7 +116,7 @@ void ShortcutContainer::drawBackground(Graphics *g) } } -void ShortcutContainer::widgetMoved(const gcn::Event& event A_UNUSED) +void ShortcutContainer::widgetMoved(const Event& event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 1db3e0482..2c237f513 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -59,9 +59,9 @@ class ShortcutContainer : public gcn::Widget, * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - virtual void widgetResized(const gcn::Event &event) override final; + virtual void widgetResized(const Event &event) override final; - virtual void widgetMoved(const gcn::Event& event) override final; + virtual void widgetMoved(const Event& event) override final; /** * Handles mouse when dragged. diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 696b0fbb4..ee76ee5dd 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -314,7 +314,7 @@ void SpellShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mSpellPopup->setVisible(false); } -void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mSpellPopup) mSpellPopup->setVisible(false); diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 3115e47fe..b5968dfe5 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -67,7 +67,7 @@ class SpellShortcutContainer final : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 500e821f5..2fe4f1332 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -72,7 +72,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : void TabbedArea::postInit() { - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } TabbedArea::~TabbedArea() @@ -365,7 +365,7 @@ void TabbedArea::setSelectedTab(Tab *const tab) if (newTab) newTab->setCurrent(); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } int TabbedArea::getSelectedTabIndex() const @@ -392,7 +392,7 @@ void TabbedArea::setSelectedTabByName(const std::string &name) } } -void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) +void TabbedArea::widgetResized(const Event &event A_UNUSED) { adjustSize(); @@ -716,7 +716,7 @@ void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) } } -void TabbedArea::death(const gcn::Event &event) +void TabbedArea::death(const Event &event) { Tab *const tab = dynamic_cast(event.getSource()); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index ec4c02ce5..d517c9a51 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -142,7 +142,7 @@ class TabbedArea final : public Widget2, void setSelectedTabByName(const std::string &name); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; /* void moveLeft(Tab *tab); @@ -184,7 +184,7 @@ class TabbedArea final : public Widget2, void setDimension(const gcn::Rectangle &dimension); - void death(const gcn::Event &event); + void death(const Event &event); void setResizeHeight(bool b) { mResizeHeight = b; } diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp index 659ef5824..9a37ced42 100644 --- a/src/gui/widgets/tabs/setuptabscroll.cpp +++ b/src/gui/widgets/tabs/setuptabscroll.cpp @@ -146,7 +146,7 @@ void SetupTabScroll::externalUnloaded() } } -void SetupTabScroll::widgetResized(const gcn::Event &event A_UNUSED) +void SetupTabScroll::widgetResized(const Event &event A_UNUSED) { mScroll->setWidth(getWidth() - 12); mScroll->setHeight(getHeight() - 12 - 12); diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h index 779826e5a..f7aa628c9 100644 --- a/src/gui/widgets/tabs/setuptabscroll.h +++ b/src/gui/widgets/tabs/setuptabscroll.h @@ -63,7 +63,7 @@ class SetupTabScroll : public SetupTab int getPreferredFirstItemSize() const A_WARN_UNUSED { return mPreferredFirstItemSize; } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void reread(const std::string &name); diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 398802eb0..db5ddf6b4 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -254,12 +254,12 @@ void Tab::draw(Graphics *graphics) BLOCK_END("Tab::draw") } -void Tab::widgetResized(const gcn::Event &event A_UNUSED) +void Tab::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void Tab::widgetMoved(const gcn::Event &event A_UNUSED) +void Tab::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index ac10b7dc7..e979c71b8 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -130,9 +130,9 @@ class Tab : public gcn::BasicContainer, int getFlash() const A_WARN_UNUSED { return mFlash; } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; void setLabelFont(gcn::Font *const font); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 22e9d42dd..58facecb8 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -760,7 +760,7 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent) } } -void TextField::focusGained(const gcn::Event &event A_UNUSED) +void TextField::focusGained(const Event &event A_UNUSED) { #ifdef ANDROID if (!client->isKeyboardVisible()) @@ -768,6 +768,6 @@ void TextField::focusGained(const gcn::Event &event A_UNUSED) #endif } -void TextField::focusLost(const gcn::Event &event A_UNUSED) +void TextField::focusLost(const Event &event A_UNUSED) { } diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 4545e9ff9..42f76985c 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -124,9 +124,9 @@ class TextField : public gcn::TextField, void handleCopy() const; - void focusGained(const gcn::Event &event) override final; + void focusGained(const Event &event) override final; - void focusLost(const gcn::Event &event) override; + void focusLost(const Event &event) override; void moveCaretBack(); diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index ed3d00219..e38ebb9af 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -79,7 +79,7 @@ void VertContainer::clear() mResizableWidgets.clear(); } -void VertContainer::widgetResized(const gcn::Event &event A_UNUSED) +void VertContainer::widgetResized(const Event &event A_UNUSED) { FOR_EACH (std::vector::const_iterator, it, mResizableWidgets) (*it)->setWidth(getWidth()); diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 34fcf3d45..1d396efc9 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -52,7 +52,7 @@ class VertContainer final : public Container, void clear(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; private: std::vector mResizableWidgets; diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 56da2d492..3957fab30 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -84,6 +84,6 @@ void WidgetGroup::clear() mCount = 0; } -void WidgetGroup::widgetResized(const gcn::Event &event A_UNUSED) +void WidgetGroup::widgetResized(const Event &event A_UNUSED) { } diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 835738a6f..b26d88d15 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -47,7 +47,7 @@ class WidgetGroup : public Container, virtual void clear(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; virtual Widget *createWidget(const std::string &name) const A_WARN_UNUSED = 0; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 1fc439abf..54c18bd52 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -490,7 +490,7 @@ void Window::setResizable(const bool r) } } -void Window::widgetResized(const gcn::Event &event A_UNUSED) +void Window::widgetResized(const Event &event A_UNUSED) { const gcn::Rectangle area = getChildrenArea(); @@ -554,12 +554,12 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED) mRedraw = true; } -void Window::widgetMoved(const gcn::Event& event A_UNUSED) +void Window::widgetMoved(const Event& event A_UNUSED) { mRedraw = true; } -void Window::widgetHidden(const gcn::Event &event A_UNUSED) +void Window::widgetHidden(const Event &event A_UNUSED) { if (gui) gui->setCursorType(Cursor::CURSOR_POINTER); @@ -1085,7 +1085,7 @@ void Window::adjustSizeToScreen() if (mDimension.height > screenHeight) mDimension.height = screenHeight; if (oldWidth != mDimension.width || oldHeight != mDimension.height) - widgetResized(gcn::Event(this)); + widgetResized(Event(this)); } int Window::getResizeHandles(const gcn::MouseEvent &event) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 5ff5abe2b..0c3b69880 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -114,14 +114,14 @@ class Window : public gcn::Window, /** * Called whenever the widget changes size. */ - virtual void widgetResized(const gcn::Event &event) override; + virtual void widgetResized(const Event &event) override; - virtual void widgetMoved(const gcn::Event& event) override; + virtual void widgetMoved(const Event& event) override; /** * Called whenever the widget is hidden. */ - virtual void widgetHidden(const gcn::Event &event) override; + virtual void widgetHidden(const Event &event) override; /** * Sets whether or not the window has a close button. diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 5d447c717..793315067 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -563,7 +563,7 @@ void CharSelectDialog::close() Window::close(); } -void CharSelectDialog::widgetResized(const gcn::Event &event) +void CharSelectDialog::widgetResized(const Event &event) { Window::widgetResized(event); if (mCharacterView) diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 6c6759932..e2b9c1ba8 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -86,7 +86,7 @@ class CharSelectDialog final : public Window, void close() override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void updateState(); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 28f58aaa9..40b4b9400 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -97,7 +97,7 @@ class ChatInput final : public TextField * Called if the chat input loses focus. It will set itself to * invisible as result. */ - void focusLost(const gcn::Event &event) + void focusLost(const Event &event) { TextField::focusLost(event); if (mFocusGaining || !config.getBoolValue("protectChatFocus")) @@ -441,7 +441,7 @@ void ChatWindow::adjustTabSize() mChatTabs->adjustSize(); } -void ChatWindow::widgetResized(const gcn::Event &event) +void ChatWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index e18eef7b2..f8458bd32 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -286,7 +286,7 @@ class ChatWindow final : public Window, void unHideWindow(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void addGlobalMessage(const std::string &line); diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 7cc074086..7e68aa6d8 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -147,7 +147,7 @@ void DebugWindow::draw(Graphics *g) BLOCK_END("DebugWindow::draw") } -void DebugWindow::widgetResized(const gcn::Event &event) +void DebugWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h index 83d6676da..aa7bdfe6c 100644 --- a/src/gui/windows/debugwindow.h +++ b/src/gui/windows/debugwindow.h @@ -151,7 +151,7 @@ class DebugWindow final : public Window void setPing(int pingTime); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; #ifdef USE_PROFILER void logicChildren(); diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index cb2fdec95..89b1eda26 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -99,7 +99,7 @@ DidYouKnowWindow::DidYouKnowWindow() : void DidYouKnowWindow::postInit() { - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } void DidYouKnowWindow::action(const ActionEvent &event) diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index 2d2fdbd26..5f3aa1bb1 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -214,7 +214,7 @@ void EmoteWindow::addListeners(ActionListener *const listener) mFontPage->addActionListener(listener); } -void EmoteWindow::widgetResized(const gcn::Event &event) +void EmoteWindow::widgetResized(const Event &event) { Window::widgetResized(event); const int pad2 = mPadding * 2; @@ -229,7 +229,7 @@ void EmoteWindow::widgetResized(const gcn::Event &event) mEmotePage->widgetResized(event); } -void EmoteWindow::widgetMoved(const gcn::Event &event) +void EmoteWindow::widgetMoved(const Event &event) { Window::widgetMoved(event); mEmotePage->widgetResized(event); diff --git a/src/gui/windows/emotewindow.h b/src/gui/windows/emotewindow.h index 2ddc64886..37a5c015f 100644 --- a/src/gui/windows/emotewindow.h +++ b/src/gui/windows/emotewindow.h @@ -61,9 +61,9 @@ class EmoteWindow final : public Window void addListeners(ActionListener *const listener); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; private: TabbedArea *mTabs; diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 53e82335e..9738378ea 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -87,7 +87,7 @@ HelpWindow::HelpWindow() : loadWindowState(); loadTags(); enableVisibleSound(true); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } void HelpWindow::action(const ActionEvent &event) diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 509b085b5..2412b524b 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -295,7 +295,7 @@ void InventoryWindow::postInit() slotsChanged(mInventory); mItems->setSortType(mSortDropDown->getSelected()); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); if (!isMainInventory()) setVisible(true); } @@ -459,7 +459,7 @@ void InventoryWindow::unselectItem() mItems->selectNone(); } -void InventoryWindow::widgetHidden(const gcn::Event &event) +void InventoryWindow::widgetHidden(const Event &event) { Window::widgetHidden(event); mItems->hidePopup(); @@ -812,7 +812,7 @@ bool InventoryWindow::isAnyInputFocused() return false; } -void InventoryWindow::widgetResized(const gcn::Event &event) +void InventoryWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 4babbc264..cd5172c03 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -92,7 +92,7 @@ class InventoryWindow final : public Window, /** * Handles closing of the window */ - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; /** * Handles the mouse clicks. @@ -145,7 +145,7 @@ class InventoryWindow final : public Window, bool isInputFocused() const A_WARN_UNUSED; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void mouseMoved(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 710702f5e..a996d776b 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -149,7 +149,7 @@ void SetupWindow::postInit() center(); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); setInGame(false); enableVisibleSound(true); } @@ -260,7 +260,7 @@ void SetupWindow::setVisible(bool visible) Window::setVisible(visible); } -void SetupWindow::widgetResized(const gcn::Event &event) +void SetupWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index 27e44b243..38b3eb206 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -71,7 +71,7 @@ class SetupWindow final : public Window, void setVisible(bool visible) override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; private: void unloadModTab(); diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 96ec8c93c..7916ce8e4 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -176,7 +176,7 @@ int ShortcutWindow::getTabIndex() const return mTabs->getSelectedTabIndex(); } -void ShortcutWindow::widgetHidden(const gcn::Event &event) +void ShortcutWindow::widgetHidden(const Event &event) { if (mItems) mItems->widgetHidden(event); @@ -226,7 +226,7 @@ void ShortcutWindow::mouseDragged(gcn::MouseEvent &event) } } -void ShortcutWindow::widgetMoved(const gcn::Event& event) +void ShortcutWindow::widgetMoved(const Event& event) { Window::widgetMoved(event); if (mItems) diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h index f4c417c94..707a0a1d7 100644 --- a/src/gui/windows/shortcutwindow.h +++ b/src/gui/windows/shortcutwindow.h @@ -60,9 +60,9 @@ class ShortcutWindow final : public Window int getTabIndex() const A_WARN_UNUSED; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; - void widgetMoved(const gcn::Event& event) override final; + void widgetMoved(const Event& event) override final; void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 12c6e76d8..deeffb9a0 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -617,7 +617,7 @@ SkillInfo* SkillDialog::getSkillByItem(const int itemId) const return nullptr; } -void SkillDialog::widgetResized(const gcn::Event &event) +void SkillDialog::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 2bedef2b0..3bf64df9b 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -88,7 +88,7 @@ class SkillDialog final : public Window, bool hasSkills() const A_WARN_UNUSED { return !mSkills.empty(); } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void useItem(const int itemId) const; diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 72590ab60..4df0ab6f1 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -1336,7 +1336,7 @@ void SocialWindow::postInit() place(0, 1, mCountLabel); place(0, 2, mTabs, 4, 4); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); loadWindowState(); @@ -1863,7 +1863,7 @@ void SocialWindow::updateParty() } } -void SocialWindow::widgetResized(const gcn::Event &event) +void SocialWindow::widgetResized(const Event &event) { Window::widgetResized(event); if (mTabs) diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 08497c5c8..fc93aed4f 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -123,7 +123,7 @@ public: void updatePickupFilter(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void setCounter(const SocialTab *const tab, const std::string &str); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 0d65eff35..201a5e11e 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -133,7 +133,7 @@ void WhoIsOnline::postInit() download(); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); config.addListener("updateOnlineList", this); config.addListener("groupFriends", this); mGroupFriends = config.getBoolValue("groupFriends"); @@ -715,7 +715,7 @@ void WhoIsOnline::action(const ActionEvent &event) } } -void WhoIsOnline::widgetResized(const gcn::Event &event) +void WhoIsOnline::widgetResized(const Event &event) { Window::widgetResized(event); updateSize(); diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index af0d14f7b..99eeb1911 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -136,7 +136,7 @@ public: void action(const ActionEvent &event) override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; const std::set &getOnlinePlayers() const A_WARN_UNUSED { return mOnlinePlayers; } diff --git a/src/listeners/deathlistener.h b/src/listeners/deathlistener.h index ad2eb5364..beefe1746 100644 --- a/src/listeners/deathlistener.h +++ b/src/listeners/deathlistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" /** * Interface for listening for death events from widgets. @@ -90,7 +90,7 @@ class DeathListener * * @param event The event of the death. */ - virtual void death(const gcn::Event &event) = 0; + virtual void death(const Event &event) = 0; protected: /** diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h index 1a6dd3fb2..c910f833e 100644 --- a/src/listeners/focuslistener.h +++ b/src/listeners/focuslistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" #include "localconsts.h" @@ -91,7 +91,7 @@ class FocusListener * * @param event Discribes the event. */ - virtual void focusGained(const gcn::Event &event A_UNUSED) + virtual void focusGained(const Event &event A_UNUSED) { } /** @@ -99,7 +99,7 @@ class FocusListener * * @param event Discribes the event. */ - virtual void focusLost(const gcn::Event &event A_UNUSED) + virtual void focusLost(const Event &event A_UNUSED) { } protected: diff --git a/src/listeners/widgetlistener.h b/src/listeners/widgetlistener.h index d7d348cd0..16d9e1f15 100644 --- a/src/listeners/widgetlistener.h +++ b/src/listeners/widgetlistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" #include "localconsts.h" @@ -94,7 +94,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetResized(const gcn::Event &event A_UNUSED) + virtual void widgetResized(const Event &event A_UNUSED) { } /** @@ -103,7 +103,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetMoved(const gcn::Event &event A_UNUSED) + virtual void widgetMoved(const Event &event A_UNUSED) { } /** @@ -113,7 +113,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetHidden(const gcn::Event &event A_UNUSED) + virtual void widgetHidden(const Event &event A_UNUSED) { } /** @@ -123,7 +123,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetShown(const gcn::Event &event A_UNUSED) + virtual void widgetShown(const Event &event A_UNUSED) { } protected: -- cgit v1.2.3-70-g09d2 From 6e6c5b2ba399e0ed364ada843c4c759ee54de219 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 22:17:22 +0300 Subject: combine font classes in one. --- src/CMakeLists.txt | 6 +- src/Makefile.am | 8 +- src/being/being.cpp | 8 +- src/being/localplayer.cpp | 2 +- src/commands.cpp | 4 +- src/flooritem.cpp | 4 +- src/gui/base/font.cpp | 87 ----- src/gui/base/font.hpp | 133 ------- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/checkbox.cpp | 3 +- src/gui/base/widgets/label.cpp | 2 +- src/gui/base/widgets/listbox.cpp | 4 +- src/gui/base/widgets/radiobutton.cpp | 3 +- src/gui/base/widgets/textbox.cpp | 3 +- src/gui/base/widgets/textfield.cpp | 3 +- src/gui/base/widgets/window.cpp | 3 +- src/gui/gui.cpp | 16 +- src/gui/gui.h | 24 +- src/gui/popups/beingpopup.cpp | 4 +- src/gui/popups/itempopup.cpp | 4 +- src/gui/popups/speechbubble.cpp | 4 +- src/gui/popups/spellpopup.cpp | 2 +- src/gui/popups/statuspopup.cpp | 2 +- src/gui/popups/textpopup.cpp | 2 +- src/gui/sdlfont.cpp | 603 ----------------------------- src/gui/sdlfont.h | 168 -------- src/gui/viewport.cpp | 4 +- src/gui/widgets/avatarlistbox.cpp | 6 +- src/gui/widgets/browserbox.cpp | 9 +- src/gui/widgets/button.cpp | 6 +- src/gui/widgets/checkbox.cpp | 4 +- src/gui/widgets/colorpage.cpp | 6 +- src/gui/widgets/dropdown.cpp | 4 +- src/gui/widgets/dropshortcutcontainer.cpp | 4 +- src/gui/widgets/emoteshortcutcontainer.cpp | 5 +- src/gui/widgets/extendedlistbox.cpp | 5 +- src/gui/widgets/itemcontainer.cpp | 4 +- src/gui/widgets/itemshortcutcontainer.cpp | 5 +- src/gui/widgets/label.cpp | 8 +- src/gui/widgets/listbox.cpp | 6 +- src/gui/widgets/progressbar.cpp | 6 +- src/gui/widgets/radiobutton.cpp | 6 +- src/gui/widgets/setupitem.cpp | 6 +- src/gui/widgets/shoplistbox.cpp | 4 +- src/gui/widgets/sliderlist.cpp | 5 +- src/gui/widgets/spellshortcutcontainer.cpp | 5 +- src/gui/widgets/tabs/setup_colors.cpp | 4 +- src/gui/widgets/tabs/setup_input.cpp | 2 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/tabs/tab.h | 2 +- src/gui/widgets/textbox.cpp | 6 +- src/gui/widgets/textfield.cpp | 6 +- src/gui/widgets/textpreview.cpp | 9 +- src/gui/widgets/textpreview.h | 4 +- src/gui/widgets/window.cpp | 4 +- src/gui/widgets/window.h | 4 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/confirmdialog.cpp | 2 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/equipmentwindow.cpp | 5 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 4 +- src/gui/windows/npcdialog.cpp | 6 +- src/gui/windows/okdialog.cpp | 2 +- src/gui/windows/questswindow.cpp | 2 +- src/gui/windows/serverdialog.cpp | 10 +- src/gui/windows/skilldialog.cpp | 5 +- src/gui/windows/textdialog.cpp | 4 +- src/gui/windows/tradewindow.cpp | 6 +- src/maplayer.cpp | 4 +- src/particle/particle.cpp | 4 +- src/particle/particle.h | 7 +- src/particle/textparticle.cpp | 4 +- src/particle/textparticle.h | 4 +- src/text.cpp | 8 +- src/text.h | 11 +- src/touchmanager.cpp | 4 +- 78 files changed, 167 insertions(+), 1189 deletions(-) delete mode 100644 src/gui/base/font.cpp delete mode 100644 src/gui/base/font.hpp delete mode 100644 src/gui/sdlfont.cpp delete mode 100644 src/gui/sdlfont.h (limited to 'src/gui/gui.h') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41f99a646..ed80c00cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -364,8 +364,8 @@ SET(SRCS gui/widgets/tabs/setup_visual.cpp gui/widgets/tabs/setup_visual.h gui/setupactiondata.h - gui/sdlfont.cpp - gui/sdlfont.h + gui/font.cpp + gui/font.h gui/windows/shopwindow.cpp gui/windows/shopwindow.h gui/windows/shortcutwindow.cpp @@ -774,7 +774,6 @@ SET(SRCS events/event.h gui/base/focushandler.hpp listeners/focuslistener.h - gui/base/font.hpp gui/base/gui.hpp gui/base/input.hpp events/inputguievent.h @@ -807,7 +806,6 @@ SET(SRCS gui/base/cliprectangle.cpp gui/base/color.cpp gui/base/focushandler.cpp - gui/base/font.cpp gui/base/gui.cpp gui/base/key.cpp gui/base/keyinput.cpp diff --git a/src/Makefile.am b/src/Makefile.am index c60b782a7..09579cc29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,14 +28,12 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/font.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ events/event.h \ - gui/base/font.hpp \ gui/base/rectangle.hpp \ gui/base/widget.hpp @@ -161,7 +159,6 @@ manaplus_SOURCES += events/actionevent.h \ events/event.h \ gui/base/focushandler.hpp \ listeners/focuslistener.h \ - gui/base/font.hpp \ render/graphics.h \ gui/base/gui.hpp \ gui/base/input.hpp \ @@ -195,7 +192,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ gui/base/focushandler.cpp \ - gui/base/font.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ gui/base/keyinput.cpp \ @@ -473,8 +469,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabs/setup_visual.cpp \ gui/widgets/tabs/setup_visual.h \ gui/setupactiondata.h \ - gui/sdlfont.cpp \ - gui/sdlfont.h \ + gui/font.cpp \ + gui/font.h \ gui/windows/shopwindow.cpp \ gui/windows/shopwindow.h \ gui/windows/shortcutwindow.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 8b2ece2b7..1fcccb0cf 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -39,7 +39,7 @@ #include "particle/particle.h" #include "particle/particleinfo.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/popups/speechbubble.h" @@ -537,7 +537,7 @@ void Being::takeDamage(Being *const attacker, const int amount, if (!userPalette || !attacker) return; - gcn::Font *font = nullptr; + Font *font = nullptr; // TRANSLATORS: hit or miss message in attacks const std::string damage = amount ? toString(amount) : type == FLEE ? _("dodge") : _("miss"); @@ -2003,7 +2003,7 @@ void Being::showName() displayName.append(", ").append(toString(getDamageTaken())); } - gcn::Font *font = nullptr; + Font *font = nullptr; if (player_node && player_node->getTarget() == this && mType != MONSTER) { @@ -2519,7 +2519,7 @@ void Being::drawSpriteAt(Graphics *const graphics, if (mDrawHotKeys && !mName.empty()) { - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); if (font) { graphics->setColor(userPalette->getColor(UserPalette::BEING)); diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ea8218ee4..0e57eabfe 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -42,8 +42,8 @@ #include "input/keyboardconfig.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/chatwindow.h" diff --git a/src/commands.cpp b/src/commands.cpp index 04cd84166..93e07b0f8 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1024,7 +1024,7 @@ impHandler0(cacheInfo) return; /* - SDLFont *const font = dynamic_cast(chatWindow->getFont()); + Font *const font = chatWindow->getFont(); if (!font) return; @@ -1361,7 +1361,7 @@ impHandler0(uploadLog) impHandler0(testsdlfont) { #if defined USE_OPENGL && defined DEBUG_SDLFONT - SDLFont *font = new SDLFont("fonts/dejavusans.ttf", 18); + Font *font = new Font("fonts/dejavusans.ttf", 18); timespec time1; timespec time2; NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics; diff --git a/src/flooritem.cpp b/src/flooritem.cpp index bf8b54f0b..2592e6feb 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -26,8 +26,8 @@ #include "render/graphics.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/userpalette.h" #include "resources/iteminfo.h" @@ -109,7 +109,7 @@ void FloorItem::draw(Graphics *const graphics, BLOCK_START("FloorItem::draw") const int x = mX * mMap->getTileWidth() + offsetX; const int y = mY * mMap->getTileHeight() + offsetY; - gcn::Font *font = nullptr; + Font *font = nullptr; if (mHighlight) { diff --git a/src/gui/base/font.cpp b/src/gui/base/font.cpp deleted file mode 100644 index ccb2f7022..000000000 --- a/src/gui/base/font.cpp +++ /dev/null @@ -1,87 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/font.hpp" - -#include - -#include "debug.h" - -namespace gcn -{ - int Font::getStringIndexAt(const std::string& text, const int x) const - { - const size_t sz = text.size(); - for (size_t i = 0; i < sz; ++i) - { - if (getWidth(text.substr(0, i)) > x) - return i; - } - - return static_cast(sz); - } -} // namespace gcn diff --git a/src/gui/base/font.hpp b/src/gui/base/font.hpp deleted file mode 100644 index 075af4136..000000000 --- a/src/gui/base/font.hpp +++ /dev/null @@ -1,133 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_FONT_HPP -#define GCN_FONT_HPP - -#include - -#include "localconsts.h" - -class Graphics; - -namespace gcn -{ - /** - * Interface for a font. - * - * @see ImageFont - */ - class Font - { - public: - /** - * Destructor. - */ - virtual ~Font() - { } - - /** - * Gets the width of a string. The width of a string is not necesserily - * the sum of all the widths of it's glyphs. - * - * @param text The string to return the width of. - * @return The width of a string. - */ - virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0; - - /** - * Gets the height of the glyphs in the font. - * - * @return The height of the glyphs int the font. - */ - virtual int getHeight() const A_WARN_UNUSED = 0; - - /** - * Gets a string index in a string providing an x coordinate. - * Used to retrive a string index (for a character in a - * string) at a certain x position. It is especially useful - * when a mouse clicks in a TextField and you want to know which - * character was clicked. - * - * @return A string index in a string providing an x coordinate. - */ - virtual int getStringIndexAt(const std::string& text, - const int x) const A_WARN_UNUSED; - - /** - * Draws a string. - * - * NOTE: You normally won't use this function to draw text since - * Graphics contains better functions for drawing text. - * - * @param graphics A Graphics object to use for drawing. - * @param text The string to draw. - * @param x The x coordinate where to draw the string. - * @param y The y coordinate where to draw the string. - */ - virtual void drawString(Graphics* graphics, const std::string& text, - int x, int y) = 0; - }; -} // namespace gcn - -#endif // end GCN_FONT_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index ce32b14f3..a459ab4f2 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -76,6 +76,7 @@ class ActionListener; class DeathListener; class FocusListener; +class Font; class Graphics; class KeyListener; class MouseListener; @@ -85,7 +86,6 @@ namespace gcn { class BasicContainer; class FocusHandler; - class Font; class KeyInput; class MouseInput; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 1276b82b2..9b7473293 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/button.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 5f2477b4d..0a3171fe8 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/checkbox.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index c23666eac..cbee2ac4c 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -67,7 +67,7 @@ #include "gui/base/widgets/label.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 7f46b4b10..6c6472636 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -67,11 +67,13 @@ #include "gui/base/widgets/listbox.hpp" +#include "gui/font.h" + #include "gui/base/basiccontainer.hpp" -#include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouseinput.hpp" + #include "listeners/selectionlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index e42773de1..f0430c7a2 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/radiobutton.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 06d0e6379..e994804d8 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -67,8 +67,9 @@ #include "gui/base/widgets/textbox.hpp" +#include "gui/font.h" + #include "gui/base/basiccontainer.hpp" -#include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index df1b844d4..1514d3afb 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/textfield.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 9207fe449..fbd42aff2 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/window.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/mouseinput.hpp" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 08794d478..f549727a4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -25,8 +25,8 @@ #include "gui/gui.h" #include "gui/focushandler.h" +#include "gui/font.h" #include "gui/palette.h" -#include "gui/sdlfont.h" #include "gui/sdlinput.h" #include "gui/theme.h" #include "gui/viewport.h" @@ -60,7 +60,7 @@ Gui *gui = nullptr; SDLInput *guiInput = nullptr; // Bolded font -SDLFont *boldFont = nullptr; +Font *boldFont = nullptr; class GuiConfigListener final : public ConfigListener { @@ -160,7 +160,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("font"); - mGuiFont = new SDLFont(fontFile, fontSize); + mGuiFont = new Font(fontFile, fontSize); // Set particle font fontFile = config.getValue("particleFont", ""); @@ -179,28 +179,28 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("particleFont"); - mInfoParticleFont = new SDLFont(fontFile, fontSize, TTF_STYLE_BOLD); + mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD); // Set bold font fontFile = config.getValue("boldFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("boldFont"); - boldFont = new SDLFont(fontFile, fontSize); + boldFont = new Font(fontFile, fontSize); // Set help font fontFile = config.getValue("helpFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("helpFont"); - mHelpFont = new SDLFont(fontFile, fontSize); + mHelpFont = new Font(fontFile, fontSize); // Set secure font fontFile = config.getValue("secureFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("secureFont"); - mSecureFont = new SDLFont(fontFile, fontSize); + mSecureFont = new Font(fontFile, fontSize); // Set npc font const int npcFontSize = config.getIntValue("npcfontSize"); @@ -220,7 +220,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("npcFont"); - mNpcFont = new SDLFont(fontFile, npcFontSize); + mNpcFont = new Font(fontFile, npcFontSize); gcn::Widget::setGlobalFont(mGuiFont); diff --git a/src/gui/gui.h b/src/gui/gui.h index 1ec73e42f..1660fcfbf 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -35,7 +35,7 @@ class GuiConfigListener; class ImageSet; class MouseEvent; class MouseInput; -class SDLFont; +class Font; class SDLInput; class Window; @@ -96,32 +96,32 @@ class Gui final : public gcn::Gui /** * Return game font. */ - SDLFont *getFont() const A_WARN_UNUSED + Font *getFont() const A_WARN_UNUSED { return mGuiFont; } /** * Return help font. */ - SDLFont *getHelpFont() const A_WARN_UNUSED + Font *getHelpFont() const A_WARN_UNUSED { return mHelpFont; } /** * Return secure font. */ - SDLFont *getSecureFont() const A_WARN_UNUSED + Font *getSecureFont() const A_WARN_UNUSED { return mSecureFont; } /** * Return npc font. */ - SDLFont *getNpcFont() const A_WARN_UNUSED + Font *getNpcFont() const A_WARN_UNUSED { return mNpcFont; } /** * Return the Font used for "Info Particles", i.e. ones showing, what * you picked up, etc. */ - SDLFont *getInfoParticleFont() const A_WARN_UNUSED + Font *getInfoParticleFont() const A_WARN_UNUSED { return mInfoParticleFont; } /** @@ -183,11 +183,11 @@ class Gui final : public gcn::Gui private: GuiConfigListener *mConfigListener; - SDLFont *mGuiFont; /**< The global GUI font */ - SDLFont *mInfoParticleFont; /**< Font for Info Particles */ - SDLFont *mHelpFont; /**< Font for Help Window */ - SDLFont *mSecureFont; /**< Font for secure labels */ - SDLFont *mNpcFont; /**< Font for npc text */ + Font *mGuiFont; /**< The global GUI font */ + Font *mInfoParticleFont; /**< Font for Info Particles */ + Font *mHelpFont; /**< Font for Help Window */ + Font *mSecureFont; /**< Font for secure labels */ + Font *mNpcFont; /**< Font for npc text */ ImageSet *mMouseCursors; /**< Mouse cursor images */ float mMouseCursorAlpha; int mMouseInactivityTimer; @@ -212,6 +212,6 @@ extern SDLInput *guiInput; /**< GUI input */ /** * Bolded text font */ -extern SDLFont *boldFont; +extern Font *boldFont; #endif // GUI_GUI_H diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 623b19d00..32aa11454 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -24,15 +24,13 @@ #include "being/being.h" #include "being/playerrelations.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/label.h" #include "utils/gettext.h" #include "utils/stringutils.h" -#include "gui/base/font.hpp" - #include "debug.h" BeingPopup::BeingPopup() : diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index f7939b666..d6ea5a48a 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -27,7 +27,7 @@ #include "item.h" #include "units.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/icon.h" #include "gui/widgets/label.h" @@ -38,8 +38,6 @@ #include "resources/image.h" #include "resources/resourcemanager.h" -#include "gui/base/font.hpp" - #include "debug.h" extern int serverVersion; diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index dd8f9ada9..c74f3f5e6 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -23,15 +23,13 @@ #include "gui/popups/speechbubble.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" #include "gui/widgets/textbox.h" -#include "gui/base/font.hpp" - #include "debug.h" SpeechBubble::SpeechBubble() : diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index cc55fef57..141879da4 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -23,7 +23,7 @@ #include "gui/popups/spellpopup.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 2332e20a9..7dd3c3634 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -33,7 +33,7 @@ #include "utils/stringutils.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 245bf58b0..0ae53ac1f 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/label.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp deleted file mode 100644 index 95a3df390..000000000 --- a/src/gui/sdlfont.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2009 Aethyra Development Team - * 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 . - */ - -#include "gui/sdlfont.h" - -#include "logger.h" -#include "main.h" - -#include "render/sdlgraphics.h" - -#include "resources/image.h" -#include "resources/imagehelper.h" -#include "resources/resourcemanager.h" -#include "resources/surfaceimagehelper.h" - -#include "utils/paths.h" -#include "utils/physfsrwops.h" -#include "utils/sdlcheckutils.h" -#include "utils/stringutils.h" -#include "utils/timer.h" - -#include "debug.h" - -const unsigned int CACHE_SIZE = 256; -const unsigned int CACHE_SIZE_SMALL1 = 2; -const unsigned int CACHE_SIZE_SMALL2 = 50; -const unsigned int CACHE_SIZE_SMALL3 = 170; -const unsigned int CLEAN_TIME = 7; -const int OUTLINE_SIZE = 1; - -bool SDLFont::mSoftMode(false); - -char *strBuf = nullptr; - -#ifdef UNITTESTS -int sdlTextChunkCnt = 0; -#endif - -SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, - const gcn::Color &color0, - const gcn::Color &color1) : - text(text0), - color(color0), - color2(color1) -{ -} - -SDLTextChunkSmall::SDLTextChunkSmall(const SDLTextChunkSmall &old) : - text(old.text), - color(old.color), - color2(old.color2) -{ -} - -bool SDLTextChunkSmall::operator==(const SDLTextChunkSmall &chunk) const -{ - return (chunk.text == text && chunk.color == color - && chunk.color2 == color2); -} - -bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const -{ - if (chunk.text != text) - return chunk.text > text; - - const gcn::Color &c = chunk.color; - if (c.r != color.r) - return c.r > color.r; - if (c.g != color.g) - return c.g > color.g; - if (c.b != color.b) - return c.b > color.b; - - const gcn::Color &c2 = chunk.color2; - if (c2.r != color2.r) - return c2.r > color2.r; - if (c2.g != color2.g) - return c2.g > color2.g; - if (c2.b != color2.b) - return c2.b > color2.b; - - if (c.a != color.a && SDLFont::mSoftMode) - return c.a > color.a; - - return false; -} - -SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1) : - img(nullptr), - text(text0), - color(color0), - color2(color1), - prev(nullptr), - next(nullptr) -{ -#ifdef UNITTESTS - sdlTextChunkCnt ++; -#endif -} - -SDLTextChunk::~SDLTextChunk() -{ - delete img; - img = nullptr; -#ifdef UNITTESTS - sdlTextChunkCnt --; -#endif -} - -bool SDLTextChunk::operator==(const SDLTextChunk &chunk) const -{ - return (chunk.text == text && chunk.color == color - && chunk.color2 == color2); -} - -void SDLTextChunk::generate(TTF_Font *const font, const float alpha) -{ - BLOCK_START("SDLTextChunk::generate") - SDL_Color sdlCol; - sdlCol.b = static_cast(color.b); - sdlCol.r = static_cast(color.r); - sdlCol.g = static_cast(color.g); -#ifdef USE_SDL2 - sdlCol.a = 255; -#else - sdlCol.unused = 0; -#endif - - getSafeUtf8String(text, strBuf); - - SDL_Surface *surface = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol); - - if (!surface) - { - img = nullptr; - BLOCK_END("SDLTextChunk::generate") - return; - } - - const int width = surface->w; - const int height = surface->h; - - if (color.r != color2.r || color.g != color2.g - || color.b != color2.b) - { // outlining - SDL_Color sdlCol2; - SDL_Surface *const background = imageHelper->create32BitSurface( - width, height); - if (!background) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("SDLTextChunk::generate") - return; - } - sdlCol2.b = static_cast(color2.b); - sdlCol2.r = static_cast(color2.r); - sdlCol2.g = static_cast(color2.g); -#ifdef USE_SDL2 - sdlCol2.a = 255; -#else - sdlCol2.unused = 0; -#endif - SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol2); - if (!surface2) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("SDLTextChunk::generate") - return; - } - SDL_Rect rect = - { - OUTLINE_SIZE, - 0, - static_cast(surface->w), - static_cast(surface->h) - }; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.y = OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = 0; - SurfaceImageHelper::combineSurface(surface, nullptr, - background, &rect); - MSDL_FreeSurface(surface); - MSDL_FreeSurface(surface2); - surface = background; - } - img = imageHelper->createTextSurface( - surface, width, height, alpha); - MSDL_FreeSurface(surface); - - BLOCK_END("SDLTextChunk::generate") -} - - -TextChunkList::TextChunkList() : - start(nullptr), - end(nullptr), - size(0), - search(), - searchWidth() -{ -} - -void TextChunkList::insertFirst(SDLTextChunk *const item) -{ - SDLTextChunk *const oldFirst = start; - if (start) - start->prev = item; - item->prev = nullptr; - if (oldFirst) - item->next = oldFirst; - else - end = item; - start = item; - size ++; - search[SDLTextChunkSmall(item->text, item->color, item->color2)] = item; - searchWidth[item->text] = item; -} - -void TextChunkList::moveToFirst(SDLTextChunk *item) -{ - if (item == start) - return; - - SDLTextChunk *oldPrev = item->prev; - if (oldPrev) - oldPrev->next = item->next; - SDLTextChunk *oldNext = item->next; - if (oldNext) - oldNext->prev = item->prev; - else - end = oldPrev; - SDLTextChunk *const oldFirst = start; - if (start) - start->prev = item; - item->prev = nullptr; - item->next = oldFirst; - start = item; -} - -void TextChunkList::removeBack() -{ - SDLTextChunk *oldEnd = end; - if (oldEnd) - { - end = oldEnd->prev; - if (end) - end->next = nullptr; - else - start = nullptr; - search.erase(SDLTextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } -} - -void TextChunkList::removeBack(int n) -{ - SDLTextChunk *item = end; - while (n && item) - { - n --; - SDLTextChunk *oldEnd = item; - item = item->prev; - search.erase(SDLTextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } - if (item) - { - item->next = nullptr; - end = item; - } - else - { - start = nullptr; - end = nullptr; - } -} - -void TextChunkList::clear() -{ - search.clear(); - searchWidth.clear(); - SDLTextChunk *item = start; - while (item) - { - SDLTextChunk *item2 = item->next; - delete item; - item = item2; - } - start = nullptr; - end = nullptr; - size = 0; -} - -static int fontCounter; - -SDLFont::SDLFont(std::string filename, - const int size, - const int style) : - mFont(nullptr), - mCreateCounter(0), - mDeleteCounter(0), - mCleanTime(cur_time + CLEAN_TIME) -{ - if (fontCounter == 0) - { - mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE; - if (TTF_Init() == -1) - { - logger->error("Unable to initialize SDL_ttf: " + - std::string(TTF_GetError())); - } - } - - if (!fontCounter) - { - strBuf = new char[65535]; - memset(strBuf, 0, 65535); - } - - ++fontCounter; - - fixDirSeparators(filename); - mFont = openFont(filename.c_str(), size); - - if (!mFont) - { - logger->log("Error finding font " + filename); - std::string backFile("fonts/dejavusans.ttf"); - mFont = openFont(fixDirSeparators(backFile).c_str(), size); - if (!mFont) - { - logger->error("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); - } - } - - TTF_SetFontStyle(mFont, style); -} - -SDLFont::~SDLFont() -{ - TTF_CloseFont(mFont); - mFont = nullptr; - --fontCounter; - clear(); - - if (fontCounter == 0) - { - TTF_Quit(); - delete []strBuf; - } -} - -TTF_Font *SDLFont::openFont(const char *const name, const int size) -{ -// disabled for now because some systems like gentoo cant use it -// #ifdef USE_SDL2 -// SDL_RWops *const rw = MPHYSFSRWOPS_openRead(name); -// if (!rw) -// return nullptr; -// return TTF_OpenFontIndexRW(rw, 1, size, 0); -// #else - return TTF_OpenFontIndex(ResourceManager::getPath(name).c_str(), - size, 0); -// #endif -} - -void SDLFont::loadFont(std::string filename, - const int size, - const int style) -{ - if (fontCounter == 0 && TTF_Init() == -1) - { - logger->log("Unable to initialize SDL_ttf: " + - std::string(TTF_GetError())); - return; - } - - fixDirSeparators(filename); - TTF_Font *const font = openFont(filename.c_str(), size); - - if (!font) - { - logger->log("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); - return; - } - - if (mFont) - TTF_CloseFont(mFont); - - mFont = font; - TTF_SetFontStyle(mFont, style); - clear(); -} - -void SDLFont::clear() -{ - for (size_t f = 0; f < CACHES_NUMBER; f ++) - mCache[f].clear(); -} - -void SDLFont::drawString(Graphics *const graphics, - const std::string &text, - const int x, const int y) -{ - BLOCK_START("SDLFont::drawString") - if (text.empty()) - { - BLOCK_END("SDLFont::drawString") - return; - } - - Graphics *const g = dynamic_cast(graphics); - if (!g) - return; - - gcn::Color col = g->getColor(); - const gcn::Color &col2 = g->getColor2(); - const float alpha = static_cast(col.a) / 255.0F; - - /* The alpha value is ignored at string generation so avoid caching the - * same text with different alpha values. - */ - col.a = 255; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->search; - std::map::iterator i - = search.find(SDLTextChunkSmall(text, col, col2)); - if (i != search.end()) - { - SDLTextChunk *const chunk2 = (*i).second; - cache->moveToFirst(chunk2); - Image *const image = chunk2->img; - if (image) - { - image->setAlpha(alpha); - g->drawImage2(image, x, y); - } - } - else - { - if (cache->size >= CACHE_SIZE) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif - cache->removeBack(); - } -#ifdef DEBUG_FONT_COUNTERS - mCreateCounter ++; -#endif - SDLTextChunk *chunk2 = new SDLTextChunk(text, col, col2); - - chunk2->generate(mFont, alpha); - cache->insertFirst(chunk2); - - const Image *const image = chunk2->img; - if (image) - g->drawImage2(image, x, y); - } - BLOCK_END("SDLFont::drawString") -} - -void SDLFont::slowLogic(const int rnd) -{ - BLOCK_START("SDLFont::slowLogic") - if (!mCleanTime) - { - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - else if (mCleanTime < cur_time) - { - doClean(); - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - BLOCK_END("SDLFont::slowLogic") -} - -int SDLFont::getWidth(const std::string &text) const -{ - if (text.empty()) - return 0; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->searchWidth; - std::map::iterator i = search.find(text); - if (i != search.end()) - { - SDLTextChunk *const chunk = (*i).second; - cache->moveToFirst(chunk); - const Image *const image = chunk->img; - if (image) - return image->getWidth(); - else - return 0; - } - - // if string was not drawed - int w, h; - getSafeUtf8String(text, strBuf); - TTF_SizeUTF8(mFont, strBuf, &w, &h); - return w; -} - -int SDLFont::getHeight() const -{ - return TTF_FontHeight(mFont); -} - -void SDLFont::doClean() -{ - for (unsigned int f = 0; f < CACHES_NUMBER; f ++) - { - TextChunkList *const cache = &mCache[f]; - const size_t size = cache->size; -#ifdef DEBUG_FONT_COUNTERS - logger->log("ptr: %d, size: %d", f, size); -#endif - if (size > CACHE_SIZE_SMALL3) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 100; -#endif - cache->removeBack(100); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete3"); -#endif - } - else if (size > CACHE_SIZE_SMALL2) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 20; -#endif - cache->removeBack(20); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete2"); -#endif - } - else if (size > CACHE_SIZE_SMALL1) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif - cache->removeBack(); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete1"); -#endif - } - } -} - -const TextChunkList *SDLFont::getCache() const -{ - return mCache; -} diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h deleted file mode 100644 index 1cb6f5c99..000000000 --- a/src/gui/sdlfont.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * Copyright (C) 2009 Aethyra Development Team - * - * 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 . - */ - -#ifndef GUI_SDLFONT_H -#define GUI_SDLFONT_H - -#include "gui/base/color.hpp" -#include "gui/base/font.hpp" - -#include - -#include -#include - -#include "localconsts.h" - -class Image; - -const unsigned int CACHES_NUMBER = 256; - -class SDLTextChunkSmall -{ - public: - SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); - - SDLTextChunkSmall(const SDLTextChunkSmall &old); - - bool operator==(const SDLTextChunkSmall &chunk) const; - bool operator<(const SDLTextChunkSmall &chunk) const; - - std::string text; - gcn::Color color; - gcn::Color color2; -}; - -class SDLTextChunk final -{ - public: - SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); - - A_DELETE_COPY(SDLTextChunk) - - ~SDLTextChunk(); - - bool operator==(const SDLTextChunk &chunk) const; - - void generate(TTF_Font *const font, const float alpha); - - Image *img; - std::string text; - gcn::Color color; - gcn::Color color2; - SDLTextChunk *prev; - SDLTextChunk *next; -}; - - -class TextChunkList final -{ - public: - TextChunkList(); - - A_DELETE_COPY(TextChunkList) - - void insertFirst(SDLTextChunk *const item); - - void moveToFirst(SDLTextChunk *item); - - void removeBack(); - - void removeBack(int n); - - void clear(); - - SDLTextChunk *start; - SDLTextChunk *end; - uint32_t size; - std::map search; - std::map searchWidth; -}; - -/** - * A wrapper around SDL_ttf for allowing the use of TrueType fonts. - * - * NOTE: This class initializes SDL_ttf as necessary. - */ -class SDLFont final : public gcn::Font -{ - public: - SDLFont(std::string filename, - const int size, - const int style = 0); - - A_DELETE_COPY(SDLFont) - - ~SDLFont(); - - void loadFont(std::string filename, - const int size, - const int style = 0); - - int getWidth(const std::string &text) const override - final A_WARN_UNUSED; - - int getHeight() const override final A_WARN_UNUSED; - - const TextChunkList *getCache() const A_WARN_UNUSED; - - /** - * @see Font::drawString - */ - void drawString(Graphics *const graphics, - const std::string &text, - const int x, const int y) override final; - - void clear(); - - void doClean(); - - void slowLogic(const int rnd); - - int getCreateCounter() const A_WARN_UNUSED - { return mCreateCounter; } - - int getDeleteCounter() const A_WARN_UNUSED - { return mDeleteCounter; } - - static bool mSoftMode; - - private: - static TTF_Font *openFont(const char *const name, const int size); - - TTF_Font *mFont; - unsigned mCreateCounter; - unsigned mDeleteCounter; - - // Word surfaces cache - int mCleanTime; - mutable TextChunkList mCache[CACHES_NUMBER]; -}; - -#ifdef UNITTESTS -extern int sdlTextChunkCnt; -#endif - -#endif // GUI_SDLFONT_H diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index c3da988b7..ee64736eb 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -42,7 +42,7 @@ #include "gui/windows/ministatuswindow.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -341,7 +341,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const gcn::Color &color) const { graphics->setColor(color); - gcn::Font *const font = getFont(); + Font *const font = getFont(); #ifdef MANASERV_SUPPORT if (Net::getNetworkType() != ServerInfo::MANASERV) diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 8e4d9e483..298ab657a 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -28,16 +28,14 @@ #include "being/localplayer.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/chatwindow.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" int AvatarListBox::instances = 0; @@ -103,7 +101,7 @@ void AvatarListBox::draw(Graphics *graphics) mListModel); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); const gcn::Widget *const parent = mParent; const std::string name = player_node->getName(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index c158171c0..60b67dc24 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -25,8 +25,8 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/widgets/linkhandler.h" @@ -37,7 +37,6 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/base/font.hpp" #include "gui/base/cliprectangle.hpp" #include "render/graphics.h" @@ -175,7 +174,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) std::string tmp = row; std::string newRow; size_t idx1; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); int linksCount = 0; if (getWidth() < 0) @@ -491,7 +490,7 @@ void BrowserBox::draw(Graphics *graphics) } } - gcn::Font *const font = getFont(); + Font *const font = getFont(); FOR_EACH (LinePartCIter, i, mLineParts) { @@ -530,7 +529,7 @@ int BrowserBox::calcHeight() if (maxWidth < 0) return 1; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int fontHeight = font->getHeight() + 2 * mItemPadding; const int fontWidthMinus = font->getWidth("-"); const char *const hyphen = "~"; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 8bc3d7540..5d27af68a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -31,7 +31,7 @@ #include "resources/imageset.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -426,7 +426,7 @@ void Button::draw(Graphics *graphics) const gcn::Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; - gcn::Font *const font = getFont(); + Font *const font = getFont(); int textY = height / 2 - font->getHeight() / 2; if (mImages) imageY = height / 2 - mImageHeight / 2; @@ -559,7 +559,7 @@ void Button::widgetMoved(const Event &event A_UNUSED) void Button::adjustSize() { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const Skin *const skin = button[BUTTON_STANDARD]; if (!skin) return; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 9b67b0359..0772c0d4f 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -100,7 +100,7 @@ void CheckBox::draw(Graphics *const graphics) BLOCK_START("CheckBox::draw") drawBox(graphics); - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index a9cf4f71e..6803fbe3c 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -22,7 +22,7 @@ #include "gui/widgets/colormodel.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -33,7 +33,7 @@ ColorPage::ColorPage(const Widget2 *const widget, { mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1; mRowHeight = 13; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) mRowHeight = font->getHeight() + 2 * mItemPadding; if (mListModel) @@ -57,7 +57,7 @@ void ColorPage::draw(Graphics *graphics) mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int rowHeight = getRowHeight(); const int width = mDimension.width; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 225ea11bb..42fa89b30 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -33,7 +33,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include @@ -235,7 +235,7 @@ void DropDown::draw(Graphics* graphics) gcn::ListModel *const model = mPopup->getListModel(); if (model && mPopup->getSelected() >= 0) { - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); if (mExtended) { diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 693245c2f..bca1f1e12 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -36,7 +36,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -116,7 +116,7 @@ void DropShortcutContainer::draw(Graphics *graphics) return; } - gcn::Font *const font = getFont(); + Font *const font = getFont(); for (unsigned i = 0; i < mMaxItems; i++) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 38c76060b..f5d1c19f0 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -27,14 +27,13 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int MAX_ITEMS = 48; @@ -112,7 +111,7 @@ void EmoteShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); drawBackground(graphics); graphics->setColorAll(mForegroundColor, mForegroundColor2); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index f06e89e55..1fcbabd2b 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -22,7 +22,8 @@ #include "gui/widgets/extendedlistmodel.h" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/listmodel.hpp" #include "render/graphics.h" @@ -58,7 +59,7 @@ void ExtendedListBox::draw(Graphics *graphics) mListModel); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int height = mRowHeight; const int pad2 = 2 + mPadding; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 4608534b1..b0f887fa2 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -46,7 +46,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "listeners/selectionlistener.h" #include @@ -251,7 +251,7 @@ void ItemContainer::draw(Graphics *graphics) return; BLOCK_START("ItemContainer::draw") - gcn::Font *const font = getFont(); + Font *const font = getFont(); for (int j = 0; j < mGridRows; j++) { diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 984803a99..2496beaa6 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -33,6 +33,7 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -45,8 +46,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" ItemShortcutContainer::ItemShortcutContainer(const unsigned number) : @@ -129,7 +128,7 @@ void ItemShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index b2b709052..6cc94cc3d 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/label.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -82,7 +82,7 @@ void Label::draw(Graphics* graphics) int textX; const gcn::Rectangle &rect = mDimension; const int textY = rect.height / 2 - getFont()->getHeight() / 2; - gcn::Font *const font = getFont(); + Font *const font = getFont(); switch (mAlignment) { @@ -108,7 +108,7 @@ void Label::draw(Graphics* graphics) void Label::adjustSize() { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int pad2 = 2 * mPadding; setWidth(font->getWidth(mCaption) + pad2); setHeight(font->getHeight() + pad2); @@ -129,7 +129,7 @@ void Label::setForegroundColorAll(const gcn::Color &color1, void Label::resizeTo(const int maxSize, const int minSize) { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int pad2 = 2 * mPadding; setHeight(font->getHeight() + pad2); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 52ff775be..537c7283c 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -28,10 +28,10 @@ #include "input/keydata.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/base/focushandler.hpp" -#include "gui/base/font.hpp" #include "gui/base/listmodel.hpp" #include "render/graphics.h" @@ -70,7 +70,7 @@ ListBox::ListBox(const Widget2 *const widget, mItemPadding = mSkin->getOption("itemPadding"); } - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) mRowHeight = font->getHeight() + 2 * mItemPadding; else @@ -110,7 +110,7 @@ void ListBox::draw(Graphics *graphics) mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int rowHeight = getRowHeight(); const int width = mDimension.width; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index b120e4289..a1f597da8 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -25,10 +25,8 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" - -#include "gui/base/font.hpp" #include "debug.h" @@ -271,7 +269,7 @@ void ProgressBar::render(Graphics *graphics) { const gcn::Color oldColor = graphics->getColor(); - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); const int textX = mDimension.width / 2; const int textY = (mDimension.height - font->getHeight()) / 2; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 2fec7a9f6..984d84d76 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -161,7 +161,7 @@ void RadioButton::draw(Graphics* graphics) BLOCK_START("RadioButton::draw") drawBox(graphics); - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); @@ -191,7 +191,7 @@ void RadioButton::keyPressed(KeyEvent& keyEvent) void RadioButton::adjustSize() { - gcn::Font *const font = getFont(); + Font *const font = getFont(); setHeight(font->getHeight() + 2 * mPadding); setWidth(mImagePadding + mImageSize + mSpacing + font->getWidth(mCaption) + mPadding); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 8b6cca5a7..aeeb8e4bc 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -24,7 +24,7 @@ #include "main.h" #include "soundmanager.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/editdialog.h" @@ -41,8 +41,6 @@ #include "utils/gettext.h" #include "utils/mathutils.h" -#include "gui/base/font.hpp" - #include "debug.h" SetupItem::SetupItem(const std::string &restrict text, @@ -918,7 +916,7 @@ int SetupItemSlider2::getMaxWidth() int maxWidth = 0; SetupItemNamesConstIter it = mValues->begin(); const SetupItemNamesConstIter it_end = mValues->end(); - const gcn::Font *const font = gui->getFont(); + const Font *const font = gui->getFont(); while (it != it_end) { diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index f364aaf46..85ff90261 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -27,6 +27,7 @@ #include "being/playerinfo.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -35,7 +36,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" #include "gui/base/listmodel.hpp" #include "debug.h" @@ -95,7 +95,7 @@ void ShopListBox::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); const int alpha = static_cast(mAlpha * 255.0F); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int sz = mListModel->getNumberOfElements(); const int fontHeigh = getFont()->getHeight(); diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 988db85dd..93a6934ba 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -20,13 +20,12 @@ #include "gui/widgets/sliderlist.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int buttonWidth = 27; @@ -209,7 +208,7 @@ int SliderList::getMaxLabelWidth() const return 1; int maxWidth = 0; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int num = mListModel->getNumberOfElements(); for (int f = 0; f < num; f ++) diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 511360b91..e8d34c9d8 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -27,6 +27,7 @@ #include "itemshortcut.h" #include "spellshortcut.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/spellpopup.h" @@ -36,8 +37,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : @@ -103,7 +102,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int selectedId = spellShortcut->getSelectedItem(); graphics->setColorAll(mForegroundColor, mForegroundColor2); diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 1a2bdfeae..d29c56c85 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/tabs/setup_colors.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/userpalette.h" #include "gui/widgets/browserbox.h" @@ -101,7 +101,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : // TRANSLATORS: color type std::string longText = _("Static"); - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText)) { // TRANSLATORS: color type diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index ba02eb5a2..22bea9a75 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -125,7 +125,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) : mKeyListModel->setSize(mActionDataSize[0]); refreshKeys(); if (gui) - mKeyList->setFont(reinterpret_cast(gui->getHelpFont())); + mKeyList->setFont(gui->getHelpFont()); mKeyList->addActionListener(this); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index a85b7927b..a097d28e2 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -264,7 +264,7 @@ void Tab::widgetMoved(const Event &event A_UNUSED) mRedraw = true; } -void Tab::setLabelFont(gcn::Font *const font) +void Tab::setLabelFont(Font *const font) { if (!mLabel) return; diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index d22c6bea5..655fba7ea 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -134,7 +134,7 @@ class Tab : public gcn::BasicContainer, void widgetMoved(const Event &event) override final; - void setLabelFont(gcn::Font *const font); + void setLabelFont(Font *const font); Label *getLabel() const A_WARN_UNUSED { return mLabel; } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index ecdc0e4d0..5f74fa1f8 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -26,7 +26,7 @@ #include "input/keydata.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include @@ -88,7 +88,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) text.substr(lastNewlinePos, newlinePos - lastNewlinePos); size_t lastSpacePos = 0; xpos = 0; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int spaceWidth = font->getWidth(" "); size_t sz = line.size(); @@ -360,7 +360,7 @@ void TextBox::draw(Graphics* graphics) graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); if (isFocused() && isEditable()) { drawCaret(graphics, font->getWidth( diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 0d01df51d..4dd2f1c7b 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -28,8 +28,8 @@ #include "events/keyevent.h" +#include "gui/font.h" #include "gui/sdlinput.h" - #include "gui/viewport.h" #include "gui/popups/popupmenu.h" @@ -39,8 +39,6 @@ #include "utils/copynpaste.h" #include "utils/timer.h" -#include "gui/base/font.hpp" - #undef DELETE // Win32 compatibility hack #include "debug.h" @@ -142,7 +140,7 @@ void TextField::draw(Graphics *graphics) BLOCK_START("TextField::draw") updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); if (isFocused()) { drawCaret(graphics, diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 5ef553b3c..2caf2e44c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -24,8 +24,8 @@ #include "client.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "debug.h" @@ -100,12 +100,11 @@ void TextPreview::draw(Graphics* graphics) if (mTextBGColor) { - const SDLFont *const font = dynamic_cast(mFont); - if (font) + if (mFont) { - const int x = font->getWidth(mText) + 1 + const int x = mFont->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); - const int y = font->getHeight() + 1 + const int y = mFont->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index f529e470c..cb524a974 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -78,7 +78,7 @@ class TextPreview final : public gcn::Widget, * * @param font the font to use. */ - inline void setFont(gcn::Font *const font) + inline void setFont(Font *const font) { mFont = font; } /** @@ -123,7 +123,7 @@ class TextPreview final : public gcn::Widget, void adjustSize(); private: - gcn::Font *mFont; + Font *mFont; std::string mText; const gcn::Color *mTextColor; const gcn::Color *mTextColor2; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c250e79a1..e2f24a0f2 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -29,6 +29,7 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -38,7 +39,6 @@ #include "resources/image.h" #include "gui/base/focushandler.hpp" -#include "gui/base/font.hpp" #include "debug.h" @@ -110,7 +110,7 @@ Window::Window(const std::string &caption, const bool modal, { setPadding(mSkin->getPadding()); if (getOptionBool("titlebarBold")) - mCaptionFont = reinterpret_cast(boldFont); + mCaptionFont = boldFont; mTitlePadding = mSkin->getTitlePadding(); mGripPadding = getOption("resizePadding"); mCaptionOffsetX = getOption("captionoffsetx"); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index a5b6be83c..c6b2ca2cb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -412,7 +412,7 @@ class Window : public gcn::Window, bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; - void setCaptionFont(gcn::Font *font) + void setCaptionFont(Font *font) { mCaptionFont = font; } void enableVisibleSound(bool b) @@ -506,7 +506,7 @@ class Window : public gcn::Window, int mGripPadding; int mResizeHandles; int mOldResizeHandles; - gcn::Font *mCaptionFont; + Font *mCaptionFont; bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseWindowButton; /**< Window has a close button */ diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index cbff544fc..e49c78803 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -39,7 +39,7 @@ #include "input/inputmanager.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/sdlinput.h" #include "gui/viewport.h" diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 499538388..6eb21622d 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -29,7 +29,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 9b3ba857c..58e6d9c24 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/setupwindow.h" diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 5caf30df1..6f2bb3b3d 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -32,6 +32,7 @@ #include "being/localplayer.h" #include "being/playerinfo.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -46,8 +47,6 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int BOX_COUNT = 13; @@ -163,7 +162,7 @@ void EquipmentWindow::draw(Graphics *graphics) Window::draw(graphics); int i = 0; - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int fontHeight = font->getHeight(); if (isBatchDrawRenders(openGLMode)) diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 95bea6e00..0b31a410b 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/didyouknowwindow.h" #include "gui/windows/setupwindow.h" diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 3eb10e0e8..c95c2c54e 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -32,6 +32,7 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" @@ -43,7 +44,6 @@ #include "gui/windows/shopwindow.h" #include "gui/windows/tradewindow.h" - #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/itemcontainer.h" @@ -58,8 +58,6 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include #include "debug.h" diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index a883406e7..d1823d5cf 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -32,8 +32,8 @@ #include "being/being.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/inventorywindow.h" @@ -59,8 +59,6 @@ #include "utils/copynpaste.h" #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" // TRANSLATORS: npc dialog button @@ -170,7 +168,7 @@ NpcDialog::NpcDialog(const int npcId) : mTextField->setVisible(true); mIntField->setVisible(true); - const gcn::Font *const fnt = mButton->getFont(); + const Font *const fnt = mButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_WAITING), fnt->getWidth(CAPTION_NEXT)); width = std::max(width, fnt->getWidth(CAPTION_CLOSE)); diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index b9f26da20..3d734b7ad 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 681949145..2e8c5dcc8 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -26,7 +26,7 @@ #include "being/localplayer.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index ce5c3c815..fb2f5258b 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -31,7 +31,7 @@ #include "input/keydata.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/editserverdialog.h" #include "gui/windows/logindialog.h" @@ -45,8 +45,6 @@ #include "utils/gettext.h" #include "utils/langs.h" -#include "gui/base/font.hpp" - #include #include "debug.h" @@ -182,8 +180,8 @@ public: height)); } - gcn::Font *const font1 = boldFont; - gcn::Font *const font2 = getFont(); + Font *const font1 = boldFont; + Font *const font2 = getFont(); const int fontHeight = font1->getHeight(); const int pad1 = fontHeight + mPadding; const int pad2 = height / 4 + mPadding; @@ -644,7 +642,7 @@ void ServerDialog::loadServers(const bool addNew) version = strprintf(_("requires v%s"), version.c_str()); } - const gcn::Font *const font = gui->getFont(); + const Font *const font = gui->getFont(); for_each_xml_child_node(subNode, serverNode) { diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 8ec8486e3..413f73226 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -29,6 +29,7 @@ #include "being/localplayer.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" @@ -53,8 +54,6 @@ #include "resources/beingcommon.h" -#include "gui/base/font.hpp" - #include "debug.h" class SkillListBox final : public ListBox @@ -121,7 +120,7 @@ class SkillListBox final : public ListBox // Draw the list elements graphics->setColorAll(mTextColor, mTextColor2); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int space = font->getHeight() + mSpacing; const int width2 = getWidth() - mPadding; for (int i = 0, y = 1; diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index c4ff71eb7..9b7bb3eb1 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -68,7 +68,7 @@ TextDialog::TextDialog(const std::string &restrict title, place(2, 2, mOkButton); place(3, 2, cancelButton); - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) { int width = font->getWidth(title); diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 1793fc2fb..d94b78c34 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -31,7 +31,7 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/inventorywindow.h" #include "gui/windows/itemamountwindow.h" @@ -51,8 +51,6 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" // TRANSLATORS: trade window button @@ -102,7 +100,7 @@ TradeWindow::TradeWindow(): if (setupWindow) setupWindow->registerWindowForReset(this); - const gcn::Font *const fnt = mOkButton->getFont(); + const Font *const fnt = mOkButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_PROPOSE), fnt->getWidth(CAPTION_CONFIRMED)); width = std::max(width, fnt->getWidth(CAPTION_ACCEPT)); diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 3da8ba7d9..86a431cdf 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -35,8 +35,8 @@ #include "resources/resourcemanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "utils/dtor.h" @@ -823,7 +823,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y, } if (!mName.empty() && mType != PORTAL && mType != EMPTY) { - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); if (font) { graphics->setColor(userPalette->getColor(UserPalette::BEING)); diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index a9cc9993f..83ec97521 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -415,7 +415,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, Particle *Particle::addTextSplashEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline) { Particle *const newParticle = new TextParticle(text, color, font, outline); @@ -439,7 +439,7 @@ Particle *Particle::addTextSplashEffect(const std::string &text, Particle *Particle::addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline) { Particle *const newParticle = new TextParticle(text, color, font, outline); diff --git a/src/particle/particle.h b/src/particle/particle.h index f75803772..f69770513 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -36,9 +36,10 @@ class ParticleEmitter; namespace gcn { class Color; - class Font; } +class Font; + typedef std::list Particles; typedef Particles::iterator ParticleIterator; typedef Particles::const_iterator ParticleConstIterator; @@ -136,7 +137,7 @@ class Particle : public Actor Particle *addTextSplashEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline = false); /** @@ -145,7 +146,7 @@ class Particle : public Actor Particle *addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline = false); /** diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index bf72baf25..1ac6ac6c2 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -27,13 +27,13 @@ #include "gui/theme.h" #include "gui/base/color.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" TextParticle::TextParticle(const std::string &text, const gcn::Color *const color, - gcn::Font *const font, const bool outline) : + Font *const font, const bool outline) : Particle(), mText(text), mTextFont(font), diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h index eb8a160e1..0d598508d 100644 --- a/src/particle/textparticle.h +++ b/src/particle/textparticle.h @@ -33,7 +33,7 @@ class TextParticle final : public Particle */ TextParticle(const std::string &text, const gcn::Color *const color, - gcn::Font *const font, const bool outline = false); + Font *const font, const bool outline = false); A_DELETE_COPY(TextParticle) @@ -53,7 +53,7 @@ class TextParticle final : public Particle private: std::string mText; /**< Text of the particle. */ - gcn::Font *mTextFont; /**< Font used for drawing the text. */ + Font *mTextFont; /**< Font used for drawing the text. */ const gcn::Color *mColor; /**< Color used for drawing the text. */ int mTextWidth; bool mOutline; /**< Make the text better readable */ diff --git a/src/text.cpp b/src/text.cpp index 943d31f67..dfc127598 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -26,14 +26,12 @@ #include "configuration.h" #include "textmanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/theme.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" int Text::mInstances = 0; @@ -42,7 +40,7 @@ ImageRect Text::mBubble; Text::Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const gcn::Color *const color, const bool isSpeech, - gcn::Font *const font) : + Font *const font) : mFont(font ? font : (gui ? gui->getFont() : nullptr)), mX(x), mY(y), @@ -154,7 +152,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) FlashText::FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, gcn::Font *const font) : + const gcn::Color *const color, Font *const font) : Text(text, x, y, alignment, color, false, font), mTime(0) { diff --git a/src/text.h b/src/text.h index b21ca51a7..cade9db18 100644 --- a/src/text.h +++ b/src/text.h @@ -30,10 +30,7 @@ #include "localconsts.h" -namespace gcn -{ - class Font; -} +class Font; class Text { @@ -46,7 +43,7 @@ class Text Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const gcn::Color *const color, const bool isSpeech = false, - gcn::Font *const font = nullptr); + Font *const font = nullptr); A_DELETE_COPY(Text) @@ -75,7 +72,7 @@ class Text const int xOff, const int yOff); private: - gcn::Font *mFont; /**< The font of the text */ + Font *mFont; /**< The font of the text */ int mX; /**< Actual x-value of left of text written. */ int mY; /**< Actual y-value of top of text written. */ int mWidth; /**< The width of the text. */ @@ -97,7 +94,7 @@ class FlashText final : public Text FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const gcn::Color *const color, - gcn::Font *const font = nullptr); + Font *const font = nullptr); A_DELETE_COPY(FlashText) diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index b7b926383..8c4c8b0db 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -25,8 +25,8 @@ #include "mouseinput.h" #include "touchactions.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "input/inputmanager.h" @@ -239,7 +239,7 @@ void TouchManager::draw() if (!gui) return; - SDLFont *const font = boldFont; + Font *const font = boldFont; mainGraphics->setColorAll(Theme::getThemeColor(Theme::TEXT), Theme::getThemeColor(Theme::TEXT_OUTLINE)); FOR_EACH (TouchItemVectorCIter, it, mObjects) -- cgit v1.2.3-70-g09d2 From e78036b3372e5773fac4207ea48bb61e2fd7873e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 00:09:12 +0300 Subject: combine mouseinput into one file. --- src/CMakeLists.txt | 5 +- src/Makefile.am | 5 +- src/gui/base/basiccontainer.cpp | 2 +- src/gui/base/gui.cpp | 2 +- src/gui/base/gui.hpp | 2 +- src/gui/base/input.hpp | 3 +- src/gui/base/mouseinput.cpp | 136 ------------------ src/gui/base/mouseinput.hpp | 260 ----------------------------------- src/gui/base/widget.cpp | 2 +- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/checkbox.cpp | 3 +- src/gui/base/widgets/listbox.cpp | 3 +- src/gui/base/widgets/radiobutton.cpp | 3 +- src/gui/base/widgets/slider.cpp | 3 +- src/gui/base/widgets/textbox.cpp | 3 +- src/gui/base/widgets/textfield.cpp | 3 +- src/gui/base/widgets/window.cpp | 2 +- src/gui/gui.cpp | 19 ++- src/gui/gui.h | 6 +- src/gui/sdlinput.cpp | 34 ++--- src/gui/sdlinput.h | 8 +- src/gui/widgets/itemlinkhandler.cpp | 11 +- src/input/mouseinput.h | 216 +++++++++++++++++++++++++++++ src/input/multitouchmanager.cpp | 2 +- src/mouseinput.cpp | 34 ----- src/mouseinput.h | 63 --------- src/touchactions.cpp | 4 +- src/touchmanager.cpp | 7 +- 29 files changed, 285 insertions(+), 561 deletions(-) delete mode 100644 src/gui/base/mouseinput.cpp delete mode 100644 src/gui/base/mouseinput.hpp create mode 100644 src/input/mouseinput.h delete mode 100644 src/mouseinput.cpp delete mode 100644 src/mouseinput.h (limited to 'src/gui/gui.h') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cc4c3dbc..b523f084c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -685,8 +685,7 @@ SET(SRCS render/mgl.h render/mobileopenglgraphics.cpp render/mobileopenglgraphics.h - mouseinput.cpp - mouseinput.h + input/mouseinput.h mumblemanager.cpp mumblemanager.h navigationmanager.cpp @@ -781,7 +780,6 @@ SET(SRCS listeners/keylistener.h gui/base/listmodel.hpp events/mouseevent.h - gui/base/mouseinput.hpp listeners/mouselistener.h gui/base/rectangle.hpp events/selectionevent.h @@ -806,7 +804,6 @@ SET(SRCS gui/base/focushandler.cpp gui/base/gui.cpp gui/base/key.cpp - gui/base/mouseinput.cpp gui/base/rectangle.cpp gui/base/widget.cpp gui/base/widgets/button.cpp diff --git a/src/Makefile.am b/src/Makefile.am index aa5314c52..19f8fe4f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -168,7 +168,6 @@ manaplus_SOURCES += events/actionevent.h \ listeners/keylistener.h \ gui/base/listmodel.hpp \ events/mouseevent.h \ - gui/base/mouseinput.hpp \ listeners/mouselistener.h \ gui/base/rectangle.hpp \ events/selectionevent.h \ @@ -193,7 +192,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/focushandler.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ - gui/base/mouseinput.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ gui/base/widgets/button.cpp \ @@ -792,8 +790,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ render/mgl.h \ render/mobileopenglgraphics.cpp \ render/mobileopenglgraphics.h \ - mouseinput.cpp \ - mouseinput.h \ + input/mouseinput.h \ navigationmanager.cpp \ navigationmanager.h \ render/normalopenglgraphics.cpp \ diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 4a745dc63..82ef1c025 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -70,7 +70,7 @@ #include #include "gui/base/focushandler.hpp" -#include "gui/base/mouseinput.hpp" +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index 56e40291a..e5291cb60 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -70,10 +70,10 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/input.hpp" -#include "gui/base/mouseinput.hpp" #include "gui/base/widget.hpp" #include "input/keyinput.h" +#include "input/mouseinput.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index b853a4210..2ec5d7082 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -70,7 +70,7 @@ #include "events/keyevent.h" #include "events/mouseevent.h" -#include "gui/base/mouseinput.hpp" +#include "input/mouseinput.h" class Graphics; class KeyListener; diff --git a/src/gui/base/input.hpp b/src/gui/base/input.hpp index 40aed4d84..1643482d3 100644 --- a/src/gui/base/input.hpp +++ b/src/gui/base/input.hpp @@ -67,11 +67,10 @@ #include "localconsts.h" class KeyInput; +class MouseInput; namespace gcn { - class MouseInput; - /** * Abstract class for providing functions for user input. * diff --git a/src/gui/base/mouseinput.cpp b/src/gui/base/mouseinput.cpp deleted file mode 100644 index bc5d6c8e0..000000000 --- a/src/gui/base/mouseinput.cpp +++ /dev/null @@ -1,136 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - MouseInput::MouseInput(const unsigned int button, - const unsigned int type, - const int x, - const int y, - const int timeStamp) : - mType(type), - mButton(button), - mTimeStamp(timeStamp), - mX(x), - mY(y) - { - } - - void MouseInput::setType(unsigned int type) - { - mType = type; - } - - unsigned int MouseInput::getType() const - { - return mType; - } - - void MouseInput::setButton(unsigned int button) - { - mButton = button; - } - - unsigned int MouseInput::getButton() const - { - return mButton; - } - - int MouseInput::getTimeStamp() const - { - return mTimeStamp; - } - - void MouseInput::setTimeStamp(int timeStamp) - { - mTimeStamp = timeStamp; - } - - void MouseInput::setX(int x) - { - mX = x; - } - - int MouseInput::getX() const - { - return mX; - } - - void MouseInput::setY(int y) - { - mY = y; - } - - int MouseInput::getY() const - { - return mY; - } -} // namespace gcn diff --git a/src/gui/base/mouseinput.hpp b/src/gui/base/mouseinput.hpp deleted file mode 100644 index 018205740..000000000 --- a/src/gui/base/mouseinput.hpp +++ /dev/null @@ -1,260 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_MOUSEINPUT_HPP -#define GCN_MOUSEINPUT_HPP - -#include "localconsts.h" - -namespace gcn -{ - - /** - * Internal class that represents mouse input. Generally you won't have to - * bother using this class unless you implement an Input class for - * a back end. - * - * @author Olof Naessén - * @author Per Larsson - * @since 0.1.0 - */ - class MouseInput - { - public: - /** - * Constructor. - */ - MouseInput() : - mType(0), - mButton(0), - mTimeStamp(0), - mX(0), - mY(0) - { } - - /** - * Constructor. - * - * @param button The button pressed. - * @param type The type of mouse input. - * @param x The mouse x coordinate. - * @param y The mouse y coordinate. - * @param timeStamp The timestamp of the mouse input. Used to - * check for double clicks. - */ - MouseInput(const unsigned int button, - const unsigned int type, - const int x, - const int y, - const int timeStamp); - - /** - * Sets the type of the mouse input. - * - * @param type The type of the mouse input. Should be a value from the - * mouse event type enum - * @see getType - * @since 0.1.0 - */ - void setType(unsigned int type); - - /** - * Gets the type of the mouse input. - * - * @return The type of the mouse input. A value from the mouse event - * type enum. - * @see setType - * @since 0.1.0 - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Sets the button pressed. - * - * @param button The button pressed. Should be one of the values - * in the mouse event button enum. - * @see getButton. - * @since 0.1.0 - */ - void setButton(unsigned int button); - - /** - * Gets the button pressed. - * - * @return The button pressed. A value from the mouse event - * button enum. - * @see setButton - * @since 0.1.0 - */ - unsigned int getButton() const A_WARN_UNUSED; - - /** - * Sets the timestamp for the mouse input. - * Used to check for double clicks. - * - * @param timeStamp The timestamp of the mouse input. - * @see getTimeStamp - * @since 0.1.0 - */ - void setTimeStamp(int timeStamp); - - /** - * Gets the time stamp of the input. - * Used to check for double clicks. - * - * @return The time stamp of the mouse input. - * @see setTimeStamp - * @since 0.1.0 - */ - int getTimeStamp() const A_WARN_UNUSED; - - /** - * Sets the x coordinate of the mouse input. - * - * @param x The x coordinate of the mouse input. - * @see getX - * @since 0.6.0 - */ - void setX(int x); - - /** - * Gets the x coordinate of the mouse input. - * - * @return The x coordinate of the mouse input. - * @see setX - * @since 0.6.0 - */ - int getX() const A_WARN_UNUSED; - - /** - * Sets the y coordinate of the mouse input. - * - * @param y The y coordinate of the mouse input. - * @see getY - * @since 0.6.0 - */ - void setY(int y); - - /** - * Gets the y coordinate of the mouse input. - * - * @return The y coordinate of the mouse input. - * @see setY - * @since 0.6.0 - */ - int getY() const A_WARN_UNUSED; - - /** - * Mouse input event types. This enum partially corresponds - * to the enum with event types in MouseEvent for easy mapping. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP - }; - - /** - * Mouse button types. - */ - enum - { - EMPTY = 0, - LEFT, - RIGHT, - MIDDLE - }; - - protected: - /** - * Holds the type of the mouse input. - */ - unsigned int mType; - - /** - * Holds the button of the mouse input. - */ - unsigned int mButton; - - /** - * Holds the timestamp of the mouse input. Used to - * check for double clicks. - */ - int mTimeStamp; - - /** - * Holds the x coordinate of the mouse input. - */ - int mX; - - /** - * Holds the y coordinate of the mouse input. - */ - int mY; - }; -} // namespace gcn - -#endif // end GCN_MOUSEINPUT_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index cf3605446..5b4ada76e 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -73,9 +73,9 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/mouseinput.hpp" #include "input/keyinput.h" +#include "input/mouseinput.h" #include "listeners/actionlistener.h" #include "listeners/deathlistener.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 4043c959a..f2718697e 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -80,6 +80,7 @@ class Font; class Graphics; class KeyInput; class KeyListener; +class MouseInput; class MouseListener; class WidgetListener; @@ -87,7 +88,6 @@ namespace gcn { class BasicContainer; class FocusHandler; - class MouseInput; /** * Abstract class for widgets of Guichan. It contains basic functions diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 9b7473293..56ba72590 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "events/mouseevent.h" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 0a3171fe8..18f635052 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 6c6472636..f13a96e39 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -72,7 +72,8 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "listeners/selectionlistener.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index f0430c7a2..ff6a39db0 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index 91c054e7d..d61f2766c 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -68,7 +68,8 @@ #include "gui/base/widgets/slider.hpp" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index e994804d8..db5d91b92 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -71,7 +71,8 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 1514d3afb..891e7e86b 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index fbd42aff2..8d33c1dd5 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -69,7 +69,7 @@ #include "gui/font.h" -#include "gui/base/mouseinput.hpp" +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 85aeb15f5..243b3817e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -20,8 +20,6 @@ * along with this program. If not, see . */ -#include "mouseinput.h" - #include "gui/gui.h" #include "gui/focushandler.h" @@ -44,6 +42,7 @@ #include "input/keydata.h" #include "input/keyinput.h" +#include "input/mouseinput.h" #include "resources/cursor.h" #include "resources/image.h" @@ -524,13 +523,13 @@ void Gui::setUseCustomCursor(const bool customCursor) } } -void Gui::handleMouseMoved(const gcn::MouseInput &mouseInput) +void Gui::handleMouseMoved(const MouseInput &mouseInput) { gcn::Gui::handleMouseMoved(mouseInput); mMouseInactivityTimer = 0; } -void Gui::handleMousePressed(const gcn::MouseInput &mouseInput) +void Gui::handleMousePressed(const MouseInput &mouseInput) { const int x = mouseInput.getX(); const int y = mouseInput.getY(); @@ -781,19 +780,19 @@ void Gui::handleMouseInput() #endif switch (mouseInput.getType()) { - case gcn::MouseInput::PRESSED: + case MouseInput::PRESSED: handleMousePressed(mouseInput); break; - case gcn::MouseInput::RELEASED: + case MouseInput::RELEASED: handleMouseReleased(mouseInput); break; - case gcn::MouseInput::MOVED: + case MouseInput::MOVED: handleMouseMoved(mouseInput); break; - case gcn::MouseInput::WHEEL_MOVED_DOWN: + case MouseInput::WHEEL_MOVED_DOWN: handleMouseWheelMovedDown(mouseInput); break; - case gcn::MouseInput::WHEEL_MOVED_UP: + case MouseInput::WHEEL_MOVED_UP: handleMouseWheelMovedUp(mouseInput); break; default: @@ -803,7 +802,7 @@ void Gui::handleMouseInput() BLOCK_END("Gui::handleMouseInput") } -void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput) +void Gui::handleMouseReleased(const MouseInput &mouseInput) { gcn::Widget *sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); diff --git a/src/gui/gui.h b/src/gui/gui.h index 1660fcfbf..b790d4d2c 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -169,11 +169,11 @@ class Gui final : public gcn::Gui static uint32_t getMouseState(int *const x, int *const y); protected: - void handleMouseMoved(const gcn::MouseInput &mouseInput); + void handleMouseMoved(const MouseInput &mouseInput); - void handleMouseReleased(const gcn::MouseInput &mouseInput); + void handleMouseReleased(const MouseInput &mouseInput); - void handleMousePressed(const gcn::MouseInput &mouseInput); + void handleMousePressed(const MouseInput &mouseInput); void handleMouseInput(); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index b61f858e8..21a8d3957 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -119,9 +119,9 @@ bool SDLInput::isMouseQueueEmpty() return mMouseInputQueue.empty(); } -gcn::MouseInput SDLInput::dequeueMouseInput() +MouseInput SDLInput::dequeueMouseInput() { - gcn::MouseInput mouseInput; + MouseInput mouseInput; if (mMouseInputQueue.empty()) return MouseInput(); @@ -189,9 +189,9 @@ void SDLInput::pushInput(const SDL_Event &event) #endif mouseInput.setButton(-1); if (y > 0) - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP); + mouseInput.setType(MouseInput::WHEEL_MOVED_UP); else - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } @@ -227,12 +227,12 @@ void SDLInput::pushInput(const SDL_Event &event) #ifndef USE_SDL2 if (event.button.button == SDL_BUTTON_WHEELDOWN) - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN); else if (event.button.button == SDL_BUTTON_WHEELUP) - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP); + mouseInput.setType(MouseInput::WHEEL_MOVED_UP); else #endif - mouseInput.setType(gcn::MouseInput::PRESSED); + mouseInput.setType(MouseInput::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -254,7 +254,7 @@ void SDLInput::pushInput(const SDL_Event &event) #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); - mouseInput.setType(gcn::MouseInput::RELEASED); + mouseInput.setType(MouseInput::RELEASED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -274,8 +274,8 @@ void SDLInput::pushInput(const SDL_Event &event) event.motion.realy / scale); #endif #endif - mouseInput.setButton(gcn::MouseInput::EMPTY); - mouseInput.setType(gcn::MouseInput::MOVED); + mouseInput.setButton(MouseInput::EMPTY); + mouseInput.setType(MouseInput::MOVED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -295,8 +295,8 @@ void SDLInput::pushInput(const SDL_Event &event) { mouseInput.setX(-1); mouseInput.setY(-1); - mouseInput.setButton(gcn::MouseInput::EMPTY); - mouseInput.setType(gcn::MouseInput::MOVED); + mouseInput.setButton(MouseInput::EMPTY); + mouseInput.setType(MouseInput::MOVED); mMouseInputQueue.push(mouseInput); } } @@ -338,11 +338,11 @@ int SDLInput::convertMouseButton(const int button) switch (button) { case SDL_BUTTON_LEFT: - return gcn::MouseInput::LEFT; + return MouseInput::LEFT; case SDL_BUTTON_RIGHT: - return gcn::MouseInput::RIGHT; + return MouseInput::RIGHT; case SDL_BUTTON_MIDDLE: - return gcn::MouseInput::MIDDLE; + return MouseInput::MIDDLE; default: // We have an unknown mouse type which is ignored. return button; @@ -569,10 +569,10 @@ void SDLInput::simulateMouseClick(const int x, const int y, mouseInput.setY(y); mouseInput.setReal(x, y); mouseInput.setButton(button); - mouseInput.setType(gcn::MouseInput::PRESSED); + mouseInput.setType(MouseInput::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); - mouseInput.setType(gcn::MouseInput::RELEASED); + mouseInput.setType(MouseInput::RELEASED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 73e2896d5..1a19e8790 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -79,13 +79,13 @@ #define GUI_SDLINPUT_H #include "input/keyinput.h" - -#include "mouseinput.h" +#include "input/mouseinput.h" #include #include "gui/base/input.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include @@ -184,7 +184,7 @@ public: bool isMouseQueueEmpty() override final A_WARN_UNUSED; - gcn::MouseInput dequeueMouseInput() override final A_WARN_UNUSED; + MouseInput dequeueMouseInput() override final A_WARN_UNUSED; MouseInput dequeueMouseInput2() A_WARN_UNUSED; diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index deb3b4451..3e9a99a2a 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -35,10 +35,11 @@ #include "resources/db/itemdb.h" -#include - #include "listeners/actionlistener.h" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" + +#include #include "debug.h" @@ -85,7 +86,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) replaceAll(url, " ", ""); listener.url = url; const int button = event->getButton(); - if (button == gcn::MouseInput::LEFT) + if (button == MouseInput::LEFT) { ConfirmDialog *const confirmDlg = new ConfirmDialog( // TRANSLATORS: dialog message @@ -93,7 +94,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) confirmDlg->postInit(); confirmDlg->addActionListener(&listener); } - else if (button == gcn::MouseInput::RIGHT) + else if (button == MouseInput::RIGHT) { if (viewport) viewport->showLinkPopup(url); diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h new file mode 100644 index 000000000..5ece1f77a --- /dev/null +++ b/src/input/mouseinput.h @@ -0,0 +1,216 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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 MOUSEINPUT_H +#define MOUSEINPUT_H + +#include "input/mouseinput.h" + +#include "localconsts.h" + +class MouseInput final +{ + public: + MouseInput() : + mType(0), + mButton(0), + mTimeStamp(0), + mX(0), + mY(0), + mRealX(0), + mRealY(0) + { } + + ~MouseInput() + { } + + /** + * Mouse input event types. This enum partially corresponds + * to the enum with event types in MouseEvent for easy mapping. + */ + enum + { + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP + }; + + /** + * Mouse button types. + */ + enum + { + EMPTY = 0, + LEFT, + RIGHT, + MIDDLE + }; + + void setType(unsigned int type) + { + mType = type; + } + + unsigned int getType() const + { + return mType; + } + + void setButton(unsigned int button) + { + mButton = button; + } + + unsigned int getButton() const + { + return mButton; + } + + int getTimeStamp() const + { + return mTimeStamp; + } + + void setTimeStamp(int timeStamp) + { + mTimeStamp = timeStamp; + } + + void setX(int x) + { + mX = x; + } + + int getX() const + { + return mX; + } + + void setY(int y) + { + mY = y; + } + + int getY() const + { + return mY; + } + + void setReal(const int x, const int y) + { mRealX = x; mRealY = y; } + + int getRealX() const A_WARN_UNUSED + { return mRealX; } + + int getRealY() const A_WARN_UNUSED + { return mRealY; } + +#ifdef ANDROID + int getTouchX() const A_WARN_UNUSED + { return mRealX; } + + int getTouchY() const A_WARN_UNUSED + { return mRealY; } +#else + int getTouchX() const A_WARN_UNUSED + { return mX; } + + int getTouchY() const A_WARN_UNUSED + { return mY; } +#endif + + protected: + /** + * Holds the type of the mouse input. + */ + unsigned int mType; + + /** + * Holds the button of the mouse input. + */ + unsigned int mButton; + + /** + * Holds the timestamp of the mouse input. Used to + * check for double clicks. + */ + int mTimeStamp; + + /** + * Holds the x coordinate of the mouse input. + */ + int mX; + + /** + * Holds the y coordinate of the mouse input. + */ + int mY; + + int mRealX; + + int mRealY; +}; + +#endif // MOUSEINPUT_H diff --git a/src/input/multitouchmanager.cpp b/src/input/multitouchmanager.cpp index 7e6798807..446e40aa1 100644 --- a/src/input/multitouchmanager.cpp +++ b/src/input/multitouchmanager.cpp @@ -82,7 +82,7 @@ void MultiTouchManager::checkDevice(const int touchId, const int w = mainGraphics->mWidth; const int h = mainGraphics->mHeight; guiInput->simulateMouseClick(finger0.x * w, finger0.y * h, - gcn::MouseInput::RIGHT); + MouseInput::RIGHT); } } } diff --git a/src/mouseinput.cpp b/src/mouseinput.cpp deleted file mode 100644 index 208690935..000000000 --- a/src/mouseinput.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-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 . - */ - -#include "mouseinput.h" - -#include "debug.h" - -MouseInput::MouseInput() : - gcn::MouseInput(), - mRealX(0), - mRealY(0) -{ -} - -MouseInput::~MouseInput() -{ -} diff --git a/src/mouseinput.h b/src/mouseinput.h deleted file mode 100644 index 47e04eceb..000000000 --- a/src/mouseinput.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-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 . - */ - -#ifndef MOUSEINPUT_H -#define MOUSEINPUT_H - -#include "gui/base/mouseinput.hpp" - -#include "localconsts.h" - -class MouseInput final : public gcn::MouseInput -{ - public: - MouseInput(); - - ~MouseInput(); - - void setReal(const int x, const int y) - { mRealX = x; mRealY = y; } - - int getRealX() const A_WARN_UNUSED - { return mRealX; } - - int getRealY() const A_WARN_UNUSED - { return mRealY; } - -#ifdef ANDROID - int getTouchX() const A_WARN_UNUSED - { return mRealX; } - - int getTouchY() const A_WARN_UNUSED - { return mRealY; } -#else - int getTouchX() const A_WARN_UNUSED - { return mX; } - - int getTouchY() const A_WARN_UNUSED - { return mY; } -#endif - - protected: - int mRealX; - int mRealY; -}; - -#endif // MOUSEINPUT_H diff --git a/src/touchactions.cpp b/src/touchactions.cpp index a79c14275..d4f7d9f6e 100644 --- a/src/touchactions.cpp +++ b/src/touchactions.cpp @@ -20,10 +20,10 @@ #include "touchactions.h" -#include "mouseinput.h" #include "touchmanager.h" #include "input/inputmanager.h" +#include "input/mouseinput.h" #include "debug.h" @@ -109,7 +109,7 @@ impHandler(padClick) impHandler(padEvents) { - if (mouseInput.getType() == gcn::MouseInput::MOVED) + if (mouseInput.getType() == MouseInput::MOVED) { if (padClicked) moveChar(mouseInput.getX(), mouseInput.getY()); diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 8c4c8b0db..20c56b8d6 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -22,9 +22,10 @@ #include "configuration.h" #include "graphicsvertexes.h" -#include "mouseinput.h" #include "touchactions.h" +#include "input/mouseinput.h" + #include "gui/font.h" #include "gui/gui.h" @@ -278,13 +279,13 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) switch (mouseInput.getType()) { - case gcn::MouseInput::PRESSED: + case MouseInput::PRESSED: if (!item->eventPressed.empty()) executeAction(item->eventPressed); else if (item->funcPressed) item->funcPressed(event); break; - case gcn::MouseInput::RELEASED: + case MouseInput::RELEASED: if (!item->eventReleased.empty()) executeAction(item->eventReleased); else if (item->funcReleased) -- cgit v1.2.3-70-g09d2 From a520c88cabf03973ddf27435eb5a970f9c214d30 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 21:31:57 +0300 Subject: combine focushandler into one file. --- src/CMakeLists.txt | 2 - src/Makefile.am | 6 +- src/gui/base/basiccontainer.cpp | 3 +- src/gui/base/focushandler.cpp | 569 ---------------------------------------- src/gui/base/focushandler.hpp | 417 ----------------------------- src/gui/base/gui.cpp | 2 +- src/gui/base/gui.hpp | 2 +- src/gui/base/widget.cpp | 3 +- src/gui/base/widget.hpp | 2 +- src/gui/focushandler.cpp | 518 +++++++++++++++++++++++++++++++++++- src/gui/focushandler.h | 379 ++++++++++++++++++++++++-- src/gui/gui.h | 2 +- src/gui/widgets/guitable.cpp | 2 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/listbox.cpp | 2 +- src/gui/widgets/window.cpp | 3 +- src/gui/windows/chatwindow.cpp | 3 +- src/input/inputmanager.cpp | 2 +- 18 files changed, 879 insertions(+), 1040 deletions(-) delete mode 100644 src/gui/base/focushandler.cpp delete mode 100644 src/gui/base/focushandler.hpp (limited to 'src/gui/gui.h') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3fca244eb..711d9e47b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -770,7 +770,6 @@ SET(SRCS gui/base/color.hpp listeners/deathlistener.h events/event.h - gui/base/focushandler.hpp listeners/focuslistener.h gui/base/gui.hpp events/inputguievent.h @@ -800,7 +799,6 @@ SET(SRCS gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp gui/base/color.cpp - gui/base/focushandler.cpp gui/base/gui.cpp input/key.cpp gui/base/rectangle.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 1b3710b60..f20376feb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,13 +29,11 @@ dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ gui/base/rectangle.cpp \ - gui/base/widget.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ events/event.h \ - gui/base/rectangle.hpp \ - gui/base/widget.hpp + gui/base/rectangle.hpp dyecmd_SOURCES += dyetool/dyemain.cpp \ animatedsprite.cpp \ @@ -157,7 +155,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/color.hpp \ listeners/deathlistener.h \ events/event.h \ - gui/base/focushandler.hpp \ listeners/focuslistener.h \ render/graphics.h \ gui/base/gui.hpp \ @@ -188,7 +185,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/focushandler.cpp \ gui/base/gui.cpp \ input/key.cpp \ gui/base/rectangle.cpp \ diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 82ef1c025..05d89f172 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -69,7 +69,8 @@ #include -#include "gui/base/focushandler.hpp" +#include "gui/focushandler.h" + #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp deleted file mode 100644 index 3c6978e70..000000000 --- a/src/gui/base/focushandler.cpp +++ /dev/null @@ -1,569 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/focushandler.hpp" - -#include "gui/base/widget.hpp" - -#include "listeners/focuslistener.h" - -#include "debug.h" - -namespace gcn -{ - FocusHandler::FocusHandler() : - mWidgets(), - mFocusedWidget(nullptr), - mModalFocusedWidget(nullptr), - mModalMouseInputFocusedWidget(nullptr), - mDraggedWidget(nullptr), - mLastWidgetWithMouse(nullptr), - mLastWidgetWithModalFocus(nullptr), - mLastWidgetWithModalMouseInputFocus(nullptr), - mLastWidgetPressed(nullptr) - { - } - - void FocusHandler::requestFocus(Widget* widget) - { - if (!widget || widget == mFocusedWidget) - return; - - int toBeFocusedIndex = -1; - for (unsigned int i = 0, sz = static_cast( - mWidgets.size()); i < sz; ++i) - { - if (mWidgets[i] == widget) - { - toBeFocusedIndex = i; - break; - } - } - - if (toBeFocusedIndex < 0) - return; - - Widget *const oldFocused = mFocusedWidget; - - if (oldFocused != widget) - { - mFocusedWidget = mWidgets.at(toBeFocusedIndex); - - if (oldFocused) - { - Event focusEvent(oldFocused); - distributeFocusLostEvent(focusEvent); - } - - Event focusEvent(mWidgets.at(toBeFocusedIndex)); - distributeFocusGainedEvent(focusEvent); - } - } - - void FocusHandler::requestModalFocus(Widget* widget) - { - if (mModalFocusedWidget && mModalFocusedWidget != widget) - return; - - mModalFocusedWidget = widget; - if (mFocusedWidget && !mFocusedWidget->isModalFocused()) - focusNone(); - } - - void FocusHandler::requestModalMouseInputFocus(Widget* widget) - { - if (mModalMouseInputFocusedWidget - && mModalMouseInputFocusedWidget != widget) - { - return; - } - - mModalMouseInputFocusedWidget = widget; - } - - void FocusHandler::releaseModalFocus(Widget* widget) - { - if (mModalFocusedWidget == widget) - mModalFocusedWidget = nullptr; - } - - void FocusHandler::releaseModalMouseInputFocus(Widget* widget) - { - if (mModalMouseInputFocusedWidget == widget) - mModalMouseInputFocusedWidget = nullptr; - } - - Widget* FocusHandler::getFocused() const - { - return mFocusedWidget; - } - - Widget* FocusHandler::getModalFocused() const - { - return mModalFocusedWidget; - } - - Widget* FocusHandler::getModalMouseInputFocused() const - { - return mModalMouseInputFocusedWidget; - } - - void FocusHandler::focusNext() - { - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - ++ focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget >= sz) - focusedWidget = 0; - - if (focusedWidget == focused) - return; - } - while (!mWidgets.at(focusedWidget)->isFocusable()); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::focusPrevious() - { - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - -- focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget <= 0) - focusedWidget = sz - 1; - - if (focusedWidget == focused) - return; - } - while (!mWidgets.at(focusedWidget)->isFocusable()); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - bool FocusHandler::isFocused(const Widget* widget) const - { - return mFocusedWidget == widget; - } - - void FocusHandler::add(Widget* widget) - { - mWidgets.push_back(widget); - } - - void FocusHandler::remove(Widget* widget) - { - if (isFocused(widget)) - mFocusedWidget = nullptr; - - for (WidgetIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++iter) - { - if ((*iter) == widget) - { - mWidgets.erase(iter); - break; - } - } - - if (mDraggedWidget == widget) - { - mDraggedWidget = nullptr; - return; - } - - if (mLastWidgetWithMouse == widget) - { - mLastWidgetWithMouse = nullptr; - return; - } - - if (mLastWidgetWithModalFocus == widget) - { - mLastWidgetWithModalFocus = nullptr; - return; - } - - if (mLastWidgetWithModalMouseInputFocus == widget) - { - mLastWidgetWithModalMouseInputFocus = nullptr; - return; - } - - if (mLastWidgetPressed == widget) - { - mLastWidgetPressed = nullptr; - return; - } - } - - void FocusHandler::focusNone() - { - if (mFocusedWidget) - { - Widget *const focused = mFocusedWidget; - mFocusedWidget = nullptr; - - Event focusEvent(focused); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::tabNext() - { - if (mFocusedWidget) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - bool done = false; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - ++ focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget >= sz) - focusedWidget = 0; - - if (focusedWidget == focused) - return; - - const Widget *const widget = mWidgets.at(focusedWidget); - if (widget->isFocusable() && widget->isTabInEnabled() && - (!mModalFocusedWidget || widget->isModalFocused())) - { - done = true; - } - } - while (!done); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::tabPrevious() - { - if (mFocusedWidget) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - bool done = false; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - -- focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget <= 0) - focusedWidget = sz - 1; - - if (focusedWidget == focused) - return; - - const Widget *const widget = mWidgets.at(focusedWidget); - if (widget->isFocusable() && widget->isTabInEnabled() && - (!mModalFocusedWidget || widget->isModalFocused())) - { - done = true; - } - } - while (!done); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) - { - Widget *const sourceWidget = focusEvent.getSource(); - - std::list focusListeners - = sourceWidget->_getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusLost(focusEvent); - } - } - - void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent) - { - Widget *const sourceWidget = focusEvent.getSource(); - - std::list focusListeners - = sourceWidget->_getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusGained(focusEvent); - } - } - - Widget* FocusHandler::getDraggedWidget() - { - return mDraggedWidget; - } - - void FocusHandler::setDraggedWidget(Widget* draggedWidget) - { - mDraggedWidget = draggedWidget; - } - - Widget* FocusHandler::getLastWidgetWithMouse() - { - return mLastWidgetWithMouse; - } - - void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse) - { - mLastWidgetWithMouse = lastWidgetWithMouse; - } - - Widget* FocusHandler::getLastWidgetWithModalFocus() - { - return mLastWidgetWithModalFocus; - } - - void FocusHandler::setLastWidgetWithModalFocus(Widget* widget) - { - mLastWidgetWithModalFocus = widget; - } - - Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() - { - return mLastWidgetWithModalMouseInputFocus; - } - - void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget) - { - mLastWidgetWithModalMouseInputFocus = widget; - } - - Widget* FocusHandler::getLastWidgetPressed() - { - return mLastWidgetPressed; - } - - void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed) - { - mLastWidgetPressed = lastWidgetPressed; - } -} // namespace gcn diff --git a/src/gui/base/focushandler.hpp b/src/gui/base/focushandler.hpp deleted file mode 100644 index a5c1b14a1..000000000 --- a/src/gui/base/focushandler.hpp +++ /dev/null @@ -1,417 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_FOCUSHANDLER_HPP -#define GCN_FOCUSHANDLER_HPP - -#include - -#include "events/event.h" - -namespace gcn -{ - class Widget; - - /** - * Handles focus for widgets in a Gui. Each Gui has at least one - * focus handler. - * You will probably not use the focus handler directly as Widget - * has functions that automatically uses the active focus handler. - * - * @see Widget::isFocus, Widget::isModalFocused, - * Widget::isModalMouseInputFocused, Widget::requestFocus, - * Widget::requestModalFocus, Widget::requestModalMouseInputFocus, - * Widget::releaseModalFocus, Widget::relaseModalMouseInputFocus, - * Widget::setFocusable, Widget::isFocusable, FocusListener - * - * @since 0.1.0 - */ - class FocusHandler - { - public: - /** - * Constructor. - */ - FocusHandler(); - - A_DELETE_COPY(FocusHandler) - - /** - * Destructor. - */ - virtual ~FocusHandler() - { } - - /** - * Requests focus for a widget. Focus will only be granted to a widget - * if it's focusable and if no other widget has modal focus. - * If a widget receives focus a focus event will be sent to the - * focus listeners of the widget. - * - * @param widget The widget to request focus for. - * @see isFocused, Widget::requestFocus - */ - virtual void requestFocus(Widget* widget); - - /** - * Requests modal focus for a widget. Focus will only be granted - * to a widget if it's focusable and if no other widget has modal - * focus. - * - * @param widget The widget to request modal focus for. - * @throws Exception when another widget already has modal focus. - * @see releaseModalFocus, Widget::requestModalFocus - */ - virtual void requestModalFocus(Widget* widget); - - /** - * Requests modal mouse input focus for a widget. Focus will only - * be granted to a widget if it's focusable and if no other widget - * has modal mouse input focus. - * - * Modal mouse input focus means no other widget then the widget with - * modal mouse input focus will receive mouse input. The widget with - * modal mouse input focus will also receive mouse input no matter what - * the mouse input is or where the mouse input occurs. - * - * @param widget The widget to focus for modal mouse input focus. - * @throws Exception when another widget already has modal mouse input - * focus. - * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus - */ - virtual void requestModalMouseInputFocus(Widget* widget); - - /** - * Releases modal focus if the widget has modal focus. - * If the widget doesn't have modal focus no relase will occur. - * - * @param widget The widget to release modal focus for. - * @see reuqestModalFocus, Widget::releaseModalFocus - */ - virtual void releaseModalFocus(Widget* widget); - - /** - * Releases modal mouse input focus if the widget has modal mouse input - * focus. If the widget doesn't have modal mouse input focus no relase - * will occur. - * - * @param widget the widget to release modal mouse input focus for. - * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus - */ - virtual void releaseModalMouseInputFocus(Widget* widget); - - /** - * Checks if a widget is focused. - * - * @param widget The widget to check. - * @return True if the widget is focused, false otherwise. - * @see Widget::isFocused - */ - virtual bool isFocused(const Widget* widget) const; - - /** - * Gets the widget with focus. - * - * @return The widget with focus. NULL if no widget has focus. - */ - virtual Widget* getFocused() const A_WARN_UNUSED; - - /** - * Gets the widget with modal focus. - * - * @return The widget with modal focus. NULL if no widget has - * modal focus. - */ - virtual Widget* getModalFocused() const A_WARN_UNUSED; - - /** - * Gets the widget with modal mouse input focus. - * - * @return The widget with modal mouse input focus. NULL if - * no widget has modal mouse input focus. - */ - virtual Widget* getModalMouseInputFocused() const A_WARN_UNUSED; - - /** - * Focuses the next widget added to a conainer. - * If no widget has focus the first widget gets focus. The order - * in which the widgets are focused is determined by the order - * they were added to a container. - * - * @see focusPrevious - */ - virtual void focusNext(); - - /** - * Focuses the previous widget added to a contaienr. - * If no widget has focus the first widget gets focus. The order - * in which the widgets are focused is determined by the order - * they were added to a container. - * - * @see focusNext - */ - virtual void focusPrevious(); - - /** - * Adds a widget to by handles by the focus handler. - * - * @param widget The widget to add. - * @see remove - */ - virtual void add(Widget* widget); - - /** - * Removes a widget from the focus handler. - * - * @param widget The widget to remove. - * @see add - */ - virtual void remove(Widget* widget); - - /** - * Focuses nothing. A focus event will also be sent to the - * focused widget's focus listeners if a widget has focus. - */ - virtual void focusNone(); - - /** - * Focuses the next widget which allows tabbing in unless - * the current focused Widget disallows tabbing out. - * - * @see tabPrevious - */ - virtual void tabNext(); - - /** - * Focuses the previous widget which allows tabbing in unless - * current focused widget disallows tabbing out. - * - * @see tabNext - */ - virtual void tabPrevious(); - - /** - * Gets the widget being dragged. Used by the Gui class to - * keep track of the dragged widget. - * - * @return the widget being dragged. - * @see setDraggedWidget - */ - virtual Widget* getDraggedWidget() A_WARN_UNUSED; - - /** - * Sets the widget being dragged. Used by the Gui class to - * keep track of the dragged widget. - * - * @param draggedWidget The widget being dragged. - * @see getDraggedWidget - */ - virtual void setDraggedWidget(Widget* draggedWidget); - - /** - * Gets the last widget with the mouse. Used by the Gui class - * to keep track the last widget with the mouse. - * - * @return The last widget with the mouse. - * @see setLastWidgetWithMouse - */ - virtual Widget* getLastWidgetWithMouse() A_WARN_UNUSED; - - /** - * Sets the last widget with the mouse. Used by the Gui class - * to keep track the last widget with the mouse. - * - * @param lastWidgetWithMouse The last widget with the mouse. - * @see getLastWidgetWithMouse - */ - virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); - - /** - * Gets the last widget with modal focus. - * - * @return The last widget with modal focus. - * @see setLastWidgetWithModalFocus - */ - virtual Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; - - /** - * Sets the last widget with modal focus. - * - * @param widget The last widget with modal focus. - * @see getLastWidgetWithModalFocus - */ - virtual void setLastWidgetWithModalFocus(Widget* widget); - - /** - * Gets the last widget with modal mouse input focus. - * - * @return The last widget with modal mouse input focus. - * @see setLastWidgetWithModalMouseInputFocus - */ - virtual Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; - - /** - * Sets the last widget with modal mouse input focus. - * - * @param widget The last widget with modal mouse input focus. - * @see getLastWidgetWithModalMouseInputFocus - */ - virtual void setLastWidgetWithModalMouseInputFocus(Widget* widget); - - /** - * Gets the last widget pressed. Used by the Gui class to keep track - * of pressed widgets. - * - * @return The last widget pressed. - * @see setLastWidgetPressed - */ - virtual Widget* getLastWidgetPressed() A_WARN_UNUSED; - - /** - * Sets the last widget pressed. Used by the Gui class to keep track - * of pressed widgets. - * - * @param lastWidgetPressed The last widget pressed. - * @see getLastWidgetPressed - */ - virtual void setLastWidgetPressed(Widget* lastWidgetPressed); - - protected: - /** - * Distributes a focus lost event. - * - * @param focusEvent the event to distribute. - * @since 0.7.0 - */ - virtual void distributeFocusLostEvent(const Event& focusEvent); - - /** - * Distributes a focus gained event. - * - * @param focusEvent the event to distribute. - * @since 0.7.0 - */ - virtual void distributeFocusGainedEvent(const Event& focusEvent); - - /** - * Typedef. - */ - typedef std::vector WidgetVector; - - /** - * Typedef. - */ - typedef WidgetVector::iterator WidgetIterator; - - /** - * Holds the widgets currently being handled by the - * focus handler. - */ - WidgetVector mWidgets; - - /** - * Holds the focused widget. NULL if no widget has focus. - */ - Widget* mFocusedWidget; - - /** - * Holds the modal focused widget. NULL if no widget has - * modal focused. - */ - Widget* mModalFocusedWidget; - - /** - * Holds the modal mouse input focused widget. NULL if no widget - * is being dragged. - */ - Widget* mModalMouseInputFocusedWidget; - - /** - * Holds the dragged widget. NULL if no widget is - * being dragged. - */ - Widget* mDraggedWidget; - - /** - * Holds the last widget with the mouse. - */ - Widget* mLastWidgetWithMouse; - - /** - * Holds the last widget with modal focus. - */ - Widget* mLastWidgetWithModalFocus; - - /** - * Holds the last widget with modal mouse input focus. - */ - Widget* mLastWidgetWithModalMouseInputFocus; - - /** - * Holds the last widget pressed. - */ - Widget* mLastWidgetPressed; - }; -} // namespace gcn - -#endif // end GCN_FOCUSHANDLER_HPP diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index 02c6e6674..f62e24260 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -68,9 +68,9 @@ #include "gui/base/gui.hpp" #include "gui/base/basiccontainer.hpp" -#include "gui/base/focushandler.hpp" #include "gui/base/widget.hpp" +#include "gui/focushandler.h" #include "gui/sdlinput.h" #include "input/keyinput.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 6e6a3867d..f614c00fd 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -72,13 +72,13 @@ #include "input/mouseinput.h" +class FocusHandler; class Graphics; class KeyListener; class SDLInput; namespace gcn { - class FocusHandler; class Widget; // The following comment will appear in the doxygen main page. diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index 5b4ada76e..9e2912d39 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -72,7 +72,8 @@ #include "events/event.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/focushandler.hpp" + +#include "gui/focushandler.h" #include "input/keyinput.h" #include "input/mouseinput.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index f2718697e..1c1c0ae14 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -75,6 +75,7 @@ class ActionListener; class DeathListener; +class FocusHandler; class FocusListener; class Font; class Graphics; @@ -87,7 +88,6 @@ class WidgetListener; namespace gcn { class BasicContainer; - class FocusHandler; /** * Abstract class for widgets of Guichan. It contains basic functions diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 04cb3f555..22153c91f 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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. + */ + #include "gui/focushandler.h" #include "gui/gui.h" @@ -28,6 +71,20 @@ #include "debug.h" +FocusHandler::FocusHandler() : + mWidgets(), + mFocusedWidget(nullptr), + mModalFocusedWidget(nullptr), + mModalMouseInputFocusedWidget(nullptr), + mDraggedWidget(nullptr), + mLastWidgetWithMouse(nullptr), + mLastWidgetWithModalFocus(nullptr), + mLastWidgetWithModalMouseInputFocus(nullptr), + mLastWidgetPressed(nullptr), + mModalStack() +{ +} + void FocusHandler::requestModalFocus(gcn::Widget *widget) { /* If there is another widget with modal focus, remove its modal focus @@ -39,7 +96,9 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) mModalFocusedWidget = nullptr; } - gcn::FocusHandler::requestModalFocus(widget); + mModalFocusedWidget = widget; + if (mFocusedWidget && !mFocusedWidget->isModalFocused()) + focusNone(); } void FocusHandler::releaseModalFocus(gcn::Widget *widget) @@ -48,14 +107,15 @@ void FocusHandler::releaseModalFocus(gcn::Widget *widget) if (mModalFocusedWidget == widget) { - gcn::FocusHandler::releaseModalFocus(widget); + if (mModalFocusedWidget == widget) + mModalFocusedWidget = nullptr; /* Check if there were any previously modal widgets that'd still like * to regain their modal focus. */ if (!mModalStack.empty()) { - gcn::FocusHandler::requestModalFocus(mModalStack.front()); + requestModalFocus(mModalStack.front()); mModalStack.pop_front(); } } @@ -65,19 +125,188 @@ void FocusHandler::remove(gcn::Widget *widget) { releaseModalFocus(widget); - gcn::FocusHandler::remove(widget); + if (isFocused(widget)) + mFocusedWidget = nullptr; + + for (WidgetIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++iter) + { + if ((*iter) == widget) + { + mWidgets.erase(iter); + break; + } + } + + if (mDraggedWidget == widget) + { + mDraggedWidget = nullptr; + return; + } + + if (mLastWidgetWithMouse == widget) + { + mLastWidgetWithMouse = nullptr; + return; + } + + if (mLastWidgetWithModalFocus == widget) + { + mLastWidgetWithModalFocus = nullptr; + return; + } + + if (mLastWidgetWithModalMouseInputFocus == widget) + { + mLastWidgetWithModalMouseInputFocus = nullptr; + return; + } + + if (mLastWidgetPressed == widget) + { + mLastWidgetPressed = nullptr; + return; + } } void FocusHandler::tabNext() { - gcn::FocusHandler::tabNext(); + if (mFocusedWidget) + { + if (!mFocusedWidget->isTabOutEnabled()) + return; + } + + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + bool done = false; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + ++ focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget >= sz) + focusedWidget = 0; + + if (focusedWidget == focused) + return; + + const gcn::Widget *const widget = mWidgets.at(focusedWidget); + if (widget->isFocusable() && widget->isTabInEnabled() && + (!mModalFocusedWidget || widget->isModalFocused())) + { + done = true; + } + } + while (!done); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } checkForWindow(); } void FocusHandler::tabPrevious() { - gcn::FocusHandler::tabPrevious(); + if (mFocusedWidget) + { + if (!mFocusedWidget->isTabOutEnabled()) + return; + } + + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + bool done = false; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + -- focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget <= 0) + focusedWidget = sz - 1; + + if (focusedWidget == focused) + return; + + const gcn::Widget *const widget = mWidgets.at(focusedWidget); + if (widget->isFocusable() && widget->isTabInEnabled() && + (!mModalFocusedWidget || widget->isModalFocused())) + { + done = true; + } + } + while (!done); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } checkForWindow(); } @@ -107,5 +336,280 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) { if (gui) gui->distributeGlobalFocusGainedEvent(focusEvent); - gcn::FocusHandler::distributeFocusGainedEvent(focusEvent); + + gcn::Widget *const sourceWidget = focusEvent.getSource(); + + std::list focusListeners + = sourceWidget->_getFocusListeners(); + + // Send the event to all focus listeners of the widget. + for (std::list::const_iterator + it = focusListeners.begin(); + it != focusListeners.end(); + ++ it) + { + (*it)->focusGained(focusEvent); + } +} + +void FocusHandler::requestFocus(gcn::Widget* widget) +{ + if (!widget || widget == mFocusedWidget) + return; + + int toBeFocusedIndex = -1; + for (unsigned int i = 0, sz = static_cast( + mWidgets.size()); i < sz; ++i) + { + if (mWidgets[i] == widget) + { + toBeFocusedIndex = i; + break; + } + } + + if (toBeFocusedIndex < 0) + return; + + gcn::Widget *const oldFocused = mFocusedWidget; + + if (oldFocused != widget) + { + mFocusedWidget = mWidgets.at(toBeFocusedIndex); + + if (oldFocused) + { + Event focusEvent(oldFocused); + distributeFocusLostEvent(focusEvent); + } + + Event focusEvent(mWidgets.at(toBeFocusedIndex)); + distributeFocusGainedEvent(focusEvent); + } +} + +void FocusHandler::requestModalMouseInputFocus(gcn::Widget* widget) +{ + if (mModalMouseInputFocusedWidget + && mModalMouseInputFocusedWidget != widget) + { + return; + } + + mModalMouseInputFocusedWidget = widget; +} + +void FocusHandler::releaseModalMouseInputFocus(gcn::Widget* widget) +{ + if (mModalMouseInputFocusedWidget == widget) + mModalMouseInputFocusedWidget = nullptr; +} + +gcn::Widget* FocusHandler::getFocused() const +{ + return mFocusedWidget; +} + +gcn::Widget* FocusHandler::getModalFocused() const +{ + return mModalFocusedWidget; +} + +gcn::Widget* FocusHandler::getModalMouseInputFocused() const +{ + return mModalMouseInputFocusedWidget; +} + +void FocusHandler::focusNext() +{ + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + ++ focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget >= sz) + focusedWidget = 0; + + if (focusedWidget == focused) + return; + } + while (!mWidgets.at(focusedWidget)->isFocusable()); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } +} + +void FocusHandler::focusPrevious() +{ + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + -- focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget <= 0) + focusedWidget = sz - 1; + + if (focusedWidget == focused) + return; + } + while (!mWidgets.at(focusedWidget)->isFocusable()); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } +} + +bool FocusHandler::isFocused(const gcn::Widget* widget) const +{ + return mFocusedWidget == widget; +} + +void FocusHandler::add(gcn::Widget* widget) +{ + mWidgets.push_back(widget); +} + +void FocusHandler::focusNone() +{ + if (mFocusedWidget) + { + gcn::Widget *const focused = mFocusedWidget; + mFocusedWidget = nullptr; + + Event focusEvent(focused); + distributeFocusLostEvent(focusEvent); + } +} + +void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) +{ + gcn::Widget *const sourceWidget = focusEvent.getSource(); + + std::list focusListeners + = sourceWidget->_getFocusListeners(); + + // Send the event to all focus listeners of the widget. + for (std::list::const_iterator + it = focusListeners.begin(); + it != focusListeners.end(); + ++ it) + { + (*it)->focusLost(focusEvent); + } +} + +gcn::Widget* FocusHandler::getDraggedWidget() +{ + return mDraggedWidget; +} + +void FocusHandler::setDraggedWidget(gcn::Widget* draggedWidget) +{ + mDraggedWidget = draggedWidget; +} + +gcn::Widget* FocusHandler::getLastWidgetWithMouse() +{ + return mLastWidgetWithMouse; +} + +void FocusHandler::setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse) +{ + mLastWidgetWithMouse = lastWidgetWithMouse; +} + +gcn::Widget* FocusHandler::getLastWidgetWithModalFocus() +{ + return mLastWidgetWithModalFocus; +} + +void FocusHandler::setLastWidgetWithModalFocus(gcn::Widget* widget) +{ + mLastWidgetWithModalFocus = widget; +} + +gcn::Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() +{ + return mLastWidgetWithModalMouseInputFocus; +} + +void FocusHandler::setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget) +{ + mLastWidgetWithModalMouseInputFocus = widget; +} + +gcn::Widget* FocusHandler::getLastWidgetPressed() +{ + return mLastWidgetPressed; +} + +void FocusHandler::setLastWidgetPressed(gcn::Widget* lastWidgetPressed) +{ + mLastWidgetPressed = lastWidgetPressed; } diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 0e07625b7..0131a4c29 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -20,59 +20,311 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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_FOCUSHANDLER_H #define GUI_FOCUSHANDLER_H -#include "gui/base/focushandler.hpp" +#include "gui/focushandler.h" + +#include "events/event.h" #include +#include #include "localconsts.h" +namespace gcn +{ + class Widget; +} + /** * The focus handler. This focus handler does exactly the same as the Guichan * focus handler, but keeps a stack of modal widgets to be able to handle * multiple modal focus requests. */ -class FocusHandler final : public gcn::FocusHandler +class FocusHandler final { public: - FocusHandler() : - mModalStack() - { } + FocusHandler(); A_DELETE_COPY(FocusHandler) /** - * Sets modal focus to a widget. When there is already a modal widget - * then that widget loses modal focus and will regain it after this - * widget releases his modal focus. - */ - void requestModalFocus(gcn::Widget *widget) override final; + * Requests focus for a widget. Focus will only be granted to a widget + * if it's focusable and if no other widget has modal focus. + * If a widget receives focus a focus event will be sent to the + * focus listeners of the widget. + * + * @param widget The widget to request focus for. + * @see isFocused, Widget::requestFocus + */ + void requestFocus(gcn::Widget* widget); /** - * Releases modal focus of a widget. When this widget had modal focus - * and there are other widgets that had also requested modal focus, - * then modal focus will be transfered to the last of those. - */ - void releaseModalFocus(gcn::Widget *widget) override final; + * Requests modal focus for a widget. Focus will only be granted + * to a widget if it's focusable and if no other widget has modal + * focus. + * + * @param widget The widget to request modal focus for. + * @throws Exception when another widget already has modal focus. + * @see releaseModalFocus, Widget::requestModalFocus + */ + void requestModalFocus(gcn::Widget* widget); /** - * Removes a widget from the focus handler. Also makes sure no dangling - * pointers remain in modal focus stack. - */ - void remove(gcn::Widget *widget) override final; + * Requests modal mouse input focus for a widget. Focus will only + * be granted to a widget if it's focusable and if no other widget + * has modal mouse input focus. + * + * Modal mouse input focus means no other widget then the widget with + * modal mouse input focus will receive mouse input. The widget with + * modal mouse input focus will also receive mouse input no matter what + * the mouse input is or where the mouse input occurs. + * + * @param widget The widget to focus for modal mouse input focus. + * @throws Exception when another widget already has modal mouse input + * focus. + * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus + */ + void requestModalMouseInputFocus(gcn::Widget* widget); /** - * Overloaded to allow windows to move to the top when one of their - * widgets is tabbed to when tabbing through focusable elements. - */ - void tabNext() override final; + * Releases modal focus if the widget has modal focus. + * If the widget doesn't have modal focus no relase will occur. + * + * @param widget The widget to release modal focus for. + * @see reuqestModalFocus, Widget::releaseModalFocus + */ + void releaseModalFocus(gcn::Widget* widget); + + /** + * Releases modal mouse input focus if the widget has modal mouse input + * focus. If the widget doesn't have modal mouse input focus no relase + * will occur. + * + * @param widget the widget to release modal mouse input focus for. + * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus + */ + void releaseModalMouseInputFocus(gcn::Widget* widget); + + /** + * Checks if a widget is focused. + * + * @param widget The widget to check. + * @return True if the widget is focused, false otherwise. + * @see Widget::isFocused + */ + bool isFocused(const gcn::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; + + /** + * Gets the widget with modal focus. + * + * @return The widget with modal focus. NULL if no widget has + * modal focus. + */ + gcn::Widget* getModalFocused() const A_WARN_UNUSED; + + /** + * Gets the widget with modal mouse input focus. + * + * @return The widget with modal mouse input focus. NULL if + * no widget has modal mouse input focus. + */ + gcn::Widget* getModalMouseInputFocused() const A_WARN_UNUSED; + + /** + * Focuses the next widget added to a conainer. + * If no widget has focus the first widget gets focus. The order + * in which the widgets are focused is determined by the order + * they were added to a container. + * + * @see focusPrevious + */ + void focusNext(); + + /** + * Focuses the previous widget added to a contaienr. + * If no widget has focus the first widget gets focus. The order + * in which the widgets are focused is determined by the order + * they were added to a container. + * + * @see focusNext + */ + void focusPrevious(); + + /** + * Adds a widget to by handles by the focus handler. + * + * @param widget The widget to add. + * @see remove + */ + void add(gcn::Widget* widget); + + /** + * Removes a widget from the focus handler. + * + * @param widget The widget to remove. + * @see add + */ + void remove(gcn::Widget* widget); + + /** + * Focuses nothing. A focus event will also be sent to the + * focused widget's focus listeners if a widget has focus. + */ + void focusNone(); + + /** + * Focuses the next widget which allows tabbing in unless + * the current focused Widget disallows tabbing out. + * + * @see tabPrevious + */ + void tabNext(); + + /** + * Focuses the previous widget which allows tabbing in unless + * current focused widget disallows tabbing out. + * + * @see tabNext + */ + void tabPrevious(); + + /** + * Gets the widget being dragged. Used by the Gui class to + * keep track of the dragged widget. + * + * @return the widget being dragged. + * @see setDraggedWidget + */ + gcn::Widget* getDraggedWidget() A_WARN_UNUSED; + + /** + * Sets the widget being dragged. Used by the Gui class to + * keep track of the dragged widget. + * + * @param draggedWidget The widget being dragged. + * @see getDraggedWidget + */ + void setDraggedWidget(gcn::Widget* draggedWidget); + + /** + * Gets the last widget with the mouse. Used by the Gui class + * to keep track the last widget with the mouse. + * + * @return The last widget with the mouse. + * @see setLastWidgetWithMouse + */ + gcn::Widget* getLastWidgetWithMouse() A_WARN_UNUSED; + + /** + * Sets the last widget with the mouse. Used by the Gui class + * to keep track the last widget with the mouse. + * + * @param lastWidgetWithMouse The last widget with the mouse. + * @see getLastWidgetWithMouse + */ + void setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse); + + /** + * Gets the last widget with modal focus. + * + * @return The last widget with modal focus. + * @see setLastWidgetWithModalFocus + */ + gcn::Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; + + /** + * Sets the last widget with modal focus. + * + * @param widget The last widget with modal focus. + * @see getLastWidgetWithModalFocus + */ + void setLastWidgetWithModalFocus(gcn::Widget* widget); + + /** + * Gets the last widget with modal mouse input focus. + * + * @return The last widget with modal mouse input focus. + * @see setLastWidgetWithModalMouseInputFocus + */ + gcn::Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; + + /** + * Sets the last widget with modal mouse input focus. + * + * @param widget The last widget with modal mouse input focus. + * @see getLastWidgetWithModalMouseInputFocus + */ + void setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget); - void tabPrevious() override final; + /** + * Gets the last widget pressed. Used by the Gui class to keep track + * of pressed widgets. + * + * @return The last widget pressed. + * @see setLastWidgetPressed + */ + gcn::Widget* getLastWidgetPressed() A_WARN_UNUSED; - void distributeFocusGainedEvent(const Event &focusEvent) - override final; + /** + * Sets the last widget pressed. Used by the Gui class to keep track + * of pressed widgets. + * + * @param lastWidgetPressed The last widget pressed. + * @see getLastWidgetPressed + */ + void setLastWidgetPressed(gcn::Widget* lastWidgetPressed); private: /** @@ -81,6 +333,81 @@ class FocusHandler final : public gcn::FocusHandler */ void checkForWindow() const; + /** + * Distributes a focus lost event. + * + * @param focusEvent the event to distribute. + * @since 0.7.0 + */ + void distributeFocusLostEvent(const Event& focusEvent); + + /** + * Distributes a focus gained event. + * + * @param focusEvent the event to distribute. + * @since 0.7.0 + */ + void distributeFocusGainedEvent(const Event& focusEvent); + + /** + * Typedef. + */ + typedef std::vector WidgetVector; + + /** + * Typedef. + */ + typedef WidgetVector::iterator WidgetIterator; + + /** + * Holds the widgets currently being handled by the + * focus handler. + */ + WidgetVector mWidgets; + + /** + * Holds the focused widget. NULL if no widget has focus. + */ + gcn::Widget* mFocusedWidget; + + /** + * Holds the modal focused widget. NULL if no widget has + * modal focused. + */ + gcn::Widget* mModalFocusedWidget; + + /** + * Holds the modal mouse input focused widget. NULL if no widget + * is being dragged. + */ + gcn::Widget* mModalMouseInputFocusedWidget; + + /** + * Holds the dragged widget. NULL if no widget is + * being dragged. + */ + gcn::Widget* mDraggedWidget; + + /** + * Holds the last widget with the mouse. + */ + gcn::Widget* mLastWidgetWithMouse; + + /** + * Holds the last widget with modal focus. + */ + gcn::Widget* mLastWidgetWithModalFocus; + + /** + * Holds the last widget with modal mouse input focus. + */ + gcn::Widget* mLastWidgetWithModalMouseInputFocus; + + /** + * Holds the last widget pressed. + */ + gcn::Widget* mLastWidgetPressed; + /** * Stack of widgets that have requested modal forcus. */ diff --git a/src/gui/gui.h b/src/gui/gui.h index b790d4d2c..aacd33946 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -90,7 +90,7 @@ class Gui final : public gcn::Gui */ void videoResized() const; - gcn::FocusHandler *getFocusHandler() const A_WARN_UNUSED + FocusHandler *getFocusHandler() const A_WARN_UNUSED { return mFocusHandler; } /** diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index f87ca2fe7..1b1124cff 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -588,7 +588,7 @@ int GuiTable::getColumnForX(int x) const return column; } -void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler) +void GuiTable::_setFocusHandler(FocusHandler* focusHandler) { // add check for focusHandler. may be need remove it? diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index da367dd94..ab7dc1a66 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -122,7 +122,7 @@ public: void moveToBottom(gcn::Widget *child) override final; - void _setFocusHandler(gcn::FocusHandler* focusHandler) override final; + void _setFocusHandler(FocusHandler* focusHandler) override final; // Inherited from KeyListener void keyPressed(KeyEvent& keyEvent) override final; diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 537c7283c..c2fa1a686 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -28,10 +28,10 @@ #include "input/keydata.h" +#include "gui/focushandler.h" #include "gui/font.h" #include "gui/gui.h" -#include "gui/base/focushandler.hpp" #include "gui/base/listmodel.hpp" #include "render/graphics.h" diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index e2f24a0f2..2ea86f9df 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -29,6 +29,7 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "gui/focushandler.h" #include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -38,8 +39,6 @@ #include "resources/cursor.h" #include "resources/image.h" -#include "gui/base/focushandler.hpp" - #include "debug.h" const int resizeMask = 8 + 4 + 2 + 1; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index e49c78803..45a76495b 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -39,6 +39,7 @@ #include "input/inputmanager.h" +#include "gui/focushandler.h" #include "gui/font.h" #include "gui/sdlinput.h" #include "gui/viewport.h" @@ -69,8 +70,6 @@ #include "resources/resourcemanager.h" -#include "gui/base/focushandler.hpp" - #include #include diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 46494532a..d19130e7c 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -51,7 +51,7 @@ #include "utils/timer.h" -#include "gui/base/focushandler.hpp" +#include "gui/focushandler.h" #include -- cgit v1.2.3-70-g09d2 From 26f9aad24bc50d4e9fd161d185df049c9e7a62cf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 19 Feb 2014 01:18:16 +0300 Subject: improve includes. --- src/actionmanager.cpp | 4 +--- src/being/actorsprite.cpp | 3 +++ src/being/being.cpp | 1 + src/being/being.h | 10 +++++++--- src/being/localplayer.cpp | 5 +++-- src/being/playerrelations.cpp | 2 ++ src/being/playerrelations.h | 3 +-- src/client.cpp | 3 ++- src/commandhandler.cpp | 2 ++ src/commandhandler.h | 5 +++-- src/configuration.cpp | 1 + src/defaults.cpp | 1 + src/defaults.h | 4 ++-- src/events/actionevent.h | 6 +++--- src/events/event.h | 6 +++--- src/events/inputguievent.h | 6 +++--- src/events/keyevent.h | 6 +++--- src/events/mouseevent.h | 6 +++--- src/events/selectionevent.h | 6 +++--- src/graphicsvertexes.h | 4 +++- src/gui/base/basiccontainer.cpp | 2 -- src/gui/base/basiccontainer.hpp | 3 +-- src/gui/base/gui.cpp | 5 ----- src/gui/base/gui.hpp | 1 - src/gui/base/rectangle.hpp | 3 +++ src/gui/base/widget.cpp | 7 ------- src/gui/base/widget.hpp | 4 +--- src/gui/base/widgets/button.cpp | 5 ----- src/gui/base/widgets/button.hpp | 2 -- src/gui/base/widgets/checkbox.cpp | 7 ------- src/gui/base/widgets/checkbox.hpp | 2 +- src/gui/base/widgets/container.hpp | 6 +----- src/gui/base/widgets/listbox.cpp | 8 -------- src/gui/base/widgets/radiobutton.cpp | 7 ------- src/gui/base/widgets/radiobutton.hpp | 2 +- src/gui/base/widgets/scrollarea.cpp | 3 --- src/gui/base/widgets/scrollarea.hpp | 2 -- src/gui/base/widgets/slider.cpp | 5 ----- src/gui/base/widgets/textbox.cpp | 5 ----- src/gui/base/widgets/textbox.hpp | 1 - src/gui/base/widgets/textfield.cpp | 5 ----- src/gui/base/widgets/window.cpp | 4 ---- src/gui/focushandler.cpp | 2 ++ src/gui/font.cpp | 1 - src/gui/gui.cpp | 2 ++ src/gui/gui.h | 3 +-- src/gui/popups/beingpopup.cpp | 1 + src/gui/popups/itempopup.cpp | 1 + src/gui/popups/itempopup.h | 1 + src/gui/popups/popupmenu.cpp | 2 ++ src/gui/popups/popupmenu.h | 1 + src/gui/popups/speechbubble.cpp | 2 +- src/gui/popups/spellpopup.cpp | 1 + src/gui/sdlinput.h | 7 +++---- src/gui/widgets/browserbox.h | 2 -- src/gui/widgets/button.cpp | 2 ++ src/gui/widgets/button.h | 2 -- src/gui/widgets/characterdisplay.cpp | 5 +++-- src/gui/widgets/characterdisplay.h | 8 +++++--- src/gui/widgets/characterviewnormal.cpp | 1 - src/gui/widgets/characterviewsmall.cpp | 2 ++ src/gui/widgets/characterviewsmall.h | 2 ++ src/gui/widgets/checkbox.cpp | 1 + src/gui/widgets/checkbox.h | 2 -- src/gui/widgets/container.cpp | 2 ++ src/gui/widgets/container.h | 2 -- src/gui/widgets/dropdown.cpp | 1 + src/gui/widgets/dropdown.h | 7 ++++++- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emotepage.h | 2 -- src/gui/widgets/emoteshortcutcontainer.cpp | 2 ++ src/gui/widgets/emoteshortcutcontainer.h | 6 +++--- src/gui/widgets/guitable.cpp | 4 ++-- src/gui/widgets/icon.cpp | 2 ++ src/gui/widgets/icon.h | 2 -- src/gui/widgets/itemcontainer.h | 2 -- src/gui/widgets/label.cpp | 1 + src/gui/widgets/layout.cpp | 2 ++ src/gui/widgets/layout.h | 8 ++++++-- src/gui/widgets/layouthelper.cpp | 2 ++ src/gui/widgets/listbox.h | 2 -- src/gui/widgets/playerbox.cpp | 2 ++ src/gui/widgets/progressbar.h | 2 -- src/gui/widgets/progressindicator.cpp | 2 ++ src/gui/widgets/progressindicator.h | 4 +--- src/gui/widgets/radiobutton.cpp | 1 + src/gui/widgets/radiobutton.h | 2 -- src/gui/widgets/scrollarea.cpp | 4 ++++ src/gui/widgets/scrollarea.h | 2 -- src/gui/widgets/setupitem.cpp | 4 ++++ src/gui/widgets/setupitem.h | 8 ++++++-- src/gui/widgets/setuptouchitem.cpp | 2 ++ src/gui/widgets/shortcutcontainer.cpp | 2 ++ src/gui/widgets/shortcutcontainer.h | 2 -- src/gui/widgets/slider.cpp | 2 ++ src/gui/widgets/slider.h | 2 -- src/gui/widgets/sliderlist.cpp | 2 ++ src/gui/widgets/sliderlist.h | 7 +++++-- src/gui/widgets/spellshortcutcontainer.cpp | 1 - src/gui/widgets/tabbedarea.cpp | 2 ++ src/gui/widgets/tabbedarea.h | 2 -- src/gui/widgets/tabs/chattab.cpp | 1 + src/gui/widgets/tabs/setup_audio.h | 2 ++ src/gui/widgets/tabs/setup_colors.cpp | 1 + src/gui/widgets/tabs/setup_colors.h | 2 -- src/gui/widgets/tabs/setup_input.cpp | 1 + src/gui/widgets/tabs/setup_relations.h | 2 ++ src/gui/widgets/tabs/setup_theme.cpp | 2 ++ src/gui/widgets/tabs/setup_touch.cpp | 2 ++ src/gui/widgets/tabs/setup_touch.h | 5 ++++- src/gui/widgets/tabs/setup_visual.h | 2 ++ src/gui/widgets/tabs/tab.cpp | 4 ++++ src/gui/widgets/tabs/tab.h | 2 -- src/gui/widgets/textbox.cpp | 1 + src/gui/widgets/textbox.h | 2 -- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textpreview.h | 2 -- src/gui/widgets/widget2.h | 1 - src/gui/widgets/window.h | 2 -- src/gui/windowmenu.cpp | 2 ++ src/gui/windowmenu.h | 4 ++-- src/gui/windows/buydialog.h | 1 - src/gui/windows/charcreatedialog.cpp | 1 + src/gui/windows/charcreatedialog.h | 4 +++- src/gui/windows/charselectdialog.cpp | 1 + src/gui/windows/charselectdialog.h | 1 - src/gui/windows/chatwindow.cpp | 3 +-- src/gui/windows/didyouknowwindow.cpp | 5 +++-- src/gui/windows/helpwindow.cpp | 5 +++-- src/gui/windows/inventorywindow.cpp | 3 +++ src/gui/windows/inventorywindow.h | 1 - src/gui/windows/itemamountwindow.cpp | 2 ++ src/gui/windows/npcdialog.h | 1 - src/gui/windows/questswindow.cpp | 3 ++- src/gui/windows/serverdialog.cpp | 4 +++- src/gui/windows/serverdialog.h | 2 +- src/gui/windows/setupwindow.cpp | 1 + src/gui/windows/textcommandeditor.cpp | 2 ++ src/gui/windows/tradewindow.cpp | 1 + src/input/inputmanager.cpp | 4 ++-- src/input/key.h | 2 +- src/input/mouseinput.h | 6 +++--- src/input/multitouchmanager.h | 2 ++ src/listeners/actionlistener.h | 6 +++--- src/listeners/deathlistener.h | 6 +++--- src/listeners/focuslistener.h | 6 +++--- src/listeners/keylistener.h | 6 +++--- src/listeners/mouselistener.h | 6 +++--- src/listeners/playerrelationslistener.h | 6 +++--- src/listeners/selectionlistener.h | 6 +++--- src/listeners/widgetlistener.h | 6 +++--- src/logger.cpp | 3 ++- src/maplayer.cpp | 1 + src/net/ea/buysellhandler.cpp | 2 -- src/net/ea/charserverhandler.cpp | 1 + src/net/ea/charserverhandler.h | 9 +++++++-- src/net/ea/chathandler.cpp | 2 ++ src/net/ea/chathandler.h | 6 +++++- src/net/ea/gamehandler.cpp | 2 ++ src/net/ea/gamehandler.h | 6 +++++- src/net/ea/gui/guildtab.cpp | 3 +-- src/net/ea/guildhandler.cpp | 4 ++++ src/net/ea/guildhandler.h | 7 +++++-- src/net/ea/inventoryhandler.cpp | 2 ++ src/net/ea/inventoryhandler.h | 6 +++++- src/net/ea/itemhandler.cpp | 2 ++ src/net/ea/itemhandler.h | 7 +++++++ src/net/ea/loginhandler.cpp | 2 ++ src/net/ea/loginhandler.h | 6 +++++- src/net/ea/npchandler.cpp | 2 ++ src/net/ea/npchandler.h | 8 +++++++- src/net/ea/partyhandler.cpp | 5 +++++ src/net/ea/partyhandler.h | 9 ++++++--- src/net/ea/playerhandler.cpp | 1 + src/net/ea/playerhandler.h | 6 +++++- src/net/ea/skillhandler.cpp | 2 ++ src/net/ea/skillhandler.h | 8 +++++++- src/net/ea/tradehandler.cpp | 1 + src/net/ea/tradehandler.h | 6 +++++- src/net/eathena/chathandler.cpp | 3 +-- src/net/eathena/chathandler.h | 2 +- src/net/eathena/generalhandler.cpp | 1 + src/net/eathena/network.cpp | 1 + src/net/eathena/network.h | 3 +-- src/net/eathena/partyhandler.cpp | 1 + src/net/tmwa/chathandler.cpp | 3 +-- src/net/tmwa/chathandler.h | 2 +- src/net/tmwa/generalhandler.cpp | 1 + src/net/tmwa/network.cpp | 1 + src/net/tmwa/network.h | 3 +-- src/net/tmwa/partyhandler.cpp | 1 + src/net/tmwa/pethandler.cpp | 3 +-- src/net/tradehandler.h | 2 ++ src/render/sdlgraphics.cpp | 2 ++ src/simpleanimation.cpp | 1 - src/statuseffect.cpp | 3 +++ src/statuseffect.h | 7 ++++--- src/touchmanager.cpp | 2 ++ src/touchmanager.h | 3 +-- src/utils/files.cpp | 1 - src/utils/paths.cpp | 2 ++ src/utils/sdlpixel.h | 6 +++--- src/utils/translation/poparser.cpp | 2 ++ src/utils/translation/poparser.h | 4 ++-- src/utils/xml.h | 2 +- 205 files changed, 376 insertions(+), 278 deletions(-) (limited to 'src/gui/gui.h') diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 473e6cbc7..b8ea34286 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -31,10 +31,9 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" -#include "events/inputevent.h" - #include "input/inputmanager.h" +#include "gui/gui.h" #include "gui/sdlinput.h" #include "gui/viewport.h" @@ -45,7 +44,6 @@ #include "gui/windows/questswindow.h" #include "gui/windows/quitdialog.h" #include "gui/windows/whoisonline.h" - #include "gui/windows/botcheckerwindow.h" #include "gui/windows/buyselldialog.h" #include "gui/windows/chatwindow.h" diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index a74f4f477..bbb016525 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -21,6 +21,7 @@ #include "being/actorsprite.h" +#include "animatedsprite.h" #include "configuration.h" #include "imagesprite.h" #include "statuseffect.h" @@ -31,6 +32,8 @@ #include "listeners/actorspritelistener.h" +#include "particle/particle.h" + #include "resources/resourcemanager.h" #include "utils/checkutils.h" diff --git a/src/being/being.cpp b/src/being/being.cpp index 1fcccb0cf..76af509d3 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -40,6 +40,7 @@ #include "particle/particleinfo.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/popups/speechbubble.h" diff --git a/src/being/being.h b/src/being/being.h index c8da2d97c..afa023068 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -23,12 +23,10 @@ #ifndef BEING_BEING_H #define BEING_BEING_H -#include "equipment.h" +//#include "equipment.h" #include "resources/beinginfo.h" -#include "gui/base/color.hpp" - #include #include "localconsts.h" @@ -45,6 +43,7 @@ static const int DEFAULT_BEING_HEIGHT = 32; class AnimatedSprite; class BeingCacheEntry; +class Equipment; class FlashText; class Guild; class ItemInfo; @@ -55,6 +54,11 @@ class Text; struct ParticleInfo; +namespace gcn +{ + class Color; +} + extern volatile int cur_time; enum Gender diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 0e57eabfe..2a3c5fa2f 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -23,6 +23,7 @@ #include "being/localplayer.h" #include "actormanager.h" +#include "animatedsprite.h" #include "client.h" #include "configuration.h" #include "dropshortcut.h" @@ -42,7 +43,6 @@ #include "input/keyboardconfig.h" -#include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -51,7 +51,6 @@ #include "gui/windows/okdialog.h" #include "gui/windows/outfitwindow.h" #include "gui/windows/shopwindow.h" -#include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" #include "gui/windows/updaterwindow.h" @@ -85,6 +84,8 @@ typedef std::map::const_iterator GuildMapCIter; LocalPlayer *player_node = nullptr; +class SkillDialog; + extern std::list beingInfoCache; extern OkDialog *weightNotice; extern int weightNoticeTime; diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp index a04c77e76..4404791ca 100644 --- a/src/being/playerrelations.cpp +++ b/src/being/playerrelations.cpp @@ -30,6 +30,8 @@ #include "utils/dtor.h" #include "utils/gettext.h" +#include "listeners/playerrelationslistener.h" + #include #include "debug.h" diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h index cddec5f10..3543d4221 100644 --- a/src/being/playerrelations.h +++ b/src/being/playerrelations.h @@ -25,14 +25,13 @@ #include "utils/stringvector.h" -#include "listeners/playerrelationslistener.h" - #include #include #include "localconsts.h" class Being; +class PlayerRelationsListener; struct PlayerRelation final { diff --git a/src/client.cpp b/src/client.cpp index 0fac5b3f2..a08406d10 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -85,6 +85,8 @@ #include "net/netconsts.h" #include "net/partyhandler.h" +#include "particle/particle.h" + #include "resources/imagehelper.h" #include "resources/openglimagehelper.h" #include "resources/surfaceimagehelper.h" @@ -112,7 +114,6 @@ #include "utils/files.h" #include "utils/fuzzer.h" #include "utils/gettext.h" -#include "utils/files.h" #include "utils/mkdir.h" #include "utils/paths.h" #include "utils/physfstools.h" diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 6d3881432..ef8acc26c 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -22,6 +22,8 @@ #include "commandhandler.h" +#include "commands.h" + #include "input/inputmanager.h" #include "gui/widgets/tabs/chattab.h" diff --git a/src/commandhandler.h b/src/commandhandler.h index de1561d74..b2b74d77d 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -23,15 +23,16 @@ #ifndef COMMANDHANDLER_H #define COMMANDHANDLER_H -#include "commands.h" - #include +#include #include #include "localconsts.h" class ChatTab; +struct CommandInfo; + extern ChatTab *localChatTab; typedef std::map CommandsMap; diff --git a/src/configuration.cpp b/src/configuration.cpp index 7d6fc43fd..ed2adfc61 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "logger.h" +#include "variabledata.h" #include "listeners/configlistener.h" diff --git a/src/defaults.cpp b/src/defaults.cpp index c343f9f11..7a110a539 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -22,6 +22,7 @@ #include "defaults.h" #include "graphicsmanager.h" +#include "variabledata.h" #include "being/being.h" diff --git a/src/defaults.h b/src/defaults.h index e4ba4d5ae..abc9eb50c 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -22,13 +22,13 @@ #ifndef DEFAULTS_H #define DEFAULTS_H -#include "variabledata.h" - #include #include #include "localconsts.h" +class VariableData; + typedef std::map DefaultsData; VariableData* createData(const int defData) A_WARN_UNUSED; diff --git a/src/events/actionevent.h b/src/events/actionevent.h index 70ed0f398..3164955e6 100644 --- a/src/events/actionevent.h +++ b/src/events/actionevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_ACTIONEVENT_HPP -#define EVENTS_ACTIONEVENT_HPP +#ifndef EVENTS_ACTIONEVENT_H +#define EVENTS_ACTIONEVENT_H #include "events/event.h" @@ -136,4 +136,4 @@ class ActionEvent final : public Event std::string mId; }; -#endif // EVENTS_ACTIONEVENT_HPP +#endif // EVENTS_ACTIONEVENT_H diff --git a/src/events/event.h b/src/events/event.h index d62dd672b..b71d0edd4 100644 --- a/src/events/event.h +++ b/src/events/event.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_EVENT_HPP -#define EVENTS_EVENT_HPP +#ifndef EVENTS_EVENT_H +#define EVENTS_EVENT_H #include "localconsts.h" @@ -114,4 +114,4 @@ class Event gcn::Widget* mSource; }; -#endif // EVENTS_EVENT_HPP +#endif // EVENTS_EVENT_H diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h index a2aefc35f..8523959ed 100644 --- a/src/events/inputguievent.h +++ b/src/events/inputguievent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_INPUTEVENT_HPP -#define EVENTS_INPUTEVENT_HPP +#ifndef EVENTS_INPUTGUIEVENT_H +#define EVENTS_INPUTGUIEVENT_H #include "events/event.h" @@ -184,4 +184,4 @@ class InputGuiEvent: public Event bool mIsConsumed; }; -#endif // EVENTS_INPUTEVENT_HPP +#endif // EVENTS_INPUTGUIEVENT_H diff --git a/src/events/keyevent.h b/src/events/keyevent.h index 728cd79ea..c0c950639 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_KEYEVENT_HPP -#define EVENTS_KEYEVENT_HPP +#ifndef EVENTS_KEYEVENT_H +#define EVENTS_KEYEVENT_H #include "events/inputguievent.h" #include "input/key.h" @@ -191,4 +191,4 @@ class KeyEvent: public InputGuiEvent bool mIsNumericPad; }; -#endif // EVENTS_KEYEVENT_HPP +#endif // EVENTS_KEYEVENT_H diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index 9284822ba..9378faac6 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_MOUSEEVENT_HPP -#define EVENTS_MOUSEEVENT_HPP +#ifndef EVENTS_MOUSEEVENT_H +#define EVENTS_MOUSEEVENT_H #include "events/inputguievent.h" @@ -237,4 +237,4 @@ class MouseEvent: public InputGuiEvent friend class gcn::Gui; }; -#endif // EVENTS_MOUSEEVENT_HPP +#endif // EVENTS_MOUSEEVENT_H diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h index fc030cab0..b2e91e04f 100644 --- a/src/events/selectionevent.h +++ b/src/events/selectionevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_SELECTIONEVENT_HPP -#define EVENTS_SELECTIONEVENT_HPP +#ifndef EVENTS_SELECTIONEVENT_H +#define EVENTS_SELECTIONEVENT_H #include "events/event.h" @@ -98,4 +98,4 @@ class SelectionEvent final: public Event { } }; -#endif // EVENTS_SELECTIONEVENT_HPP +#endif // EVENTS_SELECTIONEVENT_H diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 15256113f..8746bcce3 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -38,10 +38,12 @@ #endif -#include "resources/image.h" +#include #include +class Image; + struct DoubleRect final { SDL_Rect src; diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 05d89f172..edc465726 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -71,8 +71,6 @@ #include "gui/focushandler.h" -#include "input/mouseinput.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp index cc3aee808..fd28ef7b6 100644 --- a/src/gui/base/basiccontainer.hpp +++ b/src/gui/base/basiccontainer.hpp @@ -64,7 +64,6 @@ #ifndef GCN_BASICCONTAINER_HPP #define GCN_BASICCONTAINER_HPP -#include #include #include "gui/base/widget.hpp" @@ -85,7 +84,7 @@ namespace gcn public DeathListener { public: - BasicContainer(const Widget2 *const widget) : + explicit BasicContainer(const Widget2 *const widget) : Widget(widget), DeathListener(), mWidgets() diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index f62e24260..d5b23e960 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -67,20 +67,15 @@ #include "gui/base/gui.hpp" -#include "gui/base/basiccontainer.hpp" #include "gui/base/widget.hpp" #include "gui/focushandler.h" -#include "gui/sdlinput.h" -#include "input/keyinput.h" #include "input/mouseinput.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index f614c00fd..391a0520e 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -68,7 +68,6 @@ #include #include "events/keyevent.h" -#include "events/mouseevent.h" #include "input/mouseinput.h" diff --git a/src/gui/base/rectangle.hpp b/src/gui/base/rectangle.hpp index b8503db98..299ce99b9 100644 --- a/src/gui/base/rectangle.hpp +++ b/src/gui/base/rectangle.hpp @@ -95,6 +95,9 @@ namespace gcn */ Rectangle(const int x, const int y, const int width, const int height); + virtual ~Rectangle() + { } + /** * Sets the dimension of a rectangle. * diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index f5994d1af..692ea479c 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -71,17 +71,10 @@ #include "events/event.h" -#include "gui/base/basiccontainer.hpp" - #include "gui/focushandler.h" -#include "input/keyinput.h" -#include "input/mouseinput.h" - #include "listeners/actionlistener.h" #include "listeners/deathlistener.h" -#include "listeners/keylistener.h" -#include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 013ead3b8..6245d3c98 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -89,8 +89,6 @@ class WidgetListener; namespace gcn { - class BasicContainer; - /** * Abstract class for widgets of Guichan. It contains basic functions * every widget should have. @@ -110,7 +108,7 @@ namespace gcn * focusable as default, therefore, widgets that are supposed to be * focusable should overide this default in their own constructor. */ - Widget(const Widget2 *const widget); + explicit Widget(const Widget2 *const widget); A_DELETE_COPY(Widget) diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index e4285cffd..5187c625b 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -67,11 +67,6 @@ #include "gui/base/widgets/button.hpp" -#include "gui/font.h" - -#include "input/key.h" -#include "input/mouseinput.h" - #include "events/mouseevent.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index 7fd5613bd..fea175362 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -70,8 +70,6 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "events/mouseevent.h" - #include "gui/base/widget.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index d75fb5cb0..a5ec72dfa 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -67,13 +67,6 @@ #include "gui/base/widgets/checkbox.hpp" -#include "gui/font.h" - -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index d87a6b206..c79ccaff9 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -90,7 +90,7 @@ namespace gcn /** * Contructor. */ - CheckBox(const Widget2 *const widget); + explicit CheckBox(const Widget2 *const widget); /** * Constructor. The check box will be automatically resized diff --git a/src/gui/base/widgets/container.hpp b/src/gui/base/widgets/container.hpp index ba3cff153..3e6c0a587 100644 --- a/src/gui/base/widgets/container.hpp +++ b/src/gui/base/widgets/container.hpp @@ -64,12 +64,8 @@ #ifndef GCN_CONTAINER_HPP #define GCN_CONTAINER_HPP -#include - #include "gui/base/basiccontainer.hpp" -#include "render/graphics.h" - namespace gcn { /** @@ -89,7 +85,7 @@ namespace gcn * * @see setOpaque, isOpaque */ - Container(const Widget2 *const widget); + explicit Container(const Widget2 *const widget); /** * Destructor. diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 0dd5c88f7..02d94626c 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -69,16 +69,8 @@ #include "gui/font.h" -#include "gui/base/basiccontainer.hpp" -#include "gui/base/listmodel.hpp" - -#include "input/key.h" -#include "input/mouseinput.h" - #include "listeners/selectionlistener.h" -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index 832c00bbe..e17b9f776 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -67,13 +67,6 @@ #include "gui/base/widgets/radiobutton.hpp" -#include "gui/font.h" - -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index 4d4403fac..f4bfd53fa 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -93,7 +93,7 @@ namespace gcn /** * Constructor. */ - RadioButton(const Widget2 *const widget); + explicit RadioButton(const Widget2 *const widget); /** * Constructor. The radio button will be automatically resized diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index 68e1b72d3..0fc605fa3 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -67,9 +67,6 @@ #include "gui/base/widgets/scrollarea.hpp" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp index e2d8aada5..669ccfbdd 100644 --- a/src/gui/base/widgets/scrollarea.hpp +++ b/src/gui/base/widgets/scrollarea.hpp @@ -64,8 +64,6 @@ #ifndef GCN_SCROLLAREA_HPP #define GCN_SCROLLAREA_HPP -#include - #include "gui/base/basiccontainer.hpp" #include "listeners/mouselistener.h" diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index e995ff55a..4e9df0341 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -67,11 +67,6 @@ #include "gui/base/widgets/slider.hpp" -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 7a5b63a50..bb22a6f46 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -69,11 +69,6 @@ #include "gui/font.h" -#include "gui/base/basiccontainer.hpp" - -#include "input/key.h" -#include "input/mouseinput.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 0c96096ec..151af8c00 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -64,7 +64,6 @@ #ifndef GCN_TEXTBOX_HPP #define GCN_TEXTBOX_HPP -#include #include #include diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 6ca37c4af..ddcbec1b4 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -69,11 +69,6 @@ #include "gui/font.h" -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 0ead95bc1..401e3ab6d 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -67,10 +67,6 @@ #include "gui/base/widgets/window.hpp" -#include "gui/font.h" - -#include "input/mouseinput.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 22153c91f..0d45b6432 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -69,6 +69,8 @@ #include "gui/widgets/window.h" +#include "listeners/focuslistener.h" + #include "debug.h" FocusHandler::FocusHandler() : diff --git a/src/gui/font.cpp b/src/gui/font.cpp index a154d8c54..fcc8e8344 100644 --- a/src/gui/font.cpp +++ b/src/gui/font.cpp @@ -77,7 +77,6 @@ #include "resources/surfaceimagehelper.h" #include "utils/paths.h" -#include "utils/physfsrwops.h" #include "utils/sdlcheckutils.h" #include "utils/stringutils.h" #include "utils/timer.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 243b3817e..fdaa299af 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -40,6 +40,8 @@ #include "events/keyevent.h" +#include "listeners/focuslistener.h" + #include "input/keydata.h" #include "input/keyinput.h" #include "input/mouseinput.h" diff --git a/src/gui/gui.h b/src/gui/gui.h index aacd33946..f6b4fbbf6 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -26,10 +26,9 @@ #include "gui/base/color.hpp" #include "gui/base/gui.hpp" -#include "listeners/focuslistener.h" - #include "localconsts.h" +class FocusListener; class Graphics; class GuiConfigListener; class ImageSet; diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 32aa11454..07d4b064a 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -25,6 +25,7 @@ #include "being/playerrelations.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index d6ea5a48a..0a65ce3bc 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -28,6 +28,7 @@ #include "units.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/icon.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h index 714e0305c..f1cedf046 100644 --- a/src/gui/popups/itempopup.h +++ b/src/gui/popups/itempopup.h @@ -29,6 +29,7 @@ #include "resources/iteminfo.h" class Icon; +class Item; class Label; class TextBox; diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 450bd504f..a37994884 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -23,6 +23,7 @@ #include "gui/popups/popupmenu.h" #include "actormanager.h" +#include "commands.h" #include "commandhandler.h" #include "configuration.h" #include "dropshortcut.h" @@ -56,6 +57,7 @@ #include "gui/viewport.h" +#include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/tabs/chattab.h" #include "gui/widgets/progressbar.h" diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 1ebb0dd89..70f8b7885 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -29,6 +29,7 @@ #include "being/actorsprite.h" #include "listeners/actionlistener.h" + #include "gui/base/listmodel.hpp" #include "localconsts.h" diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index c74f3f5e6..9bb6157bc 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -24,11 +24,11 @@ #include "gui/popups/speechbubble.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/viewport.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" -#include "gui/widgets/textbox.h" #include "debug.h" diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index 141879da4..8849a53cb 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -24,6 +24,7 @@ #include "gui/popups/spellpopup.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/label.h" diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 8a9128920..29cb5ce1f 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -75,11 +75,10 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GUI_INPUT_H -#define GUI_INPUT_H +#ifndef GUI_SDLINPUT_H +#define GUI_SDLINPUT_H #include "input/keyinput.h" -#include "input/mouseinput.h" #include @@ -163,4 +162,4 @@ protected: bool mMouseInWindow; }; -#endif // GUI_INPUT_H +#endif // GUI_SDLINPUT_H diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 23f221e63..1f09dd0b1 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -24,8 +24,6 @@ #ifndef GUI_WIDGETS_BROWSERBOX_H #define GUI_WIDGETS_BROWSERBOX_H -#include "gui/widgets/widget2.h" - #include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index a9b621d90..d7871503e 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -29,9 +29,11 @@ #include "input/keydata.h" +#include "resources/image.h" #include "resources/imageset.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 73c0d70eb..4f2e9fd89 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_BUTTON_H #define GUI_WIDGETS_BUTTON_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/button.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index bdd740874..7bfc938de 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -24,6 +24,8 @@ #include "units.h" +#include "gui/gui.h" + #include "gui/windows/charselectdialog.h" #include "gui/popups/textpopup.h" @@ -32,8 +34,7 @@ #include "gui/widgets/layouthelper.h" #include "utils/gettext.h" - -#include +#include "utils/stringutils.h" #include "debug.h" diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index 8571363c3..8f9acf462 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -26,9 +26,6 @@ #include "gui/widgets/container.h" #include "gui/widgets/playerbox.h" -#include "net/charserverhandler.h" -#include "net/net.h" - #include "listeners/widgetlistener.h" #include "localconsts.h" @@ -37,6 +34,11 @@ class CharSelectDialog; class Label; class TextPopup; +namespace Net +{ + struct Character; +} + class CharacterDisplay final : public Container, public MouseListener, public WidgetListener diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp index 75481268b..1df98d85e 100644 --- a/src/gui/widgets/characterviewnormal.cpp +++ b/src/gui/widgets/characterviewnormal.cpp @@ -23,7 +23,6 @@ #include "configuration.h" #include "gui/widgets/characterdisplay.h" -#include "gui/widgets/characterviewsmall.h" #include "debug.h" diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp index eda1e4a71..4d2c93b48 100644 --- a/src/gui/widgets/characterviewsmall.cpp +++ b/src/gui/widgets/characterviewsmall.cpp @@ -24,6 +24,8 @@ #include "gui/widgets/characterdisplay.h" #include "gui/widgets/label.h" +#include "utils/stringutils.h" + #include "debug.h" CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget, diff --git a/src/gui/widgets/characterviewsmall.h b/src/gui/widgets/characterviewsmall.h index 17a549718..a9f6d7f9b 100644 --- a/src/gui/widgets/characterviewsmall.h +++ b/src/gui/widgets/characterviewsmall.h @@ -25,6 +25,8 @@ #include "localconsts.h" +class Label; + class CharacterViewSmall final : public CharacterViewBase { public: diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index e500815c0..63e32a0f9 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -31,6 +31,7 @@ #include "resources/image.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index e05ab29d3..28eadb75c 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_CHECKBOX_H #define GUI_WIDGETS_CHECKBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/checkbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 3c048d630..2d8aad965 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/container.h" +#include "gui/gui.h" + #include "debug.h" Container::Container(const Widget2 *const widget) : diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index efddb1566..36d7cce86 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_CONTAINER_H #define GUI_WIDGETS_CONTAINER_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/container.hpp" /** diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 86170036c..6189af75e 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -34,6 +34,7 @@ #include "resources/image.h" #include "gui/font.h" +#include "gui/gui.h" #include diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index b638a2a05..a1908a3c6 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/listmodel.hpp" +//#include "gui/base/listmodel.hpp" #include "listeners/actionlistener.h" #include "listeners/focuslistener.h" @@ -43,6 +43,11 @@ class PopupList; class ScrollArea; class Skin; +namespace gcn +{ + class ListModel; +} + /** * A drop down box from which you can select different values. * diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index dbaac1d9c..236415b32 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -38,7 +38,7 @@ class DropShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - DropShortcutContainer(Widget2 *const widget); + explicit DropShortcutContainer(Widget2 *const widget); A_DELETE_COPY(DropShortcutContainer) diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 8eb1e5f7b..8a508bd26 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -21,8 +21,6 @@ #ifndef GUI_WIDGETS_EMOTEPAGE_H #define GUI_WIDGETS_EMOTEPAGE_H -#include "gui/widgets/widget2.h" - #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 47c45c2dd..296f21126 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -34,6 +34,8 @@ #include "resources/image.h" +#include "resources/db/emotedb.h" + #include "debug.h" static const int MAX_ITEMS = 48; diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index ec0e98675..a3061441f 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -24,12 +24,12 @@ #include "gui/widgets/shortcutcontainer.h" -#include "resources/db/emotedb.h" - #include class TextPopup; +struct EmoteSprite; + /** * An emote shortcut container. Used to quickly use emoticons. * @@ -41,7 +41,7 @@ class EmoteShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - EmoteShortcutContainer(Widget2 *const widget); + explicit EmoteShortcutContainer(Widget2 *const widget); A_DELETE_COPY(EmoteShortcutContainer) diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 84bc19e0e..324d4b23e 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -24,6 +24,8 @@ #include "client.h" +#include "gui/gui.h" + #include "events/keyevent.h" #include "input/keydata.h" @@ -32,8 +34,6 @@ #include "listeners/actionlistener.h" -#include "input/key.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 73607c048..73c0db76c 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/icon.h" +#include "gui/gui.h" + #include "resources/image.h" #include "resources/resourcemanager.h" diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 9dc4827ac..dffdb8e8c 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_ICON_H #define GUI_WIDGETS_ICON_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 76dd51ef7..ab813b08f 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_ITEMCONTAINER_H #define GUI_WIDGETS_ITEMCONTAINER_H -#include "gui/widgets/widget2.h" - #include "listeners/keylistener.h" #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 73e3bca64..0c19d03c3 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/label.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index d9a818e0f..f16f40322 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -24,6 +24,8 @@ #include "logger.h" +#include "gui/base/widgets/container.hpp" + #include #include "debug.h" diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 013963bfa..85998d8e7 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -25,12 +25,16 @@ #include "localconsts.h" -#include "gui/base/widgets/container.hpp" - #include class LayoutCell; +namespace gcn +{ + class Container; + class Widget; +} + /** * This class is a helper for adding widgets to nested tables in a window. */ diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 066cabaf8..7b8a428a9 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/layouthelper.h" +#include "gui/base/widgets/container.hpp" + #include "debug.h" LayoutHelper::LayoutHelper(gcn::Container *const container) : diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index cd20ea50a..f1ebee317 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_LISTBOX_H #define GUI_WIDGETS_LISTBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/listbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 976a1c8f9..7ef543511 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -26,6 +26,8 @@ #include "being/being.h" +#include "gui/gui.h" + #include "resources/image.h" #include "debug.h" diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 1d4d83687..a2c55e077 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_PROGRESSBAR_H #define GUI_WIDGETS_PROGRESSBAR_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 8d4cdd67c..f5b295ec8 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -23,6 +23,8 @@ #include "simpleanimation.h" +#include "gui/gui.h" + #include "resources/animation.h" #include "resources/imageset.h" diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index 08526c7c2..e62e7ec90 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -22,8 +22,6 @@ #ifndef GUI_WIDGETS_PROGRESSINDICATOR_H #define GUI_WIDGETS_PROGRESSINDICATOR_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "localconsts.h" @@ -37,7 +35,7 @@ class SimpleAnimation; class ProgressIndicator final : public gcn::Widget { public: - ProgressIndicator(Widget2 *const widget); + explicit ProgressIndicator(Widget2 *const widget); A_DELETE_COPY(ProgressIndicator) diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index d52295b57..7b5c5fa11 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -31,6 +31,7 @@ #include "resources/image.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index faff6bc0e..2deb9a772 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_RADIOBUTTON_H #define GUI_WIDGETS_RADIOBUTTON_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/radiobutton.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 6dd2be526..0cadee888 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -25,6 +25,10 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/gui.h" + +#include "resources/image.h" + #include "debug.h" int ScrollArea::instances = 0; diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index bc652e296..39a7eea80 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_SCROLLAREA_H #define GUI_WIDGETS_SCROLLAREA_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/scrollarea.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 649388d04..1f5d48d06 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -25,9 +25,11 @@ #include "soundmanager.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/editdialog.h" +#include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/horizontcontainer.h" @@ -37,6 +39,8 @@ #include "gui/widgets/sliderlist.h" #include "gui/widgets/vertcontainer.h" +#include "gui/widgets/tabs/setuptabscroll.h" + #include "utils/base64.h" #include "utils/gettext.h" #include "utils/mathutils.h" diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index b5261e2f4..87b7c46f9 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -21,14 +21,17 @@ #ifndef GUI_WIDGETS_SETUPITEM_H #define GUI_WIDGETS_SETUPITEM_H -#include "gui/widgets/button.h" -#include "gui/widgets/tabs/setuptabscroll.h" +//#include "gui/widgets/button.h" +//#include "gui/widgets/tabs/setuptabscroll.h" + +#include "gui/widgets/widget2.h" #include "listeners/actionlistener.h" #include #include +class Button; class CheckBox; class Configuration; class DropDown; @@ -36,6 +39,7 @@ class EditDialog; class HorizontContainer; class IntTextField; class Label; +class SetupTabScroll; class Slider; class SliderList; class TextField; diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index b080de428..f4c213b2f 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -27,6 +27,8 @@ #include "gui/widgets/label.h" #include "gui/widgets/vertcontainer.h" +#include "gui/widgets/tabs/setuptabscroll.h" + #include #include "debug.h" diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 5df0eafb0..0482281ed 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -24,6 +24,8 @@ #include "graphicsvertexes.h" +#include "gui/gui.h" + #include "debug.h" float ShortcutContainer::mAlpha = 1.0; diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 610cfef1f..115298081 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_SHORTCUTCONTAINER_H #define GUI_WIDGETS_SHORTCUTCONTAINER_H -#include "gui/widgets/widget2.h" - #include "listeners/mouselistener.h" #include "gui/base/widget.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 0c9b74202..c785f4016 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -29,6 +29,8 @@ #include "input/keydata.h" +#include "gui/gui.h" + #include "resources/image.h" #include "debug.h" diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index d03799cae..2f21127d1 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_SLIDER_H #define GUI_WIDGETS_SLIDER_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/slider.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 93a6934ba..c5791f1c2 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -23,6 +23,8 @@ #include "gui/font.h" #include "gui/gui.h" +#include "gui/base/listmodel.hpp" + #include "gui/widgets/button.h" #include "gui/widgets/label.h" diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 785ada74b..9adba8080 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -21,8 +21,6 @@ #ifndef GUI_WIDGETS_SLIDERLIST_H #define GUI_WIDGETS_SLIDERLIST_H -#include "gui/base/listmodel.hpp" - #include "listeners/actionlistener.h" #include "listeners/mouselistener.h" @@ -33,6 +31,11 @@ class Button; class Label; +namespace gcn +{ + class ListModel; +} + class SliderList final : public Container, public ActionListener, public MouseListener diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 5441c4d8a..768206bdb 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -32,7 +32,6 @@ #include "gui/popups/spellpopup.h" -#include "gui/windows/inventorywindow.h" #include "gui/windows/shortcutwindow.h" #include "resources/image.h" diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index af5892845..879ac8ec0 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -69,6 +69,8 @@ #include "input/keydata.h" +#include "gui/gui.h" + #include "gui/widgets/button.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabs/tab.h" diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 1d0794c5c..a95438605 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -66,8 +66,6 @@ #ifndef GUI_WIDGETS_TABBEDAREA_H #define GUI_WIDGETS_TABBEDAREA_H -#include "gui/widgets/widget2.h" - #include "listeners/keylistener.h" #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 283f1927e..b74dc53b8 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -24,6 +24,7 @@ #include "chatlogger.h" #include "client.h" +#include "commands.h" #include "commandhandler.h" #include "configuration.h" #include "soundconsts.h" diff --git a/src/gui/widgets/tabs/setup_audio.h b/src/gui/widgets/tabs/setup_audio.h index 839734b39..aaadebf32 100644 --- a/src/gui/widgets/tabs/setup_audio.h +++ b/src/gui/widgets/tabs/setup_audio.h @@ -25,6 +25,8 @@ #include "gui/widgets/setupitem.h" +#include "gui/widgets/tabs/setuptabscroll.h" + class Setup_Audio final : public SetupTabScroll { public: diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 2aaad6301..9e78133f5 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/tabs/setup_colors.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/userpalette.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index 8864db7db..ce491706c 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -26,8 +26,6 @@ #include "listeners/selectionlistener.h" -#include - class BrowserBox; class Label; class ListBox; diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 72d05d966..03c8f31e3 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -28,6 +28,7 @@ #include "input/inputmanager.h" #include "input/keyboardconfig.h" +#include "gui/gui.h" #include "gui/setupactiondata.h" #include "gui/windows/okdialog.h" diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h index 55da0bedc..e32889008 100644 --- a/src/gui/widgets/tabs/setup_relations.h +++ b/src/gui/widgets/tabs/setup_relations.h @@ -27,6 +27,8 @@ #include "gui/widgets/tabs/setuptab.h" +#include "listeners/playerrelationslistener.h" + class Button; class CheckBox; class DropDown; diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index fd70b9158..d27a095d5 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/tabs/setup_theme.h" +#include "gui/gui.h" + #include "gui/windows/okdialog.h" #include "gui/widgets/button.h" diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index 5d995f914..2baae029e 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -21,6 +21,8 @@ #include "gui/widgets/tabs/setup_touch.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/namesmodel.h" +#include "gui/widgets/setuptouchitem.h" #include "gui/widgets/scrollarea.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/setup_touch.h b/src/gui/widgets/tabs/setup_touch.h index 9adc2d5cd..ef1afdda3 100644 --- a/src/gui/widgets/tabs/setup_touch.h +++ b/src/gui/widgets/tabs/setup_touch.h @@ -21,7 +21,10 @@ #ifndef GUI_WIDGETS_TABS_SETUP_TOUCH_H #define GUI_WIDGETS_TABS_SETUP_TOUCH_H -#include "gui/widgets/setuptouchitem.h" +#include "gui/widgets/tabs/setuptabscroll.h" + +class NamesModel; +class TouchActionsModel; class Setup_Touch final : public SetupTabScroll { diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h index 2d40d3a08..1229757dd 100644 --- a/src/gui/widgets/tabs/setup_visual.h +++ b/src/gui/widgets/tabs/setup_visual.h @@ -24,6 +24,8 @@ #include "gui/widgets/setupitem.h" +#include "gui/widgets/tabs/setuptabscroll.h" + class NamesModel; class Setup_Visual final : public SetupTabScroll diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index c1650e8a8..2d91129f2 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -68,9 +68,13 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/gui.h" + #include "gui/widgets/label.h" #include "gui/widgets/tabbedarea.h" +#include "resources/image.h" + #include "debug.h" int Tab::mInstances = 0; diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 878663e36..463a6b668 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -66,8 +66,6 @@ #ifndef GUI_WIDGETS_TABS_TAB_H #define GUI_WIDGETS_TABS_TAB_H -#include "gui/widgets/widget2.h" - #include "gui/base/basiccontainer.hpp" #include "listeners/mouselistener.h" diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 729d40ead..ec0d09a26 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -27,6 +27,7 @@ #include "input/keydata.h" #include "gui/font.h" +#include "gui/gui.h" #include diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index fe719faf8..24dd57adb 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_TEXTBOX_H #define GUI_WIDGETS_TEXTBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/textbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 226d9172c..c30045c02 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -29,7 +29,7 @@ #include "events/keyevent.h" #include "gui/font.h" -#include "gui/sdlinput.h" +#include "gui/gui.h" #include "gui/viewport.h" #include "gui/popups/popupmenu.h" diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 532175a82..31f64f545 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_TEXTPREVIEW_H #define GUI_WIDGETS_TEXTPREVIEW_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index a57ccbb41..c6317702f 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -21,7 +21,6 @@ #ifndef GUI_WIDGETS_WIDGET2_H #define GUI_WIDGETS_WIDGET2_H -#include "gui/gui.h" #include "gui/theme.h" #include "render/renderers.h" diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 64963be3e..37a9900ee 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -25,8 +25,6 @@ #include "render/graphics.h" -#include "gui/widgets/widget2.h" - #include "listeners/widgetlistener.h" #include "gui/base/widgets/window.hpp" diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 4417f18a6..27418b892 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -35,6 +35,8 @@ #include "gui/specialswindow.h" #endif +#include "gui/widgets/button.h" + #include "utils/dtor.h" #include "utils/gettext.h" diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 1f2d8adb2..a1ed66a7d 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -26,9 +26,9 @@ #include "listeners/configlistener.h" #include "gui/widgets/container.h" -#include "gui/widgets/button.h" #include "listeners/actionlistener.h" +#include "listeners/mouselistener.h" #include "listeners/selectionlistener.h" #include "localconsts.h" @@ -36,8 +36,8 @@ #include #include +class Button; class TextPopup; -class Window; struct ButtonInfo final { diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 500f378ef..aa163d5d0 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -35,7 +35,6 @@ class ShopListBox; class SortListModelBuy; class IntTextField; class Label; -class ListBox; class ScrollArea; class Slider; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index d6b572d40..fb407b9cc 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -31,6 +31,7 @@ #include "gui/windows/okdialog.h" #include "gui/widgets/button.h" +#include "gui/windows/charselectdialog.h" #include "gui/widgets/label.h" #include "gui/widgets/playerbox.h" #include "gui/widgets/radiobutton.h" diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index 123d826f2..12ddf7970 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -25,11 +25,13 @@ #include "being/being.h" -#include "gui/windows/charselectdialog.h" +#include "gui/widgets/window.h" #include "listeners/actionlistener.h" #include "listeners/keylistener.h" +class Button; +class CharSelectDialog; class Label; class PlayerBox; class RadioButton; diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 7c6e387a4..12a78ce10 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -44,6 +44,7 @@ #include "net/logindata.h" #include "net/loginhandler.h" +#include "net/net.h" #include "utils/gettext.h" diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 348811ee3..38c307f30 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -35,7 +35,6 @@ class Button; class CharacterDisplay; class CharacterViewBase; -class Label; class LoginData; class TextDialog; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 45a76495b..565d3644a 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -40,8 +40,7 @@ #include "input/inputmanager.h" #include "gui/focushandler.h" -#include "gui/font.h" -#include "gui/sdlinput.h" +#include "gui/gui.h" #include "gui/viewport.h" #include "gui/windows/emotewindow.h" diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 95d657772..79ad4c208 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/setupwindow.h" @@ -78,7 +78,8 @@ DidYouKnowWindow::DidYouKnowWindow() : Button *const okButton = new Button(this, _("Close"), "close", this); mBrowserBox->setLinkHandler(this); - mBrowserBox->setFont(gui->getHelpFont()); + if (gui) + mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVersion(true); mBrowserBox->setEnableImages(true); mBrowserBox->setEnableKeys(true); diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 7457c7b1e..fa9963217 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/didyouknowwindow.h" #include "gui/windows/setupwindow.h" @@ -73,7 +73,8 @@ HelpWindow::HelpWindow() : mBrowserBox->setOpaque(false); mBrowserBox->setLinkHandler(this); - mBrowserBox->setFont(gui->getHelpFont()); + if (gui) + mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVersion(true); mBrowserBox->setEnableImages(true); mBrowserBox->setEnableKeys(true); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index bc66f588c..603b1b26d 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -33,8 +33,11 @@ #include "input/inputmanager.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/viewport.h" +#include "gui/base/listmodel.hpp" + #include "gui/popups/textpopup.h" #include "gui/windows/equipmentwindow.h" diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 6a6999034..c81e83d77 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -37,7 +37,6 @@ class Button; class DropDown; class Item; class ItemContainer; -class Label; class LayoutCell; class ProgressBar; class SortListModelInv; diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 8e981ae96..c63157e27 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -33,6 +33,8 @@ #include "net/net.h" #include "gui/viewport.h" +#include "gui/base/listmodel.hpp" + #include "gui/popups/itempopup.h" #include "gui/windows/shopwindow.h" diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index b7b036659..b9fa1aab8 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -45,7 +45,6 @@ class ItemContainer; class NpcDialog; class PlayerBox; class ScrollArea; -class TextBox; class TextField; typedef std::map NpcDialogs; diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 1a8749899..d62ca36ad 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -27,6 +27,7 @@ #include "being/localplayer.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -166,7 +167,7 @@ QuestsWindow::QuestsWindow() : mText->setLinkHandler(mItemLinkHandler); mTextScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mQuestsListBox->setWidth(500); - if (gui->getNpcFont()->getHeight() < 20) + if (gui && gui->getNpcFont()->getHeight() < 20) mQuestsListBox->setRowHeight(20); else mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight()); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 6823c2649..a06257b10 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -32,7 +32,9 @@ #include "input/keydata.h" #include "gui/font.h" +#include "gui/gui.h" +#include "gui/widgets/checkbox.h" #include "gui/windows/editserverdialog.h" #include "gui/windows/logindialog.h" @@ -132,7 +134,7 @@ void ServersListModel::setVersionString(const int index, if (index < 0 || index >= static_cast(mVersionStrings.size())) return; - if (version.empty()) + if (version.empty() || !gui) { mVersionStrings[index] = VersionString(0, ""); } diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 112c8001d..3f63562f7 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -24,7 +24,6 @@ #define GUI_WINDOWS_SERVERDIALOG_H #include "gui/widgets/window.h" -#include "gui/widgets/checkbox.h" #include "net/download.h" #include "net/serverinfo.h" @@ -41,6 +40,7 @@ #include class Button; +class CheckBox; class Label; class ListBox; class ServerDialog; diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index a996d776b..9878807d9 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -44,6 +44,7 @@ #include "gui/widgets/tabs/setup_video.h" #include "gui/widgets/tabs/setup_visual.h" +#include "gui/widgets/button.h" #include "gui/widgets/label.h" #include "gui/widgets/tabbedarea.h" diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 98b9cae60..82d1c9ef6 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -27,6 +27,8 @@ #include "input/keyboardconfig.h" +#include "gui/base/listmodel.hpp" + #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/inttextfield.h" diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 25d077d5d..7fe1a1e36 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -32,6 +32,7 @@ #include "being/playerrelations.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/inventorywindow.h" #include "gui/windows/itemamountwindow.h" diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index d19130e7c..5d157f0fa 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -28,7 +28,6 @@ #include "input/keyboardconfig.h" #include "input/keyboarddata.h" #include "being/localplayer.h" -#include "being/playerinfo.h" #ifdef USE_SDL2 #include "input/multitouchmanager.h" #endif @@ -47,7 +46,6 @@ #include "gui/windows/setupwindow.h" #include "gui/windows/textdialog.h" #include "gui/windows/tradewindow.h" -#include "gui/windows/quitdialog.h" #include "utils/timer.h" @@ -59,6 +57,8 @@ InputManager inputManager; +class QuitDialog; + extern QuitDialog *quitDialog; static class KeyFunctor final diff --git a/src/input/key.h b/src/input/key.h index fa48d3583..97bc7113d 100644 --- a/src/input/key.h +++ b/src/input/key.h @@ -194,4 +194,4 @@ class Key final int mValue; }; -#endif // end GCN_KEY_HPP +#endif // INPUT_KEY_H diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h index 5ece1f77a..a90a1366d 100644 --- a/src/input/mouseinput.h +++ b/src/input/mouseinput.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MOUSEINPUT_H -#define MOUSEINPUT_H +#ifndef INPUT_MOUSEINPUT_H +#define INPUT_MOUSEINPUT_H #include "input/mouseinput.h" @@ -213,4 +213,4 @@ class MouseInput final int mRealY; }; -#endif // MOUSEINPUT_H +#endif // INPUT_MOUSEINPUT_H diff --git a/src/input/multitouchmanager.h b/src/input/multitouchmanager.h index 076ccb3a8..82bfd0881 100644 --- a/src/input/multitouchmanager.h +++ b/src/input/multitouchmanager.h @@ -25,7 +25,9 @@ #include "localconsts.h" +#ifdef USE_SDL2 union SDL_Event; +#endif struct MultiTouchEvent { diff --git a/src/listeners/actionlistener.h b/src/listeners/actionlistener.h index b22e5abc6..895cc985d 100644 --- a/src/listeners/actionlistener.h +++ b/src/listeners/actionlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_ACTIONLISTENER_HPP -#define LISTENERS_ACTIONLISTENER_HPP +#ifndef LISTENERS_ACTIONLISTENER_H +#define LISTENERS_ACTIONLISTENER_H #include @@ -106,4 +106,4 @@ class ActionListener { } }; -#endif // end LISTENERS_ACTIONLISTENER_HPP +#endif // LISTENERS_ACTIONLISTENER_H diff --git a/src/listeners/deathlistener.h b/src/listeners/deathlistener.h index beefe1746..ddd7db910 100644 --- a/src/listeners/deathlistener.h +++ b/src/listeners/deathlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_DEATHLISTENER_HPP -#define LISTENERS_DEATHLISTENER_HPP +#ifndef LISTENERS_DEATHLISTENER_H +#define LISTENERS_DEATHLISTENER_H #include @@ -103,4 +103,4 @@ class DeathListener { } }; -#endif // LISTENERS_DEATHLISTENER_HPP +#endif // LISTENERS_DEATHLISTENER_H diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h index c910f833e..10e4a2af0 100644 --- a/src/listeners/focuslistener.h +++ b/src/listeners/focuslistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_FOCUSLISTENER_HPP -#define LISTENERS_FOCUSLISTENER_HPP +#ifndef LISTENERS_FOCUSLISTENER_H +#define LISTENERS_FOCUSLISTENER_H #include @@ -113,4 +113,4 @@ class FocusListener { } }; -#endif // LISTENERS_FOCUSLISTENER_HPP +#endif // LISTENERS_FOCUSLISTENER_H diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h index 0873de835..efc387300 100644 --- a/src/listeners/keylistener.h +++ b/src/listeners/keylistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_KEYLISTENER_HPP -#define GCN_KEYLISTENER_HPP +#ifndef LISTENERS_KEYLISTENER_H +#define LISTENERS_KEYLISTENER_H #include "events/keyevent.h" @@ -113,4 +113,4 @@ class KeyListener { } }; -#endif // end GCN_KEYLISTENER_HPP +#endif // LISTENERS_KEYLISTENER_H diff --git a/src/listeners/mouselistener.h b/src/listeners/mouselistener.h index d294e4dd6..9a2a4ef04 100644 --- a/src/listeners/mouselistener.h +++ b/src/listeners/mouselistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_MOUSELISTENER_HPP -#define GCN_MOUSELISTENER_HPP +#ifndef LISTENERS_MOUSELISTENER_H +#define LISTENERS_MOUSELISTENER_H #include "events/mouseevent.h" @@ -190,4 +190,4 @@ class MouseListener { } }; -#endif // end GCN_MOUSELISTENER_HPP +#endif // LISTENERS_MOUSELISTENER_H diff --git a/src/listeners/playerrelationslistener.h b/src/listeners/playerrelationslistener.h index b95f18c33..6a8bf3b20 100644 --- a/src/listeners/playerrelationslistener.h +++ b/src/listeners/playerrelationslistener.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef LISTERNERS_PLAYERRELATIONSLISTENER_H -#define LISTERNERS_PLAYERRELATIONSLISTENER_H +#ifndef LISTENERS_PLAYERRELATIONSLISTENER_H +#define LISTENERS_PLAYERRELATIONSLISTENER_H #include @@ -40,4 +40,4 @@ class PlayerRelationsListener { } }; -#endif // LISTERNERS_PLAYERRELATIONSLISTENER_H +#endif // LISTENERS_PLAYERRELATIONSLISTENER_H diff --git a/src/listeners/selectionlistener.h b/src/listeners/selectionlistener.h index d3be0f0eb..2efe0a67e 100644 --- a/src/listeners/selectionlistener.h +++ b/src/listeners/selectionlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_SELECTIONLISTENER_HPP -#define GCN_SELECTIONLISTENER_HPP +#ifndef LISTENERS_SELECTIONLISTENER_H +#define LISTENERS_SELECTIONLISTENER_H #include @@ -111,4 +111,4 @@ class SelectionListener { } }; -#endif // end GCN_SELECTIONLISTENER_HPP +#endif // LISTENERS_SELECTIONLISTENER_H diff --git a/src/listeners/widgetlistener.h b/src/listeners/widgetlistener.h index 16d9e1f15..48641cbaa 100644 --- a/src/listeners/widgetlistener.h +++ b/src/listeners/widgetlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_WIDGETLISTENER_HPP -#define LISTENERS_WIDGETLISTENER_HPP +#ifndef LISTENERS_WIDGETLISTENER_H +#define LISTENERS_WIDGETLISTENER_H #include @@ -137,4 +137,4 @@ class WidgetListener { } }; -#endif // LISTENERS_WIDGETLISTENER_HPP +#endif // LISTENERS_WIDGETLISTENER_H diff --git a/src/logger.cpp b/src/logger.cpp index c430aefec..21fea14d7 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -22,9 +22,10 @@ #include "logger.h" -#include #include +#include + #ifdef WIN32 #include #elif defined __APPLE__ diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 86a431cdf..b4fbc6da6 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -33,6 +33,7 @@ #include "render/graphics.h" +#include "resources/image.h" #include "resources/resourcemanager.h" #include "gui/font.h" diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 0f592b123..d55a3cea6 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -39,8 +39,6 @@ #include "net/chathandler.h" #include "net/net.h" -#include "net/ea/eaprotocol.h" - #include "utils/timer.h" #include "debug.h" diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index a11c157fd..d541ce09b 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -33,6 +33,7 @@ #include "net/ea/gamehandler.h" #include "net/ea/network.h" +#include "net/messagein.h" #include "net/net.h" #include "utils/dtor.h" diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index 5ffd714f2..af6aafa9b 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -24,8 +24,13 @@ #define NET_EA_CHARSERVERHANDLER_H #include "net/charserverhandler.h" -#include "net/messagein.h" -#include "net/serverinfo.h" + +class ServerInfo; + +namespace Net +{ + class MessageIn; +} namespace Ea { diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 6654950f2..997e4bfc1 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -38,6 +38,8 @@ #include "gui/widgets/tabs/chattab.h" +#include "net/messagein.h" + #include #include "debug.h" diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index 1fabda09d..237abf10a 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -24,10 +24,14 @@ #define NET_EA_CHATHANDLER_H #include "net/chathandler.h" -#include "net/messagein.h" #include +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 6e1982b6d..de1d6f151 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -31,6 +31,8 @@ #include "gui/windows/okdialog.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h index 8a31ee030..4a0624be0 100644 --- a/src/net/ea/gamehandler.h +++ b/src/net/ea/gamehandler.h @@ -24,7 +24,11 @@ #define NET_EA_GAMEHANDLER_H #include "net/gamehandler.h" -#include "net/messagein.h" + +namespace Net +{ + class MessageIn; +} namespace Ea { diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 46b1f1649..af8c3b8df 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -28,10 +28,9 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "net/guildhandler.h" #include "net/net.h" -#include "net/ea/guildhandler.h" - #include "utils/gettext.h" #include "debug.h" diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 536c93263..1e56ac75b 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -30,6 +30,10 @@ #include "gui/windows/socialwindow.h" +#include "net/messagein.h" + +#include "net/ea/gui/guildtab.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 191d6fd44..e8bec6a09 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -23,12 +23,15 @@ #define NET_EA_GUILDHANDLER_H #include "net/guildhandler.h" -#include "net/messagein.h" -#include "net/ea/gui/guildtab.h" +namespace Net +{ + class MessageIn; +} namespace Ea { +class GuildTab; class GuildHandler : public Net::GuildHandler { diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 74f0a4ba7..3f4eb9228 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -29,6 +29,8 @@ #include "gui/windows/ministatuswindow.h" +#include "net/messagein.h" + #include "net/ea/eaprotocol.h" #include "debug.h" diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 6e8ecec38..494b9145a 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -33,11 +33,15 @@ #include "gui/windows/inventorywindow.h" #include "net/inventoryhandler.h" -#include "net/messagein.h" #include #include +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp index 9ce85a59b..383ba2753 100644 --- a/src/net/ea/itemhandler.cpp +++ b/src/net/ea/itemhandler.cpp @@ -24,6 +24,8 @@ #include "actormanager.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h index 6bc23fb10..80c0a4dbf 100644 --- a/src/net/ea/itemhandler.h +++ b/src/net/ea/itemhandler.h @@ -25,6 +25,13 @@ #include "net/messagein.h" +#include "localconsts.h" + +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 57edcefbf..62514b10b 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -32,6 +32,8 @@ #include "utils/gettext.h" #include "utils/paths.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index 8fea9d49f..f539176f5 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -24,7 +24,6 @@ #define NET_EA_LOGINHANDLER_H #include "net/loginhandler.h" -#include "net/messagein.h" #include "net/ea/token.h" @@ -32,6 +31,11 @@ class LoginData; +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 70c4ce08a..03def7298 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -24,6 +24,8 @@ #include "gui/windows/npcdialog.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index b8a10bc18..07c281587 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -23,11 +23,17 @@ #ifndef NET_EA_NPCHANDLER_H #define NET_EA_NPCHANDLER_H -#include "net/messagein.h" #include "net/npchandler.h" +#include "localconsts.h" + class NpcDialog; +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 98dec750a..7f29f277a 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -25,11 +25,16 @@ #include "configuration.h" #include "notifications.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" #include "gui/windows/socialwindow.h" +#include "net/messagein.h" + +#include "net/ea/gui/partytab.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index e7ab8f8ef..29f242285 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -22,15 +22,18 @@ #ifndef NET_EA_PARTYHANDLER_H #define NET_EA_PARTYHANDLER_H -#include "net/messagein.h" #include "net/partyhandler.h" -#include "net/ea/gui/partytab.h" +class Party; -#include "party.h" +namespace Net +{ + class MessageIn; +} namespace Ea { +class PartyTab; class PartyHandler : public Net::PartyHandler { diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 28f16735c..de376cead 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -41,6 +41,7 @@ #include "resources/db/deaddb.h" +#include "net/messagein.h" #include "net/net.h" #include "net/ea/eaprotocol.h" diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 589874e2e..087627f92 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -23,9 +23,13 @@ #ifndef NET_EA_PLAYERHANDLER_H #define NET_EA_PLAYERHANDLER_H -#include "net/messagein.h" #include "net/playerhandler.h" +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp index 3a5a1ab75..fd10a6087 100644 --- a/src/net/ea/skillhandler.cpp +++ b/src/net/ea/skillhandler.cpp @@ -33,6 +33,8 @@ #include "utils/stringutils.h" +#include "net/messagein.h" + #include "debug.h" /** job dependend identifiers (?) */ diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h index 8dc724e0a..484ca6878 100644 --- a/src/net/ea/skillhandler.h +++ b/src/net/ea/skillhandler.h @@ -23,9 +23,15 @@ #ifndef NET_EA_SKILLHANDLER_H #define NET_EA_SKILLHANDLER_H -#include "net/messagein.h" #include "net/skillhandler.h" +#include "localconsts.h" + +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 4cb424fc9..19e597967 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -34,6 +34,7 @@ #include "gui/windows/confirmdialog.h" #include "gui/windows/tradewindow.h" +#include "net/messagein.h" #include "net/net.h" #include "net/ea/eaprotocol.h" diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h index 22a78e9e6..d4c9510b8 100644 --- a/src/net/ea/tradehandler.h +++ b/src/net/ea/tradehandler.h @@ -23,9 +23,13 @@ #ifndef NET_EA_TRADEHANDLER_H #define NET_EA_TRADEHANDLER_H -#include "net/messagein.h" #include "net/tradehandler.h" +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 61e0a8404..a9d11f563 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -24,8 +24,7 @@ #include "being/localplayer.h" -#include "gui/widgets/tabs/chattab.h" - +#include "net/eathena/messageout.h" #include "net/eathena/protocol.h" #include diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index 9c6b8ea0c..3efaf2d31 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -26,10 +26,10 @@ #include "net/ea/chathandler.h" #include "net/eathena/messagehandler.h" -#include "net/eathena/messageout.h" namespace EAthena { +class MessageOut; class ChatHandler final : public MessageHandler, public Ea::ChatHandler { diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index ebb5d46d7..3a18dede9 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -33,6 +33,7 @@ #include "net/ea/guildhandler.h" +#include "net/ea/gui/guildtab.h" #include "net/ea/gui/partytab.h" #include "net/eathena/adminhandler.h" diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp index 56d4f5aae..0162d82e8 100644 --- a/src/net/eathena/network.cpp +++ b/src/net/eathena/network.cpp @@ -24,6 +24,7 @@ #include "logger.h" +#include "net/eathena/messagehandler.h" #include "net/eathena/messagein.h" #include "net/eathena/protocol.h" diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h index 4c9349f96..fae4f06d5 100644 --- a/src/net/eathena/network.h +++ b/src/net/eathena/network.h @@ -25,8 +25,6 @@ #include "net/ea/network.h" -#include "net/eathena/messagehandler.h" - /** * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. @@ -35,6 +33,7 @@ namespace EAthena { +class MessageHandler; class Network final : public Ea::Network { diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index fcc650171..cfec2fe81 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -24,6 +24,7 @@ #include "actormanager.h" #include "notifications.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index af236f00b..d00f12dd3 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -24,8 +24,7 @@ #include "being/localplayer.h" -#include "gui/widgets/tabs/chattab.h" - +#include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" #include diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index a7226c52c..c4f51fec7 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -26,10 +26,10 @@ #include "net/ea/chathandler.h" #include "net/tmwa/messagehandler.h" -#include "net/tmwa/messageout.h" namespace TmwAthena { +class MessageOut; class ChatHandler final : public MessageHandler, public Ea::ChatHandler { diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 683eb0711..46d1d490f 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -33,6 +33,7 @@ #include "net/ea/guildhandler.h" +#include "net/ea/gui/guildtab.h" #include "net/ea/gui/partytab.h" #include "net/tmwa/adminhandler.h" diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index c91387898..cc94b6161 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -24,6 +24,7 @@ #include "logger.h" +#include "net/tmwa/messagehandler.h" #include "net/tmwa/messagein.h" #include "net/tmwa/protocol.h" diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 6d05d0e48..bf9381227 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -25,8 +25,6 @@ #include "net/ea/network.h" -#include "net/tmwa/messagehandler.h" - /** * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. @@ -36,6 +34,7 @@ namespace TmwAthena { +class MessageHandler; class Network final : public Ea::Network { diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 78d56f669..ba18a9efa 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -24,6 +24,7 @@ #include "actormanager.h" #include "notifications.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp index 6b9e5adb7..3293b7edd 100644 --- a/src/net/tmwa/pethandler.cpp +++ b/src/net/tmwa/pethandler.cpp @@ -24,8 +24,7 @@ #include "net/net.h" -#include "net/tmwa/chathandler.h" -#include "net/tmwa/protocol.h" +#include "net/chathandler.h" #include "debug.h" diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h index 823352239..21ca65e97 100644 --- a/src/net/tradehandler.h +++ b/src/net/tradehandler.h @@ -29,6 +29,8 @@ #include "localconsts.h" +class Item; + namespace Net { class TradeHandler diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 7a15713be..2f4f6c0c2 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -33,6 +33,8 @@ #include "utils/sdlpixel.h" +#include "resources/image.h" + #include "debug.h" #if SDL_BYTEORDER == SDL_LIL_ENDIAN diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 63f15c18f..1409146df 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -29,7 +29,6 @@ #include "resources/animation.h" #include "resources/dye.h" -#include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 049c010b3..647c6dd99 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -22,12 +22,15 @@ #include "statuseffect.h" +#include "animatedsprite.h" #include "configuration.h" #include "logger.h" #include "soundmanager.h" #include "gui/widgets/tabs/chattab.h" +#include "particle/particle.h" + #include "resources/beingcommon.h" #include diff --git a/src/statuseffect.h b/src/statuseffect.h index 6dda71cfc..8bb164820 100644 --- a/src/statuseffect.h +++ b/src/statuseffect.h @@ -23,12 +23,13 @@ #ifndef STATUSEFFECT_H #define STATUSEFFECT_H -#include "animatedsprite.h" - -#include "particle/particle.h" +#include #include "localconsts.h" +class AnimatedSprite; +class Particle; + class StatusEffect final { public: diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 20c56b8d6..49a5a0d3d 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -35,6 +35,8 @@ #include "gui/theme.h" +#include "resources/image.h" + #include "debug.h" TouchManager touchManager; diff --git a/src/touchmanager.h b/src/touchmanager.h index 6419c4b17..09eaabad5 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -21,8 +21,6 @@ #ifndef TOUCHMANAGER_H #define TOUCHMANAGER_H -#include "resources/image.h" - #include "listeners/configlistener.h" #include "input/keydata.h" @@ -34,6 +32,7 @@ #include "localconsts.h" +class Image; class ImageCollection; class ImageRect; class MouseInput; diff --git a/src/utils/files.cpp b/src/utils/files.cpp index 24ec9366e..11ac222f5 100644 --- a/src/utils/files.cpp +++ b/src/utils/files.cpp @@ -24,7 +24,6 @@ #include "resources/resourcemanager.h" #endif -#include "utils/mkdir.h" #include "utils/physfstools.h" #include "localconsts.h" diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index a3f61bde3..96cd0ed29 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -28,7 +28,9 @@ #include "utils/physfstools.h" #include "utils/stringutils.h" +#ifdef USE_X11 #include "resources/resourcemanager.h" +#endif #ifdef __native_client__ #include diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index 2a26f28a1..692615688 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef UTILS_SDLPIXEL_HPP -#define UTILS_SDLPIXEL_HPP +#ifndef UTILS_SDLPIXEL_H +#define UTILS_SDLPIXEL_H #include "SDL.h" #include "gui/base/color.hpp" @@ -229,4 +229,4 @@ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, SDL_UnlockSurface(surface); } -#endif // UTILS_SDLPIXEL_HPP +#endif // UTILS_SDLPIXEL_H diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index f0ab95005..c105bf0da 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -24,6 +24,8 @@ #include "utils/stringutils.h" +#include "utils/translation/podict.h" + #include "logger.h" #include "debug.h" diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h index 08a6ac7b1..41598442b 100644 --- a/src/utils/translation/poparser.h +++ b/src/utils/translation/poparser.h @@ -21,13 +21,13 @@ #ifndef UTILS_TRANSLATION_POPARSER_H #define UTILS_TRANSLATION_POPARSER_H -#include "utils/translation/podict.h" - #include "localconsts.h" #include #include +class PoDict; + class PoParser final { public: diff --git a/src/utils/xml.h b/src/utils/xml.h index 48d60cda7..d8a281045 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -23,8 +23,8 @@ #ifndef UTILS_XML_H #define UTILS_XML_H -#include #include +#include #include -- cgit v1.2.3-70-g09d2 From 48646db55005a0da079bd2c945875dc8225e2f86 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 14:21:27 +0300 Subject: Move color into gui dir. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 8 +- src/being/being.cpp | 2 +- src/being/being.h | 10 +- src/client.cpp | 2 +- src/flooritem.cpp | 8 +- src/gui/base/color.cpp | 168 --------------------------- src/gui/base/color.hpp | 195 -------------------------------- src/gui/base/widget.hpp | 3 +- src/gui/color.cpp | 165 +++++++++++++++++++++++++++ src/gui/color.h | 192 +++++++++++++++++++++++++++++++ src/gui/font.cpp | 16 +-- src/gui/font.h | 18 +-- src/gui/gui.h | 7 +- src/gui/palette.cpp | 30 ++--- src/gui/palette.h | 29 +++-- src/gui/popups/speechbubble.cpp | 4 +- src/gui/popups/speechbubble.h | 4 +- src/gui/theme.cpp | 10 +- src/gui/theme.h | 14 +-- src/gui/userpalette.cpp | 8 +- src/gui/userpalette.h | 9 +- src/gui/viewport.cpp | 4 +- src/gui/viewport.h | 2 +- src/gui/widgets/avatarlistbox.cpp | 5 +- src/gui/widgets/browserbox.cpp | 12 +- src/gui/widgets/browserbox.h | 22 ++-- src/gui/widgets/button.h | 16 +-- src/gui/widgets/colormodel.cpp | 4 +- src/gui/widgets/colormodel.h | 16 +-- src/gui/widgets/desktop.h | 4 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/dropshortcutcontainer.h | 8 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/itemcontainer.h | 8 +- src/gui/widgets/itemshortcutcontainer.h | 8 +- src/gui/widgets/label.cpp | 6 +- src/gui/widgets/label.h | 6 +- src/gui/widgets/listbox.h | 8 +- src/gui/widgets/progressbar.cpp | 6 +- src/gui/widgets/progressbar.h | 8 +- src/gui/widgets/shoplistbox.cpp | 4 +- src/gui/widgets/shoplistbox.h | 4 +- src/gui/widgets/skillinfo.h | 4 +- src/gui/widgets/tabs/setup_colors.cpp | 6 +- src/gui/widgets/tabs/tab.h | 40 +++---- src/gui/widgets/textbox.cpp | 6 +- src/gui/widgets/textbox.h | 6 +- src/gui/widgets/textfield.h | 2 +- src/gui/widgets/textpreview.cpp | 8 +- src/gui/widgets/textpreview.h | 16 +-- src/gui/widgets/widget2.h | 16 +-- src/gui/windows/equipmentwindow.h | 8 +- src/gui/windows/outfitwindow.h | 4 +- src/gui/windows/serverdialog.cpp | 4 +- src/gui/windows/skilldialog.cpp | 4 +- src/particle/particle.cpp | 4 +- src/particle/particle.h | 13 +-- src/particle/textparticle.cpp | 6 +- src/particle/textparticle.h | 4 +- src/render/graphics.h | 17 +-- src/render/mobileopenglgraphics.h | 2 +- src/render/normalopenglgraphics.h | 2 +- src/render/nullopenglgraphics.h | 2 +- src/render/openglgraphicsdef.hpp | 4 +- src/render/safeopenglgraphics.h | 2 +- src/text.cpp | 6 +- src/text.h | 12 +- src/utils/sdlpixel.h | 7 +- 69 files changed, 625 insertions(+), 643 deletions(-) delete mode 100644 src/gui/base/color.cpp delete mode 100644 src/gui/base/color.hpp create mode 100644 src/gui/color.cpp create mode 100644 src/gui/color.h (limited to 'src/gui/gui.h') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cdc61aa91..cf8a905f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -767,7 +767,7 @@ SET(SRCS listeners/actionlistener.h gui/base/basiccontainer.hpp gui/base/cliprectangle.hpp - gui/base/color.hpp + gui/color.h listeners/deathlistener.h events/event.h listeners/focuslistener.h @@ -798,7 +798,7 @@ SET(SRCS gui/base/widgets/window.hpp gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp - gui/base/color.cpp + gui/color.cpp gui/base/gui.cpp input/key.cpp gui/base/rectangle.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 246da6073..5a2fa34d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,11 +27,11 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ - gui/base/color.cpp \ + gui/color.cpp \ gui/base/rectangle.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ - gui/base/color.hpp \ + gui/color.h \ events/event.h \ gui/base/rectangle.hpp @@ -152,7 +152,7 @@ manaplus_SOURCES += events/actionevent.h \ listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ gui/base/cliprectangle.hpp \ - gui/base/color.hpp \ + gui/color.h \ listeners/deathlistener.h \ events/event.h \ listeners/focuslistener.h \ @@ -184,7 +184,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/window.hpp \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ - gui/base/color.cpp \ + gui/color.cpp \ gui/base/gui.cpp \ input/key.cpp \ gui/base/rectangle.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 76af509d3..485b439af 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -542,7 +542,7 @@ void Being::takeDamage(Being *const attacker, const int amount, // TRANSLATORS: hit or miss message in attacks const std::string damage = amount ? toString(amount) : type == FLEE ? _("dodge") : _("miss"); - const gcn::Color *color; + const Color *color; if (gui) font = gui->getInfoParticleFont(); diff --git a/src/being/being.h b/src/being/being.h index 4ef40d9fd..e427612f0 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -41,6 +41,7 @@ static const int DEFAULT_BEING_HEIGHT = 32; class AnimatedSprite; class BeingCacheEntry; +class Color; class Equipment; class FlashText; class Guild; @@ -52,11 +53,6 @@ class Text; struct ParticleInfo; -namespace gcn -{ - class Color; -} - extern volatile int cur_time; enum Gender @@ -969,7 +965,7 @@ class Being : public ActorSprite, public ConfigListener * Holds a text object when the being displays it's name, 0 otherwise */ FlashText *mDispName; - const gcn::Color *mNameColor; + const Color *mNameColor; /** Engine-related infos about weapon. */ const ItemInfo *mEquippedWeapon; @@ -979,7 +975,7 @@ class Being : public ActorSprite, public ConfigListener Path mPath; Text *mText; - const gcn::Color *mTextColor; + const Color *mTextColor; Vector mDest; /**< destination coordinates. */ diff --git a/src/client.cpp b/src/client.cpp index a08406d10..4aa5d4cd4 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -614,7 +614,7 @@ static void updateProgress(int cnt) { const int progress = cnt + loadingProgressCounter; const int h = mainGraphics->mHeight; - mainGraphics->setColor(gcn::Color(255, 255, 255)); + mainGraphics->setColor(Color(255, 255, 255)); const int maxSize = mainGraphics->mWidth - 100; const int width = maxSize * progress / 450; mainGraphics->fillRectangle(gcn::Rectangle(50, h - 100, width, 50)); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 2592e6feb..6780b10fa 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -122,21 +122,21 @@ void FloorItem::draw(Graphics *const graphics, if (curTime > mDropTime + 28 && curTime < mDropTime + 50) { - graphics->setColor(gcn::Color(80, 200, 20, 200)); + graphics->setColor(Color(80, 200, 20, 200)); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime + 19 && curTime < mDropTime + 28) { - graphics->setColor(gcn::Color(200, 80, 20, + graphics->setColor(Color(200, 80, 20, 80 + 10 * (curTime - mDropTime - 18))); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime && curTime < mDropTime + 20) { - graphics->setColor(gcn::Color(20, 20, 255, + graphics->setColor(Color(20, 20, 255, 7 * (curTime - mDropTime))); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); @@ -153,7 +153,7 @@ void FloorItem::draw(Graphics *const graphics, { if (font && mAmount > 1) { -// graphics->setColor(gcn::Color(255, 255, 255, 100)); +// graphics->setColor(Color(255, 255, 255, 100)); graphics->setColor(userPalette->getColor( UserPalette::FLOOR_ITEM_TEXT)); font->drawString(graphics, toString(mAmount), x, y); diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp deleted file mode 100644 index 485367e6d..000000000 --- a/src/gui/base/color.cpp +++ /dev/null @@ -1,168 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/color.hpp" - -#include "debug.h" - -namespace gcn -{ - Color::Color() : - r(0U), - g(0U), - b(0U), - a(255U) - { - } - - Color::Color(const unsigned int color) : - r((color >> 16) & 0xFF), - g((color >> 8) & 0xFF), - b(color & 0xFF), - a(255U) - { - } - - Color::Color(const unsigned int ar, - const unsigned int ag, - const unsigned int ab, - const unsigned int aa) : - r(ar), - g(ag), - b(ab), - a(aa) - { - } - - Color Color::operator+(const Color& color) const - { - Color result(r + color.r, - g + color.g, - b + color.b, - 255U); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - Color Color::operator-(const Color& color) const - { - Color result(r - color.r, - g - color.g, - b - color.b, - 255U); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - Color Color::operator*(const float value) const - { - Color result(static_cast(static_cast(r) * value), - static_cast(static_cast(g) * value), - static_cast(static_cast(b) * value), - a); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - bool Color::operator==(const Color& color) const - { - return r == color.r && g == color.g && b == color.b && a == color.a; - } - - bool Color::operator!=(const Color& color) const - { - return !(r == color.r && g == color.g && b == color.b && a == color.a); - } - - std::ostream& operator<<(std::ostream& out, - const Color& color) - { - out << "Color [r = " - << color.r - << ", g = " - << color.g - << ", b = " - << color.b - << ", a = " - << color.a - << "]"; - - return out; - } -} // namespace gcn diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp deleted file mode 100644 index 781b2cb60..000000000 --- a/src/gui/base/color.hpp +++ /dev/null @@ -1,195 +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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_COLOR_HPP -#define GCN_COLOR_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * Represents a color with red, green, blue and alpha components. - */ - class Color final - { - public: - /** - * Constructor. Initializes the color to black. - */ - Color(); - - /** - * Constructor. Constructs a color from the bytes in an integer. - * Call it with a hexadecimal constant for HTML-style color representation. - * The alpha component is 255 by default. - * - * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. - * - * NOTE: Because of this constructor, integers will be automatically - * casted to a color by your compiler. - * - * @param color The color to initialise the object with. - */ - explicit Color(const unsigned int color); - - /** - * Constructor. The default alpha value is 255. - * - * @param r Red color component (range 0-255). - * @param g Green color component (range 0-255). - * @param b Blue color component (range 0-255). - * @param a Alpha, used for transparency. A value of 0 means - * totaly transparent, 255 is totaly opaque. - */ - Color(const unsigned int r, - const unsigned int g, - const unsigned int b, - const unsigned int a = 255); - - /** - * Adds the RGB values of two colors together. The values will be - * clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to add to this color. - * @return The added colors with an alpha value set to 255. - */ - Color operator+(const Color& color) const; - - /** - * Subtracts the RGB values of one color from another. - * The values will be clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to subtract from this color. - * @return The subtracted colors with an alpha value set to 255. - */ - Color operator-(const Color& color) const; - - /** - * Multiplies the RGB values of a color with a float value. - * The values will be clamped if they go out of range. - * - * @param value The value to multiply the color with. - * @return The multiplied colors. The alpha value will, unlike - * the add and subtract operations, be multiplied as - * well. - */ - Color operator*(const float value) const; - - /** - * Compares two colors. - * - * @return True if the two colors have the same RGBA components - * false otherwise. - */ - bool operator==(const Color& color) const; - - /** - * Compares two colors. - * - * @return True if the two colors have different RGBA components, - * false otherwise. - */ - bool operator!=(const Color& color) const; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param color The color to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Color& Color); - - /** - * Holds the red color component (range 0-255). - */ - unsigned int r; - - /** - * Holds the green color component (range 0-255). - */ - unsigned int g; - - /** - * Holds the blue color component (range 0-255). - */ - unsigned int b; - - /** - * Holds the alpha color component. A value of 0 means totally - * transparent while a value of 255 is considered opaque. - */ - unsigned int a; - }; -} // namespace gcn - -#endif // end GCN_COLOR_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index dd872d9a1..31d61312e 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -68,7 +68,8 @@ #include #include -#include "gui/base/color.hpp" +#include "gui/color.h" + #include "gui/base/rectangle.hpp" #include "gui/widgets/widget2.h" diff --git a/src/gui/color.cpp b/src/gui/color.cpp new file mode 100644 index 000000000..9a0034257 --- /dev/null +++ b/src/gui/color.cpp @@ -0,0 +1,165 @@ +/* + * 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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/color.h" + +#include "debug.h" + +Color::Color() : + r(0U), + g(0U), + b(0U), + a(255U) +{ +} + +Color::Color(const unsigned int color) : + r((color >> 16) & 0xFF), + g((color >> 8) & 0xFF), + b(color & 0xFF), + a(255U) +{ +} + +Color::Color(const unsigned int ar, + const unsigned int ag, + const unsigned int ab, + const unsigned int aa) : + r(ar), + g(ag), + b(ab), + a(aa) +{ +} + +Color Color::operator+(const Color& color) const +{ + Color result(r + color.r, + g + color.g, + b + color.b, + 255U); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +Color Color::operator-(const Color& color) const +{ + Color result(r - color.r, + g - color.g, + b - color.b, + 255U); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +Color Color::operator*(const float value) const +{ + Color result(static_cast(static_cast(r) * value), + static_cast(static_cast(g) * value), + static_cast(static_cast(b) * value), + a); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +bool Color::operator==(const Color& color) const +{ + return r == color.r && g == color.g && b == color.b && a == color.a; +} + +bool Color::operator!=(const Color& color) const +{ + return !(r == color.r && g == color.g && b == color.b && a == color.a); +} + +std::ostream& operator<<(std::ostream& out, + const Color& color) +{ + out << "Color [r = " + << color.r + << ", g = " + << color.g + << ", b = " + << color.b + << ", a = " + << color.a + << "]"; + + return out; +} diff --git a/src/gui/color.h b/src/gui/color.h new file mode 100644 index 000000000..646680d96 --- /dev/null +++ b/src/gui/color.h @@ -0,0 +1,192 @@ +/* + * 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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_COLOR_H +#define GUI_COLOR_H + +#include + +#include "localconsts.h" + +/** + * Represents a color with red, green, blue and alpha components. + */ +class Color final +{ + public: + /** + * Constructor. Initializes the color to black. + */ + Color(); + + /** + * Constructor. Constructs a color from the bytes in an integer. + * Call it with a hexadecimal constant for HTML-style color representation. + * The alpha component is 255 by default. + * + * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. + * + * NOTE: Because of this constructor, integers will be automatically + * casted to a color by your compiler. + * + * @param color The color to initialise the object with. + */ + explicit Color(const unsigned int color); + + /** + * Constructor. The default alpha value is 255. + * + * @param r Red color component (range 0-255). + * @param g Green color component (range 0-255). + * @param b Blue color component (range 0-255). + * @param a Alpha, used for transparency. A value of 0 means + * totaly transparent, 255 is totaly opaque. + */ + Color(const unsigned int r, + const unsigned int g, + const unsigned int b, + const unsigned int a = 255); + + /** + * Adds the RGB values of two colors together. The values will be + * clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to add to this color. + * @return The added colors with an alpha value set to 255. + */ + Color operator+(const Color& color) const; + + /** + * Subtracts the RGB values of one color from another. + * The values will be clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to subtract from this color. + * @return The subtracted colors with an alpha value set to 255. + */ + Color operator-(const Color& color) const; + + /** + * Multiplies the RGB values of a color with a float value. + * The values will be clamped if they go out of range. + * + * @param value The value to multiply the color with. + * @return The multiplied colors. The alpha value will, unlike + * the add and subtract operations, be multiplied as + * well. + */ + Color operator*(const float value) const; + + /** + * Compares two colors. + * + * @return True if the two colors have the same RGBA components + * false otherwise. + */ + bool operator==(const Color& color) const; + + /** + * Compares two colors. + * + * @return True if the two colors have different RGBA components, + * false otherwise. + */ + bool operator!=(const Color& color) const; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param color The color to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Color& Color); + + /** + * Holds the red color component (range 0-255). + */ + unsigned int r; + + /** + * Holds the green color component (range 0-255). + */ + unsigned int g; + + /** + * Holds the blue color component (range 0-255). + */ + unsigned int b; + + /** + * Holds the alpha color component. A value of 0 means totally + * transparent while a value of 255 is considered opaque. + */ + unsigned int a; +}; + +#endif // GUI_COLOR_H diff --git a/src/gui/font.cpp b/src/gui/font.cpp index fcc8e8344..e1d793ce1 100644 --- a/src/gui/font.cpp +++ b/src/gui/font.cpp @@ -99,8 +99,8 @@ int sdlTextChunkCnt = 0; #endif SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, - const gcn::Color &color0, - const gcn::Color &color1) : + const Color &color0, + const Color &color1) : text(text0), color(color0), color2(color1) @@ -125,7 +125,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const if (chunk.text != text) return chunk.text > text; - const gcn::Color &c = chunk.color; + const Color &c = chunk.color; if (c.r != color.r) return c.r > color.r; if (c.g != color.g) @@ -133,7 +133,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const if (c.b != color.b) return c.b > color.b; - const gcn::Color &c2 = chunk.color2; + const Color &c2 = chunk.color2; if (c2.r != color2.r) return c2.r > color2.r; if (c2.g != color2.g) @@ -147,8 +147,8 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const return false; } -SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1) : +SDLTextChunk::SDLTextChunk(const std::string &text0, const Color &color0, + const Color &color1) : img(nullptr), text(text0), color(color0), @@ -499,8 +499,8 @@ void Font::drawString(Graphics *const graphics, if (!g) return; - gcn::Color col = g->getColor(); - const gcn::Color &col2 = g->getColor2(); + Color col = g->getColor(); + const Color &col2 = g->getColor2(); const float alpha = static_cast(col.a) / 255.0F; /* The alpha value is ignored at string generation so avoid caching the diff --git a/src/gui/font.h b/src/gui/font.h index 8740b4f3b..bdf81dadc 100644 --- a/src/gui/font.h +++ b/src/gui/font.h @@ -67,7 +67,7 @@ #ifndef GUI_FONT_H #define GUI_FONT_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include @@ -84,8 +84,8 @@ const unsigned int CACHES_NUMBER = 256; class SDLTextChunkSmall { public: - SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); + SDLTextChunkSmall(const std::string &text0, const Color &color0, + const Color &color1); SDLTextChunkSmall(const SDLTextChunkSmall &old); @@ -93,15 +93,15 @@ class SDLTextChunkSmall bool operator<(const SDLTextChunkSmall &chunk) const; std::string text; - gcn::Color color; - gcn::Color color2; + Color color; + Color color2; }; class SDLTextChunk final { public: - SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); + SDLTextChunk(const std::string &text0, const Color &color0, + const Color &color1); A_DELETE_COPY(SDLTextChunk) @@ -113,8 +113,8 @@ class SDLTextChunk final Image *img; std::string text; - gcn::Color color; - gcn::Color color2; + Color color; + Color color2; SDLTextChunk *prev; SDLTextChunk *next; }; diff --git a/src/gui/gui.h b/src/gui/gui.h index f6b4fbbf6..232d47a22 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -23,7 +23,8 @@ #ifndef GUI_GUI_H #define GUI_GUI_H -#include "gui/base/color.hpp" +#include "gui/color.h" + #include "gui/base/gui.hpp" #include "localconsts.h" @@ -198,8 +199,8 @@ class Gui final : public gcn::Gui typedef std::list FocusListenerList; typedef FocusListenerList::iterator FocusListenerIterator; FocusListenerList mFocusListeners; - gcn::Color mForegroundColor; - gcn::Color mForegroundColor2; + Color mForegroundColor; + Color mForegroundColor2; int mTime; bool mCustomCursor; /**< Show custom cursor */ bool mDoubleClick; diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index 9d6c19095..21e027d82 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -29,18 +29,18 @@ #include "debug.h" -const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0); +const Color Palette::BLACK = Color(0, 0, 0); Palette::Palettes Palette::mInstances; -const gcn::Color Palette::RAINBOW_COLORS[7] = +const Color Palette::RAINBOW_COLORS[7] = { - gcn::Color(255, 0, 0), - gcn::Color(255, 153, 0), - gcn::Color(255, 255, 0), - gcn::Color(0, 153, 0), - gcn::Color(0, 204, 204), - gcn::Color(51, 0, 153), - gcn::Color(153, 0, 153) + Color(255, 0, 0), + Color(255, 153, 0), + Color(255, 255, 0), + Color(0, 153, 0), + Color(0, 204, 204), + Color(51, 0, 153), + Color(153, 0, 153) }; const int Palette::RAINBOW_COLOR_COUNT = 7; @@ -59,7 +59,7 @@ Palette::~Palette() mInstances.erase(this); } -const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) const +const Color& Palette::getCharColor(const signed char c, bool &valid) const { const CharColors::const_iterator it = mCharColors.find(c); if (it != mCharColors.end()) @@ -128,7 +128,7 @@ void Palette::advanceGradient() else colIndex = gradIndex; - gcn::Color &color = elem->color; + Color &color = elem->color; int colVal; if (grad == PULSE) @@ -136,7 +136,7 @@ void Palette::advanceGradient() colVal = static_cast(255.0 * sin(M_PI * colIndex / numOfColors)); - const gcn::Color &col = elem->testColor; + const Color &col = elem->testColor; color.r = ((colVal * col.r) / 255) % (col.r + 1); color.g = ((colVal * col.g) / 255) % (col.g + 1); @@ -180,9 +180,9 @@ void Palette::advanceGradient() } else if (elem->grad == RAINBOW) { - const gcn::Color &startCol = RAINBOW_COLORS[colIndex]; - const gcn::Color &destCol = - RAINBOW_COLORS[(colIndex + 1) % numOfColors]; + const Color &startCol = RAINBOW_COLORS[colIndex]; + const Color &destCol + = RAINBOW_COLORS[(colIndex + 1) % numOfColors]; double startColVal; double destColVal; diff --git a/src/gui/palette.h b/src/gui/palette.h index 1377822ca..0dbb5d3ad 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -26,7 +26,7 @@ #include "logger.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #if defined __native_client__ #include @@ -49,7 +49,7 @@ class Palette { public: /** Black Color Constant */ - static const gcn::Color BLACK; + static const Color BLACK; /** Colors can be static or can alter over time. */ enum GradientType @@ -71,8 +71,8 @@ class Palette * * @return the requested color or Palette::BLACK */ - const gcn::Color &getCharColor(const signed char c, - bool &valid) const A_WARN_UNUSED; + const Color &getCharColor(const signed char c, + bool &valid) const A_WARN_UNUSED; int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED; @@ -85,8 +85,8 @@ class Palette * * @return the requested color */ - inline const gcn::Color &getColor(int type, - const int alpha = 255) A_WARN_UNUSED + inline const Color &getColor(int type, + const int alpha = 255) A_WARN_UNUSED { if (type >= static_cast(mColors.size()) || type < 0) { @@ -94,15 +94,14 @@ class Palette type, static_cast(mColors.size())); type = 0; } - gcn::Color* col = &mColors[type].color; + Color* col = &mColors[type].color; col->a = alpha; return *col; } - inline const gcn::Color &getColorWithAlpha(const int type) - A_WARN_UNUSED + inline const Color &getColorWithAlpha(const int type) A_WARN_UNUSED { - gcn::Color* col = &mColors[type].color; + Color* col = &mColors[type].color; col->a = mColors[type].delay; return *col; } @@ -144,7 +143,7 @@ class Palette protected: /** Colors used for the rainbow gradient */ - static const gcn::Color RAINBOW_COLORS[7]; + static const Color RAINBOW_COLORS[7]; static const int RAINBOW_COLOR_COUNT; /** Time tick, that gradient-type colors were updated the last time. */ @@ -183,9 +182,9 @@ class Palette } int type; - gcn::Color color; - gcn::Color testColor; - gcn::Color committedColor; + Color color; + Color testColor; + Color committedColor; std::string text; signed char ch; GradientType grad; @@ -194,7 +193,7 @@ class Palette int delay; int committedDelay; - void set(const int type0, const gcn::Color &color0, + void set(const int type0, const Color &color0, const GradientType grad0, const int delay0) { type = type0; diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index 9bb6157bc..3d0250a78 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -57,8 +57,8 @@ void SpeechBubble::postInit() } void SpeechBubble::setCaption(const std::string &name, - const gcn::Color *const color1, - const gcn::Color *const color2) + const Color *const color1, + const Color *const color2) { mCaption->setCaption(name); mCaption->adjustSize(); diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h index 62da9b146..1bc5385a4 100644 --- a/src/gui/popups/speechbubble.h +++ b/src/gui/popups/speechbubble.h @@ -47,9 +47,9 @@ class SpeechBubble final : public Popup * Sets the name displayed for the speech bubble, and in what color. */ void setCaption(const std::string &name, - const gcn::Color *const color1 = + const Color *const color1 = &Theme::getThemeColor(Theme::BUBBLE_NAME), - const gcn::Color *const color2 = + const Color *const color2 = &Theme::getThemeColor(Theme::BUBBLE_NAME_OUTLINE)); /** diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 2a1b0d624..1a504f680 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -259,7 +259,7 @@ void Theme::deleteInstance() mInstance = nullptr; } -gcn::Color Theme::getProgressColor(const int type, const float progress) +Color Theme::getProgressColor(const int type, const float progress) { int color[3] = {0, 0, 0}; @@ -273,7 +273,7 @@ gcn::Color Theme::getProgressColor(const int type, const float progress) logger->log("color not found: " + toString(type)); } - return gcn::Color(color[0], color[1], color[2]); + return Color(color[0], color[1], color[2]); } Skin *Theme::load(const std::string &filename, const std::string &filename2, @@ -972,7 +972,7 @@ static int readColorType(const std::string &type) return -1; } -static gcn::Color readColor(const std::string &description) +static Color readColor(const std::string &description) { const int size = static_cast(description.length()); if (size < 7 || description[0] != '#') @@ -1010,7 +1010,7 @@ static gcn::Color readColor(const std::string &description) v = (v << 4) | n; } - return gcn::Color(v); + return Color(v); } static Palette::GradientType readColorGradient(const std::string &grad) @@ -1084,7 +1084,7 @@ void Theme::loadColors(std::string file) int type; std::string temp; - gcn::Color color; + Color color; GradientType grad; for_each_xml_child_node(paletteNode, root) diff --git a/src/gui/theme.h b/src/gui/theme.h index 826902004..86543ea64 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -450,21 +450,21 @@ class Theme final : public Palette, public ConfigListener * * @return the requested color */ - inline static const gcn::Color &getThemeColor(const int type, - const int alpha = 255) - A_WARN_UNUSED + inline static const Color &getThemeColor(const int type, + const int alpha = 255) + A_WARN_UNUSED { return mInstance->getColor(type, alpha); } - static const gcn::Color &getThemeCharColor(const signed char c, - bool &valid) A_WARN_UNUSED + static const Color &getThemeCharColor(const signed char c, + bool &valid) A_WARN_UNUSED { return mInstance->getCharColor(c, valid); } static int getThemeIdByChar(const signed char c, bool &valid) A_WARN_UNUSED { return mInstance->getIdByChar(c, valid); } - static gcn::Color getProgressColor(const int type, - const float progress) A_WARN_UNUSED; + static Color getProgressColor(const int type, + const float progress) A_WARN_UNUSED; /** * Loads a skin. diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 69125f8e2..74d47203f 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -237,7 +237,7 @@ UserPalette::~UserPalette() void UserPalette::setColor(const int type, const int r, const int g, const int b) { - gcn::Color &color = mColors[type].color; + Color &color = mColors[type].color; color.r = r; color.g = g; color.b = b; @@ -296,14 +296,14 @@ void UserPalette::rollback() if (i->grad != i->committedGrad) setGradient(i->type, i->committedGrad); - const gcn::Color &committedColor = i->committedColor; + const Color &committedColor = i->committedColor; setGradientDelay(i->type, i->committedDelay); setColor(i->type, committedColor.r, committedColor.g, committedColor.b); if (i->grad == PULSE) { - gcn::Color &testColor = i->testColor; + Color &testColor = i->testColor; testColor.r = committedColor.r; testColor.g = committedColor.g; testColor.b = committedColor.b; @@ -342,7 +342,7 @@ void UserPalette::addColor(const unsigned type, const unsigned rgb, rgbValue = atox(rgbString); else rgbValue = atoi(rgbString.c_str()); - const gcn::Color &trueCol = gcn::Color(rgbValue); + const Color &trueCol = Color(rgbValue); grad = static_cast(config.getValue(configName + "Gradient", static_cast(grad))); delay = config.getValueInt(configName + "Delay", delay); diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index fbba415b8..e37eee0ca 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -100,8 +100,8 @@ class UserPalette final : public Palette, public gcn::ListModel * * @return the requested committed color */ - inline const gcn::Color &getCommittedColor(const int type) - const A_WARN_UNUSED + inline const Color &getCommittedColor(const int type) + const A_WARN_UNUSED { return mColors[type].committedColor; } @@ -113,8 +113,7 @@ class UserPalette final : public Palette, public gcn::ListModel * * @return the requested test color */ - inline const gcn::Color &getTestColor(const int type) - const A_WARN_UNUSED + inline const Color &getTestColor(const int type) const A_WARN_UNUSED { return mColors[type].testColor; } /** @@ -123,7 +122,7 @@ class UserPalette final : public Palette, public gcn::ListModel * @param type the color type requested * @param color the color that should be tested */ - inline void setTestColor(const int type, const gcn::Color &color) + inline void setTestColor(const int type, const Color &color) { mColors[type].testColor = color; } /** diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ee64736eb..54619c3e6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -121,7 +121,7 @@ void Viewport::draw(Graphics *graphics) if (!mMap || !player_node) { - graphics->setColor(gcn::Color(64, 64, 64)); + graphics->setColor(Color(64, 64, 64)); graphics->fillRectangle( gcn::Rectangle(0, 0, getWidth(), getHeight())); BLOCK_END("Viewport::draw 1") @@ -338,7 +338,7 @@ void Viewport::_drawDebugPath(Graphics *const graphics) } void Viewport::_drawPath(Graphics *const graphics, const Path &path, - const gcn::Color &color) const + const Color &color) const { graphics->setColor(color); Font *const font = getFont(); diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 2b297de37..16d0e4e34 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -298,7 +298,7 @@ class Viewport final : public WindowContainer, * Draws the given path. */ void _drawPath(Graphics *const graphics, const Path &path, - const gcn::Color &color = gcn::Color(255, 0, 0)) const; + const Color &color = Color(255, 0, 0)) const; /** * Make the player go to the mouse position. diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 298ab657a..a71051b5d 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -154,7 +154,7 @@ void AvatarListBox::draw(Graphics *graphics) } if (parent && a->getMaxHp()) { - gcn::Color color = Theme::getProgressColor( + Color color = Theme::getProgressColor( Theme::PROG_HP, static_cast(a->getHp()) / static_cast(a->getMaxHp())); color.a = 80; @@ -180,8 +180,7 @@ void AvatarListBox::draw(Graphics *graphics) if (parent) { - gcn::Color color = Theme::getProgressColor(Theme::PROG_HP, - 1); + Color color = Theme::getProgressColor(Theme::PROG_HP, 1); color.a = 80; graphics->setColor(color); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index cc83d2b83..b6644cbc1 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -534,8 +534,8 @@ int BrowserBox::calcHeight() const char *const hyphen = "~"; const int hyphenWidth = font->getWidth(hyphen); - gcn::Color selColor[2] = {mForegroundColor, mForegroundColor2}; - const gcn::Color textColor[2] = {mForegroundColor, mForegroundColor2}; + Color selColor[2] = {mForegroundColor, mForegroundColor2}; + const Color textColor[2] = {mForegroundColor, mForegroundColor2}; ResourceManager *const resman = ResourceManager::getInstance(); mLineParts.clear(); @@ -581,7 +581,7 @@ int BrowserBox::calcHeight() continue; } - gcn::Color prevColor[2]; + Color prevColor[2]; prevColor[0] = selColor[0]; prevColor[1] = selColor[1]; bold = false; @@ -621,7 +621,7 @@ int BrowserBox::calcHeight() const signed char c = row.at(start + 2); bool valid(false); - const gcn::Color col[2] = + const Color col[2] = { getThemeCharColor(c, valid), getThemeCharColor(c | 0x80, valid) @@ -897,8 +897,8 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const return str; } -void BrowserBox::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void BrowserBox::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 1f09dd0b1..a33c69698 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -58,8 +58,8 @@ struct BrowserLink final class LinePart final { public: - LinePart(const int x, const int y, const gcn::Color &color, - const gcn::Color &color2, const std::string &text, + LinePart(const int x, const int y, const Color &color, + const Color &color2, const std::string &text, const bool bold) : mX(x), mY(y), @@ -72,8 +72,8 @@ class LinePart final { } - LinePart(const int x, const int y, const gcn::Color &color, - const gcn::Color &color2, Image *const image) : + LinePart(const int x, const int y, const Color &color, + const Color &color2, Image *const image) : mX(x), mY(y), mColor(color), @@ -88,8 +88,8 @@ class LinePart final ~LinePart(); int mX, mY; - gcn::Color mColor; - gcn::Color mColor2; + Color mColor; + Color mColor2; std::string mText; unsigned char mType; Image *mImage; @@ -228,8 +228,8 @@ class BrowserBox final : public gcn::Widget, int getPadding() const A_WARN_UNUSED { return mPadding; } - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); int getDataWidth() const { return mDataWidth; } @@ -266,9 +266,9 @@ class BrowserBox final : public gcn::Widget, int mItemPadding; unsigned int mDataWidth; - gcn::Color mHighlightColor; - gcn::Color mHyperLinkColor; - gcn::Color mColors[2][COLORS_MAX]; + Color mHighlightColor; + Color mHyperLinkColor; + Color mColors[2][COLORS_MAX]; bool mOpaque; bool mUseLinksAndUserColors; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 4f2e9fd89..039475150 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -165,14 +165,14 @@ class Button final : public gcn::Button, std::string mDescription; ImageCollection *mVertexes2; - gcn::Color mEnabledColor; - gcn::Color mEnabledColor2; - gcn::Color mDisabledColor; - gcn::Color mDisabledColor2; - gcn::Color mHighlightedColor; - gcn::Color mHighlightedColor2; - gcn::Color mPressedColor; - gcn::Color mPressedColor2; + Color mEnabledColor; + Color mEnabledColor2; + Color mDisabledColor; + Color mDisabledColor2; + Color mHighlightedColor; + Color mHighlightedColor2; + Color mPressedColor; + Color mPressedColor2; Image **mImages; ImageSet *mImageSet; unsigned mClickCount; diff --git a/src/gui/widgets/colormodel.cpp b/src/gui/widgets/colormodel.cpp index 7e59553e3..3a71a93cc 100644 --- a/src/gui/widgets/colormodel.cpp +++ b/src/gui/widgets/colormodel.cpp @@ -56,8 +56,8 @@ const ColorPair *ColorModel::getColorAt(const int i) const return &mColors[i]; } -void ColorModel::add(const std::string &name, const gcn::Color *const color1, - const gcn::Color *const color2) +void ColorModel::add(const std::string &name, const Color *const color1, + const Color *const color2) { mNames.push_back(name); mColors.push_back(ColorPair(color1, color2)); diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h index c019d9aac..7386a856b 100644 --- a/src/gui/widgets/colormodel.h +++ b/src/gui/widgets/colormodel.h @@ -27,23 +27,19 @@ #include "localconsts.h" +class Color; class Widget2; -namespace gcn -{ - class Color; -} - struct ColorPair { - ColorPair(const gcn::Color* c1, const gcn::Color* c2) : + ColorPair(const Color* c1, const Color* c2) : color1(c1), color2(c2) { } - const gcn::Color* color1; - const gcn::Color* color2; + const Color* color1; + const Color* color2; }; class ColorModel : public gcn::ListModel @@ -67,8 +63,8 @@ class ColorModel : public gcn::ListModel size_t size() A_WARN_UNUSED { return mNames.size(); } - void add(const std::string &name, const gcn::Color *const color1, - const gcn::Color *const color2); + void add(const std::string &name, const Color *const color1, + const Color *const color2); static ColorModel *createDefault(const Widget2 *const widget); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index ad07b0ff8..f0fd500ea 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -72,8 +72,8 @@ class Desktop final : public Container, Image *mWallpaper; Label *mVersionLabel; Skin *mSkin; - gcn::Color mBackgroundColor; - gcn::Color mBackgroundGrayColor; + Color mBackgroundColor; + Color mBackgroundGrayColor; bool mShowBackground; }; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 9bb459d45..815e4a85d 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -144,8 +144,8 @@ class DropDown final : public ActionListener, void drawButton(Graphics *graphics); PopupList *mPopup; - gcn::Color mShadowColor; - gcn::Color mHighlightColor; + Color mShadowColor; + Color mHighlightColor; int mPadding; int mImagePadding; int mSpacing; diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 236415b32..1888292de 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -79,10 +79,10 @@ class DropShortcutContainer final : public ShortcutContainer bool mItemClicked; ItemPopup *mItemPopup; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; }; #endif // GUI_WIDGETS_DROPSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 96f2a9532..b2c7c5620 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -188,7 +188,7 @@ private: /** * Holds the background color of the table. */ - gcn::Color mHighlightColor; + Color mHighlightColor; int mSelectedRow; int mSelectedColumn; diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index ab813b08f..32daa459b 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -181,10 +181,10 @@ class ItemContainer final : public gcn::Widget, ItemPopup *mItemPopup; int *mShowMatrix; Skin *mSkin; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; typedef std::list SelectionListenerList; typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index dd95851a6..07c3ef822 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -83,10 +83,10 @@ class ItemShortcutContainer final : public ShortcutContainer ItemPopup *mItemPopup; SpellPopup *mSpellPopup; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; }; #endif // GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 0c19d03c3..c02f37adb 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -114,14 +114,14 @@ void Label::adjustSize() setHeight(font->getHeight() + pad2); } -void Label::setForegroundColor(const gcn::Color &color) +void Label::setForegroundColor(const Color &color) { mForegroundColor = color; mForegroundColor2 = color; } -void Label::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void Label::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index b63c9b10e..616f6cc79 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -62,10 +62,10 @@ class Label final : public gcn::Label void adjustSize(); - void setForegroundColor(const gcn::Color &color); + void setForegroundColor(const Color &color); - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); void resizeTo(const int maxSize, const int minSize); diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 625f21085..61e1596f7 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_LISTBOX_H #define GUI_WIDGETS_LISTBOX_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include "gui/base/widgets/listbox.hpp" @@ -115,9 +115,9 @@ class ListBox : public gcn::ListBox { mRowHeight = n; } protected: - gcn::Color mHighlightColor; - gcn::Color mForegroundSelectedColor; - gcn::Color mForegroundSelectedColor2; + Color mHighlightColor; + Color mForegroundSelectedColor; + Color mForegroundSelectedColor2; int mOldSelected; int mPadding; int mPressedIndex; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index b44b6a1a0..7d2d00ad4 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -184,7 +184,7 @@ void ProgressBar::setProgressPalette(const int progressPalette) } } -void ProgressBar::setBackgroundColor(const gcn::Color &color) +void ProgressBar::setBackgroundColor(const Color &color) { mRedraw = true; mBackgroundColorToGo = color; @@ -193,7 +193,7 @@ void ProgressBar::setBackgroundColor(const gcn::Color &color) mBackgroundColor = color; } -void ProgressBar::setColor(const gcn::Color &color1, const gcn::Color &color2) +void ProgressBar::setColor(const Color &color1, const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; @@ -269,7 +269,7 @@ void ProgressBar::render(Graphics *graphics) // The label if (!mText.empty()) { - const gcn::Color oldColor = graphics->getColor(); + const Color oldColor = graphics->getColor(); Font *const font = gui->getFont(); const int textX = mDimension.width / 2; diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index a2c55e077..a4862882e 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -93,14 +93,14 @@ class ProgressBar final : public gcn::Widget, /** * Change the color of the progress bar. */ - void setBackgroundColor(const gcn::Color &color); + void setBackgroundColor(const Color &color); - void setColor(const gcn::Color &color1, const gcn::Color &color2); + void setColor(const Color &color1, const Color &color2); /** * Returns the color of the progress bar. */ - const gcn::Color &getBackgroundColor() const A_WARN_UNUSED + const Color &getBackgroundColor() const A_WARN_UNUSED { return mBackgroundColor; } /** @@ -145,7 +145,7 @@ class ProgressBar final : public gcn::Widget, float mProgress; float mProgressToGo; - gcn::Color mBackgroundColorToGo; + Color mBackgroundColorToGo; std::string mText; ImageCollection *mVertexes; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 85ff90261..59ae1059e 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -106,8 +106,8 @@ void ShopListBox::draw(Graphics *graphics) ++i, y += mRowHeight) { bool needDraw(false); - gcn::Color temp; - gcn::Color* backgroundColor = &mBackgroundColor; + Color temp; + Color* backgroundColor = &mBackgroundColor; ShopItem *const item = mShopItems->at(i); if (item && ((mShopItems && mPlayerMoney < item->getPrice() diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 1cf628cca..38e209c33 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -94,8 +94,8 @@ class ShopListBox final : public ListBox ItemPopup *mItemPopup; - gcn::Color mBackgroundColor; - gcn::Color mWarningColor; + Color mBackgroundColor; + Color mWarningColor; bool mPriceCheck; bool mProtectItems; diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h index a201f3274..f9baec6cc 100644 --- a/src/gui/widgets/skillinfo.h +++ b/src/gui/widgets/skillinfo.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_SKILLINFO_H #define GUI_WIDGETS_SKILLINFO_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include #include @@ -43,7 +43,7 @@ struct SkillInfo final std::string skillLevel; std::string skillExp; float progress; - gcn::Color color; + Color color; SkillDataMap dataMap; SkillModel *model; SkillData *data; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 9e78133f5..61219fa98 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -253,7 +253,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) mSelected = mColorBox->getSelected(); const int type = userPalette->getColorTypeAt(mSelected); - const gcn::Color *col = &userPalette->getColor(type); + const Color *col = &userPalette->getColor(type); const Palette::GradientType grad = userPalette->getGradientType(type); const int delay = userPalette->getGradientDelay(type); @@ -383,7 +383,7 @@ void Setup_Colors::cancel() userPalette->rollback(); const int type = userPalette->getColorTypeAt(mSelected); - const gcn::Color *const col = &userPalette->getColor(type); + const Color *const col = &userPalette->getColor(type); mGradTypeSlider->setValue2(userPalette->getGradientType(type)); const int delay = userPalette->getGradientDelay(type); setEntry(mGradDelaySlider, mGradDelayText, delay); @@ -444,7 +444,7 @@ void Setup_Colors::updateColor() } else if (grad == Palette::PULSE) { - userPalette->setTestColor(type, gcn::Color( + userPalette->setTestColor(type, Color( static_cast(mRedSlider->getValue()), static_cast(mGreenSlider->getValue()), static_cast(mBlueSlider->getValue()))); diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 463a6b668..1f52cde88 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -114,8 +114,8 @@ class Tab : public gcn::BasicContainer, /** * Set the normal color for the tab's text. */ - void setTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setTabColor(const Color *const color1, + const Color *const color2) { mTabColor = color1; mTabOutlineColor = color2; @@ -124,8 +124,8 @@ class Tab : public gcn::BasicContainer, /** * Set the highlighted color for the tab's text. */ - void setHighlightedTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setHighlightedTabColor(const Color *const color1, + const Color *const color2) { mTabHighlightedColor = color1; mTabHighlightedOutlineColor = color2; @@ -134,8 +134,8 @@ class Tab : public gcn::BasicContainer, /** * Set the selected color for the tab's text. */ - void setSelectedTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setSelectedTabColor(const Color *const color1, + const Color *const color2) { mTabSelectedColor = color1; mTabSelectedOutlineColor = color2; @@ -144,8 +144,8 @@ class Tab : public gcn::BasicContainer, /** * Set the flash color for the tab's text. */ - void setFlashTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setFlashTabColor(const Color *const color1, + const Color *const color2) { mFlashColor = color1; mFlashOutlineColor = color2; @@ -154,8 +154,8 @@ class Tab : public gcn::BasicContainer, /** * Set the player flash color for the tab's text. */ - void setPlayerFlashTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setPlayerFlashTabColor(const Color *const color1, + const Color *const color2) { mPlayerFlashColor = color1; mPlayerFlashOutlineColor = color2; @@ -214,16 +214,16 @@ class Tab : public gcn::BasicContainer, static int mInstances; /**< Number of tab instances */ static float mAlpha; - const gcn::Color *mTabColor; - const gcn::Color *mTabOutlineColor; - const gcn::Color *mTabHighlightedColor; - const gcn::Color *mTabHighlightedOutlineColor; - const gcn::Color *mTabSelectedColor; - const gcn::Color *mTabSelectedOutlineColor; - const gcn::Color *mFlashColor; - const gcn::Color *mFlashOutlineColor; - const gcn::Color *mPlayerFlashColor; - const gcn::Color *mPlayerFlashOutlineColor; + const Color *mTabColor; + const Color *mTabOutlineColor; + const Color *mTabHighlightedColor; + const Color *mTabHighlightedOutlineColor; + const Color *mTabSelectedColor; + const Color *mTabSelectedOutlineColor; + const Color *mFlashColor; + const Color *mFlashOutlineColor; + const Color *mPlayerFlashColor; + const Color *mPlayerFlashOutlineColor; int mFlash; ImageCollection *mVertexes; Image *mImage; diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index ec0d09a26..e0327e670 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -379,14 +379,14 @@ void TextBox::draw(Graphics* graphics) BLOCK_END("TextBox::draw") } -void TextBox::setForegroundColor(const gcn::Color &color) +void TextBox::setForegroundColor(const Color &color) { mForegroundColor = color; mForegroundColor2 = color; } -void TextBox::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void TextBox::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 24dd57adb..3f78fd247 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -61,10 +61,10 @@ class TextBox final : public gcn::TextBox void draw(Graphics* graphics) override final; - void setForegroundColor(const gcn::Color &color); + void setForegroundColor(const Color &color); - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); private: int mMinWidth; diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index b05a498dc..ccc1b16d6 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -159,7 +159,7 @@ class TextField : public gcn::TextField, static Skin *mSkin; private: - const gcn::Color *mCaretColor; + const Color *mCaretColor; PopupMenu *mPopupMenu; static int instances; static float mAlpha; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 1344c647a..462ba17d9 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -89,7 +89,7 @@ void TextPreview::draw(Graphics* graphics) if (mOpaque) { - graphics->setColor(gcn::Color(static_cast(mBGColor->r), + graphics->setColor(Color(static_cast(mBGColor->r), static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0F))); @@ -105,7 +105,7 @@ void TextPreview::draw(Graphics* graphics) + 2 * ((mOutline || mShadow) ? 1 :0); const int y = mFont->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); - graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), + graphics->setColor(Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), intAlpha)); @@ -113,9 +113,9 @@ void TextPreview::draw(Graphics* graphics) } } - graphics->setColorAll(gcn::Color(mTextColor->r, + graphics->setColorAll(Color(mTextColor->r, mTextColor->g, mTextColor->b, alpha), - gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); + Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); if (mOutline && mTextColor != mTextColor2) graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE)); diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 31f64f545..31768fa66 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -40,10 +40,10 @@ class TextPreview final : public gcn::Widget ~TextPreview(); - inline void setTextColor(const gcn::Color *color) + inline void setTextColor(const Color *color) { mTextColor = color; adjustSize(); } - inline void setTextColor2(const gcn::Color *color) + inline void setTextColor2(const Color *color) { mTextColor2 = color; adjustSize(); } /** @@ -60,7 +60,7 @@ class TextPreview final : public gcn::Widget * * @param color the color to set */ - inline void setTextBGColor(const gcn::Color *color) + inline void setTextBGColor(const Color *color) { mTextBGColor = color; } /** @@ -68,7 +68,7 @@ class TextPreview final : public gcn::Widget * * @param color the color to set */ - inline void setBGColor(const gcn::Color *color) + inline void setBGColor(const Color *color) { mBGColor = color; } /** @@ -123,10 +123,10 @@ class TextPreview final : public gcn::Widget private: Font *mFont; std::string mText; - const gcn::Color *mTextColor; - const gcn::Color *mTextColor2; - const gcn::Color *mBGColor; - const gcn::Color *mTextBGColor; + const Color *mTextColor; + const Color *mTextColor2; + const Color *mBGColor; + const Color *mTextBGColor; int mPadding; static int instances; static float mAlpha; diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index c6317702f..ff565815f 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -32,16 +32,16 @@ class Widget2 { } - inline const gcn::Color &getThemeColor(const int type, - const int alpha = 255) - const A_WARN_UNUSED + inline const Color &getThemeColor(const int type, + const int alpha = 255) + const A_WARN_UNUSED { return Theme::getThemeColor(mPaletteOffset + type, alpha); } - inline const gcn::Color &getThemeCharColor(const signed char c, - bool &valid) - const A_WARN_UNUSED + inline const Color &getThemeCharColor(const signed char c, + bool &valid) + const A_WARN_UNUSED { const int colorId = Theme::getThemeIdByChar(c, valid); if (valid) @@ -71,7 +71,7 @@ class Widget2 } } - void setForegroundColor2(const gcn::Color &color) + void setForegroundColor2(const Color &color) { mForegroundColor2 = color; } @@ -85,7 +85,7 @@ class Widget2 } int mPaletteOffset; - gcn::Color mForegroundColor2; + Color mForegroundColor2; }; extern RenderType openGLMode; diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index c9ca12bbd..0ab4ca462 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -136,10 +136,10 @@ class EquipmentWindow final : public Window, ImageSet *mImageSet; Being *mBeing; std::vector mBoxes; - gcn::Color mHighlightColor; - gcn::Color mBorderColor; - gcn::Color mLabelsColor; - gcn::Color mLabelsColor2; + Color mHighlightColor; + Color mBorderColor; + Color mLabelsColor; + Color mLabelsColor2; Image *mSlotBackground; Image *mSlotHighlightedBackground; ImageCollection *mVertexes; diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 909b84a41..55948f834 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -115,8 +115,8 @@ class OutfitWindow final : public Window, int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT]; int mAwayOutfit; - gcn::Color mBorderColor; - gcn::Color mBackgroundColor; + Color mBorderColor; + Color mBackgroundColor; unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT]; bool mItemClicked; bool mItemsUnequip[OUTFITS_COUNT]; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index a06257b10..cbab4710d 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -236,8 +236,8 @@ public: return 2 * getFont()->getHeight() + 5; } private: - gcn::Color mNotSupportedColor; - gcn::Color mNotSupportedColor2; + Color mNotSupportedColor; + Color mNotSupportedColor2; }; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 9cc952ec6..2e9a8be10 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -231,8 +231,8 @@ class SkillListBox final : public ListBox private: SkillModel *mModel; TextPopup *mPopup; - gcn::Color mTextColor; - gcn::Color mTextColor2; + Color mTextColor; + Color mTextColor2; int mTextPadding; int mSpacing; bool mSkillClicked; diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 83ec97521..c446fa177 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -414,7 +414,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, Particle *Particle::addTextSplashEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) { @@ -438,7 +438,7 @@ Particle *Particle::addTextSplashEffect(const std::string &text, Particle *Particle::addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) { diff --git a/src/particle/particle.h b/src/particle/particle.h index f69770513..491232b17 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -30,16 +30,11 @@ #include #include +class Color; +class Font; class Particle; class ParticleEmitter; -namespace gcn -{ - class Color; -} - -class Font; - typedef std::list Particles; typedef Particles::iterator ParticleIterator; typedef Particles::const_iterator ParticleConstIterator; @@ -136,7 +131,7 @@ class Particle : public Actor */ Particle *addTextSplashEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); @@ -145,7 +140,7 @@ class Particle : public Actor */ Particle *addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index 1ac6ac6c2..41ea683f6 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -26,13 +26,13 @@ #include "gui/theme.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #include "gui/font.h" #include "debug.h" TextParticle::TextParticle(const std::string &text, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) : Particle(), mText(text), @@ -74,7 +74,7 @@ void TextParticle::draw(Graphics *const graphics, / static_cast(mFadeIn); } - gcn::Color color = *mColor; + Color color = *mColor; color.a = static_cast(alpha); graphics->setColor(color); diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h index 0d598508d..ec586c3a9 100644 --- a/src/particle/textparticle.h +++ b/src/particle/textparticle.h @@ -32,7 +32,7 @@ class TextParticle final : public Particle * Constructor. */ TextParticle(const std::string &text, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); A_DELETE_COPY(TextParticle) @@ -54,7 +54,7 @@ class TextParticle final : public Particle private: std::string mText; /**< Text of the particle. */ Font *mTextFont; /**< Font used for drawing the text. */ - const gcn::Color *mColor; /**< Color used for drawing the text. */ + const Color *mColor; /**< Color used for drawing the text. */ int mTextWidth; bool mOutline; /**< Make the text better readable */ }; diff --git a/src/render/graphics.h b/src/render/graphics.h index 53eb4af12..2356d2d31 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -70,10 +70,11 @@ #include "sdlshared.h" +#include "gui/color.h" + #include "render/renderers.h" #include "gui/base/cliprectangle.hpp" -#include "gui/base/color.hpp" #ifdef USE_SDL2 #include @@ -331,27 +332,27 @@ class Graphics virtual void initArrays() { } - virtual void setColor(const gcn::Color &color) + virtual void setColor(const Color &color) { mColor = color; mColor2 = color; mAlpha = (color.a != 255); } - void setColor2(const gcn::Color &color) + void setColor2(const Color &color) { mColor2 = color; } - void setColorAll(const gcn::Color &color, const gcn::Color &color2) + void setColorAll(const Color &color, const Color &color2) { mColor = color; mColor2 = color2; mAlpha = (color.a != 255); } - const gcn::Color &getColor() const + const Color &getColor() const { return mColor; } - const gcn::Color &getColor2() const + const Color &getColor2() const { return mColor2; } #ifdef DEBUG_DRAW_CALLS @@ -534,8 +535,8 @@ class Graphics int mStartFreeMem; bool mSync; int mScale; - gcn::Color mColor; - gcn::Color mColor2; + Color mColor; + Color mColor2; }; extern Graphics *mainGraphics; diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index f665f743b..0b9cd83e2 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -127,7 +127,7 @@ class MobileOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; GLuint mImageCached; float mFloatColor; int mMaxVertices; diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 882ff5ed8..214954e3c 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -143,7 +143,7 @@ class NormalOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; GLuint mImageCached; float mFloatColor; int mMaxVertices; diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index cbab0614d..ee2a5d189 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -130,7 +130,7 @@ class NullOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; float mFloatColor; int mMaxVertices; bool mColorAlpha; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 89f8e63a9..99bf8e82a 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -92,14 +92,14 @@ void popClipArea() override final; - void setColor(const gcn::Color &color) override final + void setColor(const Color &color) override final { mColor = color; mColor2 = color; mColorAlpha = (color.a != 255); } - void setColorAll(const gcn::Color &color, const gcn::Color &color2) + void setColorAll(const Color &color, const Color &color2) { mColor = color; mColor2 = color2; diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index 28d61b59a..fbb156c6c 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -90,7 +90,7 @@ class SafeOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; float mFloatColor; bool mColorAlpha; FBOInfo mFbo; diff --git a/src/text.cpp b/src/text.cpp index dfc127598..27d794d33 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -39,7 +39,7 @@ ImageRect Text::mBubble; Text::Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, const bool isSpeech, + const Color *const color, const bool isSpeech, Font *const font) : mFont(font ? font : (gui ? gui->getFont() : nullptr)), mX(x), @@ -112,7 +112,7 @@ Text::~Text() } } -void Text::setColor(const gcn::Color *const color) +void Text::setColor(const Color *const color) { mColor = color; } @@ -152,7 +152,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) FlashText::FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, Font *const font) : + const Color *const color, Font *const font) : Text(text, x, y, alignment, color, false, font), mTime(0) { diff --git a/src/text.h b/src/text.h index cade9db18..497792091 100644 --- a/src/text.h +++ b/src/text.h @@ -26,7 +26,7 @@ #include "render/graphics.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #include "localconsts.h" @@ -42,7 +42,7 @@ class Text */ Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, const bool isSpeech = false, + const Color *const color, const bool isSpeech = false, Font *const font = nullptr); A_DELETE_COPY(Text) @@ -52,7 +52,7 @@ class Text */ virtual ~Text(); - void setColor(const gcn::Color *const color); + void setColor(const Color *const color); int getWidth() const A_WARN_UNUSED { return mWidth; } @@ -80,8 +80,8 @@ class Text int mXOffset; /**< The offset of mX from the desired x. */ static int mInstances; /**< Instances of text. */ std::string mText; /**< The text to display. */ - const gcn::Color *mColor; /**< The color of the text. */ - const gcn::Color mOutlineColor; + const Color *mColor; /**< The color of the text. */ + const Color mOutlineColor; bool mIsSpeech; /**< Is this text a speech bubble? */ protected: @@ -93,7 +93,7 @@ class FlashText final : public Text public: FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, + const Color *const color, Font *const font = nullptr); A_DELETE_COPY(FlashText) diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index a01858831..282b90afb 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -64,8 +64,9 @@ #ifndef UTILS_SDLPIXEL_H #define UTILS_SDLPIXEL_H +#include "gui/color.h" + #include "SDL.h" -#include "gui/base/color.hpp" /** * Puts a pixel on an SDL_Surface. @@ -75,7 +76,7 @@ * @param color the color the pixel should be in. */ inline void SDLputPixel(SDL_Surface* surface, int x, int y, - const gcn::Color& color) + const Color& color) { if (!surface) return; @@ -175,7 +176,7 @@ inline unsigned short SDLAlpha16(const unsigned short src, * @param color the color the pixel should be in. */ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, - const gcn::Color& color) + const Color& color) { const int bpp = surface->format->BytesPerPixel; -- cgit v1.2.3-70-g09d2 From 4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 15:43:12 +0300 Subject: Move Widget into gui/widgets directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/events/actionevent.h | 7 +- src/events/event.h | 11 +- src/events/inputguievent.h | 2 +- src/events/keyevent.h | 7 +- src/events/mouseevent.h | 5 +- src/events/selectionevent.h | 7 +- src/gui/base/basiccontainer.hpp | 2 +- src/gui/base/gui.cpp | 2 +- src/gui/base/gui.hpp | 3 +- src/gui/base/widget.cpp | 679 ---------------- src/gui/base/widget.hpp | 1231 ------------------------------ src/gui/base/widgets/button.cpp | 4 +- src/gui/base/widgets/button.hpp | 2 +- src/gui/base/widgets/checkbox.cpp | 4 +- src/gui/base/widgets/checkbox.hpp | 2 +- src/gui/base/widgets/label.cpp | 4 +- src/gui/base/widgets/label.hpp | 2 +- src/gui/base/widgets/listbox.cpp | 4 +- src/gui/base/widgets/listbox.hpp | 2 +- src/gui/base/widgets/radiobutton.cpp | 4 +- src/gui/base/widgets/radiobutton.hpp | 2 +- src/gui/base/widgets/slider.cpp | 4 +- src/gui/base/widgets/slider.hpp | 2 +- src/gui/base/widgets/textbox.cpp | 4 +- src/gui/base/widgets/textbox.hpp | 2 +- src/gui/base/widgets/textfield.cpp | 4 +- src/gui/base/widgets/textfield.hpp | 2 +- src/gui/focushandler.cpp | 56 +- src/gui/focushandler.h | 68 +- src/gui/gui.cpp | 22 +- src/gui/gui.h | 6 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/browserbox.h | 5 +- src/gui/widgets/browserbox_unittest.cc | 2 +- src/gui/widgets/container.cpp | 2 +- src/gui/widgets/container.h | 2 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 4 +- src/gui/widgets/flowcontainer.cpp | 2 +- src/gui/widgets/flowcontainer.h | 2 +- src/gui/widgets/guitable.cpp | 30 +- src/gui/widgets/guitable.h | 12 +- src/gui/widgets/horizontcontainer.cpp | 4 +- src/gui/widgets/horizontcontainer.h | 4 +- src/gui/widgets/icon.cpp | 4 +- src/gui/widgets/icon.h | 4 +- src/gui/widgets/itemcontainer.cpp | 4 +- src/gui/widgets/itemcontainer.h | 4 +- src/gui/widgets/layout.cpp | 4 +- src/gui/widgets/layout.h | 11 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/layouthelper.h | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 2 +- src/gui/widgets/popuplist.cpp | 2 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/progressindicator.cpp | 2 +- src/gui/widgets/progressindicator.h | 4 +- src/gui/widgets/radiogroup.cpp | 2 +- src/gui/widgets/radiogroup.h | 6 +- src/gui/widgets/scrollarea.cpp | 10 +- src/gui/widgets/scrollarea.h | 2 +- src/gui/widgets/setupitem.cpp | 2 +- src/gui/widgets/setupitem.h | 10 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/shortcutcontainer.h | 5 +- src/gui/widgets/tabbedarea.cpp | 34 +- src/gui/widgets/tabbedarea.h | 16 +- src/gui/widgets/tablemodel.cpp | 8 +- src/gui/widgets/tablemodel.h | 13 +- src/gui/widgets/tabs/setup_joystick.cpp | 2 +- src/gui/widgets/tabs/setup_relations.cpp | 6 +- src/gui/widgets/tabstrip.cpp | 4 +- src/gui/widgets/tabstrip.h | 6 +- src/gui/widgets/textbox.cpp | 4 +- src/gui/widgets/textpreview.cpp | 2 +- src/gui/widgets/textpreview.h | 4 +- src/gui/widgets/vertcontainer.cpp | 6 +- src/gui/widgets/vertcontainer.h | 6 +- src/gui/widgets/widget.cpp | 676 ++++++++++++++++ src/gui/widgets/widget.h | 1228 +++++++++++++++++++++++++++++ src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 2 +- src/gui/widgets/window.cpp | 6 +- src/gui/widgets/window.h | 6 +- src/gui/widgets/windowcontainer.cpp | 6 +- src/gui/widgets/windowcontainer.h | 8 +- src/gui/windows/botcheckerwindow.cpp | 8 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/socialwindow.cpp | 2 +- 96 files changed, 2185 insertions(+), 2207 deletions(-) delete mode 100644 src/gui/base/widget.cpp delete mode 100644 src/gui/base/widget.hpp create mode 100644 src/gui/widgets/widget.cpp create mode 100644 src/gui/widgets/widget.h (limited to 'src/gui/gui.h') 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 -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 -#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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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::mWidgets; - std::set 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::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)) - != 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& Widget::_getMouseListeners() - { - return mMouseListeners; - } - - const std::list& Widget::_getKeyListeners() - { - return mKeyListeners; - } - - const std::list& 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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 -#include -#include - -#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& _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& _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& _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 MouseListenerList; - - /** - * Typdef. - */ - typedef MouseListenerList::iterator MouseListenerIterator; - - /** - * Holds the mouse listeners of the widget. - */ - MouseListenerList mMouseListeners; - - /** - * Typdef. - */ - typedef std::list KeyListenerList; - - /** - * Holds the key listeners of the widget. - */ - KeyListenerList mKeyListeners; - - /** - * Typdef. - */ - typedef KeyListenerList::iterator KeyListenerIterator; - - /** - * Typdef. - */ - typedef std::list ActionListenerList; - - /** - * Holds the action listeners of the widget. - */ - ActionListenerList mActionListeners; - - /** - * Typdef. - */ - typedef ActionListenerList::iterator ActionListenerIterator; - - /** - * Typdef. - */ - typedef std::list DeathListenerList; - - /** - * Holds the death listeners of the widget. - */ - DeathListenerList mDeathListeners; - - /** - * Typdef. - */ - typedef DeathListenerList::iterator DeathListenerIterator; - - /** - * Typdef. - */ - typedef std::list FocusListenerList; - - /** - * Holds the focus listeners of the widget. - */ - FocusListenerList mFocusListeners; - - /** - * Typdef. - */ - typedef FocusListenerList::iterator FocusListenerIterator; - - typedef std::list 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 mWidgets; - - static std::set 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 -#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 -#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 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 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 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 WidgetVector; + typedef std::vector 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 mModalStack; + std::list 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 #include @@ -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 @@ -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 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 @@ -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 mTempWidgets; + std::list 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, widget)); + mTabs.push_back(std::pair(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(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(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(source); if (tab) @@ -677,7 +677,7 @@ Tab *TabbedArea::getTabByIndex(const int index) const return static_cast(mTabs[index].first); } -gcn::Widget *TabbedArea::getWidgetByIndex(const int index) const +Widget *TabbedArea::getWidgetByIndex(const int index) const { if (index < 0 || index >= static_cast(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 > TabContainer; + typedef std::vector > 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 mTableModel; + std::vector mTableModel; std::vector 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 mWidgets; + std::vector 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(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::const_iterator, it, mResizableWidgets) + FOR_EACH (std::vector::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 mResizableWidgets; + std::vector 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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::mWidgets; +std::set 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::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)) + != 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& Widget::_getMouseListeners() +{ + return mMouseListeners; +} + +const std::list& Widget::_getKeyListeners() +{ + return mKeyListeners; +} + +const std::list& 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * 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 +#include +#include + +#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& _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& _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& _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 MouseListenerList; + + /** + * Typdef. + */ + typedef MouseListenerList::iterator MouseListenerIterator; + + /** + * Holds the mouse listeners of the widget. + */ + MouseListenerList mMouseListeners; + + /** + * Typdef. + */ + typedef std::list KeyListenerList; + + /** + * Holds the key listeners of the widget. + */ + KeyListenerList mKeyListeners; + + /** + * Typdef. + */ + typedef KeyListenerList::iterator KeyListenerIterator; + + /** + * Typdef. + */ + typedef std::list ActionListenerList; + + /** + * Holds the action listeners of the widget. + */ + ActionListenerList mActionListeners; + + /** + * Typdef. + */ + typedef ActionListenerList::iterator ActionListenerIterator; + + /** + * Typdef. + */ + typedef std::list DeathListenerList; + + /** + * Holds the death listeners of the widget. + */ + DeathListenerList mDeathListeners; + + /** + * Typdef. + */ + typedef DeathListenerList::iterator DeathListenerIterator; + + /** + * Typdef. + */ + typedef std::list FocusListenerList; + + /** + * Holds the focus listeners of the widget. + */ + FocusListenerList mFocusListeners; + + /** + * Typdef. + */ + typedef FocusListenerList::iterator FocusListenerIterator; + + typedef std::list 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 mWidgets; + + static std::set 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 Widgets; + typedef std::vector 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::const_iterator it = mWidgets.begin(); + for (std::vector::const_iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) { delete *it; @@ -253,7 +253,7 @@ public: protected: std::vector mPlayers; - std::vector mWidgets; + std::vector 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( 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; -- cgit v1.2.3-70-g09d2