15 #ifndef GUI_WIDGETS_AUXILIARY_EVENT_DISPATCHER_HPP_INCLUDED
16 #define GUI_WIDGETS_AUXILIARY_EVENT_DISPATCHER_HPP_INCLUDED
23 #include <SDL_events.h>
26 #include <boost/mpl/int.hpp>
27 #include <boost/utility/enable_if.hpp>
50 typedef std::function<
void(
104 typedef std::function<bool(
tdispatcher& dispatcher,
153 virtual bool is_at(
const tpoint& coordinate)
const = 0;
276 typename boost::enable_if<boost::mpl::has_key<
tset_event,
277 boost::mpl::int_<E> > >
::type
295 typename boost::enable_if<boost::mpl::has_key<
tset_event,
296 boost::mpl::int_<E> > >
::type
312 boost::mpl::int_<E> > >
::type
331 boost::mpl::int_<E> > >
::type
347 boost::mpl::int_<E> > >
::type
366 boost::mpl::int_<E> > >
::type
385 boost::mpl::int_<E> > >
::type
409 boost::mpl::int_<E> > >
::type
428 boost::mpl::int_<E> > >
::type
452 boost::mpl::int_<E> > >
::type
537 std::map<tevent, tsignal<T> >
queue;
545 queue[
event].pre_child.insert(
546 queue[event].pre_child.begin(), signal);
549 queue[
event].pre_child.push_back(signal);
554 .child.insert(queue[event].
child.begin(), signal);
557 queue[
event].child.push_back(signal);
561 queue[
event].post_child.insert(
562 queue[event].post_child.begin(), signal);
565 queue[
event].post_child.push_back(signal);
583 = signal_queue.
child.begin();
587 if(signal.target_type() ==
itor->target_type()) {
598 = signal_queue.
child.begin();
602 if(signal.target_type() ==
itor->target_type()) {
613 = signal_queue.
child.begin();
617 if(signal.target_type() ==
itor->target_type()) {
639 const thotkey_function&
function);
686 std::map<hotkey::HOTKEY_COMMAND, thotkey_function>
hotkeys_;
711 const tsignal_function& signal)
718 const tsignal_function& signal)
726 const tsignal_notification_function& signal)
tsignal_queue< tsignal_notification_function > signal_notification_queue_
Signal queue for callbacks in tset_event_notification.
boost::enable_if< boost::mpl::has_key< tset_event_mouse, boost::mpl::int_< E > > >::type connect_signal(const tsignal_mouse_function &signal, const tposition position=back_child)
Connect a signal for callback in tset_event_mouse.
void connect_signal_pre_key_press(tdispatcher &dispatcher, const tsignal_keyboard_function &signal)
Connects the signal for 'snooping' on the keypress.
boost::enable_if< boost::mpl::has_key< tset_event_message, boost::mpl::int_< E > > >::type disconnect_signal(const tsignal_message_function &signal, const tposition position=back_child)
Disconnect a signal for callback in tset_event_message.
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
void connect_signal(const tevent event, const tposition position, const T &signal)
Helper struct to generate the various event queues.
boost::enable_if< boost::mpl::has_key< tset_event_keyboard, boost::mpl::int_< E > > >::type connect_signal(const tsignal_keyboard_function &signal, const tposition position=back_child)
Connect a signal for callback in tset_event_keyboard.
boost::mpl::set< boost::mpl::int_< DRAW >, boost::mpl::int_< CLOSE_WINDOW >, boost::mpl::int_< MOUSE_ENTER >, boost::mpl::int_< MOUSE_LEAVE >, boost::mpl::int_< LEFT_BUTTON_DOWN >, boost::mpl::int_< LEFT_BUTTON_UP >, boost::mpl::int_< LEFT_BUTTON_CLICK >, boost::mpl::int_< LEFT_BUTTON_DOUBLE_CLICK >, boost::mpl::int_< MIDDLE_BUTTON_DOWN >, boost::mpl::int_< MIDDLE_BUTTON_UP >, boost::mpl::int_< MIDDLE_BUTTON_CLICK >, boost::mpl::int_< MIDDLE_BUTTON_DOUBLE_CLICK >, boost::mpl::int_< RIGHT_BUTTON_DOWN >, boost::mpl::int_< RIGHT_BUTTON_UP >, boost::mpl::int_< RIGHT_BUTTON_CLICK >, boost::mpl::int_< RIGHT_BUTTON_DOUBLE_CLICK > > tset_event
Helper for catching use error of tdispatcher::connect_signal.
boost::mpl::set< boost::mpl::int_< SDL_VIDEO_RESIZE >, boost::mpl::int_< SDL_MOUSE_MOTION >, boost::mpl::int_< MOUSE_MOTION >, boost::mpl::int_< SDL_LEFT_BUTTON_DOWN >, boost::mpl::int_< SDL_LEFT_BUTTON_UP >, boost::mpl::int_< SDL_MIDDLE_BUTTON_DOWN >, boost::mpl::int_< SDL_MIDDLE_BUTTON_UP >, boost::mpl::int_< SDL_RIGHT_BUTTON_DOWN >, boost::mpl::int_< SDL_RIGHT_BUTTON_UP >, boost::mpl::int_< SHOW_TOOLTIP >, boost::mpl::int_< SHOW_HELPTIP >, boost::mpl::int_< SDL_WHEEL_UP >, boost::mpl::int_< SDL_WHEEL_DOWN >, boost::mpl::int_< SDL_WHEEL_LEFT >, boost::mpl::int_< SDL_WHEEL_RIGHT > > tset_event_mouse
Helper for catching use error of tdispatcher::connect_signal.
GLuint GLuint GLsizei GLenum type
void connect_signal_notify_modified(tdispatcher &dispatcher, const tsignal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
void set_want_keyboard_input(const bool want_keyboard_input)
boost::enable_if< boost::mpl::has_key< tset_event, boost::mpl::int_< E > > >::type disconnect_signal(const tsignal_function &signal, const tposition position=back_child)
Disconnect a signal for callback in tset_event.
std::vector< T > post_child
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const thotkey_function &function)
Registers a hotkey.
std::function< bool(tdispatcher &dispatcher, hotkey::HOTKEY_COMMAND id)> thotkey_function
Hotkey function handler signature.
Base class for event handling.
tmouse_behavior mouse_behavior_
The mouse behavior for the dispatcher.
void capture_mouse()
Captures the mouse.
boost::enable_if< boost::mpl::has_key< tset_event, boost::mpl::int_< E > > >::type connect_signal(const tsignal_function &signal, const tposition position=back_child)
Connect a signal for callback in tset_event.
std::function< void(tdispatcher &dispatcher, const tevent event, bool &handled, bool &halt, const SDLKey key, const SDLMod modifier, const utf8::string &unicode)> tsignal_keyboard_function
Callback function signature.
boost::mpl::set< boost::mpl::int_< MESSAGE_SHOW_TOOLTIP >, boost::mpl::int_< MESSAGE_SHOW_HELPTIP >, boost::mpl::int_< REQUEST_PLACEMENT > > tset_event_message
Helper for catching use error of tdispatcher::connect_signal.
bool connected_
Are we connected to the event handler.
void disconnect_signal(const tevent event, const tposition position, const T &signal)
A left mouse button click event for a widget.
std::map< hotkey::HOTKEY_COMMAND, thotkey_function > hotkeys_
The registered hotkeys for this dispatcher.
A class inherited from ttext_box that displays its input as stars.
std::function< void(tdispatcher &dispatcher, const tevent event, bool &handled, bool &halt, tmessage &message)> tsignal_message_function
Callback function signature.
tsignal_queue< tsignal_message_function > signal_message_queue_
Signal queue for callbacks in tset_event_message.
bool want_keyboard_input_
Does the dispatcher want to receive keyboard input.
boost::enable_if< boost::mpl::has_key< tset_event_mouse, boost::mpl::int_< E > > >::type disconnect_signal(const tsignal_mouse_function &signal, const tposition position=back_child)
Disconnect a signal for callback in tset_event_mouse.
void release_mouse()
Releases the mouse capture.
std::function< void(tdispatcher &dispatcher, const tevent event, bool &handled, bool &halt, const tpoint &coordinate)> tsignal_mouse_function
Callback function signature.
bool fire(const tevent event, twidget &target)
Fires an event which has no extra parameters.
bool execute_hotkey(const hotkey::HOTKEY_COMMAND id)
Executes a hotkey.
Compatibility layer for using SDL 1.2 and 2.0.
boost::enable_if< boost::mpl::has_key< tset_event_notification, boost::mpl::int_< E > > >::type connect_signal(const tsignal_notification_function &signal, const tposition position=back_child)
Connect a signal for callback in tset_event_notification.
tsignal_queue< tsignal_mouse_function > signal_mouse_queue_
Signal queue for callbacks in tset_event_mouse.
void connect()
Connects the dispatcher to the event handler.
std::function< void(tdispatcher &dispatcher, const tevent event, bool &handled, bool &halt)> tsignal_function
Callback function signature.
tsignal_queue< tsignal_keyboard_function > signal_keyboard_queue_
Signal queue for callbacks in tset_event_keyboard.
void release_mouse(tdispatcher *dispatcher)
Releases a captured mouse.
tposition
The position where to add a new callback in the signal handler.
Send by a widget to notify others its contents or state are modified.
tevent
The event send to the dispatcher.
tmouse_behavior get_mouse_behavior() const
void set_mouse_behavior(const tmouse_behavior mouse_behavior)
Helper struct to generate the various signal types.
virtual bool is_at(const tpoint &coordinate) const =0
Determines whether the location is inside an active widget.
std::map< tevent, tsignal< T > > queue
std::map< std::string, tfilter >::iterator itor
boost::mpl::set< boost::mpl::int_< NOTIFY_REMOVAL >, boost::mpl::int_< NOTIFY_MODIFIED >, boost::mpl::int_< RECEIVE_KEYBOARD_FOCUS >, boost::mpl::int_< LOSE_KEYBOARD_FOCUS >, boost::mpl::int_< NOTIFY_REMOVE_TOOLTIP >, boost::mpl::int_< SDL_ACTIVATE > > tset_event_notification
Helper for catching use error of tdispatcher::connect_signal.
boost::enable_if< boost::mpl::has_key< tset_event_notification, boost::mpl::int_< E > > >::type disconnect_signal(const tsignal_notification_function &signal, const tposition position=back_child)
Disconnect a signal for callback in tset_event_notification.
boost::enable_if< boost::mpl::has_key< tset_event_keyboard, boost::mpl::int_< E > > >::type disconnect_signal(const tsignal_keyboard_function &signal, const tposition position=back_child)
Disconnect a signal for callback in tset_event_keyboard.
void disconnect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Disconnects a signal handler for a left mouse button click.
void capture_mouse(tdispatcher *dispatcher)
Captures the mouse.
The message callbacks hold a reference to a message.
std::function< void(tdispatcher &dispatcher, const tevent event, bool &handled, bool &halt, void *)> tsignal_notification_function
Callback function signature.
tmouse_behavior
The behavior of the mouse events.
bool has_event(const tevent event, const tevent_type event_type)
GLsizei GLenum GLuint GLuint GLsizei char * message
tsignal_queue< tsignal_function > signal_queue_
Signal queue for callbacks in tset_event.
bool get_want_keyboard_input() const
std::vector< T > pre_child
boost::mpl::set< boost::mpl::int_< SDL_KEY_DOWN > > tset_event_keyboard
Helper for catching use error of tdispatcher::connect_signal.
boost::enable_if< boost::mpl::has_key< tset_event_message, boost::mpl::int_< E > > >::type connect_signal(const tsignal_message_function &signal, const tposition position=back_child)
Connect a signal for callback in tset_event_message.