Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GNASH_EVENT_ID_H
00022 #define GNASH_EVENT_ID_H
00023
00024 #include <string>
00025 #include "GnashKey.h"
00026
00027
00028 namespace gnash {
00029 struct ObjectURI;
00030 }
00031
00032 namespace gnash {
00033
00034
00036
00042
00047
00049
00052 class event_id
00053 {
00054 public:
00055
00057 enum EventCode
00058 {
00059 INVALID,
00060
00061
00062 PRESS,
00063 RELEASE,
00064 RELEASE_OUTSIDE,
00065 ROLL_OVER,
00066 ROLL_OUT,
00067 DRAG_OVER,
00068 DRAG_OUT,
00069 KEY_PRESS,
00070
00071
00072 INITIALIZE,
00073 LOAD,
00074 UNLOAD,
00075 ENTER_FRAME,
00076 MOUSE_DOWN,
00077 MOUSE_UP,
00078 MOUSE_MOVE,
00079 KEY_DOWN,
00080 KEY_UP,
00081 DATA,
00082 CONSTRUCT
00083 };
00084
00086
00088 event_id()
00089 :
00090 _id(INVALID),
00091 _keyCode(key::INVALID)
00092 {}
00093
00095
00099 explicit event_id(EventCode id, key::code c = key::INVALID)
00100 :
00101 _id(id),
00102 _keyCode(c)
00103 {
00104
00105
00106
00107 }
00108
00110
00113 void setKeyCode(boost::uint8_t SWFkey)
00114 {
00115
00116
00117
00118
00119
00120 int i = 0;
00121 while (key::codeMap[i][key::SWF] != SWFkey && i < key::KEYCOUNT) i++;
00122
00123 if (i == key::KEYCOUNT) _keyCode = key::INVALID;
00124 else _keyCode = static_cast<key::code>(i);
00125 }
00126
00129 const std::string& functionName() const;
00130
00133 const ObjectURI& functionURI() const;
00134
00136
00138 key::code keyCode() const { return _keyCode; }
00139
00141 EventCode id() const { return _id; }
00142
00143 private:
00144
00145 EventCode _id;
00146
00147
00148
00149
00150
00151
00152 key::code _keyCode;
00153
00154
00155 };
00156
00158
00162 inline bool
00163 operator==(const event_id& a, const event_id& b)
00164 {
00165 return a.id() == b.id() && a.keyCode() == b.keyCode();
00166 }
00167
00169 inline bool
00170 operator<(const event_id& a, const event_id& b)
00171 {
00172 if (a.id() == b.id()) return a.keyCode() < b.keyCode();
00173 return a.id() < b.id();
00174 }
00175
00176
00178
00181 bool isButtonEvent(const event_id& e);
00182
00184
00187 bool isKeyEvent(const event_id& e);
00188
00189 std::ostream& operator<< (std::ostream& o, const event_id& ev);
00190
00191 }
00192
00193
00194 #endif
00195
00196
00197
00198
00199
00200