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