summaryrefslogtreecommitdiff
path: root/src/events
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-01 19:13:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-01 19:13:11 +0300
commita260aeab234704ace8ba672b1d1ce57e18425e07 (patch)
treee215c6eeeae7e6c2ca4f4453718cef6ca9a8af6a /src/events
parent382067b05c4fe97bcf0da0143405375ec295f7c6 (diff)
parent2c62286a7ecf246e8a445dd7d00f618efae2a96a (diff)
downloadmv-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.gz
mv-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.bz2
mv-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.xz
mv-a260aeab234704ace8ba672b1d1ce57e18425e07.zip
Merge branch 'master' into stable
Diffstat (limited to 'src/events')
-rw-r--r--src/events/actionevent.h136
-rw-r--r--src/events/event.h114
-rw-r--r--src/events/inputevent.h54
-rw-r--r--src/events/inputguievent.h187
-rw-r--r--src/events/keyevent.h191
-rw-r--r--src/events/mouseevent.h241
-rw-r--r--src/events/selectionevent.h98
7 files changed, 1021 insertions, 0 deletions
diff --git a/src/events/actionevent.h b/src/events/actionevent.h
new file mode 100644
index 000000000..25f936cdd
--- /dev/null
+++ b/src/events/actionevent.h
@@ -0,0 +1,136 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_ACTIONEVENT_H
+#define EVENTS_ACTIONEVENT_H
+
+#include "events/event.h"
+
+#include <string>
+
+#include "localconsts.h"
+
+class Widget;
+
+/**
+ * Represents an action event. An action event is an event
+ * that can be fired by a widget whenever an action has occured.
+ * What exactly an action is is up to the widget that fires
+ * the action event. An example is a Button which fires an action
+ * event as soon as the Button is clicked, another example is
+ * TextField which fires an action event as soon as the enter
+ * key is pressed.
+ *
+ * Any object can listen for actions from widgets by implementing
+ * the ActionListener interface.
+ *
+ * If you have implement a widget of your own it's a good idea to
+ * let the widget fire action events whenever you feel an action
+ * has occured so action listeners of the widget can be informed
+ * of the state of the widget.
+ *
+ * @see Widget::addActionListener, Widget::removeActionListener,
+ * Widget::distributeActionEvent
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class ActionEvent final : public Event
+{
+ public:
+ /**
+ * Constructor.
+ *
+ * @param source The source widget of the event.
+ * @param id An identifier of the event.
+ */
+ ActionEvent(Widget *const source, const std::string &id) :
+ Event(source),
+ mId(id)
+ {
+ }
+
+ /**
+ * Destructor.
+ */
+ virtual ~ActionEvent()
+ { }
+
+ /**
+ * Gets the identifier of the event. An identifier can
+ * be used to distinguish from two actions from the same
+ * widget or to let many widgets fire the same widgets
+ * that should be treated equally.
+ *
+ * @return The identifier of the event.
+ */
+ const std::string &getId() const A_WARN_UNUSED
+ { return mId; }
+
+ protected:
+ /**
+ * Holds the identifier of the event.
+ */
+ std::string mId;
+};
+
+#endif // EVENTS_ACTIONEVENT_H
diff --git a/src/events/event.h b/src/events/event.h
new file mode 100644
index 000000000..63ccb207d
--- /dev/null
+++ b/src/events/event.h
@@ -0,0 +1,114 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_EVENT_H
+#define EVENTS_EVENT_H
+
+#include "localconsts.h"
+
+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) :
+ 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.
+ */
+ Widget* getSource() const A_WARN_UNUSED
+ { return mSource; }
+
+ protected:
+ /**
+ * Holds the source widget of the event.
+ */
+ Widget* mSource;
+};
+
+#endif // EVENTS_EVENT_H
diff --git a/src/events/inputevent.h b/src/events/inputevent.h
new file mode 100644
index 000000000..2d8a36796
--- /dev/null
+++ b/src/events/inputevent.h
@@ -0,0 +1,54 @@
+/*
+ * 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 EVENTS_INPUTEVENT_H
+#define EVENTS_INPUTEVENT_H
+
+#include <map>
+#include <vector>
+
+#include "localconsts.h"
+
+typedef std::vector<int> KeysVector;
+typedef KeysVector::iterator KeysVectorIter;
+typedef KeysVector::const_iterator KeysVectorCIter;
+
+typedef std::map<int, KeysVector> KeyToActionMap;
+typedef KeyToActionMap::iterator KeyToActionMapIter;
+
+typedef std::map<int, int> KeyToIdMap;
+typedef KeyToIdMap::iterator KeyToIdMapIter;
+
+typedef std::map<int, int> KeyTimeMap;
+typedef KeyTimeMap::iterator KeyTimeMapIter;
+
+struct InputEvent final
+{
+ InputEvent(const int action0, const int mask0) :
+ action(action0),
+ mask(mask0)
+ { }
+
+ int action;
+
+ int mask;
+};
+
+#endif // EVENTS_INPUTEVENT_H
diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h
new file mode 100644
index 000000000..2e5136ea2
--- /dev/null
+++ b/src/events/inputguievent.h
@@ -0,0 +1,187 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_INPUTGUIEVENT_H
+#define EVENTS_INPUTGUIEVENT_H
+
+#include "events/event.h"
+
+/**
+ * Base class for all events concerning input.
+ *
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class InputGuiEvent: public Event
+{
+ public:
+ /**
+ * Constructor.
+ *
+ * @param source The source widget of the event.
+ * @param isShiftPressed True if shift is pressed, false otherwise.
+ * @param isControlPressed True if control is pressed, false otherwise.
+ * @param isAltPressed True if alt is pressed, false otherwise.
+ * @param isMetaPressed True if meta is pressed, false otherwise.
+ */
+ InputGuiEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed) :
+ Event(source),
+ mShiftPressed(shiftPressed),
+ mControlPressed(controlPressed),
+ mAltPressed(altPressed),
+ mMetaPressed(metaPressed),
+ mIsConsumed(false)
+ { }
+
+ /**
+ * Checks if shift is pressed.
+ *
+ * @return True if shift was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isShiftPressed() const A_WARN_UNUSED
+ { return mShiftPressed; }
+
+ /**
+ * Checks if control is pressed.
+ *
+ * @return True if control was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isControlPressed() const A_WARN_UNUSED
+ { return mControlPressed; }
+
+ /**
+ * Checks if alt is pressed.
+ *
+ * @return True if alt was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isAltPressed() const A_WARN_UNUSED
+ { return mAltPressed; }
+
+ /**
+ * Checks whether meta is pressed.
+ *
+ * @return True if meta was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isMetaPressed() const A_WARN_UNUSED
+ { return mMetaPressed; }
+
+ /**
+ * Marks the event as consumed. Input event listeners may discard
+ * consumed input or act on consumed input. An example of a widget
+ * that discards consumed input is the ScrollArea widget that
+ * discards consumed mouse wheel events so the ScrollArea will not
+ * scroll if for instance a Slider's value inside the ScrollArea was
+ * changed with the mouse wheel.
+ *
+ * @see isConsumed
+ */
+ void consume()
+ { mIsConsumed = true; }
+
+ /**
+ * Checks if the input event is consumed.
+ *
+ * @return True if the input event is consumed,
+ * false otherwise.
+ * @see consume
+ */
+ bool isConsumed() const A_WARN_UNUSED
+ { return mIsConsumed; }
+
+ protected:
+ /**
+ * True if shift is pressed, false otherwise.
+ */
+ bool mShiftPressed;
+
+ /**
+ * True if control is pressed, false otherwise.
+ */
+ bool mControlPressed;
+
+ /**
+ * True if alt is pressed, false otherwise.
+ */
+ bool mAltPressed;
+
+ /**
+ * True if meta is pressed, false otherwise.
+ */
+ bool mMetaPressed;
+
+ /**
+ * True if the input event is consumed,
+ * false otherwise.
+ */
+ bool mIsConsumed;
+};
+
+#endif // EVENTS_INPUTGUIEVENT_H
diff --git a/src/events/keyevent.h b/src/events/keyevent.h
new file mode 100644
index 000000000..360d229d7
--- /dev/null
+++ b/src/events/keyevent.h
@@ -0,0 +1,191 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_KEYEVENT_H
+#define EVENTS_KEYEVENT_H
+
+#include "events/inputguievent.h"
+#include "input/key.h"
+
+#include <string>
+
+class Widget;
+
+/**
+ * Represents a key event.
+ */
+class KeyEvent: public InputGuiEvent
+{
+ public:
+ /**
+ * Key event types.
+ */
+ enum
+ {
+ PRESSED = 0,
+ RELEASED
+ };
+
+ /**
+ * 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 int actionId,
+ const Key &key) :
+ InputGuiEvent(source,
+ shiftPressed,
+ controlPressed,
+ altPressed,
+ metaPressed),
+ mKey(key),
+#ifdef USE_SDL2
+ mText(),
+#endif
+ mType(type),
+ mActionId(actionId),
+ mIsNumericPad(numericPad)
+ { }
+
+ /**
+ * Destructor.
+ */
+ virtual ~KeyEvent()
+ { }
+
+ /**
+ * 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
+ { return mIsNumericPad; }
+
+ /**
+ * Gets the key of the event.
+ *
+ * @return The key of the event.
+ */
+ const 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.
+ */
+ Key mKey;
+
+#ifdef USE_SDL2
+ std::string mText;
+#endif
+
+ /**
+ * Holds the type of the key event.
+ */
+ unsigned int mType;
+
+ int mActionId;
+
+ /**
+ * True if the numeric pad was used, false otherwise.
+ */
+ bool mIsNumericPad;
+};
+
+#endif // EVENTS_KEYEVENT_H
diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h
new file mode 100644
index 000000000..a717980f9
--- /dev/null
+++ b/src/events/mouseevent.h
@@ -0,0 +1,241 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_MOUSEEVENT_H
+#define EVENTS_MOUSEEVENT_H
+
+#include "events/inputguievent.h"
+
+namespace gcn
+{
+ class Gui;
+}
+
+class Widget;
+
+/**
+ * Represents a mouse event.
+ *
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class MouseEvent: public InputGuiEvent
+{
+ public:
+ /**
+ * Constructor.
+ *
+ * @param source The source widget of the mouse 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 mouse event.
+ * @param button The button of the mouse event.
+ * @param x The x coordinate of the event relative to the source widget.
+ * @param y The y coordinate of the event relative the source widget.
+ * @param clickCount The number of clicks generated with the same button.
+ * It's set to zero if another button is used.
+ */
+ MouseEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed,
+ const unsigned int type,
+ const unsigned int button,
+ const int x,
+ const int y,
+ const int clickCount) :
+ InputGuiEvent(source,
+ shiftPressed,
+ controlPressed,
+ altPressed,
+ metaPressed),
+ mType(type),
+ mButton(button),
+ mX(x),
+ mY(y),
+ mClickCount(clickCount)
+ {
+ }
+
+ /**
+ * Gets the button of the mouse event.
+ *
+ * @return The button of the mouse event.
+ */
+ unsigned int getButton() const A_WARN_UNUSED
+ { return mButton; }
+
+ /**
+ * Gets the x coordinate of the mouse event.
+ * The coordinate relative to widget the mouse listener
+ * receiving the events have registered to.
+ *
+ * @return The x coordinate of the mouse event.
+ * @see Widget::addMouseListener, Widget::removeMouseListener
+ */
+ int getX() const A_WARN_UNUSED
+ { return mX; }
+
+ /**
+ * Gets the y coordinate of the mouse event.
+ * The coordinate relative to widget the mouse listener
+ * receiving the events have registered to.
+ *
+ * @return The y coordinate of the mouse event.
+ * @see Widget::addMouseListener, Widget::removeMouseListener
+ */
+ int getY() const A_WARN_UNUSED
+ { return mY; }
+
+ /**
+ * Gets the number of clicks generated with the same button.
+ * It's set to zero if another button is used.
+ *
+ * @return The number of clicks generated with the same button.
+ */
+ int getClickCount() const A_WARN_UNUSED
+ { return mClickCount; }
+
+ /**
+ * Gets the type of the event.
+ *
+ * @return The type of the event.
+ */
+ unsigned int getType() const A_WARN_UNUSED
+ { return mType; }
+
+ void setX(int n)
+ { mX = n; }
+
+ void setY(int n)
+ { mY = n; }
+
+ /**
+ * Mouse event types.
+ */
+ enum
+ {
+ MOVED = 0,
+ PRESSED,
+ RELEASED,
+ WHEEL_MOVED_DOWN,
+ WHEEL_MOVED_UP,
+ CLICKED,
+ ENTERED,
+ EXITED,
+ DRAGGED
+ };
+
+ /**
+ * Mouse button types.
+ */
+ enum
+ {
+ EMPTY = 0,
+ LEFT,
+ RIGHT,
+ MIDDLE
+ };
+
+ protected:
+ /**
+ * Holds the type of the mouse event.
+ */
+ unsigned int mType;
+
+ /**
+ * Holds the button of the mouse event.
+ */
+ unsigned int mButton;
+
+ /**
+ * Holds the x-coordinate of the mouse event.
+ */
+ int mX;
+
+ /**
+ * Holds the y-coordinate of the mouse event.
+ */
+ int mY;
+
+ /**
+ * The number of clicks generated with the same button.
+ * It's set to zero if another button is used.
+ */
+ int mClickCount;
+
+ /**
+ * Gui is a friend of this class in order to be able to manipulate
+ * the protected member variables of this class and at the same time
+ * keep the MouseEvent class as const as possible. Gui needs to
+ * update the x och y coordinates for the coordinates to be relative
+ * to widget the mouse listener receiving the events have registered
+ * to.
+ */
+ friend class gcn::Gui;
+};
+
+#endif // EVENTS_MOUSEEVENT_H
diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h
new file mode 100644
index 000000000..927b66f77
--- /dev/null
+++ b/src/events/selectionevent.h
@@ -0,0 +1,98 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_SELECTIONEVENT_H
+#define EVENTS_SELECTIONEVENT_H
+
+#include "events/event.h"
+
+#include "localconsts.h"
+
+class Widget;
+
+/**
+ * Represents a selection event.
+ *
+ * @author Olof Naessén
+ * @since 0.8.0
+ */
+class SelectionEvent final: public Event
+{
+ public:
+ /**
+ * Constructor.
+ *
+ * @param source source The widget of the selection event.
+ */
+ explicit SelectionEvent(Widget *const source) :
+ Event(source)
+ { }
+
+ /**
+ * Destructor.
+ */
+ virtual ~SelectionEvent()
+ { }
+};
+
+#endif // EVENTS_SELECTIONEVENT_H