2
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef GNASH_EVENT_ID_H
21
#define GNASH_EVENT_ID_H
23
#include "string_table.h"
26
#include "GnashKey.h" // for gnash::key::code
30
/// For keyDown and stuff like that.
32
/// Implementation is currently in action.cpp
34
class DSOEXPORT event_id
37
/// These must match the function names in event_id::get_function_name()
42
// These are for buttons & sprites.
52
// These are for sprites only.
64
// These are for the MoveClipLoader ActionScript only
70
// These are for the XMLSocket ActionScript only
75
// This is for setInterval
87
// keyCode must be the unique gnash key identifier
89
// edit_text_character has to be able to work out the
90
// ASCII value from keyCode, while other users need
91
// the SWF code or the Flash key code.
94
event_id() : m_id(INVALID), keyCode(key::INVALID) {}
96
event_id(id_code id, key::code c = key::INVALID)
101
// you must supply a key code for KEY_PRESS event
103
// we do have a testcase with m_id == KEY_PRESS, and keyCode==0(KEY_INVALID)
104
// see key_event_test.swf(produced by Ming)
106
//assert((keyCode == key::INVALID && (m_id != KEY_PRESS))
107
// || (keyCode != key::INVALID && (m_id == KEY_PRESS)));
111
/// @param SWFKey The SWF code matched to the event. This
112
/// must be converted to a unique gnash::key::code.
113
void setKeyCode(boost::uint8_t SWFkey)
115
// Lookup the SWFcode in the gnash::key::code table.
116
// Some are not unique (keypad numbers are the
117
// same as normal numbers), so we take the first match.
118
// As long as we can work out the SWFCode from the
119
// gnash::key::code it's all right.
121
while (key::codeMap[i][key::SWF] != SWFkey && i < key::KEYCOUNT) i++;
123
if (i == key::KEYCOUNT) keyCode = key::INVALID;
124
else keyCode = static_cast<key::code>(i);
127
bool operator==(const event_id& id) const
129
return m_id == id.m_id && keyCode == id.keyCode;
132
bool operator< (const event_id& id) const
134
if ( m_id < id.m_id ) return true;
135
if ( m_id > id.m_id ) return false;
137
// m_id are equal, check key code
138
if ( keyCode < id.keyCode ) return true;
142
/// Return the name of a method-handler function
143
/// corresponding to this event.
144
const std::string& get_function_name() const;
146
/// Return the string_table key of a method-handler function
147
/// corresponding to this event.
148
string_table::key get_function_key() const;
151
/// Return true if this is a mouse event
152
/// (triggerable with a mouse activity)
153
bool is_mouse_event() const;
155
/// Return true if this is a key event
156
bool is_key_event() const;
158
/// Return true if this is a button-like event
160
/// Button-like events are: PRESS, RELEASE, RELEASE_OUTSIDE,
161
/// ROLL_OVER, ROLL_OUT,
162
/// DRAG_OVER, DRAG_OUT,
165
/// TODO: check if we need anything more
166
/// The way to test is using the 'enabled'
167
/// property to see which ones are disabled
168
/// by setting it to false.
170
bool is_button_event() const;
172
id_code id() const { return m_id; }
175
std::ostream& operator<< (std::ostream& o, const event_id& ev);
177
} // end namespace gnash
180
#endif // GNASH_EVENT_ID_H
185
// indent-tabs-mode: t