1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Event classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "event.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
37 #include "wx/control.h"
46 #include "wx/validate.h"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 wxEventType wxEVT_NULL
= 0;
54 wxEventType wxEVT_FIRST
= 10000;
56 #if WXWIN_COMPATIBILITY_2
57 wxEventType wxEVT_USER_FIRST
= wxEVT_FIRST
+ 2000;
58 #endif // WXWIN_COMPATIBILITY_2
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler
, wxObject
)
65 IMPLEMENT_ABSTRACT_CLASS(wxEvent
, wxObject
)
66 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent
, wxEvent
)
69 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent
, wxEvent
)
70 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent
, wxCommandEvent
)
71 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent
, wxCommandEvent
)
72 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent
, wxEvent
)
73 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent
, wxEvent
)
74 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent
, wxEvent
)
75 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent
, wxEvent
)
76 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent
, wxEvent
)
77 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent
, wxEvent
)
78 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent
, wxEvent
)
79 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent
, wxEvent
)
80 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent
, wxEvent
)
81 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent
, wxEvent
)
82 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent
, wxEvent
)
83 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent
, wxEvent
)
84 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent
, wxEvent
)
85 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent
, wxEvent
)
86 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent
, wxEvent
)
87 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent
, wxEvent
)
88 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent
, wxEvent
)
89 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent
, wxEvent
)
90 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent
, wxCommandEvent
)
91 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent
, wxCommandEvent
)
92 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent
, wxEvent
)
93 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent
, wxEvent
)
94 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent
, wxEvent
)
95 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent
, wxEvent
)
96 IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent
, wxCommandEvent
)
99 const wxEventTable
*wxEvtHandler::GetEventTable() const
100 { return &wxEvtHandler::sm_eventTable
; }
102 const wxEventTable
wxEvtHandler::sm_eventTable
=
103 { (const wxEventTable
*)NULL
, &wxEvtHandler::sm_eventTableEntries
[0] };
105 const wxEventTableEntry
wxEvtHandler::sm_eventTableEntries
[] =
106 { wxEventTableEntry(0, 0, 0, (wxObjectEventFunction
)NULL
, NULL
) };
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 // To put pending event handlers
113 wxList
*wxPendingEvents
= (wxList
*)NULL
;
116 // protects wxPendingEvents list
117 wxCriticalSection
*wxPendingEventsLocker
= (wxCriticalSection
*)NULL
;
120 wxEventType wxEVT_COMMAND_BUTTON_CLICKED
;
121 wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED
;
122 wxEventType wxEVT_COMMAND_CHOICE_SELECTED
;
123 wxEventType wxEVT_COMMAND_LISTBOX_SELECTED
;
124 wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
;
125 wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
;
126 wxEventType wxEVT_COMMAND_TEXT_UPDATED
;
127 wxEventType wxEVT_COMMAND_TEXT_ENTER
;
128 wxEventType wxEVT_COMMAND_MENU_SELECTED
;
129 wxEventType wxEVT_COMMAND_TOOL_CLICKED
;
130 wxEventType wxEVT_COMMAND_SLIDER_UPDATED
;
131 wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED
;
132 wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED
;
133 wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED
;
134 wxEventType wxEVT_COMMAND_VLBOX_SELECTED
;
135 wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED
;
136 wxEventType wxEVT_COMMAND_TOOL_RCLICKED
;
137 wxEventType wxEVT_COMMAND_TOOL_ENTER
;
138 wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED
;
140 // Sockets and timers send events, too
141 wxEventType wxEVT_SOCKET
;
142 wxEventType wxEVT_TIMER
;
145 wxEventType wxEVT_LEFT_DOWN
;
146 wxEventType wxEVT_LEFT_UP
;
147 wxEventType wxEVT_MIDDLE_DOWN
;
148 wxEventType wxEVT_MIDDLE_UP
;
149 wxEventType wxEVT_RIGHT_DOWN
;
150 wxEventType wxEVT_RIGHT_UP
;
151 wxEventType wxEVT_MOTION
;
152 wxEventType wxEVT_ENTER_WINDOW
;
153 wxEventType wxEVT_LEAVE_WINDOW
;
154 wxEventType wxEVT_LEFT_DCLICK
;
155 wxEventType wxEVT_MIDDLE_DCLICK
;
156 wxEventType wxEVT_RIGHT_DCLICK
;
157 wxEventType wxEVT_SET_FOCUS
;
158 wxEventType wxEVT_KILL_FOCUS
;
160 // Non-client mouse events
161 wxEventType wxEVT_NC_LEFT_DOWN
;
162 wxEventType wxEVT_NC_LEFT_UP
;
163 wxEventType wxEVT_NC_MIDDLE_DOWN
;
164 wxEventType wxEVT_NC_MIDDLE_UP
;
165 wxEventType wxEVT_NC_RIGHT_DOWN
;
166 wxEventType wxEVT_NC_RIGHT_UP
;
167 wxEventType wxEVT_NC_MOTION
;
168 wxEventType wxEVT_NC_ENTER_WINDOW
;
169 wxEventType wxEVT_NC_LEAVE_WINDOW
;
170 wxEventType wxEVT_NC_LEFT_DCLICK
;
171 wxEventType wxEVT_NC_MIDDLE_DCLICK
;
172 wxEventType wxEVT_NC_RIGHT_DCLICK
;
174 // Character input event type
175 wxEventType wxEVT_CHAR
;
176 wxEventType wxEVT_CHAR_HOOK
;
177 wxEventType wxEVT_NAVIGATION_KEY
;
178 wxEventType wxEVT_KEY_DOWN
;
179 wxEventType wxEVT_KEY_UP
;
182 wxEventType wxEVT_SET_CURSOR
;
184 // wxScrollbar and wxSlider event identifiers
185 wxEventType wxEVT_SCROLL_TOP
;
186 wxEventType wxEVT_SCROLL_BOTTOM
;
187 wxEventType wxEVT_SCROLL_LINEUP
;
188 wxEventType wxEVT_SCROLL_LINEDOWN
;
189 wxEventType wxEVT_SCROLL_PAGEUP
;
190 wxEventType wxEVT_SCROLL_PAGEDOWN
;
191 wxEventType wxEVT_SCROLL_THUMBTRACK
;
192 wxEventType wxEVT_SCROLL_THUMBRELEASE
;
194 // Scroll events from wxWindow
195 wxEventType wxEVT_SCROLLWIN_TOP
;
196 wxEventType wxEVT_SCROLLWIN_BOTTOM
;
197 wxEventType wxEVT_SCROLLWIN_LINEUP
;
198 wxEventType wxEVT_SCROLLWIN_LINEDOWN
;
199 wxEventType wxEVT_SCROLLWIN_PAGEUP
;
200 wxEventType wxEVT_SCROLLWIN_PAGEDOWN
;
201 wxEventType wxEVT_SCROLLWIN_THUMBTRACK
;
202 wxEventType wxEVT_SCROLLWIN_THUMBRELEASE
;
205 wxEventType wxEVT_SIZE
;
206 wxEventType wxEVT_MOVE
;
207 wxEventType wxEVT_CLOSE_WINDOW
;
208 wxEventType wxEVT_END_SESSION
;
209 wxEventType wxEVT_QUERY_END_SESSION
;
210 wxEventType wxEVT_ACTIVATE_APP
;
211 wxEventType wxEVT_POWER
;
212 wxEventType wxEVT_ACTIVATE
;
213 wxEventType wxEVT_CREATE
;
214 wxEventType wxEVT_DESTROY
;
215 wxEventType wxEVT_SHOW
;
216 wxEventType wxEVT_ICONIZE
;
217 wxEventType wxEVT_MAXIMIZE
;
218 wxEventType wxEVT_MOUSE_CAPTURE_CHANGED
;
219 wxEventType wxEVT_PAINT
;
220 wxEventType wxEVT_ERASE_BACKGROUND
;
221 wxEventType wxEVT_NC_PAINT
;
222 wxEventType wxEVT_PAINT_ICON
;
223 wxEventType wxEVT_MENU_CHAR
;
224 wxEventType wxEVT_MENU_INIT
;
225 wxEventType wxEVT_MENU_HIGHLIGHT
;
226 wxEventType wxEVT_POPUP_MENU_INIT
;
227 wxEventType wxEVT_CONTEXT_MENU
;
228 wxEventType wxEVT_SYS_COLOUR_CHANGED
;
229 wxEventType wxEVT_SETTING_CHANGED
;
230 wxEventType wxEVT_QUERY_NEW_PALETTE
;
231 wxEventType wxEVT_PALETTE_CHANGED
;
232 wxEventType wxEVT_JOY_BUTTON_DOWN
;
233 wxEventType wxEVT_JOY_BUTTON_UP
;
234 wxEventType wxEVT_JOY_MOVE
;
235 wxEventType wxEVT_JOY_ZMOVE
;
236 wxEventType wxEVT_DROP_FILES
;
237 wxEventType wxEVT_DRAW_ITEM
;
238 wxEventType wxEVT_MEASURE_ITEM
;
239 wxEventType wxEVT_COMPARE_ITEM
;
240 wxEventType wxEVT_INIT_DIALOG
;
241 wxEventType wxEVT_IDLE
;
242 wxEventType wxEVT_UPDATE_UI
;
245 wxEventType wxEVT_END_PROCESS
;
248 wxEventType wxEVT_DIALUP_CONNECTED
;
249 wxEventType wxEVT_DIALUP_DISCONNECTED
;
251 // Generic command events
252 // Note: a click is a higher-level event than button down/up
253 wxEventType wxEVT_COMMAND_LEFT_CLICK
;
254 wxEventType wxEVT_COMMAND_LEFT_DCLICK
;
255 wxEventType wxEVT_COMMAND_RIGHT_CLICK
;
256 wxEventType wxEVT_COMMAND_RIGHT_DCLICK
;
257 wxEventType wxEVT_COMMAND_SET_FOCUS
;
258 wxEventType wxEVT_COMMAND_KILL_FOCUS
;
259 wxEventType wxEVT_COMMAND_ENTER
;
261 // Tree control event types
262 wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG
;
263 wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG
;
264 wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
;
265 wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT
;
266 wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM
;
267 wxEventType wxEVT_COMMAND_TREE_GET_INFO
;
268 wxEventType wxEVT_COMMAND_TREE_SET_INFO
;
269 wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED
;
270 wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING
;
271 wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED
;
272 wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING
;
273 wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED
;
274 wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING
;
275 wxEventType wxEVT_COMMAND_TREE_KEY_DOWN
;
276 wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED
;
277 wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK
;
278 wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK
;
279 wxEventType wxEVT_COMMAND_TREE_END_DRAG
;
281 // List control event types
282 wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG
;
283 wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG
;
284 wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
;
285 wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT
;
286 wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM
;
287 wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
;
288 wxEventType wxEVT_COMMAND_LIST_GET_INFO
;
289 wxEventType wxEVT_COMMAND_LIST_SET_INFO
;
290 wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED
;
291 wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED
;
292 wxEventType wxEVT_COMMAND_LIST_KEY_DOWN
;
293 wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM
;
294 wxEventType wxEVT_COMMAND_LIST_COL_CLICK
;
295 wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
;
296 wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
;
297 wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED
;
299 // Tab and notebook control event types
300 wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED
;
301 wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING
;
302 wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
;
303 wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
;
306 wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
;
307 wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
;
308 wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
;
309 wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT
;
312 wxEventType wxEVT_WIZARD_PAGE_CHANGED
;
313 wxEventType wxEVT_WIZARD_PAGE_CHANGING
;
314 wxEventType wxEVT_WIZARD_CANCEL
;
317 wxEventType wxEVT_CALENDAR_SEL_CHANGED
;
318 wxEventType wxEVT_CALENDAR_DAY_CHANGED
;
319 wxEventType wxEVT_CALENDAR_MONTH_CHANGED
;
320 wxEventType wxEVT_CALENDAR_YEAR_CHANGED
;
321 wxEventType wxEVT_CALENDAR_DOUBLECLICKED
;
322 wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED
;
325 wxEventType wxEVT_HELP
;
326 wxEventType wxEVT_DETAILED_HELP
;
328 // ============================================================================
330 // ============================================================================
332 // ----------------------------------------------------------------------------
333 // event initialization
334 // ----------------------------------------------------------------------------
339 static int s_lastUsedEventType
= wxEVT_FIRST
;
341 return s_lastUsedEventType
++;
344 static void InitEvents()
347 // this function is supposed to be called only once, as normally this
348 // should be always true we only do this check in debug mode
349 static bool s_inInitEvents
= FALSE
;
350 wxCHECK_RET( !s_inInitEvents
, _T("InitEvents() reentrancy!") );
352 // note that we don't reset it to FALSE any more as we shouldn't be called
354 s_inInitEvents
= TRUE
;
355 #endif // __WXDEBUG__
357 wxEVT_COMMAND_BUTTON_CLICKED
= wxNewEventType();
358 wxEVT_COMMAND_CHECKBOX_CLICKED
= wxNewEventType();
359 wxEVT_COMMAND_CHOICE_SELECTED
= wxNewEventType();
360 wxEVT_COMMAND_LISTBOX_SELECTED
= wxNewEventType();
361 wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
= wxNewEventType();
362 wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
= wxNewEventType();
363 wxEVT_COMMAND_TEXT_UPDATED
= wxNewEventType();
364 wxEVT_COMMAND_TEXT_ENTER
= wxNewEventType();
365 wxEVT_COMMAND_MENU_SELECTED
= wxNewEventType();
366 wxEVT_COMMAND_TOOL_CLICKED
= wxNewEventType();
367 wxEVT_COMMAND_SLIDER_UPDATED
= wxNewEventType();
368 wxEVT_COMMAND_RADIOBOX_SELECTED
= wxNewEventType();
369 wxEVT_COMMAND_RADIOBUTTON_SELECTED
= wxNewEventType();
370 wxEVT_COMMAND_SCROLLBAR_UPDATED
= wxNewEventType();
371 wxEVT_COMMAND_VLBOX_SELECTED
= wxNewEventType();
372 wxEVT_COMMAND_COMBOBOX_SELECTED
= wxNewEventType();
373 wxEVT_COMMAND_TOOL_RCLICKED
= wxNewEventType();
374 wxEVT_COMMAND_TOOL_ENTER
= wxNewEventType();
375 wxEVT_COMMAND_SPINCTRL_UPDATED
= wxNewEventType();
377 // Sockets and timers send events, too
378 wxEVT_SOCKET
= wxNewEventType();
379 wxEVT_TIMER
= wxNewEventType();
382 wxEVT_LEFT_DOWN
= wxNewEventType();
383 wxEVT_LEFT_UP
= wxNewEventType();
384 wxEVT_MIDDLE_DOWN
= wxNewEventType();
385 wxEVT_MIDDLE_UP
= wxNewEventType();
386 wxEVT_RIGHT_DOWN
= wxNewEventType();
387 wxEVT_RIGHT_UP
= wxNewEventType();
388 wxEVT_MOTION
= wxNewEventType();
389 wxEVT_ENTER_WINDOW
= wxNewEventType();
390 wxEVT_LEAVE_WINDOW
= wxNewEventType();
391 wxEVT_LEFT_DCLICK
= wxNewEventType();
392 wxEVT_MIDDLE_DCLICK
= wxNewEventType();
393 wxEVT_RIGHT_DCLICK
= wxNewEventType();
394 wxEVT_SET_FOCUS
= wxNewEventType();
395 wxEVT_KILL_FOCUS
= wxNewEventType();
397 // Non-client mouse events
398 wxEVT_NC_LEFT_DOWN
= wxNewEventType();
399 wxEVT_NC_LEFT_UP
= wxNewEventType();
400 wxEVT_NC_MIDDLE_DOWN
= wxNewEventType();
401 wxEVT_NC_MIDDLE_UP
= wxNewEventType();
402 wxEVT_NC_RIGHT_DOWN
= wxNewEventType();
403 wxEVT_NC_RIGHT_UP
= wxNewEventType();
404 wxEVT_NC_MOTION
= wxNewEventType();
405 wxEVT_NC_ENTER_WINDOW
= wxNewEventType();
406 wxEVT_NC_LEAVE_WINDOW
= wxNewEventType();
407 wxEVT_NC_LEFT_DCLICK
= wxNewEventType();
408 wxEVT_NC_MIDDLE_DCLICK
= wxNewEventType();
409 wxEVT_NC_RIGHT_DCLICK
= wxNewEventType();
411 // Character input event type
412 wxEVT_CHAR
= wxNewEventType();
413 wxEVT_CHAR_HOOK
= wxNewEventType();
414 wxEVT_NAVIGATION_KEY
= wxNewEventType();
415 wxEVT_KEY_DOWN
= wxNewEventType();
416 wxEVT_KEY_UP
= wxNewEventType();
419 wxEVT_SET_CURSOR
= wxNewEventType();
421 // wxScrollbar and wxSlider event identifiers
422 wxEVT_SCROLL_TOP
= wxNewEventType();
423 wxEVT_SCROLL_BOTTOM
= wxNewEventType();
424 wxEVT_SCROLL_LINEUP
= wxNewEventType();
425 wxEVT_SCROLL_LINEDOWN
= wxNewEventType();
426 wxEVT_SCROLL_PAGEUP
= wxNewEventType();
427 wxEVT_SCROLL_PAGEDOWN
= wxNewEventType();
428 wxEVT_SCROLL_THUMBTRACK
= wxNewEventType();
429 wxEVT_SCROLL_THUMBRELEASE
= wxNewEventType();
431 // Scroll events from wxWindow
432 wxEVT_SCROLLWIN_TOP
= wxNewEventType();
433 wxEVT_SCROLLWIN_BOTTOM
= wxNewEventType();
434 wxEVT_SCROLLWIN_LINEUP
= wxNewEventType();
435 wxEVT_SCROLLWIN_LINEDOWN
= wxNewEventType();
436 wxEVT_SCROLLWIN_PAGEUP
= wxNewEventType();
437 wxEVT_SCROLLWIN_PAGEDOWN
= wxNewEventType();
438 wxEVT_SCROLLWIN_THUMBTRACK
= wxNewEventType();
439 wxEVT_SCROLLWIN_THUMBRELEASE
= wxNewEventType();
442 wxEVT_SIZE
= wxNewEventType();
443 wxEVT_MOVE
= wxNewEventType();
444 wxEVT_CLOSE_WINDOW
= wxNewEventType();
445 wxEVT_END_SESSION
= wxNewEventType();
446 wxEVT_QUERY_END_SESSION
= wxNewEventType();
447 wxEVT_ACTIVATE_APP
= wxNewEventType();
448 wxEVT_POWER
= wxNewEventType();
449 wxEVT_ACTIVATE
= wxNewEventType();
450 wxEVT_CREATE
= wxNewEventType();
451 wxEVT_DESTROY
= wxNewEventType();
452 wxEVT_SHOW
= wxNewEventType();
453 wxEVT_ICONIZE
= wxNewEventType();
454 wxEVT_MAXIMIZE
= wxNewEventType();
455 wxEVT_MOUSE_CAPTURE_CHANGED
= wxNewEventType();
456 wxEVT_PAINT
= wxNewEventType();
457 wxEVT_ERASE_BACKGROUND
= wxNewEventType();
458 wxEVT_NC_PAINT
= wxNewEventType();
459 wxEVT_PAINT_ICON
= wxNewEventType();
460 wxEVT_MENU_CHAR
= wxNewEventType();
461 wxEVT_MENU_INIT
= wxNewEventType();
462 wxEVT_MENU_HIGHLIGHT
= wxNewEventType();
463 wxEVT_POPUP_MENU_INIT
= wxNewEventType();
464 wxEVT_CONTEXT_MENU
= wxNewEventType();
465 wxEVT_SYS_COLOUR_CHANGED
= wxNewEventType();
466 wxEVT_SETTING_CHANGED
= wxNewEventType();
467 wxEVT_QUERY_NEW_PALETTE
= wxNewEventType();
468 wxEVT_PALETTE_CHANGED
= wxNewEventType();
469 wxEVT_JOY_BUTTON_DOWN
= wxNewEventType();
470 wxEVT_JOY_BUTTON_UP
= wxNewEventType();
471 wxEVT_JOY_MOVE
= wxNewEventType();
472 wxEVT_JOY_ZMOVE
= wxNewEventType();
473 wxEVT_DROP_FILES
= wxNewEventType();
474 wxEVT_DRAW_ITEM
= wxNewEventType();
475 wxEVT_MEASURE_ITEM
= wxNewEventType();
476 wxEVT_COMPARE_ITEM
= wxNewEventType();
477 wxEVT_INIT_DIALOG
= wxNewEventType();
478 wxEVT_IDLE
= wxNewEventType();
479 wxEVT_UPDATE_UI
= wxNewEventType();
482 wxEVT_END_PROCESS
= wxNewEventType();
485 wxEVT_DIALUP_CONNECTED
= wxNewEventType();
486 wxEVT_DIALUP_DISCONNECTED
= wxNewEventType();
488 // Generic command events
489 // Note: a click is a higher-level event than button down/up
490 wxEVT_COMMAND_LEFT_CLICK
= wxNewEventType();
491 wxEVT_COMMAND_LEFT_DCLICK
= wxNewEventType();
492 wxEVT_COMMAND_RIGHT_CLICK
= wxNewEventType();
493 wxEVT_COMMAND_RIGHT_DCLICK
= wxNewEventType();
494 wxEVT_COMMAND_SET_FOCUS
= wxNewEventType();
495 wxEVT_COMMAND_KILL_FOCUS
= wxNewEventType();
496 wxEVT_COMMAND_ENTER
= wxNewEventType();
498 // Tree control event types
499 wxEVT_COMMAND_TREE_BEGIN_DRAG
= wxNewEventType();
500 wxEVT_COMMAND_TREE_BEGIN_RDRAG
= wxNewEventType();
501 wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
= wxNewEventType();
502 wxEVT_COMMAND_TREE_END_LABEL_EDIT
= wxNewEventType();
503 wxEVT_COMMAND_TREE_DELETE_ITEM
= wxNewEventType();
504 wxEVT_COMMAND_TREE_GET_INFO
= wxNewEventType();
505 wxEVT_COMMAND_TREE_SET_INFO
= wxNewEventType();
506 wxEVT_COMMAND_TREE_ITEM_EXPANDED
= wxNewEventType();
507 wxEVT_COMMAND_TREE_ITEM_EXPANDING
= wxNewEventType();
508 wxEVT_COMMAND_TREE_ITEM_COLLAPSED
= wxNewEventType();
509 wxEVT_COMMAND_TREE_ITEM_COLLAPSING
= wxNewEventType();
510 wxEVT_COMMAND_TREE_SEL_CHANGED
= wxNewEventType();
511 wxEVT_COMMAND_TREE_SEL_CHANGING
= wxNewEventType();
512 wxEVT_COMMAND_TREE_KEY_DOWN
= wxNewEventType();
513 wxEVT_COMMAND_TREE_ITEM_ACTIVATED
= wxNewEventType();
514 wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK
= wxNewEventType();
515 wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK
= wxNewEventType();
516 wxEVT_COMMAND_TREE_END_DRAG
= wxNewEventType();
518 // List control event types
519 wxEVT_COMMAND_LIST_BEGIN_DRAG
= wxNewEventType();
520 wxEVT_COMMAND_LIST_BEGIN_RDRAG
= wxNewEventType();
521 wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
= wxNewEventType();
522 wxEVT_COMMAND_LIST_END_LABEL_EDIT
= wxNewEventType();
523 wxEVT_COMMAND_LIST_DELETE_ITEM
= wxNewEventType();
524 wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
= wxNewEventType();
525 wxEVT_COMMAND_LIST_GET_INFO
= wxNewEventType();
526 wxEVT_COMMAND_LIST_SET_INFO
= wxNewEventType();
527 wxEVT_COMMAND_LIST_ITEM_SELECTED
= wxNewEventType();
528 wxEVT_COMMAND_LIST_ITEM_DESELECTED
= wxNewEventType();
529 wxEVT_COMMAND_LIST_KEY_DOWN
= wxNewEventType();
530 wxEVT_COMMAND_LIST_INSERT_ITEM
= wxNewEventType();
531 wxEVT_COMMAND_LIST_COL_CLICK
= wxNewEventType();
532 wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
= wxNewEventType();
533 wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
= wxNewEventType();
534 wxEVT_COMMAND_LIST_ITEM_ACTIVATED
= wxNewEventType();
536 // Tab and notebook control event types
537 wxEVT_COMMAND_TAB_SEL_CHANGED
= wxNewEventType();
538 wxEVT_COMMAND_TAB_SEL_CHANGING
= wxNewEventType();
539 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
= wxNewEventType();
540 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
= wxNewEventType();
543 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
= wxNewEventType();
544 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
= wxNewEventType();
545 wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
= wxNewEventType();
546 wxEVT_COMMAND_SPLITTER_UNSPLIT
= wxNewEventType();
549 wxEVT_WIZARD_PAGE_CHANGED
= wxNewEventType();
550 wxEVT_WIZARD_PAGE_CHANGING
= wxNewEventType();
551 wxEVT_WIZARD_CANCEL
= wxNewEventType();
554 wxEVT_CALENDAR_SEL_CHANGED
= wxNewEventType();
555 wxEVT_CALENDAR_DAY_CHANGED
= wxNewEventType();
556 wxEVT_CALENDAR_MONTH_CHANGED
= wxNewEventType();
557 wxEVT_CALENDAR_YEAR_CHANGED
= wxNewEventType();
558 wxEVT_CALENDAR_DOUBLECLICKED
= wxNewEventType();
559 wxEVT_CALENDAR_WEEKDAY_CLICKED
= wxNewEventType();
562 wxEVT_HELP
= wxNewEventType();
563 wxEVT_DETAILED_HELP
= wxNewEventType();
566 // ----------------------------------------------------------------------------
568 // ----------------------------------------------------------------------------
570 wxEventTableEntry::wxEventTableEntry(int evType
, int id
, int idLast
,
571 wxObjectEventFunction fn
, wxObject
*data
)
573 static bool s_initEventsDone
= FALSE
;
574 if ( !s_initEventsDone
)
578 s_initEventsDone
= TRUE
;
581 m_eventType
= evType
;
585 m_callbackUserData
= data
;
588 // ----------------------------------------------------------------------------
590 // ----------------------------------------------------------------------------
593 * General wxWindows events, covering
594 * all interesting things that might happen (button clicking, resizing,
595 * setting text in widgets, etc.).
597 * For each completely new event type, derive a new event class.
601 wxEvent::wxEvent(int theId
)
603 m_eventType
= wxEVT_NULL
;
604 m_eventObject
= (wxObject
*) NULL
;
608 m_callbackUserData
= (wxObject
*) NULL
;
609 m_isCommandEvent
= FALSE
;
612 void wxEvent::CopyObject(wxObject
& object_dest
) const
614 wxEvent
*obj
= (wxEvent
*)&object_dest
;
615 wxObject::CopyObject(object_dest
);
617 obj
->m_eventType
= m_eventType
;
618 obj
->m_eventObject
= m_eventObject
;
619 obj
->m_timeStamp
= m_timeStamp
;
621 obj
->m_skipped
= m_skipped
;
622 obj
->m_callbackUserData
= m_callbackUserData
;
623 obj
->m_isCommandEvent
= m_isCommandEvent
;
633 wxCommandEvent::wxCommandEvent(wxEventType commandType
, int theId
)
635 m_eventType
= commandType
;
636 m_clientData
= (char *) NULL
;
637 m_clientObject
= (wxClientData
*) NULL
;
641 m_commandString
= wxEmptyString
;
642 m_isCommandEvent
= TRUE
;
645 void wxCommandEvent::CopyObject(wxObject
& obj_d
) const
647 wxCommandEvent
*obj
= (wxCommandEvent
*)&obj_d
;
649 wxEvent::CopyObject(obj_d
);
651 obj
->m_clientData
= m_clientData
;
652 obj
->m_clientObject
= m_clientObject
;
653 obj
->m_extraLong
= m_extraLong
;
654 obj
->m_commandInt
= m_commandInt
;
655 obj
->m_commandString
= m_commandString
;
662 void wxNotifyEvent::CopyObject(wxObject
& obj_d
) const
664 wxNotifyEvent
*obj
= (wxNotifyEvent
*)&obj_d
;
666 wxEvent::CopyObject(obj_d
);
668 if (!m_bAllow
) obj
->Veto();
675 wxScrollEvent::wxScrollEvent(wxEventType commandType
,
679 : wxCommandEvent(commandType
, id
)
681 m_extraLong
= orient
;
689 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType
,
693 m_eventType
= commandType
;
694 m_extraLong
= orient
;
698 void wxScrollWinEvent::CopyObject(wxObject
& obj_d
) const
700 wxScrollWinEvent
*obj
= (wxScrollWinEvent
*)&obj_d
;
702 wxEvent::CopyObject(obj_d
);
704 obj
->m_extraLong
= m_extraLong
;
705 obj
->m_commandInt
= m_commandInt
;
713 wxMouseEvent::wxMouseEvent(wxEventType commandType
)
715 m_eventType
= commandType
;
718 m_controlDown
= FALSE
;
722 m_middleDown
= FALSE
;
727 void wxMouseEvent::CopyObject(wxObject
& obj_d
) const
729 wxMouseEvent
*obj
= (wxMouseEvent
*)&obj_d
;
731 wxEvent::CopyObject(obj_d
);
733 obj
->m_metaDown
= m_metaDown
;
734 obj
->m_altDown
= m_altDown
;
735 obj
->m_controlDown
= m_controlDown
;
736 obj
->m_shiftDown
= m_shiftDown
;
737 obj
->m_leftDown
= m_leftDown
;
738 obj
->m_rightDown
= m_rightDown
;
739 obj
->m_middleDown
= m_middleDown
;
744 // True if was a button dclick event (1 = left, 2 = middle, 3 = right)
745 // or any button dclick event (but = -1)
746 bool wxMouseEvent::ButtonDClick(int but
) const
751 return (LeftDClick() || MiddleDClick() || RightDClick());
755 return MiddleDClick();
757 return RightDClick();
759 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
765 // True if was a button down event (1 = left, 2 = middle, 3 = right)
766 // or any button down event (but = -1)
767 bool wxMouseEvent::ButtonDown(int but
) const
772 return (LeftDown() || MiddleDown() || RightDown());
780 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
786 // True if was a button up event (1 = left, 2 = middle, 3 = right)
787 // or any button up event (but = -1)
788 bool wxMouseEvent::ButtonUp(int but
) const
792 return (LeftUp() || MiddleUp() || RightUp());
800 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
806 // True if the given button is currently changing state
807 bool wxMouseEvent::Button(int but
) const
811 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
813 return (LeftDown() || LeftUp() || LeftDClick());
815 return (MiddleDown() || MiddleUp() || MiddleDClick());
817 return (RightDown() || RightUp() || RightDClick());
819 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
825 bool wxMouseEvent::ButtonIsDown(int but
) const
829 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
833 return MiddleIsDown();
835 return RightIsDown();
837 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
843 // Find the logical position of the event given the DC
844 wxPoint
wxMouseEvent::GetLogicalPosition(const wxDC
& dc
) const
846 wxPoint
pt(dc
.DeviceToLogicalX(m_x
), dc
.DeviceToLogicalY(m_y
));
856 wxKeyEvent::wxKeyEvent(wxEventType type
)
860 m_controlDown
= FALSE
;
867 void wxKeyEvent::CopyObject(wxObject
& obj_d
) const
869 wxKeyEvent
*obj
= (wxKeyEvent
*)&obj_d
;
870 wxEvent::CopyObject(obj_d
);
874 obj
->m_keyCode
= m_keyCode
;
876 obj
->m_shiftDown
= m_shiftDown
;
877 obj
->m_controlDown
= m_controlDown
;
878 obj
->m_metaDown
= m_metaDown
;
879 obj
->m_altDown
= m_altDown
;
880 obj
->m_keyCode
= m_keyCode
;
888 void wxSizeEvent::CopyObject(wxObject
& obj_d
) const
890 wxSizeEvent
*obj
= (wxSizeEvent
*)&obj_d
;
891 wxEvent::CopyObject(obj_d
);
893 obj
->m_size
= m_size
;
896 void wxMoveEvent::CopyObject(wxObject
& obj_d
) const
898 wxMoveEvent
*obj
= (wxMoveEvent
*)&obj_d
;
899 wxEvent::CopyObject(obj_d
);
904 void wxEraseEvent::CopyObject(wxObject
& obj_d
) const
906 wxEraseEvent
*obj
= (wxEraseEvent
*)&obj_d
;
907 wxEvent::CopyObject(obj_d
);
912 void wxActivateEvent::CopyObject(wxObject
& obj_d
) const
914 wxActivateEvent
*obj
= (wxActivateEvent
*)&obj_d
;
915 wxEvent::CopyObject(obj_d
);
917 obj
->m_active
= m_active
;
920 void wxMenuEvent::CopyObject(wxObject
& obj_d
) const
922 wxMenuEvent
*obj
= (wxMenuEvent
*)&obj_d
;
923 wxEvent::CopyObject(obj_d
);
925 obj
->m_menuId
= m_menuId
;
928 void wxCloseEvent::CopyObject(wxObject
& obj_d
) const
930 wxCloseEvent
*obj
= (wxCloseEvent
*)&obj_d
;
931 wxEvent::CopyObject(obj_d
);
933 obj
->m_loggingOff
= m_loggingOff
;
934 obj
->m_veto
= m_veto
;
935 #if WXWIN_COMPATIBILITY
936 obj
->m_force
= m_force
;
938 obj
->m_canVeto
= m_canVeto
;
941 void wxShowEvent::CopyObject(wxObject
& obj_d
) const
943 wxShowEvent
*obj
= (wxShowEvent
*)&obj_d
;
944 wxEvent::CopyObject(obj_d
);
946 obj
->m_show
= m_show
;
949 void wxJoystickEvent::CopyObject(wxObject
& obj_d
) const
951 wxJoystickEvent
*obj
= (wxJoystickEvent
*)&obj_d
;
952 wxEvent::CopyObject(obj_d
);
955 obj
->m_zPosition
= m_zPosition
;
956 obj
->m_buttonChange
= m_buttonChange
;
957 obj
->m_buttonState
= m_buttonState
;
958 obj
->m_joyStick
= m_joyStick
;
961 void wxDropFilesEvent::CopyObject(wxObject
& obj_d
) const
963 wxDropFilesEvent
*obj
= (wxDropFilesEvent
*)&obj_d
;
964 wxEvent::CopyObject(obj_d
);
966 obj
->m_noFiles
= m_noFiles
;
968 // TODO: Problem with obj->m_files. It should be deallocated by the
969 // destructor of the event.
972 void wxUpdateUIEvent::CopyObject(wxObject
&obj_d
) const
974 wxUpdateUIEvent
*obj
= (wxUpdateUIEvent
*)&obj_d
;
975 wxEvent::CopyObject(obj_d
);
977 obj
->m_checked
= m_checked
;
978 obj
->m_enabled
= m_enabled
;
979 obj
->m_text
= m_text
;
980 obj
->m_setText
= m_setText
;
981 obj
->m_setChecked
= m_setChecked
;
982 obj
->m_setEnabled
= m_setEnabled
;
985 void wxPaletteChangedEvent::CopyObject(wxObject
&obj_d
) const
987 wxPaletteChangedEvent
*obj
= (wxPaletteChangedEvent
*)&obj_d
;
988 wxEvent::CopyObject(obj_d
);
990 obj
->m_changedWindow
= m_changedWindow
;
993 void wxQueryNewPaletteEvent::CopyObject(wxObject
& obj_d
) const
995 wxQueryNewPaletteEvent
*obj
= (wxQueryNewPaletteEvent
*)&obj_d
;
996 wxEvent::CopyObject(obj_d
);
998 obj
->m_paletteRealized
= m_paletteRealized
;
1001 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow
*win
)
1003 SetEventType(wxEVT_CREATE
);
1004 SetEventObject(win
);
1007 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow
*win
)
1009 SetEventType(wxEVT_DESTROY
);
1010 SetEventObject(win
);
1015 void wxIdleEvent::CopyObject(wxObject
& obj_d
) const
1017 wxIdleEvent
*obj
= (wxIdleEvent
*)&obj_d
;
1018 wxEvent::CopyObject(obj_d
);
1020 obj
->m_requestMore
= m_requestMore
;
1027 wxEvtHandler::wxEvtHandler()
1029 m_nextHandler
= (wxEvtHandler
*) NULL
;
1030 m_previousHandler
= (wxEvtHandler
*) NULL
;
1032 m_dynamicEvents
= (wxList
*) NULL
;
1034 m_pendingEvents
= (wxList
*) NULL
;
1036 # if !defined(__VISAGECPP__)
1037 m_eventsLocker
= new wxCriticalSection
;
1042 wxEvtHandler::~wxEvtHandler()
1044 // Takes itself out of the list of handlers
1045 if (m_previousHandler
)
1046 m_previousHandler
->m_nextHandler
= m_nextHandler
;
1049 m_nextHandler
->m_previousHandler
= m_previousHandler
;
1051 if (m_dynamicEvents
)
1053 wxNode
*node
= m_dynamicEvents
->First();
1056 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)node
->Data();
1057 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
1059 node
= node
->Next();
1061 delete m_dynamicEvents
;
1064 delete m_pendingEvents
;
1067 # if !defined(__VISAGECPP__)
1068 delete m_eventsLocker
;
1075 bool wxEvtHandler::ProcessThreadEvent(wxEvent
& event
)
1077 // check that we are really in a child thread
1078 wxASSERT_MSG( !wxThread::IsMain(),
1079 wxT("use ProcessEvent() in main thread") );
1081 AddPendingEvent(event
);
1086 #endif // wxUSE_THREADS
1088 void wxEvtHandler::AddPendingEvent(wxEvent
& event
)
1090 // 1) Add event to list of pending events of this event handler
1092 #if defined(__VISAGECPP__)
1093 wxENTER_CRIT_SECT( m_eventsLocker
);
1095 wxENTER_CRIT_SECT( *m_eventsLocker
);
1098 if ( !m_pendingEvents
)
1099 m_pendingEvents
= new wxList
;
1101 wxEvent
*event2
= (wxEvent
*)event
.Clone();
1103 m_pendingEvents
->Append(event2
);
1105 #if defined(__VISAGECPP__)
1106 wxLEAVE_CRIT_SECT( m_eventsLocker
);
1108 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
1111 // 2) Add this event handler to list of event handlers that
1112 // have pending events.
1114 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
1116 if ( !wxPendingEvents
)
1117 wxPendingEvents
= new wxList
;
1118 wxPendingEvents
->Append(this);
1120 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
1122 // 3) Inform the system that new pending events are somwehere,
1123 // and that these should be processed in idle time.
1127 void wxEvtHandler::ProcessPendingEvents()
1129 #if defined(__VISAGECPP__)
1130 wxENTER_CRIT_SECT( m_eventsLocker
);
1132 wxENTER_CRIT_SECT( *m_eventsLocker
);
1135 wxNode
*node
= m_pendingEvents
->First();
1138 wxEvent
*event
= (wxEvent
*)node
->Data();
1141 // In ProcessEvent, new events might get added and
1142 // we can safely leave the crtical section here.
1143 #if defined(__VISAGECPP__)
1144 wxLEAVE_CRIT_SECT( m_eventsLocker
);
1146 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
1148 ProcessEvent(*event
);
1150 #if defined(__VISAGECPP__)
1151 wxENTER_CRIT_SECT( m_eventsLocker
);
1153 wxENTER_CRIT_SECT( *m_eventsLocker
);
1156 node
= m_pendingEvents
->First();
1159 #if defined(__VISAGECPP__)
1160 wxLEAVE_CRIT_SECT( m_eventsLocker
);
1162 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
1170 bool wxEvtHandler::ProcessEvent(wxEvent
& event
)
1173 // check that our flag corresponds to reality
1174 wxASSERT( m_isWindow
== IsKindOf(CLASSINFO(wxWindow
)) );
1177 // An event handler can be enabled or disabled
1178 if ( GetEvtHandlerEnabled() )
1183 What is this? When using GUI threads, a non main
1184 threads can send an event and process it itself.
1185 This breaks GTK's GUI threads, so please explain.
1188 // Check whether we are in a child thread.
1189 if ( !wxThread::IsMain() )
1190 return ProcessThreadEvent(event
);
1193 // Handle per-instance dynamic event tables first
1194 if ( m_dynamicEvents
&& SearchDynamicEventTable(event
) )
1197 // Then static per-class event tables
1198 const wxEventTable
*table
= GetEventTable();
1200 #if wxUSE_GUI && wxUSE_VALIDATORS
1201 // Try the associated validator first, if this is a window.
1202 // Problem: if the event handler of the window has been replaced,
1203 // this wxEvtHandler may no longer be a window.
1204 // Therefore validators won't be processed if the handler
1205 // has been replaced with SetEventHandler.
1206 // THIS CAN BE CURED if PushEventHandler is used instead of
1207 // SetEventHandler, and then processing will be passed down the
1208 // chain of event handlers.
1211 wxWindow
*win
= (wxWindow
*)this;
1213 // Can only use the validator of the window which
1214 // is receiving the event
1215 if ( win
== event
.GetEventObject() )
1217 wxValidator
*validator
= win
->GetValidator();
1218 if ( validator
&& validator
->ProcessEvent(event
) )
1226 // Search upwards through the inheritance hierarchy
1229 if ( SearchEventTable((wxEventTable
&)*table
, event
) )
1231 table
= table
->baseTable
;
1235 // Try going down the event handler chain
1236 if ( GetNextHandler() )
1238 if ( GetNextHandler()->ProcessEvent(event
) )
1243 // Carry on up the parent-child hierarchy,
1244 // but only if event is a command event: it wouldn't
1245 // make sense for a parent to receive a child's size event, for example
1246 if ( m_isWindow
&& event
.IsCommandEvent() )
1248 wxWindow
*win
= (wxWindow
*)this;
1249 wxWindow
*parent
= win
->GetParent();
1250 if (parent
&& !parent
->IsBeingDeleted())
1251 return parent
->GetEventHandler()->ProcessEvent(event
);
1255 // Last try - application object.
1256 if ( wxTheApp
&& (this != wxTheApp
) )
1258 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
1259 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
1260 // processed appropriately via SearchEventTable.
1261 if ( event
.GetEventType() != wxEVT_IDLE
)
1263 if ( wxTheApp
->ProcessEvent(event
) )
1271 bool wxEvtHandler::SearchEventTable(wxEventTable
& table
, wxEvent
& event
)
1273 wxEventType eventType
= event
.GetEventType();
1274 int eventId
= event
.GetId();
1276 // BC++ doesn't like testing for m_fn without != 0
1277 for ( int i
= 0; table
.entries
[i
].m_fn
!= 0; i
++ )
1279 // the line using reference exposes a bug in gcc: although it _seems_
1280 // to work, it leads to weird crashes later on during program
1283 wxEventTableEntry entry
= table
.entries
[i
];
1285 const wxEventTableEntry
& entry
= table
.entries
[i
];
1288 // match only if the event type is the same and the id is either -1 in
1289 // the event table (meaning "any") or the event id matches the id
1290 // specified in the event table either exactly or by falling into
1291 // range between first and last
1292 if ( eventType
== entry
.m_eventType
)
1294 int tableId1
= entry
.m_id
,
1295 tableId2
= entry
.m_lastId
;
1297 if ( (tableId1
== -1) ||
1298 (tableId2
== -1 && eventId
== tableId1
) ||
1300 (eventId
>= tableId1
&& eventId
<= tableId2
)) )
1303 event
.m_callbackUserData
= entry
.m_callbackUserData
;
1305 (this->*((wxEventFunction
) (entry
.m_fn
)))(event
);
1307 return !event
.GetSkipped();
1315 void wxEvtHandler::Connect( int id
, int lastId
,
1317 wxObjectEventFunction func
,
1318 wxObject
*userData
)
1320 wxDynamicEventTableEntry
*entry
=
1321 new wxDynamicEventTableEntry(eventType
, id
, lastId
, func
, userData
);
1323 if (!m_dynamicEvents
)
1324 m_dynamicEvents
= new wxList
;
1326 m_dynamicEvents
->Append( (wxObject
*) entry
);
1329 bool wxEvtHandler::Disconnect( int id
, int lastId
, wxEventType eventType
,
1330 wxObjectEventFunction func
,
1331 wxObject
*userData
)
1333 if (!m_dynamicEvents
)
1336 wxNode
*node
= m_dynamicEvents
->First();
1339 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)node
->Data();
1340 if ((entry
->m_id
== id
) &&
1341 ((entry
->m_lastId
== lastId
) || (lastId
== -1)) &&
1342 ((entry
->m_eventType
== eventType
) || (eventType
== wxEVT_NULL
)) &&
1343 ((entry
->m_fn
== func
) || (func
== (wxObjectEventFunction
)NULL
)) &&
1344 ((entry
->m_callbackUserData
== userData
) || (userData
== (wxObject
*)NULL
)))
1346 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
1347 m_dynamicEvents
->DeleteNode( node
);
1351 node
= node
->Next();
1356 bool wxEvtHandler::SearchDynamicEventTable( wxEvent
& event
)
1358 wxCHECK_MSG( m_dynamicEvents
, FALSE
,
1359 wxT("caller should check that we have dynamic events") );
1361 int commandId
= event
.GetId();
1363 wxNode
*node
= m_dynamicEvents
->First();
1366 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)node
->Data();
1370 // Match, if event spec says any id will do (id == -1)
1371 if ( (event
.GetEventType() == entry
->m_eventType
) &&
1372 (entry
->m_id
== -1 ||
1373 (entry
->m_lastId
== -1 && commandId
== entry
->m_id
) ||
1374 (entry
->m_lastId
!= -1 &&
1375 (commandId
>= entry
->m_id
&& commandId
<= entry
->m_lastId
))) )
1378 event
.m_callbackUserData
= entry
->m_callbackUserData
;
1380 (this->*((wxEventFunction
) (entry
->m_fn
)))(event
);
1382 if (event
.GetSkipped())
1388 node
= node
->Next();
1393 #if WXWIN_COMPATIBILITY
1394 bool wxEvtHandler::OnClose()
1396 if (GetNextHandler())
1397 return GetNextHandler()->OnClose();
1401 #endif // WXWIN_COMPATIBILITY
1405 // Find a window with the focus, that is also a descendant of the given window.
1406 // This is used to determine the window to initially send commands to.
1407 wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
)
1409 // Process events starting with the window with the focus, if any.
1410 wxWindow
* focusWin
= wxWindow::FindFocus();
1411 wxWindow
* win
= focusWin
;
1413 // Check if this is a descendant of this frame.
1414 // If not, win will be set to NULL.
1417 if (win
== ancestor
)
1420 win
= win
->GetParent();
1422 if (win
== (wxWindow
*) NULL
)
1423 focusWin
= (wxWindow
*) NULL
;