summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-30 00:41:05 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-30 00:41:05 +0300
commitec51be4fd71babf30a73332bc4b73edb994ee462 (patch)
tree0199da5c75066083b4287204d3532f69420764eb /src
parent7969f0590204ac48d74e98c3211bca27693bac44 (diff)
downloadmanaplus-ec51be4fd71babf30a73332bc4b73edb994ee462.tar.gz
manaplus-ec51be4fd71babf30a73332bc4b73edb994ee462.tar.bz2
manaplus-ec51be4fd71babf30a73332bc4b73edb994ee462.tar.xz
manaplus-ec51be4fd71babf30a73332bc4b73edb994ee462.zip
Convert KeyEvent enum into strong typed enum.
Diffstat (limited to 'src')
-rw-r--r--src/enums/events/keyeventtype.h17
-rw-r--r--src/events/keyevent.h6
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/input/keyinput.h6
4 files changed, 15 insertions, 18 deletions
diff --git a/src/enums/events/keyeventtype.h b/src/enums/events/keyeventtype.h
index 7c96b749a..b04ddab7e 100644
--- a/src/enums/events/keyeventtype.h
+++ b/src/enums/events/keyeventtype.h
@@ -64,16 +64,13 @@
#ifndef ENUMS_EVENTS_KEYEVENTTYPE_H
#define ENUMS_EVENTS_KEYEVENTTYPE_H
-namespace KeyEventType
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(KeyEventType)
{
- /**
- * Key event types.
- */
- enum Type
- {
- PRESSED = 0,
- RELEASED
- };
-} // namespace KeyEventType
+ PRESSED = 0,
+ RELEASED
+}
+enumEnd(KeyEventType);
#endif // ENUMS_EVENTS_KEYEVENTTYPE_H
diff --git a/src/events/keyevent.h b/src/events/keyevent.h
index 3cad1bce2..9f0a54972 100644
--- a/src/events/keyevent.h
+++ b/src/events/keyevent.h
@@ -88,7 +88,7 @@ class KeyEvent: public InputGuiEvent
* @param key The key of the event.
*/
KeyEvent(Widget *const source,
- KeyEventType::Type type,
+ KeyEventTypeT type,
const int actionId,
const Key &key) :
InputGuiEvent(source),
@@ -111,7 +111,7 @@ class KeyEvent: public InputGuiEvent
*
* @return The type of the event.
*/
- KeyEventType::Type getType() const A_WARN_UNUSED
+ KeyEventTypeT getType() const A_WARN_UNUSED
{ return mType; }
/**
@@ -146,7 +146,7 @@ class KeyEvent: public InputGuiEvent
/**
* Holds the type of the key event.
*/
- KeyEventType::Type mType;
+ KeyEventTypeT mType;
int mActionId;
};
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 49b6d2774..4cfd83f0f 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -1263,7 +1263,7 @@ void Gui::distributeKeyEvent(KeyEvent &event) const
std::list<KeyListener*> keyListeners
= widget->getKeyListeners();
- const KeyEventType::Type eventType = event.getType();
+ const KeyEventTypeT eventType = event.getType();
// Send the event to all key listeners of the source widget.
FOR_EACH (std::list<KeyListener*>::const_iterator,
it, keyListeners)
@@ -1296,7 +1296,7 @@ void Gui::distributeKeyEvent(KeyEvent &event) const
void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& event)
{
BLOCK_START("Gui::distributeKeyEventToGlobalKeyListeners")
- const KeyEventType::Type eventType = event.getType();
+ const KeyEventTypeT eventType = event.getType();
FOR_EACH (KeyListenerListIterator, it, mKeyListeners)
{
switch (eventType)
diff --git a/src/input/keyinput.h b/src/input/keyinput.h
index f308af244..8555d8bbb 100644
--- a/src/input/keyinput.h
+++ b/src/input/keyinput.h
@@ -85,12 +85,12 @@ class KeyInput final
~KeyInput()
{ }
- void setType(KeyEventType::Type type)
+ void setType(KeyEventTypeT type)
{
mType = type;
}
- KeyEventType::Type getType() const
+ KeyEventTypeT getType() const
{
return mType;
}
@@ -136,7 +136,7 @@ class KeyInput final
/**
* Holds the type of the key input.
*/
- KeyEventType::Type mType;
+ KeyEventTypeT mType;
#ifdef USE_SDL2
std::string mText;