#include <xrb_event.hpp>
Public Types | |
enum | EventType { DUMMY = 0, KEYDOWN, KEYUP, KEYREPEAT, MOUSEBUTTONDOWN, MOUSEBUTTONUP, MOUSEWHEEL, MOUSEMOTION, JOYAXIS, JOYBALL, JOYBUTTONDOWN, JOYBUTTONUP, JOYHAT, FOCUS, MOUSEOVER, DELETE_CHILD_WIDGET, QUIT, STATE_MACHINE_INPUT, ENGINE2_DELETE_ENTITY, ENGINE2_REMOVE_ENTITY_FROM_WORLD, CUSTOM } |
Enumeration for all Event subclasses. More... | |
Public Member Functions | |
Event (Float time, EventType event_type) | |
Construct an event with the given timestamp and event_type. | |
virtual | ~Event ()=0 |
Destructor. | |
Float | Time () const |
Returns the event's timestamp. | |
EventType | GetEventType () const |
Returns the event's type. | |
Uint32 | ID () const |
Returns the ID of the event. | |
bool | IsScheduledForDeletion () const |
Returns true iff the EventQueue has scheduled this event to be deleted. | |
virtual bool | IsInputEvent () const |
Returns true iff this is an input event (key/mouse/joy). | |
virtual bool | IsKeyEvent () const |
Returns true iff this is a keyboard event. | |
virtual bool | IsMouseEvent () const |
Returns true iff this is a mouse event. | |
virtual bool | IsMouseButtonEvent () const |
Returns true iff this is a mouse button event. | |
virtual bool | IsMouseMotionEvent () const |
Returns true iff this is a mouse motion event. | |
virtual bool | IsJoyEvent () const |
Returns true iff this is a joy event. | |
Static Public Member Functions | |
static std::string const & | Name (EventType event_type) |
Returns the textual representation of the event type. | |
Friends | |
class | EventQueue |
Events are generated to indicate when certain events have happened, such as a key stroke, mouse motion, etc. The Event object itself carries all the information about the event as well. Events are processed by subclasses of EventHandler, in their overridden Xrb::EventHandler::HandleEvent methods.
Events are generally created in the game loop, though they are also produced elsewhere ( e.g. in Xrb::Widget::InternalProcessMouseEvent ). The most important concept is that the event handler should never delete the event itself. This restriction is made so that the event pointer points to valid memory for the entire scope of all HandleEvent calls (specifically referring to the recursive event handling of the widget hierarchy), only being deleted when execution gets back to the scope at which the event was created (e.g. the game loop).
Events contain a timestamp, which is usually the time at which they were generated. This is necessary for purposes of proper ordering for events queued in EventQueue. For events being queued in EventQueue, the event may be constructed with a time in the future. This has the intuitive function of scheduling the event to be processed at (no earlier than) that future time.
Events processed by EventHandler must be processed in chronological order. Care must be used, when constructing events, to supply the correct timestamp. ---- It is planned that a GameLoop class will be made, which will handle all tracking of the "current time", and all necessary queries for the current time will be made to the GameLoop class, so that it doesn't need to be derived from some other object (like a FrameHandler).
Definition at line 53 of file xrb_event.hpp.
Enumeration for all Event subclasses.
These enum values are used for real-time type information, used mainly for determining what specific event handler function should be used to process the event.
Definition at line 62 of file xrb_event.hpp.
Xrb::Event::Event | ( | Float | time, | |
EventType | event_type | |||
) | [inline] |
Construct an event with the given timestamp and event_type.
It should be noted that EventHandler checks that the events it processes have non-descending timestamps. Processing an event with a time less than the most recently processed will cause an assert.
Definition at line 93 of file xrb_event.hpp.
Xrb::Event::~Event | ( | ) | [pure virtual] |
Destructor.
Pure virtual. No other pure virtual functions exist in Event, so the destructor must be pure virtual in order to make Event pure virtual. A non-subclassed Event cannot be created.
Definition at line 20 of file xrb_event.cpp.
Uint32 Xrb::Event::ID | ( | ) | const [inline] |
Returns the ID of the event.
This is used by EventQueue. You should not need to use it.
Definition at line 120 of file xrb_event.hpp.
bool Xrb::Event::IsScheduledForDeletion | ( | ) | const [inline] |
Returns true iff the EventQueue has scheduled this event to be deleted.
Events that have been scheduled to be deleted should never be processed.
Definition at line 126 of file xrb_event.hpp.
Referenced by Xrb::EventHandler::ProcessEvent().
virtual bool Xrb::Event::IsInputEvent | ( | ) | const [inline, virtual] |
Returns true iff this is an input event (key/mouse/joy).
Input event subclasses (key/mouse/joy) will override this function to return true.
Reimplemented in Xrb::EventInput.
Definition at line 131 of file xrb_event.hpp.
virtual bool Xrb::Event::IsKeyEvent | ( | ) | const [inline, virtual] |
Returns true iff this is a keyboard event.
Keyboard event subclasses will override this function to return true.
Reimplemented in Xrb::EventKey.
Definition at line 135 of file xrb_event.hpp.
Referenced by Xrb::KeyRepeater::HandleEvent().
virtual bool Xrb::Event::IsMouseEvent | ( | ) | const [inline, virtual] |
Returns true iff this is a mouse event.
Mouse event subclasses will override this function to return true.
Reimplemented in Xrb::EventMouse.
Definition at line 139 of file xrb_event.hpp.
virtual bool Xrb::Event::IsMouseButtonEvent | ( | ) | const [inline, virtual] |
Returns true iff this is a mouse button event.
Mouse button event subclasses will override this function to return true.
Reimplemented in Xrb::EventMouseButton.
Definition at line 144 of file xrb_event.hpp.
virtual bool Xrb::Event::IsMouseMotionEvent | ( | ) | const [inline, virtual] |
Returns true iff this is a mouse motion event.
Mouse motion event subclasses will override this function to return true.
Reimplemented in Xrb::EventMouseMotion.
Definition at line 149 of file xrb_event.hpp.
virtual bool Xrb::Event::IsJoyEvent | ( | ) | const [inline, virtual] |
Returns true iff this is a joy event.
Joy event subclasses will override this function to return true.
Reimplemented in Xrb::EventJoy.
Definition at line 153 of file xrb_event.hpp.