]> git.saurik.com Git - wxWidgets.git/blob - src/common/event.cpp
Whole lotta stuff for wxPlotWindow,
[wxWidgets.git] / src / common / event.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: event.cpp
3 // Purpose: Event classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "event.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/defs.h"
33 #include "wx/app.h"
34 #include "wx/list.h"
35
36 #if wxUSE_GUI
37 #include "wx/control.h"
38 #include "wx/utils.h"
39 #include "wx/dc.h"
40 #endif // wxUSE_GUI
41 #endif
42
43 #include "wx/event.h"
44
45 #if wxUSE_GUI
46 #include "wx/validate.h"
47 #endif // wxUSE_GUI
48
49
50 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
51 // must define these static for VA or else you get multiply defined symbols everywhere
52 const wxEventType wxEVT_NULL = 0;
53 const wxEventType wxEVT_FIRST = 10000;
54
55 const wxEventType wxEVT_COMMAND_BUTTON_CLICKED = wxEVT_FIRST + 1;
56 const wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED = wxEVT_FIRST + 2;
57 const wxEventType wxEVT_COMMAND_CHOICE_SELECTED = wxEVT_FIRST + 3;
58 const wxEventType wxEVT_COMMAND_LISTBOX_SELECTED = wxEVT_FIRST + 4;
59 const wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxEVT_FIRST + 5;
60 const wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxEVT_FIRST + 6;
61 const wxEventType wxEVT_COMMAND_TEXT_UPDATED = wxEVT_FIRST + 7;
62 const wxEventType wxEVT_COMMAND_TEXT_ENTER = wxEVT_FIRST + 8;
63 const wxEventType wxEVT_COMMAND_MENU_SELECTED = wxEVT_FIRST + 9;
64 const wxEventType wxEVT_COMMAND_TOOL_CLICKED = wxEVT_COMMAND_MENU_SELECTED;
65 const wxEventType wxEVT_COMMAND_SLIDER_UPDATED = wxEVT_FIRST + 10;
66 const wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED = wxEVT_FIRST + 11;
67 const wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED = wxEVT_FIRST + 12;
68 //const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use wxEVT_SCROLL... events
69 const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED = wxEVT_FIRST + 13;
70 const wxEventType wxEVT_COMMAND_VLBOX_SELECTED = wxEVT_FIRST + 14;
71 const wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED = wxEVT_FIRST + 15;
72 const wxEventType wxEVT_COMMAND_TOOL_RCLICKED = wxEVT_FIRST + 16;
73 const wxEventType wxEVT_COMMAND_TOOL_ENTER = wxEVT_FIRST + 17;
74 const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED = wxEVT_FIRST + 18;
75
76 /* Sockets send events, too */
77 const wxEventType wxEVT_SOCKET = wxEVT_FIRST + 50;
78 const wxEventType wxEVT_TIMER = wxEVT_FIRST + 80;
79
80 /* Mouse event types */
81 const wxEventType wxEVT_LEFT_DOWN = wxEVT_FIRST + 100;
82 const wxEventType wxEVT_LEFT_UP = wxEVT_FIRST + 101;
83 const wxEventType wxEVT_MIDDLE_DOWN = wxEVT_FIRST + 102;
84 const wxEventType wxEVT_MIDDLE_UP = wxEVT_FIRST + 103;
85 const wxEventType wxEVT_RIGHT_DOWN = wxEVT_FIRST + 104;
86 const wxEventType wxEVT_RIGHT_UP = wxEVT_FIRST + 105;
87 const wxEventType wxEVT_MOTION = wxEVT_FIRST + 106;
88 const wxEventType wxEVT_ENTER_WINDOW = wxEVT_FIRST + 107;
89 const wxEventType wxEVT_LEAVE_WINDOW = wxEVT_FIRST + 108;
90 const wxEventType wxEVT_LEFT_DCLICK = wxEVT_FIRST + 109;
91 const wxEventType wxEVT_MIDDLE_DCLICK = wxEVT_FIRST + 110;
92 const wxEventType wxEVT_RIGHT_DCLICK = wxEVT_FIRST + 111;
93 const wxEventType wxEVT_SET_FOCUS = wxEVT_FIRST + 112;
94 const wxEventType wxEVT_KILL_FOCUS = wxEVT_FIRST + 113;
95
96 /* Non-client mouse events */
97 const wxEventType wxEVT_NC_LEFT_DOWN = wxEVT_FIRST + 200;
98 const wxEventType wxEVT_NC_LEFT_UP = wxEVT_FIRST + 201;
99 const wxEventType wxEVT_NC_MIDDLE_DOWN = wxEVT_FIRST + 202;
100 const wxEventType wxEVT_NC_MIDDLE_UP = wxEVT_FIRST + 203;
101 const wxEventType wxEVT_NC_RIGHT_DOWN = wxEVT_FIRST + 204;
102 const wxEventType wxEVT_NC_RIGHT_UP = wxEVT_FIRST + 205;
103 const wxEventType wxEVT_NC_MOTION = wxEVT_FIRST + 206;
104 const wxEventType wxEVT_NC_ENTER_WINDOW = wxEVT_FIRST + 207;
105 const wxEventType wxEVT_NC_LEAVE_WINDOW = wxEVT_FIRST + 208;
106 const wxEventType wxEVT_NC_LEFT_DCLICK = wxEVT_FIRST + 209;
107 const wxEventType wxEVT_NC_MIDDLE_DCLICK = wxEVT_FIRST + 210;
108 const wxEventType wxEVT_NC_RIGHT_DCLICK = wxEVT_FIRST + 211;
109
110 /* Character input event type */
111 const wxEventType wxEVT_CHAR = wxEVT_FIRST + 212;
112 const wxEventType wxEVT_CHAR_HOOK = wxEVT_FIRST + 213;
113 const wxEventType wxEVT_NAVIGATION_KEY = wxEVT_FIRST + 214;
114 const wxEventType wxEVT_KEY_DOWN = wxEVT_FIRST + 215;
115 const wxEventType wxEVT_KEY_UP = wxEVT_FIRST + 216;
116
117 /*
118 * wxScrollbar and wxSlider event identifiers
119 */
120 const wxEventType wxEVT_SCROLL_TOP = wxEVT_FIRST + 300;
121 const wxEventType wxEVT_SCROLL_BOTTOM = wxEVT_FIRST + 301;
122 const wxEventType wxEVT_SCROLL_LINEUP = wxEVT_FIRST + 302;
123 const wxEventType wxEVT_SCROLL_LINEDOWN = wxEVT_FIRST + 303;
124 const wxEventType wxEVT_SCROLL_PAGEUP = wxEVT_FIRST + 304;
125 const wxEventType wxEVT_SCROLL_PAGEDOWN = wxEVT_FIRST + 305;
126 const wxEventType wxEVT_SCROLL_THUMBTRACK = wxEVT_FIRST + 306;
127
128 /*
129 * Scroll events from wxWindow
130 */
131 const wxEventType wxEVT_SCROLLWIN_TOP = wxEVT_FIRST + 320;
132 const wxEventType wxEVT_SCROLLWIN_BOTTOM = wxEVT_FIRST + 321;
133 const wxEventType wxEVT_SCROLLWIN_LINEUP = wxEVT_FIRST + 322;
134 const wxEventType wxEVT_SCROLLWIN_LINEDOWN = wxEVT_FIRST + 323;
135 const wxEventType wxEVT_SCROLLWIN_PAGEUP = wxEVT_FIRST + 324;
136 const wxEventType wxEVT_SCROLLWIN_PAGEDOWN = wxEVT_FIRST + 325;
137 const wxEventType wxEVT_SCROLLWIN_THUMBTRACK = wxEVT_FIRST + 326;
138
139 /*
140 * System events
141 */
142 const wxEventType wxEVT_SIZE = wxEVT_FIRST + 400;
143 const wxEventType wxEVT_MOVE = wxEVT_FIRST + 401;
144 const wxEventType wxEVT_CLOSE_WINDOW = wxEVT_FIRST + 402;
145 const wxEventType wxEVT_END_SESSION = wxEVT_FIRST + 403;
146 const wxEventType wxEVT_QUERY_END_SESSION = wxEVT_FIRST + 404;
147 const wxEventType wxEVT_ACTIVATE_APP = wxEVT_FIRST + 405;
148 const wxEventType wxEVT_POWER = wxEVT_FIRST + 406;
149 const wxEventType wxEVT_ACTIVATE = wxEVT_FIRST + 409;
150 const wxEventType wxEVT_CREATE = wxEVT_FIRST + 410;
151 const wxEventType wxEVT_DESTROY = wxEVT_FIRST + 411;
152 const wxEventType wxEVT_SHOW = wxEVT_FIRST + 412;
153 const wxEventType wxEVT_ICONIZE = wxEVT_FIRST + 413;
154 const wxEventType wxEVT_MAXIMIZE = wxEVT_FIRST + 414;
155 const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED = wxEVT_FIRST + 415;
156 const wxEventType wxEVT_PAINT = wxEVT_FIRST + 416;
157 const wxEventType wxEVT_ERASE_BACKGROUND = wxEVT_FIRST + 417;
158 const wxEventType wxEVT_NC_PAINT = wxEVT_FIRST + 418;
159 const wxEventType wxEVT_PAINT_ICON = wxEVT_FIRST + 419;
160 const wxEventType wxEVT_MENU_CHAR = wxEVT_FIRST + 420;
161 const wxEventType wxEVT_MENU_INIT = wxEVT_FIRST + 421;
162 const wxEventType wxEVT_MENU_HIGHLIGHT = wxEVT_FIRST + 422;
163 const wxEventType wxEVT_POPUP_MENU_INIT = wxEVT_FIRST + 423;
164 const wxEventType wxEVT_CONTEXT_MENU = wxEVT_FIRST + 424;
165 const wxEventType wxEVT_SYS_COLOUR_CHANGED = wxEVT_FIRST + 425;
166 const wxEventType wxEVT_SETTING_CHANGED = wxEVT_FIRST + 426;
167 const wxEventType wxEVT_QUERY_NEW_PALETTE = wxEVT_FIRST + 427;
168 const wxEventType wxEVT_PALETTE_CHANGED = wxEVT_FIRST + 428;
169 const wxEventType wxEVT_JOY_BUTTON_DOWN = wxEVT_FIRST + 429;
170 const wxEventType wxEVT_JOY_BUTTON_UP = wxEVT_FIRST + 430;
171 const wxEventType wxEVT_JOY_MOVE = wxEVT_FIRST + 431;
172 const wxEventType wxEVT_JOY_ZMOVE = wxEVT_FIRST + 432;
173 const wxEventType wxEVT_DROP_FILES = wxEVT_FIRST + 433;
174 const wxEventType wxEVT_DRAW_ITEM = wxEVT_FIRST + 434;
175 const wxEventType wxEVT_MEASURE_ITEM = wxEVT_FIRST + 435;
176 const wxEventType wxEVT_COMPARE_ITEM = wxEVT_FIRST + 436;
177 const wxEventType wxEVT_INIT_DIALOG = wxEVT_FIRST + 437;
178 const wxEventType wxEVT_IDLE = wxEVT_FIRST + 438;
179 const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439;
180
181 /* System misc. */
182 const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440;
183
184 /* Dial up events */
185 const wxEventType wxEVT_DIALUP_CONNECTED = wxEVT_FIRST + 450;
186 const wxEventType wxEVT_DIALUP_DISCONNECTED = wxEVT_FIRST + 451;
187
188 /* Generic command events */
189 /* Note: a click is a higher-level event than button down/up */
190 const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500;
191 const wxEventType wxEVT_COMMAND_LEFT_DCLICK = wxEVT_FIRST + 501;
192 const wxEventType wxEVT_COMMAND_RIGHT_CLICK = wxEVT_FIRST + 502;
193 const wxEventType wxEVT_COMMAND_RIGHT_DCLICK = wxEVT_FIRST + 503;
194 const wxEventType wxEVT_COMMAND_SET_FOCUS = wxEVT_FIRST + 504;
195 const wxEventType wxEVT_COMMAND_KILL_FOCUS = wxEVT_FIRST + 505;
196 const wxEventType wxEVT_COMMAND_ENTER = wxEVT_FIRST + 506;
197
198 /* Tree control event types */
199 const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG = wxEVT_FIRST + 600;
200 const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG = wxEVT_FIRST + 601;
201 const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wxEVT_FIRST + 602;
202 const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT = wxEVT_FIRST + 603;
203 const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM = wxEVT_FIRST + 604;
204 const wxEventType wxEVT_COMMAND_TREE_GET_INFO = wxEVT_FIRST + 605;
205 const wxEventType wxEVT_COMMAND_TREE_SET_INFO = wxEVT_FIRST + 606;
206 const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED = wxEVT_FIRST + 607;
207 const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING = wxEVT_FIRST + 608;
208 const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wxEVT_FIRST + 609;
209 const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxEVT_FIRST + 610;
210 const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611;
211 const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612;
212 const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613;
213 const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxEVT_FIRST + 614;
214 const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxEVT_FIRST + 615;
215 const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 616;
216
217 /* List control event types */
218 const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700;
219 const wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxEVT_FIRST + 701;
220 const wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxEVT_FIRST + 702;
221 const wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT = wxEVT_FIRST + 703;
222 const wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM = wxEVT_FIRST + 704;
223 const wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wxEVT_FIRST + 705;
224 const wxEventType wxEVT_COMMAND_LIST_GET_INFO = wxEVT_FIRST + 706;
225 const wxEventType wxEVT_COMMAND_LIST_SET_INFO = wxEVT_FIRST + 707;
226 const wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED = wxEVT_FIRST + 708;
227 const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxEVT_FIRST + 709;
228 const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN = wxEVT_FIRST + 710;
229 const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM = wxEVT_FIRST + 711;
230 const wxEventType wxEVT_COMMAND_LIST_COL_CLICK = wxEVT_FIRST + 712;
231 const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713;
232 const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714;
233 const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxEVT_FIRST + 715;
234
235 /* Tab and notebook control event types */
236 const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800;
237 const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING = wxEVT_FIRST + 801;
238 const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxEVT_FIRST + 802;
239 const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxEVT_FIRST + 803;
240
241 /* Splitter events */
242 const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED = wxEVT_FIRST + 850;
243 const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING = wxEVT_FIRST + 851;
244 const wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED = wxEVT_FIRST + 852;
245 const wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT = wxEVT_FIRST + 853;
246
247 /* Wizard events */
248 const wxEventType wxEVT_WIZARD_PAGE_CHANGED = wxEVT_FIRST + 900;
249 const wxEventType wxEVT_WIZARD_PAGE_CHANGING = wxEVT_FIRST + 901;
250 const wxEventType wxEVT_WIZARD_CANCEL = wxEVT_FIRST + 902;
251
252 /* Calendar events */
253 const wxEventType wxEVT_CALENDAR_SEL_CHANGED = wxEVT_FIRST + 950;
254 const wxEventType wxEVT_CALENDAR_DAY_CHANGED = wxEVT_FIRST + 951;
255 const wxEventType wxEVT_CALENDAR_MONTH_CHANGED = wxEVT_FIRST + 952;
256 const wxEventType wxEVT_CALENDAR_YEAR_CHANGED = wxEVT_FIRST + 953;
257 const wxEventType wxEVT_CALENDAR_DOUBLECLICKED = wxEVT_FIRST + 954;
258 const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED = wxEVT_FIRST + 955;
259
260 const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
261 #endif
262
263 // ----------------------------------------------------------------------------
264 // wxWin macros
265 // ----------------------------------------------------------------------------
266
267 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
268 IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
269 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
270
271 #if wxUSE_GUI
272 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent)
273 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent)
274 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent)
275 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent, wxEvent)
276 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent)
277 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent)
278 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent)
279 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent)
280 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent)
281 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent)
282 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent)
283 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent)
284 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent)
285 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent)
286 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent)
287 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent)
288 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent)
289 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent)
290 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent)
291 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent)
292 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent)
293 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent)
294 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent)
295 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent)
296 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent, wxEvent)
297 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent, wxEvent)
298 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent)
299 #endif // wxUSE_GUI
300
301 const wxEventTable *wxEvtHandler::GetEventTable() const
302 { return &wxEvtHandler::sm_eventTable; }
303
304 const wxEventTable wxEvtHandler::sm_eventTable =
305 { (const wxEventTable *)NULL, &wxEvtHandler::sm_eventTableEntries[0] };
306
307 const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] =
308 { { 0, 0, 0, (wxObjectEventFunction) NULL, (wxObject*) NULL } };
309
310
311 // ----------------------------------------------------------------------------
312 // global variables
313 // ----------------------------------------------------------------------------
314
315 // To put pending event handlers
316 wxList *wxPendingEvents = (wxList *)NULL;
317
318 #if wxUSE_THREADS
319 // protects wxPendingEvents list
320 wxCriticalSection *wxPendingEventsLocker = (wxCriticalSection *)NULL;
321 #endif
322
323 // ============================================================================
324 // implementation
325 // ============================================================================
326
327 // ----------------------------------------------------------------------------
328 // wxEvent
329 // ----------------------------------------------------------------------------
330
331 /*
332 * General wxWindows events, covering
333 * all interesting things that might happen (button clicking, resizing,
334 * setting text in widgets, etc.).
335 *
336 * For each completely new event type, derive a new event class.
337 *
338 */
339
340 wxEvent::wxEvent(int theId)
341 {
342 m_eventType = wxEVT_NULL;
343 m_eventObject = (wxObject *) NULL;
344 m_timeStamp = 0;
345 m_id = theId;
346 m_skipped = FALSE;
347 m_callbackUserData = (wxObject *) NULL;
348 m_isCommandEvent = FALSE;
349 }
350
351 void wxEvent::CopyObject(wxObject& object_dest) const
352 {
353 wxEvent *obj = (wxEvent *)&object_dest;
354 wxObject::CopyObject(object_dest);
355
356 obj->m_eventType = m_eventType;
357 obj->m_eventObject = m_eventObject;
358 obj->m_timeStamp = m_timeStamp;
359 obj->m_id = m_id;
360 obj->m_skipped = m_skipped;
361 obj->m_callbackUserData = m_callbackUserData;
362 obj->m_isCommandEvent = m_isCommandEvent;
363 }
364
365 #if wxUSE_GUI
366
367 /*
368 * Command events
369 *
370 */
371
372 wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId)
373 {
374 m_eventType = commandType;
375 m_clientData = (char *) NULL;
376 m_clientObject = (wxClientData *) NULL;
377 m_extraLong = 0;
378 m_commandInt = 0;
379 m_id = theId;
380 m_commandString = wxEmptyString;
381 m_isCommandEvent = TRUE;
382 }
383
384 void wxCommandEvent::CopyObject(wxObject& obj_d) const
385 {
386 wxCommandEvent *obj = (wxCommandEvent *)&obj_d;
387
388 wxEvent::CopyObject(obj_d);
389
390 obj->m_clientData = m_clientData;
391 obj->m_clientObject = m_clientObject;
392 obj->m_extraLong = m_extraLong;
393 obj->m_commandInt = m_commandInt;
394 obj->m_commandString = m_commandString;
395 }
396
397 /*
398 * Notify events
399 */
400
401 void wxNotifyEvent::CopyObject(wxObject& obj_d) const
402 {
403 wxNotifyEvent *obj = (wxNotifyEvent *)&obj_d;
404
405 wxEvent::CopyObject(obj_d);
406
407 if (!m_bAllow) obj->Veto();
408 }
409
410 /*
411 * Scroll events
412 */
413
414 wxScrollEvent::wxScrollEvent(wxEventType commandType,
415 int id,
416 int pos,
417 int orient)
418 : wxCommandEvent(commandType, id)
419 {
420 m_extraLong = orient;
421 m_commandInt = pos;
422 m_isScrolling = TRUE;
423 }
424
425 void wxScrollEvent::CopyObject(wxObject& obj_d) const
426 {
427 wxScrollEvent *obj = (wxScrollEvent*)&obj_d;
428
429 wxCommandEvent::CopyObject(obj_d);
430
431 obj->m_isScrolling = m_isScrolling;
432 }
433
434 /*
435 * ScrollWin events
436 */
437
438 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType,
439 int pos,
440 int orient)
441 {
442 m_eventType = commandType;
443 m_extraLong = orient;
444 m_commandInt = pos;
445 m_isScrolling = TRUE;
446 }
447
448 void wxScrollWinEvent::CopyObject(wxObject& obj_d) const
449 {
450 wxScrollWinEvent *obj = (wxScrollWinEvent*)&obj_d;
451
452 wxEvent::CopyObject(obj_d);
453
454 obj->m_extraLong = m_extraLong;
455 obj->m_commandInt = m_commandInt;
456 obj->m_isScrolling = m_isScrolling;
457 }
458
459 /*
460 * Mouse events
461 *
462 */
463
464 wxMouseEvent::wxMouseEvent(wxEventType commandType)
465 {
466 m_eventType = commandType;
467 m_metaDown = FALSE;
468 m_altDown = FALSE;
469 m_controlDown = FALSE;
470 m_shiftDown = FALSE;
471 m_leftDown = FALSE;
472 m_rightDown = FALSE;
473 m_middleDown = FALSE;
474 m_x = 0;
475 m_y = 0;
476 }
477
478 void wxMouseEvent::CopyObject(wxObject& obj_d) const
479 {
480 wxMouseEvent *obj = (wxMouseEvent *)&obj_d;
481
482 wxEvent::CopyObject(obj_d);
483
484 obj->m_metaDown = m_metaDown;
485 obj->m_altDown = m_altDown;
486 obj->m_controlDown = m_controlDown;
487 obj->m_shiftDown = m_shiftDown;
488 obj->m_leftDown = m_leftDown;
489 obj->m_rightDown = m_rightDown;
490 obj->m_middleDown = m_middleDown;
491 obj->m_x = m_x;
492 obj->m_y = m_y;
493 }
494
495 // True if was a button dclick event (1 = left, 2 = middle, 3 = right)
496 // or any button dclick event (but = -1)
497 bool wxMouseEvent::ButtonDClick(int but) const
498 {
499 switch (but)
500 {
501 case -1:
502 return (LeftDClick() || MiddleDClick() || RightDClick());
503 case 1:
504 return LeftDClick();
505 case 2:
506 return MiddleDClick();
507 case 3:
508 return RightDClick();
509 default:
510 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
511 }
512
513 return FALSE;
514 }
515
516 // True if was a button down event (1 = left, 2 = middle, 3 = right)
517 // or any button down event (but = -1)
518 bool wxMouseEvent::ButtonDown(int but) const
519 {
520 switch (but)
521 {
522 case -1:
523 return (LeftDown() || MiddleDown() || RightDown());
524 case 1:
525 return LeftDown();
526 case 2:
527 return MiddleDown();
528 case 3:
529 return RightDown();
530 default:
531 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
532 }
533
534 return FALSE;
535 }
536
537 // True if was a button up event (1 = left, 2 = middle, 3 = right)
538 // or any button up event (but = -1)
539 bool wxMouseEvent::ButtonUp(int but) const
540 {
541 switch (but) {
542 case -1:
543 return (LeftUp() || MiddleUp() || RightUp());
544 case 1:
545 return LeftUp();
546 case 2:
547 return MiddleUp();
548 case 3:
549 return RightUp();
550 default:
551 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
552 }
553
554 return FALSE;
555 }
556
557 // True if the given button is currently changing state
558 bool wxMouseEvent::Button(int but) const
559 {
560 switch (but) {
561 case -1:
562 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
563 case 1:
564 return (LeftDown() || LeftUp() || LeftDClick());
565 case 2:
566 return (MiddleDown() || MiddleUp() || MiddleDClick());
567 case 3:
568 return (RightDown() || RightUp() || RightDClick());
569 default:
570 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
571 }
572
573 return FALSE;
574 }
575
576 bool wxMouseEvent::ButtonIsDown(int but) const
577 {
578 switch (but) {
579 case -1:
580 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
581 case 1:
582 return LeftIsDown();
583 case 2:
584 return MiddleIsDown();
585 case 3:
586 return RightIsDown();
587 default:
588 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
589 }
590
591 return FALSE;
592 }
593
594 // Find the logical position of the event given the DC
595 wxPoint wxMouseEvent::GetLogicalPosition(const wxDC& dc) const
596 {
597 wxPoint pt(dc.DeviceToLogicalX(m_x), dc.DeviceToLogicalY(m_y));
598 return pt;
599 }
600
601
602 /*
603 * Keyboard events
604 *
605 */
606
607 wxKeyEvent::wxKeyEvent(wxEventType type)
608 {
609 m_eventType = type;
610 m_shiftDown = FALSE;
611 m_controlDown = FALSE;
612 m_metaDown = FALSE;
613 m_altDown = FALSE;
614 m_keyCode = 0;
615 m_scanCode = 0;
616 }
617
618 void wxKeyEvent::CopyObject(wxObject& obj_d) const
619 {
620 wxKeyEvent *obj = (wxKeyEvent *)&obj_d;
621 wxEvent::CopyObject(obj_d);
622
623 obj->m_x = m_x;
624 obj->m_y = m_y;
625 obj->m_keyCode = m_keyCode;
626
627 obj->m_shiftDown = m_shiftDown;
628 obj->m_controlDown = m_controlDown;
629 obj->m_metaDown = m_metaDown;
630 obj->m_altDown = m_altDown;
631 obj->m_keyCode = m_keyCode;
632 }
633
634
635 /*
636 * Misc events
637 */
638
639 void wxSizeEvent::CopyObject(wxObject& obj_d) const
640 {
641 wxSizeEvent *obj = (wxSizeEvent *)&obj_d;
642 wxEvent::CopyObject(obj_d);
643
644 obj->m_size = m_size;
645 }
646
647 void wxMoveEvent::CopyObject(wxObject& obj_d) const
648 {
649 wxMoveEvent *obj = (wxMoveEvent *)&obj_d;
650 wxEvent::CopyObject(obj_d);
651
652 obj->m_pos = m_pos;
653 }
654
655 void wxEraseEvent::CopyObject(wxObject& obj_d) const
656 {
657 wxEraseEvent *obj = (wxEraseEvent *)&obj_d;
658 wxEvent::CopyObject(obj_d);
659
660 obj->m_dc = m_dc;
661 }
662
663 void wxActivateEvent::CopyObject(wxObject& obj_d) const
664 {
665 wxActivateEvent *obj = (wxActivateEvent *)&obj_d;
666 wxEvent::CopyObject(obj_d);
667
668 obj->m_active = m_active;
669 }
670
671 void wxMenuEvent::CopyObject(wxObject& obj_d) const
672 {
673 wxMenuEvent *obj = (wxMenuEvent *)&obj_d;
674 wxEvent::CopyObject(obj_d);
675
676 obj->m_menuId = m_menuId;
677 }
678
679 void wxCloseEvent::CopyObject(wxObject& obj_d) const
680 {
681 wxCloseEvent *obj = (wxCloseEvent *)&obj_d;
682 wxEvent::CopyObject(obj_d);
683
684 obj->m_loggingOff = m_loggingOff;
685 obj->m_veto = m_veto;
686 #if WXWIN_COMPATIBILITY
687 obj->m_force = m_force;
688 #endif
689 obj->m_canVeto = m_canVeto;
690 }
691
692 void wxShowEvent::CopyObject(wxObject& obj_d) const
693 {
694 wxShowEvent *obj = (wxShowEvent *)&obj_d;
695 wxEvent::CopyObject(obj_d);
696
697 obj->m_show = m_show;
698 }
699
700 void wxJoystickEvent::CopyObject(wxObject& obj_d) const
701 {
702 wxJoystickEvent *obj = (wxJoystickEvent *)&obj_d;
703 wxEvent::CopyObject(obj_d);
704
705 obj->m_pos = m_pos;
706 obj->m_zPosition = m_zPosition;
707 obj->m_buttonChange = m_buttonChange;
708 obj->m_buttonState = m_buttonState;
709 obj->m_joyStick = m_joyStick;
710 }
711
712 void wxDropFilesEvent::CopyObject(wxObject& obj_d) const
713 {
714 wxDropFilesEvent *obj = (wxDropFilesEvent *)&obj_d;
715 wxEvent::CopyObject(obj_d);
716
717 obj->m_noFiles = m_noFiles;
718 obj->m_pos = m_pos;
719 // TODO: Problem with obj->m_files. It should be deallocated by the
720 // destructor of the event.
721 }
722
723 void wxUpdateUIEvent::CopyObject(wxObject &obj_d) const
724 {
725 wxUpdateUIEvent *obj = (wxUpdateUIEvent *)&obj_d;
726 wxEvent::CopyObject(obj_d);
727
728 obj->m_checked = m_checked;
729 obj->m_enabled = m_enabled;
730 obj->m_text = m_text;
731 obj->m_setText = m_setText;
732 obj->m_setChecked = m_setChecked;
733 obj->m_setEnabled = m_setEnabled;
734 }
735
736 void wxPaletteChangedEvent::CopyObject(wxObject &obj_d) const
737 {
738 wxPaletteChangedEvent *obj = (wxPaletteChangedEvent *)&obj_d;
739 wxEvent::CopyObject(obj_d);
740
741 obj->m_changedWindow = m_changedWindow;
742 }
743
744 void wxQueryNewPaletteEvent::CopyObject(wxObject& obj_d) const
745 {
746 wxQueryNewPaletteEvent *obj = (wxQueryNewPaletteEvent *)&obj_d;
747 wxEvent::CopyObject(obj_d);
748
749 obj->m_paletteRealized = m_paletteRealized;
750 }
751
752 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win)
753 : wxEvent()
754 {
755 SetEventType(wxEVT_CREATE);
756 SetEventObject(win);
757 }
758
759 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow *win)
760 : wxEvent()
761 {
762 SetEventType(wxEVT_DESTROY);
763 SetEventObject(win);
764 }
765
766 #endif // wxUSE_GUI
767
768 void wxIdleEvent::CopyObject(wxObject& obj_d) const
769 {
770 wxIdleEvent *obj = (wxIdleEvent *)&obj_d;
771 wxEvent::CopyObject(obj_d);
772
773 obj->m_requestMore = m_requestMore;
774 }
775
776 /*
777 * Event handler
778 */
779
780 wxEvtHandler::wxEvtHandler()
781 {
782 m_nextHandler = (wxEvtHandler *) NULL;
783 m_previousHandler = (wxEvtHandler *) NULL;
784 m_enabled = TRUE;
785 m_dynamicEvents = (wxList *) NULL;
786 m_isWindow = FALSE;
787 m_pendingEvents = (wxList *) NULL;
788 #if wxUSE_THREADS
789 # if !defined(__VISAGECPP__)
790 m_eventsLocker = new wxCriticalSection;
791 # endif
792 #endif
793 }
794
795 wxEvtHandler::~wxEvtHandler()
796 {
797 // Takes itself out of the list of handlers
798 if (m_previousHandler)
799 m_previousHandler->m_nextHandler = m_nextHandler;
800
801 if (m_nextHandler)
802 m_nextHandler->m_previousHandler = m_previousHandler;
803
804 if (m_dynamicEvents)
805 {
806 wxNode *node = m_dynamicEvents->First();
807 while (node)
808 {
809 wxEventTableEntry *entry = (wxEventTableEntry*)node->Data();
810 if (entry->m_callbackUserData) delete entry->m_callbackUserData;
811 delete entry;
812 node = node->Next();
813 }
814 delete m_dynamicEvents;
815 };
816
817 delete m_pendingEvents;
818
819 #if wxUSE_THREADS
820 # if !defined(__VISAGECPP__)
821 delete m_eventsLocker;
822 # endif
823 #endif
824 }
825
826 #if wxUSE_THREADS
827
828 bool wxEvtHandler::ProcessThreadEvent(wxEvent& event)
829 {
830 // check that we are really in a child thread
831 wxASSERT_MSG( !wxThread::IsMain(),
832 wxT("use ProcessEvent() in main thread") );
833
834 AddPendingEvent(event);
835
836 return TRUE;
837 }
838
839 #endif // wxUSE_THREADS
840
841 void wxEvtHandler::AddPendingEvent(wxEvent& event)
842 {
843 // 1) Add event to list of pending events of this event handler
844
845 #if defined(__VISAGECPP__)
846 wxENTER_CRIT_SECT( m_eventsLocker);
847 #else
848 wxENTER_CRIT_SECT( *m_eventsLocker);
849 #endif
850
851 if ( !m_pendingEvents )
852 m_pendingEvents = new wxList;
853
854 wxEvent *event2 = (wxEvent *)event.Clone();
855
856 m_pendingEvents->Append(event2);
857
858 #if defined(__VISAGECPP__)
859 wxLEAVE_CRIT_SECT( m_eventsLocker);
860 #else
861 wxLEAVE_CRIT_SECT( *m_eventsLocker);
862 #endif
863
864 // 2) Add this event handler to list of event handlers that
865 // have pending events.
866
867 wxENTER_CRIT_SECT(*wxPendingEventsLocker);
868
869 if ( !wxPendingEvents )
870 wxPendingEvents = new wxList;
871 wxPendingEvents->Append(this);
872
873 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
874
875 // 3) Inform the system that new pending events are somwehere,
876 // and that these should be processed in idle time.
877 wxWakeUpIdle();
878 }
879
880 void wxEvtHandler::ProcessPendingEvents()
881 {
882 #if defined(__VISAGECPP__)
883 wxENTER_CRIT_SECT( m_eventsLocker);
884 #else
885 wxENTER_CRIT_SECT( *m_eventsLocker);
886 #endif
887
888 wxNode *node = m_pendingEvents->First();
889 while ( node )
890 {
891 wxEvent *event = (wxEvent *)node->Data();
892 delete node;
893
894 // In ProcessEvent, new events might get added and
895 // we can safely leave the crtical section here.
896 #if defined(__VISAGECPP__)
897 wxLEAVE_CRIT_SECT( m_eventsLocker);
898 #else
899 wxLEAVE_CRIT_SECT( *m_eventsLocker);
900 #endif
901 ProcessEvent(*event);
902 delete event;
903 #if defined(__VISAGECPP__)
904 wxENTER_CRIT_SECT( m_eventsLocker);
905 #else
906 wxENTER_CRIT_SECT( *m_eventsLocker);
907 #endif
908
909 node = m_pendingEvents->First();
910 }
911
912 #if defined(__VISAGECPP__)
913 wxLEAVE_CRIT_SECT( m_eventsLocker);
914 #else
915 wxLEAVE_CRIT_SECT( *m_eventsLocker);
916 #endif
917 }
918
919 /*
920 * Event table stuff
921 */
922
923 bool wxEvtHandler::ProcessEvent(wxEvent& event)
924 {
925 #if wxUSE_GUI
926 // check that our flag corresponds to reality
927 wxASSERT( m_isWindow == IsKindOf(CLASSINFO(wxWindow)) );
928 #endif // wxUSE_GUI
929
930 // An event handler can be enabled or disabled
931 if ( GetEvtHandlerEnabled() )
932 {
933
934 #if 0
935 /*
936 What is this? When using GUI threads, a non main
937 threads can send an event and process it itself.
938 This breaks GTK's GUI threads, so please explain.
939 */
940
941 // Check whether we are in a child thread.
942 if ( !wxThread::IsMain() )
943 return ProcessThreadEvent(event);
944 #endif
945
946 // Handle per-instance dynamic event tables first
947 if ( m_dynamicEvents && SearchDynamicEventTable(event) )
948 return TRUE;
949
950 // Then static per-class event tables
951 const wxEventTable *table = GetEventTable();
952
953 #if wxUSE_GUI && wxUSE_VALIDATORS
954 // Try the associated validator first, if this is a window.
955 // Problem: if the event handler of the window has been replaced,
956 // this wxEvtHandler may no longer be a window.
957 // Therefore validators won't be processed if the handler
958 // has been replaced with SetEventHandler.
959 // THIS CAN BE CURED if PushEventHandler is used instead of
960 // SetEventHandler, and then processing will be passed down the
961 // chain of event handlers.
962 if (m_isWindow)
963 {
964 wxWindow *win = (wxWindow *)this;
965
966 // Can only use the validator of the window which
967 // is receiving the event
968 if ( win == event.GetEventObject() )
969 {
970 wxValidator *validator = win->GetValidator();
971 if ( validator && validator->ProcessEvent(event) )
972 {
973 return TRUE;
974 }
975 }
976 }
977 #endif
978
979 // Search upwards through the inheritance hierarchy
980 while (table)
981 {
982 if ( SearchEventTable((wxEventTable&)*table, event) )
983 return TRUE;
984 table = table->baseTable;
985 }
986 }
987
988 // Try going down the event handler chain
989 if ( GetNextHandler() )
990 {
991 if ( GetNextHandler()->ProcessEvent(event) )
992 return TRUE;
993 }
994
995 #if wxUSE_GUI
996 // Carry on up the parent-child hierarchy,
997 // but only if event is a command event: it wouldn't
998 // make sense for a parent to receive a child's size event, for example
999 if ( m_isWindow && event.IsCommandEvent() )
1000 {
1001 wxWindow *win = (wxWindow *)this;
1002 wxWindow *parent = win->GetParent();
1003 if (parent && !parent->IsBeingDeleted())
1004 return parent->GetEventHandler()->ProcessEvent(event);
1005 }
1006 #endif // wxUSE_GUI
1007
1008 // Last try - application object.
1009 if ( wxTheApp && (this != wxTheApp) )
1010 {
1011 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
1012 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
1013 // processed appropriately via SearchEventTable.
1014 if ( event.GetEventType() != wxEVT_IDLE )
1015 {
1016 if ( wxTheApp->ProcessEvent(event) )
1017 return TRUE;
1018 }
1019 }
1020
1021 return FALSE;
1022 }
1023
1024 bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
1025 {
1026 int i = 0;
1027 int commandId = event.GetId();
1028
1029 // BC++ doesn't like while (table.entries[i].m_fn)
1030
1031 #ifdef __SC__
1032 while (table.entries[i].m_fn != 0)
1033 #else
1034 while (table.entries[i].m_fn != 0L)
1035 #endif
1036 {
1037 if ((event.GetEventType() == table.entries[i].m_eventType) &&
1038 (table.entries[i].m_id == -1 || // Match, if event spec says any id will do (id == -1)
1039 (table.entries[i].m_lastId == -1 && commandId == table.entries[i].m_id) ||
1040 (table.entries[i].m_lastId != -1 &&
1041 (commandId >= table.entries[i].m_id && commandId <= table.entries[i].m_lastId))))
1042 {
1043 event.Skip(FALSE);
1044 event.m_callbackUserData = table.entries[i].m_callbackUserData;
1045
1046 (this->*((wxEventFunction) (table.entries[i].m_fn)))(event);
1047
1048 if ( event.GetSkipped() )
1049 return FALSE;
1050 else
1051 return TRUE;
1052 }
1053 i++;
1054 }
1055 return FALSE;
1056 }
1057
1058 void wxEvtHandler::Connect( int id, int lastId,
1059 wxEventType eventType,
1060 wxObjectEventFunction func,
1061 wxObject *userData )
1062 {
1063 wxEventTableEntry *entry = new wxEventTableEntry;
1064 entry->m_id = id;
1065 entry->m_lastId = lastId;
1066 entry->m_eventType = eventType;
1067 entry->m_fn = func;
1068 entry->m_callbackUserData = userData;
1069
1070 if (!m_dynamicEvents)
1071 m_dynamicEvents = new wxList;
1072
1073 m_dynamicEvents->Append( (wxObject*) entry );
1074 }
1075
1076 bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
1077 wxObjectEventFunction func,
1078 wxObject *userData )
1079 {
1080 if (!m_dynamicEvents)
1081 return FALSE;
1082
1083 wxNode *node = m_dynamicEvents->First();
1084 while (node)
1085 {
1086 wxEventTableEntry *entry = (wxEventTableEntry*)node->Data();
1087 if ((entry->m_id == id) &&
1088 ((entry->m_lastId == lastId) || (lastId == -1)) &&
1089 ((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
1090 ((entry->m_fn == func) || (func == (wxObjectEventFunction)NULL)) &&
1091 ((entry->m_callbackUserData == userData) || (userData == (wxObject*)NULL)))
1092 {
1093 if (entry->m_callbackUserData) delete entry->m_callbackUserData;
1094 m_dynamicEvents->DeleteNode( node );
1095 delete entry;
1096 return TRUE;
1097 }
1098 node = node->Next();
1099 }
1100 return FALSE;
1101 }
1102
1103 bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
1104 {
1105 wxCHECK_MSG( m_dynamicEvents, FALSE,
1106 wxT("caller should check that we have dynamic events") );
1107
1108 int commandId = event.GetId();
1109
1110 wxNode *node = m_dynamicEvents->First();
1111 while (node)
1112 {
1113 wxEventTableEntry *entry = (wxEventTableEntry*)node->Data();
1114
1115 if (entry->m_fn)
1116 {
1117 // Match, if event spec says any id will do (id == -1)
1118 if ( (event.GetEventType() == entry->m_eventType) &&
1119 (entry->m_id == -1 ||
1120 (entry->m_lastId == -1 && commandId == entry->m_id) ||
1121 (entry->m_lastId != -1 &&
1122 (commandId >= entry->m_id && commandId <= entry->m_lastId))) )
1123 {
1124 event.Skip(FALSE);
1125 event.m_callbackUserData = entry->m_callbackUserData;
1126
1127 (this->*((wxEventFunction) (entry->m_fn)))(event);
1128
1129 if (event.GetSkipped())
1130 return FALSE;
1131 else
1132 return TRUE;
1133 }
1134 }
1135 node = node->Next();
1136 }
1137 return FALSE;
1138 };
1139
1140 #if WXWIN_COMPATIBILITY
1141 bool wxEvtHandler::OnClose()
1142 {
1143 if (GetNextHandler())
1144 return GetNextHandler()->OnClose();
1145 else
1146 return FALSE;
1147 }
1148 #endif // WXWIN_COMPATIBILITY
1149
1150 #if wxUSE_GUI
1151
1152 // Find a window with the focus, that is also a descendant of the given window.
1153 // This is used to determine the window to initially send commands to.
1154 wxWindow* wxFindFocusDescendant(wxWindow* ancestor)
1155 {
1156 // Process events starting with the window with the focus, if any.
1157 wxWindow* focusWin = wxWindow::FindFocus();
1158 wxWindow* win = focusWin;
1159
1160 // Check if this is a descendant of this frame.
1161 // If not, win will be set to NULL.
1162 while (win)
1163 {
1164 if (win == ancestor)
1165 break;
1166 else
1167 win = win->GetParent();
1168 }
1169 if (win == (wxWindow*) NULL)
1170 focusWin = (wxWindow*) NULL;
1171
1172 return focusWin;
1173 }
1174
1175 #endif // wxUSE_GUI