diff options
57 files changed, 200 insertions, 373 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c82f792b..1714b01c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -667,8 +667,6 @@ SET(SRCS input/keyboardconfig.h input/keyboarddata.h input/keydata.h - input/keyevent.cpp - input/keyevent.h input/keyinput.cpp input/keyinput.h input/multitouchmanager.cpp @@ -784,7 +782,7 @@ SET(SRCS gui/base/input.hpp events/inputguievent.h gui/base/key.hpp - gui/base/keyevent.hpp + events/keyevent.h gui/base/keyinput.hpp listeners/keylistener.h gui/base/listmodel.hpp @@ -816,7 +814,6 @@ SET(SRCS gui/base/font.cpp gui/base/gui.cpp gui/base/key.cpp - gui/base/keyevent.cpp gui/base/keyinput.cpp gui/base/mouseevent.cpp gui/base/mouseinput.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 94a671dfc..268344f2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -202,7 +202,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/font.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ - gui/base/keyevent.cpp \ gui/base/keyinput.cpp \ gui/base/mouseevent.cpp \ gui/base/mouseinput.cpp \ @@ -787,8 +786,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ input/keyboardconfig.h \ input/keyboarddata.h \ input/keydata.h \ - input/keyevent.cpp \ - input/keyevent.h \ input/keyinput.cpp \ input/keyinput.h \ input/multitouchmanager.cpp \ diff --git a/src/gui/base/keyevent.hpp b/src/events/keyevent.h index dd2b5f296..ec5b5489a 100644 --- a/src/gui/base/keyevent.hpp +++ b/src/events/keyevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_KEYEVENT_HPP -#define GCN_KEYEVENT_HPP +#ifndef EVENTS_KEYEVENT_HPP +#define EVENTS_KEYEVENT_HPP #include "events/inputguievent.h" #include "gui/base/key.hpp" @@ -70,16 +70,17 @@ namespace gcn { class Widget; +} - /** - * Represents a key event. - */ - class KeyEvent: public InputGuiEvent - { +/** + * Represents a key event. + */ +class KeyEvent: public InputGuiEvent +{ public: /** - * Key event types. - */ + * Key event types. + */ enum { PRESSED = 0, @@ -87,71 +88,105 @@ namespace gcn }; /** - * Constructor. - * - * @param source The source widget of the event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. - * @param type The type of the event. A value from KeyEventType. - * @param numericPad True if the event occured on the numeric pad, - * false otherwise. - * @param key The key of the event. - */ - KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const Key& key); + * Constructor. + * + * @param source The source widget of the event. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. + * @param type The type of the event. A value from KeyEventType. + * @param numericPad True if the event occured on the numeric pad, + * false otherwise. + * @param key The key of the event. + */ + KeyEvent(gcn::Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const int actionId, + const gcn::Key &key) : + InputGuiEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), + mKey(key), +#ifdef USE_SDL2 + mText(), +#endif + mType(type), + mActionId(actionId), + mIsNumericPad(numericPad) + { } /** - * Destructor. - */ - virtual ~KeyEvent(); + * Destructor. + */ + virtual ~KeyEvent() + { } /** - * Gets the type of the event. - * - * @return The type of the event. - */ - unsigned int getType() const A_WARN_UNUSED; + * Gets the type of the event. + * + * @return The type of the event. + */ + unsigned int getType() const A_WARN_UNUSED + { return mType; } /** - * Checks if the key event occured on the numeric pad. - * - * @return True if key event occured on the numeric pad, - * false otherwise. - * - */ - bool isNumericPad() const A_WARN_UNUSED; + * Checks if the key event occured on the numeric pad. + * + * @return True if key event occured on the numeric pad, + * false otherwise. + * + */ + bool isNumericPad() const A_WARN_UNUSED + { return mIsNumericPad; } /** - * Gets the key of the event. - * - * @return The key of the event. - */ - const Key& getKey() const A_WARN_UNUSED; + * Gets the key of the event. + * + * @return The key of the event. + */ + const gcn::Key &getKey() const A_WARN_UNUSED + { return mKey; } + + int getActionId() const A_WARN_UNUSED + { return mActionId; } + +#ifdef USE_SDL2 + void setText(const std::string &text) + { mText = text; } + + std::string getText() const + { return mText; } +#endif protected: + /** + * Holds the key of the key event. + */ + gcn::Key mKey; + +#ifdef USE_SDL2 + std::string mText; +#endif + /** - * Holds the type of the key event. - */ + * Holds the type of the key event. + */ unsigned int mType; + int mActionId; + /** - * True if the numeric pad was used, false otherwise. - */ + * True if the numeric pad was used, false otherwise. + */ bool mIsNumericPad; +}; - /** - * Holds the key of the key event. - */ - Key mKey; - }; -} // namespace gcn - -#endif // end GCN_KEYEVENT_HPP +#endif // EVENTS_KEYEVENT_HPP diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index b1d13dcd7..5198b066a 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -67,7 +67,7 @@ #include <list> #include <deque> -#include "gui/base/keyevent.hpp" +#include "events/keyevent.h" #include "gui/base/mouseevent.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/keyevent.cpp b/src/gui/base/keyevent.cpp deleted file mode 100644 index d8d954bf3..000000000 --- a/src/gui/base/keyevent.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/keyevent.hpp" - -#include "debug.h" - -namespace gcn -{ - KeyEvent::KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const Key& key) : - InputGuiEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), - mType(type), - mIsNumericPad(numericPad), - mKey(key) - { - } - - KeyEvent::~KeyEvent() - { - } - - unsigned int KeyEvent::getType() const - { - return mType; - } - - bool KeyEvent::isNumericPad() const - { - return mIsNumericPad; - } - - const Key& KeyEvent::getKey() const - { - return mKey; - } -} // namespace gcn diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5d72c9dcb..7708183e5 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -39,8 +39,9 @@ #include "dragdrop.h" #include "touchmanager.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "input/keyinput.h" #include "resources/cursor.h" diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 5478d8164..10088d5f4 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "graphicsvertexes.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/imageset.h" @@ -589,7 +590,7 @@ void Button::setCaption(const std::string& caption) mCaption = caption; } -void Button::keyPressed(gcn::KeyEvent& keyEvent) +void Button::keyPressed(KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); @@ -600,7 +601,7 @@ void Button::keyPressed(gcn::KeyEvent& keyEvent) } } -void Button::keyReleased(gcn::KeyEvent& keyEvent) +void Button::keyReleased(KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 7fd7e4a9a..5dc89ea4d 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -144,9 +144,9 @@ class Button final : public gcn::Button, void setCaption(const std::string& caption); - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; - void keyReleased(gcn::KeyEvent &keyEvent) override final; + void keyReleased(KeyEvent &keyEvent) override final; bool isPressed2() const A_WARN_UNUSED; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 0721e29f6..2514f30d3 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/image.h" @@ -181,7 +182,7 @@ void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED) mHasMouse = false; } -void CheckBox::keyPressed(gcn::KeyEvent& keyEvent) +void CheckBox::keyPressed(KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 8e5958c92..2d1502552 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -81,7 +81,7 @@ class CheckBox final : public gcn::CheckBox, */ void mouseExited(gcn::MouseEvent& event) override final; - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void adjustSize(); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index bbba0cd99..db3393b46 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/extendedlistmodel.h" #include "gui/widgets/popuplist.h" @@ -309,7 +310,7 @@ void DropDown::drawButton(Graphics *graphics) } } -void DropDown::keyPressed(gcn::KeyEvent& keyEvent) +void DropDown::keyPressed(KeyEvent& keyEvent) { if (keyEvent.isConsumed()) return; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index f3431459f..58942bdb5 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -89,7 +89,7 @@ class DropDown final : public ActionListener, // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; // Inherited from MouseListener diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index dcb5431d5..1d3dc0c55 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -24,7 +24,8 @@ #include "client.h" -#include "input/keyevent.h" +#include "events/keyevent.h" + #include "input/keydata.h" #include "utils/dtor.h" @@ -418,7 +419,7 @@ gcn::Rectangle GuiTable::getChildrenArea() } // -- KeyListener notifications -void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) +void GuiTable::keyPressed(KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index a751cac59..766f7a3de 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -125,7 +125,7 @@ public: void _setFocusHandler(gcn::FocusHandler* focusHandler) override final; // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; /** * Sets the table to be opaque, that is sets the table diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index e50bd232b..8e3713522 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -26,8 +26,9 @@ #include "gui/sdlinput.h" #endif +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "utils/stringutils.h" #include "debug.h" @@ -49,7 +50,7 @@ IntTextField::IntTextField(const Widget2 *const widget, const int def, setWidth(width); } -void IntTextField::keyPressed(gcn::KeyEvent &event) +void IntTextField::keyPressed(KeyEvent &event) { const int action = static_cast<KeyEvent*>(&event)->getActionId(); diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index 3493cf52b..2e4e68083 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -68,7 +68,7 @@ class IntTextField final : public TextField /** * Responds to key presses. */ - void keyPressed(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; private: int mMin; /**< Minimum value */ diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 2c9e9b731..b2fa6a47e 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -386,11 +386,11 @@ void ItemContainer::hidePopup() mItemPopup->setVisible(false); } -void ItemContainer::keyPressed(gcn::KeyEvent &event A_UNUSED) +void ItemContainer::keyPressed(KeyEvent &event A_UNUSED) { } -void ItemContainer::keyReleased(gcn::KeyEvent &event A_UNUSED) +void ItemContainer::keyReleased(KeyEvent &event A_UNUSED) { } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index ecb7b658e..bc1bee695 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -85,8 +85,8 @@ class ItemContainer final : public gcn::Widget, void draw(Graphics *graphics) override final; // KeyListener - void keyPressed(gcn::KeyEvent &event) override final; - void keyReleased(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; + void keyReleased(KeyEvent &event) override final; // MouseListener void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index e71907f37..bd685632f 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/gui.h" @@ -174,7 +175,7 @@ void ListBox::draw(Graphics *graphics) BLOCK_END("ListBox::draw") } -void ListBox::keyPressed(gcn::KeyEvent &keyEvent) +void ListBox::keyPressed(KeyEvent &keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT) diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 459aea2e3..883814456 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -67,7 +67,7 @@ class ListBox : public gcn::ListBox, // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; // Inherited from MouseListener diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 092841dcf..75ea4819a 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/image.h" @@ -177,7 +178,7 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) mHasMouse = false; } -void RadioButton::keyPressed(gcn::KeyEvent& keyEvent) +void RadioButton::keyPressed(KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT) diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index ff6f5aafd..9802fb5fd 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -74,7 +74,7 @@ class RadioButton final : public gcn::RadioButton, */ void mouseExited(gcn::MouseEvent& event) override final; - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void updateAlpha(); diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 8eb27824d..4513ca167 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "graphicsvertexes.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/image.h" @@ -340,7 +341,7 @@ void Slider::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) mouseEvent.consume(); } -void Slider::keyPressed(gcn::KeyEvent& keyEvent) +void Slider::keyPressed(KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index c59e0c47f..38c149560 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -85,7 +85,7 @@ class Slider final : public gcn::Slider, void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) override final; - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void setValue2(const double value); diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 2fe4f1332..bc41ba824 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -22,8 +22,9 @@ #include "gui/widgets/tabbedarea.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/button.h" #include "gui/widgets/scrollarea.h" @@ -683,7 +684,7 @@ void TabbedArea::setDimension(const gcn::Rectangle &dimension) adjustSize(); } -void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) +void TabbedArea::keyPressed(KeyEvent& keyEvent) { if (mBlockSwitching || keyEvent.isConsumed() || !isFocused()) return; diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index d517c9a51..de470e89d 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -171,7 +171,7 @@ class TabbedArea final : public Widget2, bool getFollowDownScroll() const A_WARN_UNUSED { return mFollowDownScroll; } - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void setBlockSwitching(const bool b) { mBlockSwitching = b; } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 6bd301b32..8130469b7 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -22,8 +22,9 @@ #include "gui/widgets/textbox.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/base/font.hpp" @@ -165,7 +166,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) gcn::TextBox::setText(wrappedStream.str()); } -void TextBox::keyPressed(gcn::KeyEvent& keyEvent) +void TextBox::keyPressed(KeyEvent& keyEvent) { const gcn::Key &key = keyEvent.getKey(); const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index d8841cfeb..6b0429483 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -60,7 +60,7 @@ class TextBox final : public gcn::TextBox, int getMinWidth() const A_WARN_UNUSED { return mMinWidth; } - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void draw(Graphics* graphics) override final; diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 58facecb8..81a69e472 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -26,7 +26,7 @@ #include "input/inputmanager.h" -#include "input/keyevent.h" +#include "events/keyevent.h" #include "gui/sdlinput.h" @@ -198,7 +198,7 @@ int TextField::getValue() const return value; } -void TextField::keyPressed(gcn::KeyEvent &keyEvent) +void TextField::keyPressed(KeyEvent &keyEvent) { const int val = keyEvent.getKey().getValue(); #ifdef USE_SDL2 diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 42f76985c..71285bd64 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -90,7 +90,7 @@ class TextField : public gcn::TextField, /** * Processes one keypress. */ - void keyPressed(gcn::KeyEvent &keyEvent) override; + void keyPressed(KeyEvent &keyEvent) override; /** * Set the minimum value for a range diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 23be4eacf..0d324439b 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -24,8 +24,9 @@ #include "main.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/okdialog.h" @@ -664,7 +665,7 @@ void CharCreateDialog::updatePlayer() } } -void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) +void CharCreateDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (actionId) diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index d98860566..123d826f2 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -76,7 +76,7 @@ class CharCreateDialog final : public Window, void updatePlayer(); - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: int getDistributedPoints() const A_WARN_UNUSED; diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 793315067..b18e6df5b 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -26,8 +26,9 @@ #include "configuration.h" #include "units.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/charcreatedialog.h" #include "gui/windows/confirmdialog.h" @@ -315,7 +316,7 @@ void CharSelectDialog::use(const int selected) } } -void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) +void CharSelectDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (actionId) diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index e2b9c1ba8..348811ee3 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -63,7 +63,7 @@ class CharSelectDialog final : public Window, void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; enum SelectAction { diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 40b4b9400..11551b5cb 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -35,8 +35,9 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" +#include "events/keyevent.h" + #include "input/inputmanager.h" -#include "input/keyevent.h" #include "gui/sdlfont.h" #include "gui/sdlinput.h" @@ -836,7 +837,7 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) temp = str; \ break -void ChatWindow::keyPressed(gcn::KeyEvent &event) +void ChatWindow::keyPressed(KeyEvent &event) { const int key = event.getKey().getValue(); const int actionId = static_cast<KeyEvent*>(&event)->getActionId(); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index f8458bd32..e664e63ce 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -169,7 +169,7 @@ class ChatWindow final : public Window, void localChatInput(const std::string &msg) const; /** Called when key is pressed */ - void keyPressed(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; /** Set the chat input as the given text. */ void setInputText(const std::string &text); diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index d8301f5ce..82c255863 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -21,8 +21,9 @@ #include "gui/windows/editserverdialog.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/okdialog.h" #include "gui/windows/serverdialog.h" @@ -284,7 +285,7 @@ void EditServerDialog::action(const ActionEvent &event) } } -void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent) +void EditServerDialog::keyPressed(KeyEvent &keyEvent) { if (keyEvent.isConsumed()) return; diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 55c200934..8907a2846 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -94,7 +94,7 @@ class EditServerDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: TextField *mServerAddressField; diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 2412b524b..24b5cdab3 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -28,8 +28,9 @@ #include "being/playerinfo.h" +#include "events/keyevent.h" + #include "input/inputmanager.h" -#include "input/keyevent.h" #include "gui/viewport.h" @@ -612,7 +613,7 @@ void InventoryWindow::mouseExited(gcn::MouseEvent &event A_UNUSED) mTextPopup->hide(); } -void InventoryWindow::keyPressed(gcn::KeyEvent &event) +void InventoryWindow::keyPressed(KeyEvent &event) { if (static_cast<KeyEvent*>(&event)->getActionId() == static_cast<int>(Input::KEY_GUI_MOD)) @@ -621,7 +622,7 @@ void InventoryWindow::keyPressed(gcn::KeyEvent &event) } } -void InventoryWindow::keyReleased(gcn::KeyEvent &event) +void InventoryWindow::keyReleased(KeyEvent &event) { if (static_cast<KeyEvent*>(&event)->getActionId() == static_cast<int>(Input::KEY_GUI_MOD)) diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index cd5172c03..03f64b562 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -102,12 +102,12 @@ class InventoryWindow final : public Window, /** * Handles the key presses. */ - void keyPressed(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; /** * Handles the key releases. */ - void keyReleased(gcn::KeyEvent &event) override final; + void keyReleased(KeyEvent &event) override final; /** * Updates labels to currently selected item. diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 40ca481b0..2158c4dd9 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -435,7 +435,7 @@ void ItemAmountWindow::close() scheduleDelete(); } -void ItemAmountWindow::keyReleased(gcn::KeyEvent &keyEvent A_UNUSED) +void ItemAmountWindow::keyReleased(KeyEvent &keyEvent A_UNUSED) { mItemAmountSlide->setValue2(mItemAmountTextField->getValue()); } diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index 46e20353e..76d53eeeb 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -82,7 +82,7 @@ class ItemAmountWindow final : public Window, */ void close(); - void keyReleased(gcn::KeyEvent &keyEvent) override final; + void keyReleased(KeyEvent &keyEvent) override final; /** * Creates the dialog, or bypass it if there aren't enough items. diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 44a19346f..f9988a0c3 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "configuration.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/confirmdialog.h" @@ -318,7 +319,7 @@ void LoginDialog::action(const ActionEvent &event) } } -void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) +void LoginDialog::keyPressed(KeyEvent &keyEvent) { if (keyEvent.isConsumed()) { diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index fee21f307..7150b62c1 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -71,7 +71,7 @@ class LoginDialog final : public Window, /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; void close() override final; diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 2c264f232..c47fb1f0e 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -28,8 +28,9 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/viewport.h" @@ -202,7 +203,7 @@ void QuitDialog::action(const ActionEvent &event) scheduleDelete(); } -void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) +void QuitDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); int dir = 0; diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h index 5f0824ff4..8ce60d06c 100644 --- a/src/gui/windows/quitdialog.h +++ b/src/gui/windows/quitdialog.h @@ -64,7 +64,7 @@ class QuitDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: void placeOption(ContainerPlacer &placer, diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index a89b09d5b..530a33758 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/okdialog.h" @@ -281,7 +282,7 @@ void RegisterDialog::action(const ActionEvent &event) } } -void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) +void RegisterDialog::keyPressed(KeyEvent &keyEvent) { if (keyEvent.isConsumed()) { diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h index 766f4b6b1..1d5b5e48b 100644 --- a/src/gui/windows/registerdialog.h +++ b/src/gui/windows/registerdialog.h @@ -87,7 +87,7 @@ class RegisterDialog final : public Window, /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent) override; + void keyPressed(KeyEvent &keyEvent) override; void close() override; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 8d42d83e9..6d61b3eb2 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -27,8 +27,9 @@ #include "configuration.h" #include "main.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/sdlfont.h" @@ -444,7 +445,7 @@ void ServerDialog::action(const ActionEvent &event) } } -void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) +void ServerDialog::keyPressed(KeyEvent &keyEvent) { switch (static_cast<KeyEvent*>(&keyEvent)->getActionId()) { diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 4e711d732..d14360b88 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -118,7 +118,7 @@ class ServerDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; /** * Called when the selected value changed in the servers list box. diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 9df4fdc57..12a5cb0c4 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "configuration.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -290,7 +291,7 @@ void UpdaterWindow::action(const ActionEvent &event) } } -void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) +void UpdaterWindow::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL)) diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index 879a9eac3..ffd5b3103 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -121,7 +121,7 @@ class UpdaterWindow final : public Window, void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; void logic() override final; diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 5d81e249e..03545bcc4 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/button.h" #include "gui/widgets/layout.h" @@ -153,7 +154,7 @@ void WorldSelectDialog::action(const ActionEvent &event) } } -void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) +void WorldSelectDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast<KeyEvent*>( &keyEvent)->getActionId(); diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h index 9315317bf..9d06ac25e 100644 --- a/src/gui/windows/worldselectdialog.h +++ b/src/gui/windows/worldselectdialog.h @@ -65,7 +65,7 @@ class WorldSelectDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: WorldListModel *mWorldListModel; diff --git a/src/input/keyevent.cpp b/src/input/keyevent.cpp deleted file mode 100644 index 5695cd99b..000000000 --- a/src/input/keyevent.cpp +++ /dev/null @@ -1,47 +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 <http://www.gnu.org/licenses/>. - */ - -#include "input/keyevent.h" - -#include "debug.h" - -KeyEvent::KeyEvent(gcn::Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const int actionId, - const gcn::Key& key) : - gcn::KeyEvent(source, shiftPressed, controlPressed, altPressed, - metaPressed, type, numericPad, key), -#ifdef USE_SDL2 - mActionId(actionId), - mText() -#else - mActionId(actionId) -#endif -{ -} - -KeyEvent::~KeyEvent() -{ -} diff --git a/src/input/keyevent.h b/src/input/keyevent.h deleted file mode 100644 index 3637d720c..000000000 --- a/src/input/keyevent.h +++ /dev/null @@ -1,66 +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 <http://www.gnu.org/licenses/>. - */ - -#ifndef INPUT_KEYEVENT_H -#define INPUT_KEYEVENT_H - -#include "gui/base/key.hpp" -#include "gui/base/keyevent.hpp" - -#include <string> - -#include "localconsts.h" - -class KeyEvent final : public gcn::KeyEvent -{ - public: - KeyEvent(gcn::Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const int actionId, - const gcn::Key& key); - - A_DELETE_COPY(KeyEvent) - - ~KeyEvent(); - - int getActionId() const A_WARN_UNUSED - { return mActionId; } - -#ifdef USE_SDL2 - void setText(const std::string &text) - { mText = text; } - - std::string getText() const - { return mText; } -#endif - - protected: - int mActionId; -#ifdef USE_SDL2 - std::string mText; -#endif -}; - -#endif // INPUT_KEYEVENT_H diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h index e4cd42b67..2d4a74b9e 100644 --- a/src/listeners/keylistener.h +++ b/src/listeners/keylistener.h @@ -64,7 +64,7 @@ #ifndef GCN_KEYLISTENER_HPP #define GCN_KEYLISTENER_HPP -#include "gui/base/keyevent.hpp" +#include "events/keyevent.h" #include "localconsts.h" @@ -94,7 +94,7 @@ class KeyListener * * @param keyEvent Discribes the event. */ - virtual void keyPressed(gcn::KeyEvent &keyEvent A_UNUSED) + virtual void keyPressed(KeyEvent &keyEvent A_UNUSED) { } /** @@ -102,7 +102,7 @@ class KeyListener * * @param keyEvent Discribes the event. */ - virtual void keyReleased(gcn::KeyEvent &keyEvent A_UNUSED) + virtual void keyReleased(KeyEvent &keyEvent A_UNUSED) { } protected: |