Gnash
0.8.11dev
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
libcore
event_id.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3
// Free Software Foundation, Inc
4
//
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
//
19
20
21
#ifndef GNASH_EVENT_ID_H
22
#define GNASH_EVENT_ID_H
23
24
#include <string>
25
#include "
GnashKey.h
"
26
27
// Forward declarations
28
namespace
gnash {
29
struct
ObjectURI;
30
}
31
32
namespace
gnash {
33
34
36
//
42
//
47
//
49
//
52
class
event_id
53
{
54
public
:
55
57
enum
EventCode
58
{
59
INVALID
,
60
61
// These are for buttons and sprites.
62
PRESS
,
63
RELEASE
,
64
RELEASE_OUTSIDE
,
65
ROLL_OVER
,
66
ROLL_OUT
,
67
DRAG_OVER
,
68
DRAG_OUT
,
69
KEY_PRESS
,
70
71
// These are for sprites only.
72
INITIALIZE
,
73
LOAD
,
74
UNLOAD
,
75
ENTER_FRAME
,
76
MOUSE_DOWN
,
77
MOUSE_UP
,
78
MOUSE_MOVE
,
79
KEY_DOWN
,
80
KEY_UP
,
81
DATA
,
82
CONSTRUCT
83
};
84
86
//
88
event_id
()
89
:
90
_id(
INVALID
),
91
_keyCode(key::
INVALID
)
92
{}
93
95
//
99
explicit
event_id
(
EventCode
id
,
key::code
c
=
key::INVALID
)
100
:
101
_id(id),
102
_keyCode(
c
)
103
{
104
// We do have a testcase with _id == KEY_PRESS,
105
// and keyCode==0(KEY_INVALID)
106
// see key_event_test.swf(produced by Ming)
107
}
108
110
//
113
void
setKeyCode
(boost::uint8_t SWFkey)
114
{
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.
120
int
i
= 0;
121
while
(
key::codeMap
[i][
key::SWF
] != SWFkey && i <
key::KEYCOUNT
) i++;
122
123
if
(i ==
key::KEYCOUNT
) _keyCode =
key::INVALID
;
124
else
_keyCode =
static_cast<
key::code
>
(
i
);
125
}
126
129
const
std::string&
functionName
()
const
;
130
133
const
ObjectURI
&
functionURI
()
const
;
134
136
//
138
key::code
keyCode
()
const
{
return
_keyCode; }
139
141
EventCode
id
()
const
{
return
_id; }
142
143
private
:
144
145
EventCode
_id;
146
147
// keyCode must be the unique gnash key identifier
148
// gnash::key::code.
149
// TextField has to be able to work out the
150
// ASCII value from keyCode, while other users need
151
// the SWF code or the Flash key code.
152
key::code
_keyCode;
153
154
155
};
156
158
//
162
inline
bool
163
operator==
(
const
event_id
&
a
,
const
event_id
&
b
)
164
{
165
return
a.
id
() == b.
id
() && a.
keyCode
() == b.
keyCode
();
166
}
167
169
inline
bool
170
operator<
(
const
event_id
&
a
,
const
event_id
&
b
)
171
{
172
if
(a.
id
() == b.
id
())
return
a.
keyCode
() < b.
keyCode
();
173
return
a.
id
() < b.
id
();
174
}
175
176
178
//
181
bool
isButtonEvent
(
const
event_id&
e
);
182
184
//
187
bool
isKeyEvent
(
const
event_id&
e
);
188
189
std::ostream&
operator<<
(std::ostream&
o
,
const
event_id& ev);
190
191
}
// namespace gnash
192
193
194
#endif
195
196
197
// Local Variables:
198
// mode: C++
199
// indent-tabs-mode: t
200
// End:
Generated on Tue Jan 28 2014 17:18:06 for Gnash by
1.8.4