1 // Canvas Event for event model similar to DOM Level 3 Event Model
3 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
10 // This library 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 GNU
13 // Library General Public License for more details.
15 // You should have received a copy of the GNU Library General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef CANVAS_EVENT_HXX_
20 #define CANVAS_EVENT_HXX_
22 #include "canvas_fwd.hxx"
23 #include <boost/bimap.hpp>
38 # define ENUM_MAPPING(name, str) name,
39 # include "CanvasEventTypes.hxx"
41 CUSTOM_EVENT ///< all user defined event types share the same id. They
42 /// are just differentiated by using the type string.
46 ElementWeakPtr target,
49 bool propagation_stopped;
53 // We need a vtable to allow nasal::Ghost to determine the dynamic type
54 // of the actual event instances.
58 * Get whether this events support bubbling
60 virtual bool canBubble() const;
65 * If no such type exists it is registered.
67 void setType(const std::string& type);
70 std::string getTypeString() const;
72 ElementWeakPtr getTarget() const;
73 ElementWeakPtr getCurrentTarget() const;
75 double getTime() const;
77 void stopPropagation();
79 static int getOrRegisterType(const std::string& type);
80 static int strToType(const std::string& type);
81 static std::string typeToStr(int type);
86 typedef boost::bimaps::bimap<
87 boost::bimaps::tagged<std::string, name>,
88 boost::bimaps::tagged<int, id>
91 static TypeMap& getTypeMap();
96 } // namespace simgear
98 #endif /* CANVAS_EVENT_HXX_ */