From 9093f12ebbfbdacb3df7a5f5fcdda422daa22754 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 00:12:40 +0300 Subject: move mouselistener from base into listeners. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/gui.cpp | 2 +- src/gui/base/mouselistener.hpp | 196 ---------------------------------- src/gui/base/widget.cpp | 2 +- src/gui/base/widget.hpp | 2 +- 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/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/scrollarea.cpp | 6 +- src/gui/base/widgets/scrollarea.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/base/widgets/window.cpp | 4 +- src/gui/base/widgets/window.hpp | 3 +- src/gui/gui.cpp | 4 +- src/gui/viewport.cpp | 2 +- src/gui/viewport.h | 4 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/browserbox.h | 4 +- src/gui/widgets/characterdisplay.cpp | 2 +- src/gui/widgets/characterdisplay.h | 2 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 7 +- src/gui/widgets/guitable.cpp | 2 +- src/gui/widgets/guitable.h | 4 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 4 +- src/gui/widgets/linkhandler.h | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 5 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/shortcutcontainer.h | 4 +- src/gui/widgets/sliderlist.cpp | 2 +- src/gui/widgets/sliderlist.h | 4 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 4 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/tabs/tab.h | 5 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 2 +- src/listeners/mouselistener.h | 193 +++++++++++++++++++++++++++++++++ 53 files changed, 271 insertions(+), 270 deletions(-) delete mode 100644 src/gui/base/mouselistener.hpp create mode 100644 src/listeners/mouselistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 324e65cac..edfdec695 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -790,7 +790,7 @@ SET(SRCS gui/base/listmodel.hpp gui/base/mouseevent.hpp gui/base/mouseinput.hpp - gui/base/mouselistener.hpp + listeners/mouselistener.h gui/base/rectangle.hpp gui/base/selectionevent.hpp gui/base/selectionlistener.hpp diff --git a/src/Makefile.am b/src/Makefile.am index da16e98d7..f6787bcff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,7 +178,7 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/listmodel.hpp \ gui/base/mouseevent.hpp \ gui/base/mouseinput.hpp \ - gui/base/mouselistener.hpp \ + listeners/mouselistener.hpp \ gui/base/rectangle.hpp \ gui/base/selectionevent.hpp \ gui/base/selectionlistener.hpp \ diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index e85a17d97..f16048bbb 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -76,7 +76,7 @@ #include "gui/base/widget.hpp" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "render/graphics.h" diff --git a/src/gui/base/mouselistener.hpp b/src/gui/base/mouselistener.hpp deleted file mode 100644 index 32486e56f..000000000 --- a/src/gui/base/mouselistener.hpp +++ /dev/null @@ -1,196 +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_MOUSELISTENER_HPP -#define GCN_MOUSELISTENER_HPP - -#include "gui/base/mouseevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for mouse events from widgets. - * - * @see Widget::addMouseListener, Widget::removeMouseListener - * @since 0.1.0 - */ - class MouseListener - { - public: - /** - * Destructor. - */ - virtual ~MouseListener() - { } - - /** - * Called when the mouse has entered into the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseEntered(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has exited the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseExited(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button has been pressed on the widget area. - * - * NOTE: A mouse press is NOT equal to a mouse click. - * Use mouseClickMessage to check for mouse clicks. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mousePressed(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button has been released on the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseReleased(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button is pressed and released (clicked) on - * the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseClicked(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse wheel has moved up on the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse wheel has moved down on the widget area. - * - * @param mousEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has moved in the widget area and no mouse button - * has been pressed (i.e no widget is being dragged). - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseMoved(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has moved and the mouse has previously been - * pressed on the widget. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseDragged(MouseEvent& mouseEvent A_UNUSED) - { - } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of MouseListener, - * therefore its constructor is protected. - */ - MouseListener() - { } - }; -} // namespace gcn - -#endif // end GCN_MOUSELISTENER_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index c72a06e8b..b05a0d5b1 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -78,7 +78,7 @@ #include "listeners/deathlistener.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 583ade076..af04714f6 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -78,6 +78,7 @@ class DeathListener; class FocusListener; class Graphics; class KeyListener; +class MouseListener; namespace gcn { @@ -86,7 +87,6 @@ namespace gcn class Font; class KeyInput; class MouseInput; - class MouseListener; class WidgetListener; /** diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 4631ed80f..7f1aea668 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -81,7 +81,7 @@ namespace gcn { Button::Button() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), FocusListener(), mCaption(), @@ -102,7 +102,7 @@ namespace gcn Button::Button(const std::string& caption) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), FocusListener(), mCaption(caption), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index 779a75aa5..c81fec14f 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -68,7 +68,7 @@ #include "listeners/focuslistener.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/mouseevent.hpp" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index ceb59a1eb..5f2477b4d 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -80,7 +80,7 @@ namespace gcn CheckBox::CheckBox() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(false), mCaption() @@ -92,7 +92,7 @@ namespace gcn CheckBox::CheckBox(const std::string &caption, bool selected) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(selected), mCaption() diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index 4904a022f..c03187bba 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -67,7 +67,7 @@ #include #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 771f22f64..3ae4caa91 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -82,7 +82,7 @@ namespace gcn { ListBox::ListBox() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(-1), mListModel(nullptr), @@ -98,7 +98,7 @@ namespace gcn ListBox::ListBox(ListModel *listModel) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(-1), mListModel(listModel), diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index 11983262f..793aba840 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -70,7 +70,7 @@ #include "gui/base/widget.hpp" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" namespace gcn { diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index f7145fd55..e42773de1 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -81,7 +81,7 @@ namespace gcn RadioButton::RadioButton() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(false), mCaption(), @@ -98,7 +98,7 @@ namespace gcn const std::string &group, bool selected) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(false), mCaption(), diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index 98b562676..8a9a8b585 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -68,7 +68,7 @@ #include #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index 308cee473..ffcaffdb1 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -77,7 +77,7 @@ namespace gcn { ScrollArea::ScrollArea() : gcn::BasicContainer(), - gcn::MouseListener(), + MouseListener(), mVScroll(0), mHScroll(0), mScrollbarWidth(12), @@ -104,7 +104,7 @@ namespace gcn ScrollArea::ScrollArea(Widget *const content) : gcn::BasicContainer(), - gcn::MouseListener(), + MouseListener(), mVScroll(0), mHScroll(0), mScrollbarWidth(12), @@ -134,7 +134,7 @@ namespace gcn ScrollPolicy hPolicy, ScrollPolicy vPolicy) : gcn::BasicContainer(), - gcn::MouseListener(), + MouseListener(), mVScroll(0), mHScroll(0), mScrollbarWidth(12), diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp index e75390ec0..1d4c0dd54 100644 --- a/src/gui/base/widgets/scrollarea.hpp +++ b/src/gui/base/widgets/scrollarea.hpp @@ -67,7 +67,7 @@ #include #include "gui/base/basiccontainer.hpp" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" namespace gcn { diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index 2a3fb8c24..91c054e7d 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -78,7 +78,7 @@ namespace gcn { Slider::Slider(const double scaleEnd) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mDragged(false), mValue(0), @@ -97,7 +97,7 @@ namespace gcn Slider::Slider(const double scaleStart, const double scaleEnd) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mDragged(false), mValue(scaleStart), diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp index fa047a739..f77d3f5dd 100644 --- a/src/gui/base/widgets/slider.hpp +++ b/src/gui/base/widgets/slider.hpp @@ -65,7 +65,7 @@ #define GCN_SLIDER_HPP #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index c146c4f08..06d0e6379 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -80,7 +80,7 @@ namespace gcn { TextBox::TextBox() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mTextRows(), mCaretColumn(0), @@ -98,7 +98,7 @@ namespace gcn TextBox::TextBox(const std::string& text) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mTextRows(), mCaretColumn(0), diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 894616360..8fc788816 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -69,7 +69,7 @@ #include #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 178a012b7..df1b844d4 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -79,7 +79,7 @@ namespace gcn { TextField::TextField() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mText(), mCaretPosition(0), @@ -93,7 +93,7 @@ namespace gcn TextField::TextField(const std::string& text) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mText(text), mCaretPosition(0), diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp index 56d60b7aa..099ed1356 100644 --- a/src/gui/base/widgets/textfield.hpp +++ b/src/gui/base/widgets/textfield.hpp @@ -65,7 +65,7 @@ #define GCN_TEXTFIELD_HPP #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 6373bcb63..02611f819 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -79,7 +79,7 @@ namespace gcn { Window::Window() : Container(), - gcn::MouseListener(), + MouseListener(), mCaption(), mAlignment(Graphics::CENTER), mPadding(2), @@ -96,7 +96,7 @@ namespace gcn Window::Window(const std::string& caption) : Container(), - gcn::MouseListener(), + MouseListener(), mCaption(caption), mAlignment(Graphics::CENTER), mPadding(2), diff --git a/src/gui/base/widgets/window.hpp b/src/gui/base/widgets/window.hpp index 9c7e6bcbf..030d57edc 100644 --- a/src/gui/base/widgets/window.hpp +++ b/src/gui/base/widgets/window.hpp @@ -66,7 +66,8 @@ #include -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" + #include "gui/base/widgets/container.hpp" namespace gcn diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a398ca427..bced937c7 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -697,11 +697,11 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, mouseEvent.setX(x - widgetX); mouseEvent.setY(y - widgetY); - std::list mouseListeners + std::list mouseListeners = widget->_getMouseListeners(); // Send the event to all mouse listeners of the widget. - for (std::list::const_iterator + for (std::list::const_iterator it = mouseListeners.begin(); it != mouseListeners.end(); ++ it) { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 2a91d1991..b3cafa104 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -51,7 +51,7 @@ extern MiniStatusWindow *miniStatusWindow; Viewport::Viewport() : WindowContainer(nullptr), - gcn::MouseListener(), + MouseListener(), mMap(nullptr), mScrollRadius(config.getIntValue("ScrollRadius")), mScrollLaziness(config.getIntValue("ScrollLaziness")), diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 9adaa6c18..6fd062c35 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -29,7 +29,7 @@ #include "gui/widgets/windowcontainer.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" class ActorSprite; class Button; @@ -60,7 +60,7 @@ const int walkingMouseDelay = 500; * coordinates. */ class Viewport final : public WindowContainer, - public gcn::MouseListener, + public MouseListener, public ConfigListener { public: diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 024dde9c8..cfbc0ec41 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -55,7 +55,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const std::string &skin) : gcn::Widget(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), mTextRows(), mTextRowLinksCount(), mLineParts(), diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 85ce9b96b..fa3b90963 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" #include @@ -104,7 +104,7 @@ class LinePart final */ class BrowserBox final : public gcn::Widget, public Widget2, - public gcn::MouseListener + public MouseListener { public: /** diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 5ae4e2f5b..54cb3b28d 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -40,7 +40,7 @@ CharacterDisplay::CharacterDisplay(const Widget2 *const widget, CharSelectDialog *const charSelectDialog) : Container(widget), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mCharacter(nullptr), mPlayerBox(new PlayerBox(nullptr)), diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index ebb0d46da..0352a91a0 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -38,7 +38,7 @@ class Label; class TextPopup; class CharacterDisplay final : public Container, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index e4e38aa90..efb3235a4 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -59,7 +59,7 @@ DropDown::DropDown(const Widget2 *const widget, ActionListener(), gcn::BasicContainer(), KeyListener(), - gcn::MouseListener(), + MouseListener(), FocusListener(), gcn::SelectionListener(), Widget2(widget), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 525ce83e3..7d645a478 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -31,7 +31,7 @@ #include "listeners/actionlistener.h" #include "listeners/focuslistener.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/selectionlistener.hpp" #include "localconsts.h" @@ -53,7 +53,7 @@ class Skin; class DropDown final : public ActionListener, public gcn::BasicContainer, public KeyListener, - public gcn::MouseListener, + public MouseListener, public FocusListener, public gcn::SelectionListener, public Widget2 diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 6101c20ae..c086cd463 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -36,7 +36,7 @@ namespace EmotePage::EmotePage(const Widget2 *const widget) : gcn::Widget(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mEmotes(ResourceManager::getInstance()->getImageSet( "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)), diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 9cd2867aa..c773d9a66 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -23,15 +23,16 @@ #include "gui/widgets/widget2.h" -#include "gui/base/mouselistener.hpp" -#include "gui/base/widget.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" +#include "gui/base/widget.hpp" + #include "localconsts.h" class EmotePage final : public gcn::Widget, public Widget2, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index fff2416bf..3d987ed63 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -96,7 +96,7 @@ GuiTable::GuiTable(const Widget2 *const widget, TableModel *const initial_model, const bool opacity) : gcn::Widget(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), KeyListener(), mModel(nullptr), mTopWidget(nullptr), diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 8d551de2b..a751cac59 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -29,7 +29,7 @@ #include "gui/widgets/widget2.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" @@ -48,7 +48,7 @@ class GuiTableActionListener; */ class GuiTable final : public gcn::Widget, public Widget2, - public gcn::MouseListener, + public MouseListener, public KeyListener, public TableModelListener { diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 4fa8a2705..40c87d272 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -161,7 +161,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget, gcn::Widget(), Widget2(widget), KeyListener(), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mInventory(inventory), mSelImg(Theme::getImageFromThemeXml("item_selection.xml", "")), diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 7757fa65c..77d7e1c28 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "gui/base/widget.hpp" @@ -53,7 +53,7 @@ namespace gcn class ItemContainer final : public gcn::Widget, public Widget2, public KeyListener, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h index f79f1bf50..2f3a6e53f 100644 --- a/src/gui/widgets/linkhandler.h +++ b/src/gui/widgets/linkhandler.h @@ -25,7 +25,7 @@ #include -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" /** * A simple interface to windows that need to handle links from BrowserBox diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index c1319737e..a4908c23b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -34,7 +34,7 @@ Popup::Popup(const std::string &name, std::string skin) : Container(nullptr), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mPadding(3), mSkin(nullptr), diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index f0fd1b932..d09331136 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -26,7 +26,7 @@ #include "gui/widgets/container.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" class ImageCollection; @@ -45,7 +45,8 @@ class WindowContainer; * * \ingroup GUI */ -class Popup : public Container, public gcn::MouseListener, +class Popup : public Container, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index a3030b035..dcb7d1138 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -32,7 +32,7 @@ ShortcutContainer::ShortcutContainer() : gcn::Widget(), Widget2(), gcn::WidgetListener(), - gcn::MouseListener(), + MouseListener(), mBackgroundImg(nullptr), mMaxItems(0), mBoxWidth(1), diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 4d4ff2389..1d734de6a 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" #include "gui/base/widgetlistener.hpp" @@ -40,7 +40,7 @@ class ImageCollection; class ShortcutContainer : public gcn::Widget, public Widget2, public gcn::WidgetListener, - public gcn::MouseListener + public MouseListener { public: A_DELETE_COPY(ShortcutContainer) diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 0ae0890dc..d70977ff3 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -37,7 +37,7 @@ SliderList::SliderList(const Widget2 *const widget, gcn::ListModel *const listModel) : Container(widget), ActionListener(), - gcn::MouseListener(), + MouseListener(), mLabel(new Label(this)), mListModel(listModel), mPrevEventId(), diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 3d86f8735..144fa0cf1 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -22,9 +22,9 @@ #define GUI_WIDGETS_SLIDERLIST_H #include "gui/base/listmodel.hpp" -#include "gui/base/mouselistener.hpp" #include "listeners/actionlistener.h" +#include "listeners/mouselistener.h" #include "gui/widgets/container.h" @@ -35,7 +35,7 @@ class Label; class SliderList final : public Container, public ActionListener, - public gcn::MouseListener + public MouseListener { public: SliderList(const Widget2 *const widget, diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 8841560e2..2c431c452 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -38,7 +38,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : ActionListener(), gcn::BasicContainer(), KeyListener(), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mSelectedTab(nullptr), mTabContainer(new gcn::Container()), diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 03a9f6868..b8b075ade 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "gui/base/widgets/container.hpp" @@ -44,7 +44,7 @@ class TabbedArea final : public Widget2, public ActionListener, public gcn::BasicContainer, public KeyListener, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index bba1ef7b6..877329cf8 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -46,7 +46,7 @@ Skin *Tab::tabImg[Tab::TAB_COUNT]; Tab::Tab(const Widget2 *const widget) : gcn::BasicContainer(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mLabel(new Label(this)), mTabbedArea(nullptr), diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 66f7521d9..a67025842 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -26,7 +26,8 @@ #include "gui/widgets/widget2.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/mouselistener.hpp" + +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "localconsts.h" @@ -41,7 +42,7 @@ class TabbedArea; */ class Tab : public gcn::BasicContainer, public Widget2, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 3ef3e73ce..aeef201e7 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -46,7 +46,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : Container(widget), ActionListener(), gcn::SelectionListener(), - gcn::MouseListener(), + MouseListener(), mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "") : nullptr), mPadding(mSkin ? mSkin->getPadding() : 1), diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index d7e16e7fa..0b613fce9 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -79,7 +79,7 @@ class WindowMenu final : public Container, public ConfigListener, public ActionListener, public gcn::SelectionListener, - public gcn::MouseListener + public MouseListener { public: explicit WindowMenu(const Widget2 *const widget); diff --git a/src/listeners/mouselistener.h b/src/listeners/mouselistener.h new file mode 100644 index 000000000..e95d2ca01 --- /dev/null +++ b/src/listeners/mouselistener.h @@ -0,0 +1,193 @@ +/* + * 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_MOUSELISTENER_HPP +#define GCN_MOUSELISTENER_HPP + +#include "gui/base/mouseevent.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for mouse events from widgets. + * + * @see Widget::addMouseListener, Widget::removeMouseListener + * @since 0.1.0 + */ +class MouseListener +{ + public: + /** + * Destructor. + */ + virtual ~MouseListener() + { } + + /** + * Called when the mouse has entered into the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseEntered(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has exited the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseExited(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button has been pressed on the widget area. + * + * NOTE: A mouse press is NOT equal to a mouse click. + * Use mouseClickMessage to check for mouse clicks. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mousePressed(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button has been released on the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseReleased(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button is pressed and released (clicked) on + * the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseClicked(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse wheel has moved up on the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseWheelMovedUp(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse wheel has moved down on the widget area. + * + * @param mousEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has moved in the widget area and no mouse button + * has been pressed (i.e no widget is being dragged). + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseMoved(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has moved and the mouse has previously been + * pressed on the widget. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseDragged(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of MouseListener, + * therefore its constructor is protected. + */ + MouseListener() + { } +}; + +#endif // end GCN_MOUSELISTENER_HPP -- cgit v1.2.3-70-g09d2