update version to the release
[gnash.git] / libcore / event_id.cpp
blob3f6b021b0088914c159c883a80c55ec2ec5c8ef2
1 // event_id.cpp: static ActionScript events for Gnash.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
4 // Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "log.h"
23 #include "event_id.h"
24 #include "namedStrings.h"
25 #include "ObjectURI.h"
27 #include <map>
28 #include <string>
29 #include <algorithm>
30 #include <boost/format.hpp>
31 #include <cassert>
32 #include <boost/assign/list_of.hpp>
34 namespace gnash {
36 const std::string&
37 event_id::functionName() const
39 typedef std::map<EventCode, std::string> EventFunctionNameMap;
40 static const EventFunctionNameMap e = boost::assign::map_list_of
41 (INVALID, "INVALID")
42 (PRESS, "onPress")
43 (RELEASE, "onRelease")
44 (RELEASE_OUTSIDE, "onReleaseOutside")
45 (ROLL_OVER, "onRollOver")
46 (ROLL_OUT, "onRollOut")
47 (DRAG_OVER, "onDragOver")
48 (DRAG_OUT, "onDragOut")
49 (KEY_PRESS, "onKeyPress")
50 (INITIALIZE, "onInitialize")
51 (LOAD, "onLoad")
52 (UNLOAD, "onUnload")
53 (ENTER_FRAME, "onEnterFrame")
54 (MOUSE_DOWN, "onMouseDown")
55 (MOUSE_UP, "onMouseUp")
56 (MOUSE_MOVE, "onMouseMove")
57 (KEY_DOWN, "onKeyDown")
58 (KEY_UP, "onKeyUp")
59 (DATA, "onData")
60 (CONSTRUCT, "onConstruct");
62 EventFunctionNameMap::const_iterator it = e.find(_id);
63 assert(it != e.end());
64 return it->second;
67 const ObjectURI&
68 event_id::functionURI() const
70 typedef std::map<EventCode, ObjectURI> EventFunctionMap;
72 // TODO: make this table non-static, as
73 // it contains string_table-dependent
74 // mutable entries
76 static const EventFunctionMap e = boost::assign::map_list_of
77 (PRESS, NSV::PROP_ON_PRESS)
78 (RELEASE, NSV::PROP_ON_RELEASE)
79 (RELEASE_OUTSIDE, NSV::PROP_ON_RELEASE_OUTSIDE)
80 (ROLL_OVER, NSV::PROP_ON_ROLL_OVER )
81 (ROLL_OUT, NSV::PROP_ON_ROLL_OUT)
82 (DRAG_OVER, NSV::PROP_ON_DRAG_OVER)
83 (DRAG_OUT, NSV::PROP_ON_DRAG_OUT)
84 (KEY_PRESS, NSV::PROP_ON_KEY_PRESS)
85 (INITIALIZE, NSV::PROP_ON_INITIALIZE)
86 (LOAD, NSV::PROP_ON_LOAD)
87 (UNLOAD, NSV::PROP_ON_UNLOAD)
88 (ENTER_FRAME, NSV::PROP_ON_ENTER_FRAME)
89 (MOUSE_DOWN, NSV::PROP_ON_MOUSE_DOWN)
90 (MOUSE_UP, NSV::PROP_ON_MOUSE_UP)
91 (MOUSE_MOVE, NSV::PROP_ON_MOUSE_MOVE)
92 (KEY_DOWN, NSV::PROP_ON_KEY_DOWN)
93 (KEY_UP, NSV::PROP_ON_KEY_UP)
94 (DATA, NSV::PROP_ON_DATA)
95 (CONSTRUCT, NSV::PROP_ON_CONSTRUCT);
97 EventFunctionMap::const_iterator it = e.find(_id);
98 assert(it != e.end());
99 return it->second;
102 bool
103 isKeyEvent(const event_id& e)
105 switch (e.id())
107 case event_id::KEY_DOWN:
108 case event_id::KEY_PRESS:
109 case event_id::KEY_UP:
110 return true;
111 default:
112 return false;
116 bool
117 isButtonEvent(const event_id& e)
119 switch (e.id())
121 case event_id::PRESS:
122 case event_id::RELEASE:
123 case event_id::RELEASE_OUTSIDE:
124 case event_id::ROLL_OVER:
125 case event_id::ROLL_OUT:
126 case event_id::DRAG_OVER:
127 case event_id::DRAG_OUT:
128 case event_id::KEY_PRESS:
129 return true;
130 default:
131 return false;
135 std::ostream& operator<< (std::ostream& o, const event_id& ev)
137 return (o << ev.functionName());
140 } // end of namespace gnash
142 // Local Variables:
143 // mode: C++
144 // indent-tabs-mode: t
145 // End: