00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "xrb_event.hpp"
00012
00013 #include "xrb_gui_events.hpp"
00014 #include "xrb_input_events.hpp"
00015 #include "xrb_inputstate.hpp"
00016
00017 namespace Xrb
00018 {
00019
00020 Event::~Event () { }
00021
00022 std::string const &Event::Name (EventType const event_type)
00023 {
00024 static std::string const s_event_type_name[] =
00025 {
00026 "DUMMY",
00027 "KEYDOWN",
00028 "KEYUP",
00029 "KEYREPEAT",
00030 "MOUSEBUTTONDOWN",
00031 "MOUSEBUTTONUP",
00032 "MOUSEWHEEL",
00033 "MOUSEMOTION",
00034 "JOYAXIS",
00035 "JOYBALL",
00036 "JOYBUTTONDOWN",
00037 "JOYBUTTONUP",
00038 "JOYHAT",
00039 "FOCUS",
00040 "MOUSEOVER",
00041 "DELETE_CHILD_WIDGET",
00042 "QUIT",
00043 "STATE_MACHINE_INPUT",
00044 "ENGINE2_DELETE_ENTITY",
00045 "ENGINE2_REMOVE_ENTITY_FROM_WORLD"
00046 "CUSTOM"
00047 };
00048 DEBUG1_CODE(static Uint32 const s_event_type_name_count = sizeof(s_event_type_name) / sizeof(std::string));
00049 ASSERT1(static_cast<Uint32>(event_type) < s_event_type_name_count);
00050 return s_event_type_name[static_cast<Uint32>(event_type)];
00051 }
00052
00053 EventCustom::~EventCustom () { }
00054
00055
00056
00057
00058
00059 bool MatchEventType (Event const *event, Event::EventType const event_type)
00060 {
00061 ASSERT1(event != NULL);
00062
00063 return event->GetEventType() == event_type;
00064 }
00065
00066 bool MatchCustomType (Event const *event, EventCustom::CustomType const custom_type)
00067 {
00068 ASSERT1(event != NULL);
00069
00070 return dynamic_cast<EventCustom const *>(event) != NULL &&
00071 static_cast<EventCustom const *>(event)->GetCustomType() == custom_type;
00072 }
00073
00074 }