~ubuntu-branches/ubuntu/karmic/gnash/karmic

« back to all changes in this revision

Viewing changes to libcore/event_id.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
3
// 
 
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.
 
8
// 
 
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.
 
13
// 
 
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
 
17
//
 
18
 
 
19
 
 
20
#ifndef GNASH_EVENT_ID_H
 
21
#define GNASH_EVENT_ID_H
 
22
 
 
23
#include "string_table.h"
 
24
#include "dsodefs.h"
 
25
 
 
26
#include "GnashKey.h" // for gnash::key::code
 
27
 
 
28
namespace gnash {
 
29
 
 
30
/// For keyDown and stuff like that.
 
31
//
 
32
/// Implementation is currently in action.cpp
 
33
///
 
34
class DSOEXPORT event_id
 
35
{
 
36
public:
 
37
        /// These must match the function names in event_id::get_function_name()
 
38
        enum id_code
 
39
        {
 
40
                INVALID,
 
41
 
 
42
                // These are for buttons & sprites.
 
43
                PRESS,
 
44
                RELEASE,
 
45
                RELEASE_OUTSIDE,
 
46
                ROLL_OVER,
 
47
                ROLL_OUT,
 
48
                DRAG_OVER,
 
49
                DRAG_OUT,
 
50
                KEY_PRESS,
 
51
 
 
52
                // These are for sprites only.
 
53
                INITIALIZE,
 
54
                LOAD,
 
55
                UNLOAD,
 
56
                ENTER_FRAME,
 
57
                MOUSE_DOWN,
 
58
                MOUSE_UP,
 
59
                MOUSE_MOVE,
 
60
                KEY_DOWN,
 
61
                KEY_UP,
 
62
                DATA,
 
63
                
 
64
                // These are for the MoveClipLoader ActionScript only
 
65
                LOAD_START,
 
66
                LOAD_ERROR,
 
67
                LOAD_PROGRESS,
 
68
                LOAD_INIT,
 
69
                
 
70
                // These are for the XMLSocket ActionScript only
 
71
                CLOSE,
 
72
                CONNECT,
 
73
                XML,
 
74
                
 
75
                // This is for setInterval
 
76
                TIMER,
 
77
 
 
78
                CONSTRUCT,
 
79
                SETFOCUS,
 
80
                KILLFOCUS,
 
81
 
 
82
                EVENT_COUNT
 
83
        };
 
84
 
 
85
        id_code m_id;
 
86
        
 
87
        // keyCode must be the unique gnash key identifier
 
88
        // gnash::key::code.
 
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.
 
92
        key::code keyCode;
 
93
 
 
94
        event_id() : m_id(INVALID), keyCode(key::INVALID) {}
 
95
 
 
96
        event_id(id_code id, key::code c = key::INVALID)
 
97
                :
 
98
                m_id(id),
 
99
                keyCode(c)
 
100
        {
 
101
                // you must supply a key code for KEY_PRESS event
 
102
                // 
 
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)
 
105
                // 
 
106
                //assert((keyCode == key::INVALID && (m_id != KEY_PRESS))
 
107
                //      || (keyCode != key::INVALID && (m_id == KEY_PRESS)));
 
108
        }
 
109
 
 
110
        ///
 
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)
 
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
 
 
127
        bool    operator==(const event_id& id) const
 
128
        {
 
129
            return m_id == id.m_id && keyCode == id.keyCode;
 
130
        }
 
131
 
 
132
        bool operator< (const event_id& id) const
 
133
        {
 
134
                if ( m_id < id.m_id ) return true;
 
135
                if ( m_id > id.m_id ) return false;
 
136
 
 
137
                // m_id are equal, check key code
 
138
                if ( keyCode < id.keyCode ) return true;
 
139
                return false;
 
140
        }
 
141
 
 
142
        /// Return the name of a method-handler function
 
143
        /// corresponding to this event.
 
144
        const std::string& get_function_name() const;
 
145
 
 
146
        /// Return the string_table key of a method-handler function
 
147
        /// corresponding to this event.
 
148
        string_table::key get_function_key() const;
 
149
 
 
150
        /// \brief
 
151
        /// Return true if this is a mouse event
 
152
        /// (triggerable with a mouse activity)
 
153
        bool is_mouse_event() const;
 
154
  
 
155
        /// Return true if this is a key event
 
156
        bool is_key_event() const;
 
157
 
 
158
        /// Return true if this is a button-like event
 
159
        //
 
160
        /// Button-like events are: PRESS, RELEASE, RELEASE_OUTSIDE,
 
161
        ///                         ROLL_OVER, ROLL_OUT,
 
162
        ///                         DRAG_OVER, DRAG_OUT,
 
163
        ///                         KEY_PRESS
 
164
        ///
 
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.
 
169
        ///
 
170
        bool is_button_event() const;
 
171
 
 
172
        id_code id() const { return m_id; }
 
173
};
 
174
 
 
175
std::ostream& operator<< (std::ostream& o, const event_id& ev);
 
176
 
 
177
}       // end namespace gnash
 
178
 
 
179
 
 
180
#endif // GNASH_EVENT_ID_H
 
181
 
 
182
 
 
183
// Local Variables:
 
184
// mode: C++
 
185
// indent-tabs-mode: t
 
186
// End: