Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends

gui2::event::thandler Class Reference

This singleton class handles all events. More...

Inheritance diagram for gui2::event::thandler:
Inheritance graph
[legend]
Collaboration diagram for gui2::event::thandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 thandler ()
 ~thandler ()
void handle_event (const SDL_Event &event)
 Inherited from events::handler.
void connect (tdispatcher *dispatcher)
 Connects a dispatcher.
void disconnect (tdispatcher *dispatcher)
 Disconnects a dispatcher.

Public Attributes

tdispatchermouse_focus
 The dispatcher that captured the mouse focus.

Private Member Functions

void activate ()
 Reinitializes the state of all dispatchers.
void draw (const bool force)
 Fires a draw event.
void video_resize (const tpoint &new_size)
 Fires a video resize event.
void mouse (const tevent event, const tpoint &position)
 Fires a generic mouse event.
void mouse_button_up (const tpoint &position, const Uint8 button)
 Fires a mouse button up event.
void mouse_button_down (const tpoint &position, const Uint8 button)
 Fires a mouse button down event.
tdispatcherkeyboard_dispatcher ()
 Gets the dispatcher that wants to receive the keyboard input.
void hat_motion (const SDL_JoyHatEvent &event)
 Handles a hat motion event.
void button_down (const SDL_JoyButtonEvent &event)
 Handles a joystick button down event.
void key_down (const SDL_KeyboardEvent &event)
 Fires a key down event.
bool hotkey_pressed (const hotkey::hotkey_item &key)
 Handles the pressing of a hotkey.
void key_down (const SDLKey key, const SDLMod modifier, const Uint16 unicode)
 Fires a key down event.
void keyboard (const tevent event)
 Fires a keyboard event which has no parameters.

Private Attributes

std::vector< tdispatcher * > dispatchers_
 The dispatchers.
tdispatcherkeyboard_focus_
 Needed to determine which dispatcher gets the keyboard events.

Friends

bool gui2::is_in_dialog ()
void capture_keyboard (tdispatcher *)
 Captures the keyboard.

Detailed Description

This singleton class handles all events.

It's a new experimental class.

Definition at line 120 of file handler.cpp.


Constructor & Destructor Documentation

gui2::event::thandler::thandler (  ) 

Definition at line 275 of file handler.cpp.

References events::handler::join().

Here is the call graph for this function:

gui2::event::thandler::~thandler (  ) 

Definition at line 293 of file handler.cpp.

References events::handler::leave().

Here is the call graph for this function:


Member Function Documentation

void gui2::event::thandler::activate (  )  [private]

Reinitializes the state of all dispatchers.

This is needed when the application gets activated, to make sure the state of mainly the mouse is set properly.

Definition at line 449 of file handler.cpp.

References dispatchers_, gui2::event::tdispatcher::fire(), and gui2::event::SDL_ACTIVATE.

Referenced by disconnect(), and handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::button_down ( const SDL_JoyButtonEvent &  event  )  [private]

Handles a joystick button down event.

Parameters:
event The SDL joystick button event triggered.

Definition at line 637 of file handler.cpp.

References hotkey::get_hotkey(), hotkey_pressed(), and hotkey::hotkey_item::null().

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::connect ( tdispatcher dispatcher  ) 

Connects a dispatcher.

Parameters:
dispatcher The dispatcher to connect.

Definition at line 401 of file handler.cpp.

References dispatchers_, gui2::event::event_context, gui2::event::find(), and events::handler::join().

Here is the call graph for this function:

void gui2::event::thandler::disconnect ( tdispatcher dispatcher  ) 

Disconnects a dispatcher.

Parameters:
dispatcher The dispatcher to disconnect.

Definition at line 414 of file handler.cpp.

References activate(), dispatchers_, gui2::event::find(), keyboard_focus_, events::handler::leave(), and mouse_focus.

Here is the call graph for this function:

void gui2::event::thandler::draw ( const bool  force  )  [private]

Fires a draw event.

Todo:
Need to evaluate which windows really to redraw.

For now we use a hack, but would be nice to rewrite it for 1.9/1.11.

Definition at line 458 of file handler.cpp.

References dispatchers_, events::handler::draw(), gui2::event::DRAW, gui2::event::tdispatcher::fire(), CVideo::flip(), CVideo::getSurface(), and cursor::undraw().

Here is the call graph for this function:

void gui2::event::thandler::handle_event ( const SDL_Event &  event  )  [virtual]
void gui2::event::thandler::hat_motion ( const SDL_JoyHatEvent &  event  )  [private]

Handles a hat motion event.

Parameters:
event The SDL joystick hat event triggered.

Definition at line 625 of file handler.cpp.

References hotkey::get_hotkey(), hotkey_pressed(), and hotkey::hotkey_item::null().

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

bool gui2::event::thandler::hotkey_pressed ( const hotkey::hotkey_item key  )  [private]

Handles the pressing of a hotkey.

Parameters:
key The hotkey item pressed.
Returns:
True if the hotkey is handled false otherwise.

Definition at line 661 of file handler.cpp.

References gui2::event::tdispatcher::execute_hotkey(), hotkey::hotkey_item::get_id(), and keyboard_dispatcher().

Referenced by button_down(), hat_motion(), and key_down().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::key_down ( const SDLKey  key,
const SDLMod  modifier,
const Uint16  unicode 
) [private]

Fires a key down event.

Parameters:
key The SDL key code of the key pressed.
modifier The SDL key modifiers used.
unicode The unicode value for the key pressed.

Definition at line 672 of file handler.cpp.

References DBG_GUI_E, keyboard_dispatcher(), and gui2::event::SDL_KEY_DOWN.

Here is the call graph for this function:

void gui2::event::thandler::key_down ( const SDL_KeyboardEvent &  event  )  [private]

Fires a key down event.

Parameters:
event The SDL keyboard event triggered.

Definition at line 649 of file handler.cpp.

References hotkey::get_hotkey(), hotkey_pressed(), and hotkey::hotkey_item::null().

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::keyboard ( const tevent  event  )  [private]

Fires a keyboard event which has no parameters.

This can happen for example when the mouse wheel is used.

Parameters:
event The event to fire.

Definition at line 687 of file handler.cpp.

References DBG_GUI_E, and keyboard_dispatcher().

Here is the call graph for this function:

tdispatcher * gui2::event::thandler::keyboard_dispatcher (  )  [private]

Gets the dispatcher that wants to receive the keyboard input.

Returns:
The dispatcher.
Return values:
NULL No dispatcher found.

Definition at line 608 of file handler.cpp.

References dispatchers_, and keyboard_focus_.

Referenced by hotkey_pressed(), key_down(), and keyboard().

Here is the caller graph for this function:

void gui2::event::thandler::mouse ( const tevent  event,
const tpoint position 
) [private]

Fires a generic mouse event.

Parameters:
event The event to fire.
position The position of the mouse.

Definition at line 513 of file handler.cpp.

References DBG_GUI_E, dispatchers_, gui2::event::tdispatcher::fire(), and mouse_focus.

Referenced by handle_event(), mouse_button_down(), and mouse_button_up().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::mouse_button_down ( const tpoint position,
const Uint8  button 
) [private]

Fires a mouse button down event.

Parameters:
position The position of the mouse.
button The SDL id of the button that caused the event.

Definition at line 578 of file handler.cpp.

References mouse(), SDL_BUTTON_WHEELDOWN, SDL_BUTTON_WHEELLEFT, SDL_BUTTON_WHEELRIGHT, SDL_BUTTON_WHEELUP, gui2::event::SDL_LEFT_BUTTON_DOWN, gui2::event::SDL_MIDDLE_BUTTON_DOWN, gui2::event::SDL_RIGHT_BUTTON_DOWN, and WRN_GUI_E.

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::mouse_button_up ( const tpoint position,
const Uint8  button 
) [private]

Fires a mouse button up event.

Parameters:
position The position of the mouse.
button The SDL id of the button that caused the event.

Definition at line 545 of file handler.cpp.

References gui2::get_mouse_position(), mouse(), SDL_BUTTON_WHEELDOWN, SDL_BUTTON_WHEELLEFT, SDL_BUTTON_WHEELRIGHT, SDL_BUTTON_WHEELUP, gui2::event::SDL_LEFT_BUTTON_UP, gui2::event::SDL_MIDDLE_BUTTON_UP, gui2::event::SDL_RIGHT_BUTTON_UP, gui2::event::SDL_WHEEL_DOWN, gui2::event::SDL_WHEEL_LEFT, gui2::event::SDL_WHEEL_RIGHT, gui2::event::SDL_WHEEL_UP, and WRN_GUI_E.

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::event::thandler::video_resize ( const tpoint new_size  )  [private]

Fires a video resize event.

Parameters:
new_size The new size of the window.

Definition at line 502 of file handler.cpp.

References DBG_GUI_E, dispatchers_, gui2::event::tdispatcher::fire(), and gui2::event::SDL_VIDEO_RESIZE.

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

void capture_keyboard ( tdispatcher  )  [friend]

Captures the keyboard.

A dispatcher can capture the keyboard, when for example it's pressed on a button, this means all keyboard events after that are send to that widget.

Parameters:
dispatcher The dispatcher which should get the keyboard focus.
bool gui2::is_in_dialog (  )  [friend]

Member Data Documentation

The dispatchers.

The order of the items in the list is also the z-order the front item being the one completely in the background and the back item the one completely in the foreground.

Definition at line 264 of file handler.cpp.

Referenced by activate(), connect(), disconnect(), draw(), handle_event(), keyboard_dispatcher(), mouse(), and video_resize().

Needed to determine which dispatcher gets the keyboard events.

NOTE the keyboard events aren't really wired in yet so doesn't do much.

Definition at line 271 of file handler.cpp.

Referenced by disconnect(), and keyboard_dispatcher().

The dispatcher that captured the mouse focus.

Definition at line 147 of file handler.cpp.

Referenced by disconnect(), and mouse().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:24:03 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs