X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fcanvas%2FCanvasEvent.cxx;h=414d19938eb775485f3510fa6ec97e829084b2b5;hb=efbec8b3671f4f909461f458fb9aa96bb86d6164;hp=36b73ecf313919b00af9f99f1b69dbe43bb72f38;hpb=77946585b1c9b54c4848b604eb1549e2ec55df12;p=simgear.git diff --git a/simgear/canvas/CanvasEvent.cxx b/simgear/canvas/CanvasEvent.cxx index 36b73ecf..414d1993 100644 --- a/simgear/canvas/CanvasEvent.cxx +++ b/simgear/canvas/CanvasEvent.cxx @@ -1,4 +1,4 @@ -// Canvas Event for event model similar to DOM Level 2 Event Model +// Canvas Event for event model similar to DOM Level 3 Event Model // // Copyright (C) 2012 Thomas Geymayer // @@ -25,7 +25,14 @@ namespace canvas //---------------------------------------------------------------------------- Event::Event(): - type(UNKNOWN) + type(UNKNOWN), + propagation_stopped(false) + { + + } + + //---------------------------------------------------------------------------- + Event::~Event() { } @@ -55,5 +62,43 @@ namespace canvas return target; } + //---------------------------------------------------------------------------- + ElementWeakPtr Event::getCurrentTarget() const + { + return current_target; + } + + //---------------------------------------------------------------------------- + double Event::getTime() const + { + return time; + } + + //---------------------------------------------------------------------------- + void Event::stopPropagation() + { + propagation_stopped = true; + } + + //---------------------------------------------------------------------------- + Event::Type Event::strToType(const std::string& str) + { + typedef std::map TypeMap; + static TypeMap type_map; + + if( type_map.empty() ) + { +# define ENUM_MAPPING(type, str) type_map[ str ] = type; +# include "CanvasEventTypes.hxx" +# undef ENUM_MAPPING + } + + TypeMap::const_iterator it = type_map.find(str); + if( it == type_map.end() ) + return UNKNOWN; + + return it->second; + } + } // namespace canvas } // namespace simgear