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