32 #include "autocreatelistener.h"
45 class WimpMessageListener;
50 class PrePollListener;
51 class PostPollListener;
52 class PostEventListener;
53 class UncaughtHandler;
56 const int WINDOW_AND_COMPONENT_KEY_PRESSED = 12;
57 const int WINDOW_AND_COMPONENT_MOUSE_CLICK = 13;
65 static EventRouter *instance() {
return _instance;}
71 void catch_exceptions(
bool c) {_catch_exceptions = c;}
72 void uncaught_handler(UncaughtHandler *handler) {_uncaught_handler = handler;}
76 friend class Application;
78 friend class Component;
82 void add_autocreate_listener(
const char *template_name, AutoCreateListener *listener);
83 void remove_autocreate_listener(
const char *template_name);
86 void remove_object_listener(
ObjectId handle,
ComponentId component_id,
int action, Listener *listener);
89 void add_window_event_listener(
ObjectId handle,
int event_code, Listener *listener);
90 void remove_window_event_listener(
ObjectId handle,
int event_code, Listener *listener);
91 void add_window_event_listener(
ObjectId handle,
ComponentId component_id,
int event_code, Listener *listener);
92 void remove_window_event_listener(
ObjectId handle,
ComponentId component_id,
int event_code, Listener *listener);
93 void add_window_component_event_listener(
ObjectId handle,
int event_code, Listener *listener);
94 void remove_window_component_event_listener(
ObjectId handle,
int event_code, Listener *listener);
96 void remove_all_listeners(
ObjectId handle);
99 void set_autocreate_listener(std::string template_name, AutoCreateListener *listener);
100 void clear_autocreate_listener(std::string template_name);
102 void add_message_listener(
int type,
int message_id, WimpMessageListener *listener);
103 void remove_message_listener(
int type,
int message_id, WimpMessageListener *listener);
105 void add_null_event_command(Command *command);
106 void remove_null_event_command(Command *command);
108 void set_drag_handler(DragHandler *handler,
int drag_stop_swi = 0);
111 void add_timer(
int elapsed, Timer *timer);
112 void remove_timer(Timer *timer);
115 void route_event(
int event_code);
117 void process_toolbox_event();
120 void process_null_event();
121 void process_redraw_request();
122 void process_open_window_request();
123 void process_close_window_request();
124 void process_pointer_leaving_window();
125 void process_pointer_entering_window();
126 void process_mouse_click();
127 void process_key_pressed();
128 void process_scroll_request();
129 void process_lose_caret();
130 void process_gain_caret();
132 void process_user_message();
133 void process_recorded_message();
134 void process_acknowledge_message();
139 PollBlock _poll_block;
141 bool _catch_exceptions;
142 UncaughtHandler *_uncaught_handler;
144 PrePollListener *_pre_poll_listener;
145 PostPollListener *_post_poll_listener;
146 PostEventListener *_post_event_listener;
150 struct ObjectListenerItem
156 ObjectListenerItem *next;
160 struct WindowEventListenerItem
163 WindowEventListenerItem *next;
168 struct WimpMessageListenerItem
171 WimpMessageListener *listener;
172 WimpMessageListenerItem *next;
177 bool _remove_running;
178 ObjectListenerItem *_running_object_item;
179 WindowEventListenerItem *_running_window_event_item;
180 WimpMessageListenerItem *_running_message_item;
182 std::map<ObjectId, ObjectListenerItem *> _object_listeners;
183 std::map<std::string, AutoCreateListener*> *_autocreate_listeners;
184 std::map<int, WimpMessageListenerItem *> **_message_listeners;
185 std::map<ObjectId, WindowEventListenerItem **> *_window_event_listeners;
188 class NullCommandQueue
191 unsigned int _capacity;
199 void add(Command *command);
200 void remove(Command *command);
203 unsigned int size()
const {
return _size;}
204 } *_null_event_commands;
206 DragHandler *_drag_handler;
212 unsigned int elapsed;
219 ObjectListenerItem *find_first_object_listener(
ObjectId handle,
int action);
220 WindowEventListenerItem *find_window_event_listener(
ObjectId object_id,
int event_code);
221 WindowEventListenerItem *find_window_event_component(WindowEventListenerItem *&item,
ComponentId component_id);
222 void remove_running_window_event_listener(
ObjectId object_id,
int event_code);
224 void add_timer_info(TimerInfo *info);
227 static EventRouter *_instance;
231 inline EventRouter *event_router() {
return EventRouter::instance();}