1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/event.cpp
3 // Purpose: Event classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
33 #include "wx/stopwatch.h"
34 #include "wx/module.h"
37 #include "wx/window.h"
38 #include "wx/control.h"
40 #include "wx/textctrl.h"
41 #include "wx/validate.h"
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
50 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler
, wxObject
)
51 IMPLEMENT_ABSTRACT_CLASS(wxEvent
, wxObject
)
52 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent
, wxEvent
)
56 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent
, wxEvent
)
57 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent
, wxCommandEvent
)
58 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent
, wxCommandEvent
)
59 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent
, wxEvent
)
60 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent
, wxEvent
)
61 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent
, wxEvent
)
62 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent
, wxEvent
)
63 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent
, wxEvent
)
64 IMPLEMENT_DYNAMIC_CLASS(wxNcPaintEvent
, wxEvent
)
65 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent
, wxEvent
)
66 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent
, wxEvent
)
67 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent
, wxEvent
)
68 IMPLEMENT_DYNAMIC_CLASS(wxChildFocusEvent
, wxCommandEvent
)
69 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent
, wxEvent
)
70 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent
, wxEvent
)
71 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent
, wxEvent
)
72 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent
, wxEvent
)
73 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent
, wxEvent
)
74 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent
, wxEvent
)
75 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent
, wxEvent
)
76 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent
, wxEvent
)
77 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent
, wxEvent
)
78 IMPLEMENT_DYNAMIC_CLASS(wxSetCursorEvent
, wxEvent
)
79 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent
, wxEvent
)
80 IMPLEMENT_DYNAMIC_CLASS(wxDisplayChangedEvent
, wxEvent
)
81 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent
, wxCommandEvent
)
82 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent
, wxEvent
)
83 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent
, wxEvent
)
84 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent
, wxEvent
)
85 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent
, wxEvent
)
86 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent
, wxEvent
)
87 IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent
, wxCommandEvent
)
88 IMPLEMENT_DYNAMIC_CLASS(wxContextMenuEvent
, wxCommandEvent
)
89 IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureChangedEvent
, wxEvent
)
90 IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureLostEvent
, wxEvent
)
91 IMPLEMENT_DYNAMIC_CLASS(wxClipboardTextEvent
, wxCommandEvent
)
96 const wxEventTable
*wxEvtHandler::GetEventTable() const
97 { return &wxEvtHandler::sm_eventTable
; }
99 const wxEventTable
wxEvtHandler::sm_eventTable
=
100 { (const wxEventTable
*)NULL
, &wxEvtHandler::sm_eventTableEntries
[0] };
102 wxEventHashTable
&wxEvtHandler::GetEventHashTable() const
103 { return wxEvtHandler::sm_eventHashTable
; }
105 wxEventHashTable
wxEvtHandler::sm_eventHashTable(wxEvtHandler::sm_eventTable
);
107 const wxEventTableEntry
wxEvtHandler::sm_eventTableEntries
[] =
108 { DECLARE_EVENT_TABLE_ENTRY(wxEVT_NULL
, 0, 0, (wxObjectEventFunction
)NULL
, NULL
) };
111 // wxUSE_MEMORY_TRACING considers memory freed from the static objects dtors
112 // leaked, so we need to manually clean up all event tables before checking for
113 // the memory leaks when using it, however this breaks re-initializing the
114 // library (i.e. repeated calls to wxInitialize/wxUninitialize) because the
115 // event tables won't be rebuilt the next time, so disable this by default
116 #if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
118 class wxEventTableEntryModule
: public wxModule
121 wxEventTableEntryModule() { }
122 virtual bool OnInit() { return true; }
123 virtual void OnExit() { wxEventHashTable::ClearAll(); }
125 DECLARE_DYNAMIC_CLASS(wxEventTableEntryModule
)
128 IMPLEMENT_DYNAMIC_CLASS(wxEventTableEntryModule
, wxModule
)
130 #endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
132 // ----------------------------------------------------------------------------
134 // ----------------------------------------------------------------------------
136 // To put pending event handlers
137 wxList
*wxPendingEvents
= (wxList
*)NULL
;
140 // protects wxPendingEvents list
141 wxCriticalSection
*wxPendingEventsLocker
= (wxCriticalSection
*)NULL
;
144 #if !WXWIN_COMPATIBILITY_EVENT_TYPES
146 // common event types are defined here, other event types are defined by the
147 // components which use them
149 const wxEventType wxEVT_FIRST
= 10000;
150 const wxEventType wxEVT_USER_FIRST
= wxEVT_FIRST
+ 2000;
152 DEFINE_EVENT_TYPE(wxEVT_NULL
)
153 DEFINE_EVENT_TYPE(wxEVT_IDLE
)
154 DEFINE_EVENT_TYPE(wxEVT_SOCKET
)
155 DEFINE_EVENT_TYPE(wxEVT_TIMER
)
157 #endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
163 #if !WXWIN_COMPATIBILITY_EVENT_TYPES
165 DEFINE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED
)
166 DEFINE_EVENT_TYPE(wxEVT_COMMAND_CHECKBOX_CLICKED
)
167 DEFINE_EVENT_TYPE(wxEVT_COMMAND_CHOICE_SELECTED
)
168 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED
)
169 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
)
170 DEFINE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
)
171 DEFINE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED
)
172 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED
)
173 DEFINE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED
)
174 DEFINE_EVENT_TYPE(wxEVT_COMMAND_RADIOBUTTON_SELECTED
)
175 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SCROLLBAR_UPDATED
)
176 DEFINE_EVENT_TYPE(wxEVT_COMMAND_VLBOX_SELECTED
)
177 DEFINE_EVENT_TYPE(wxEVT_COMMAND_COMBOBOX_SELECTED
)
178 DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_RCLICKED
)
179 DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER
)
180 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED
)
181 DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED
)
184 DEFINE_EVENT_TYPE(wxEVT_LEFT_DOWN
)
185 DEFINE_EVENT_TYPE(wxEVT_LEFT_UP
)
186 DEFINE_EVENT_TYPE(wxEVT_MIDDLE_DOWN
)
187 DEFINE_EVENT_TYPE(wxEVT_MIDDLE_UP
)
188 DEFINE_EVENT_TYPE(wxEVT_RIGHT_DOWN
)
189 DEFINE_EVENT_TYPE(wxEVT_RIGHT_UP
)
190 DEFINE_EVENT_TYPE(wxEVT_MOTION
)
191 DEFINE_EVENT_TYPE(wxEVT_ENTER_WINDOW
)
192 DEFINE_EVENT_TYPE(wxEVT_LEAVE_WINDOW
)
193 DEFINE_EVENT_TYPE(wxEVT_LEFT_DCLICK
)
194 DEFINE_EVENT_TYPE(wxEVT_MIDDLE_DCLICK
)
195 DEFINE_EVENT_TYPE(wxEVT_RIGHT_DCLICK
)
196 DEFINE_EVENT_TYPE(wxEVT_SET_FOCUS
)
197 DEFINE_EVENT_TYPE(wxEVT_KILL_FOCUS
)
198 DEFINE_EVENT_TYPE(wxEVT_CHILD_FOCUS
)
199 DEFINE_EVENT_TYPE(wxEVT_MOUSEWHEEL
)
200 DEFINE_EVENT_TYPE(wxEVT_AUX1_DOWN
)
201 DEFINE_EVENT_TYPE(wxEVT_AUX1_UP
)
202 DEFINE_EVENT_TYPE(wxEVT_AUX1_DCLICK
)
203 DEFINE_EVENT_TYPE(wxEVT_AUX2_DOWN
)
204 DEFINE_EVENT_TYPE(wxEVT_AUX2_UP
)
205 DEFINE_EVENT_TYPE(wxEVT_AUX2_DCLICK
)
207 // Non-client mouse events
208 DEFINE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN
)
209 DEFINE_EVENT_TYPE(wxEVT_NC_LEFT_UP
)
210 DEFINE_EVENT_TYPE(wxEVT_NC_MIDDLE_DOWN
)
211 DEFINE_EVENT_TYPE(wxEVT_NC_MIDDLE_UP
)
212 DEFINE_EVENT_TYPE(wxEVT_NC_RIGHT_DOWN
)
213 DEFINE_EVENT_TYPE(wxEVT_NC_RIGHT_UP
)
214 DEFINE_EVENT_TYPE(wxEVT_NC_MOTION
)
215 DEFINE_EVENT_TYPE(wxEVT_NC_ENTER_WINDOW
)
216 DEFINE_EVENT_TYPE(wxEVT_NC_LEAVE_WINDOW
)
217 DEFINE_EVENT_TYPE(wxEVT_NC_LEFT_DCLICK
)
218 DEFINE_EVENT_TYPE(wxEVT_NC_MIDDLE_DCLICK
)
219 DEFINE_EVENT_TYPE(wxEVT_NC_RIGHT_DCLICK
)
221 // Character input event type
222 DEFINE_EVENT_TYPE(wxEVT_CHAR
)
223 DEFINE_EVENT_TYPE(wxEVT_CHAR_HOOK
)
224 DEFINE_EVENT_TYPE(wxEVT_NAVIGATION_KEY
)
225 DEFINE_EVENT_TYPE(wxEVT_KEY_DOWN
)
226 DEFINE_EVENT_TYPE(wxEVT_KEY_UP
)
228 DEFINE_EVENT_TYPE(wxEVT_HOTKEY
)
232 DEFINE_EVENT_TYPE(wxEVT_SET_CURSOR
)
234 // wxScrollbar and wxSlider event identifiers
235 DEFINE_EVENT_TYPE(wxEVT_SCROLL_TOP
)
236 DEFINE_EVENT_TYPE(wxEVT_SCROLL_BOTTOM
)
237 DEFINE_EVENT_TYPE(wxEVT_SCROLL_LINEUP
)
238 DEFINE_EVENT_TYPE(wxEVT_SCROLL_LINEDOWN
)
239 DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP
)
240 DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN
)
241 DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK
)
242 DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE
)
243 DEFINE_EVENT_TYPE(wxEVT_SCROLL_CHANGED
)
245 // Scroll events from wxWindow
246 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP
)
247 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_BOTTOM
)
248 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEUP
)
249 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEDOWN
)
250 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEUP
)
251 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEDOWN
)
252 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBTRACK
)
253 DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBRELEASE
)
256 DEFINE_EVENT_TYPE(wxEVT_SIZE
)
257 DEFINE_EVENT_TYPE(wxEVT_SIZING
)
258 DEFINE_EVENT_TYPE(wxEVT_MOVE
)
259 DEFINE_EVENT_TYPE(wxEVT_MOVING
)
260 DEFINE_EVENT_TYPE(wxEVT_MOVE_START
)
261 DEFINE_EVENT_TYPE(wxEVT_MOVE_END
)
262 DEFINE_EVENT_TYPE(wxEVT_CLOSE_WINDOW
)
263 DEFINE_EVENT_TYPE(wxEVT_END_SESSION
)
264 DEFINE_EVENT_TYPE(wxEVT_QUERY_END_SESSION
)
265 DEFINE_EVENT_TYPE(wxEVT_HIBERNATE
)
266 DEFINE_EVENT_TYPE(wxEVT_ACTIVATE_APP
)
267 DEFINE_EVENT_TYPE(wxEVT_POWER
)
268 DEFINE_EVENT_TYPE(wxEVT_ACTIVATE
)
269 DEFINE_EVENT_TYPE(wxEVT_CREATE
)
270 DEFINE_EVENT_TYPE(wxEVT_DESTROY
)
271 DEFINE_EVENT_TYPE(wxEVT_SHOW
)
272 DEFINE_EVENT_TYPE(wxEVT_ICONIZE
)
273 DEFINE_EVENT_TYPE(wxEVT_MAXIMIZE
)
274 DEFINE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED
)
275 DEFINE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_LOST
)
276 DEFINE_EVENT_TYPE(wxEVT_PAINT
)
277 DEFINE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND
)
278 DEFINE_EVENT_TYPE(wxEVT_NC_PAINT
)
279 DEFINE_EVENT_TYPE(wxEVT_PAINT_ICON
)
280 DEFINE_EVENT_TYPE(wxEVT_MENU_OPEN
)
281 DEFINE_EVENT_TYPE(wxEVT_MENU_CLOSE
)
282 DEFINE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT
)
283 DEFINE_EVENT_TYPE(wxEVT_CONTEXT_MENU
)
284 DEFINE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED
)
285 DEFINE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED
)
286 DEFINE_EVENT_TYPE(wxEVT_SETTING_CHANGED
)
287 DEFINE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE
)
288 DEFINE_EVENT_TYPE(wxEVT_PALETTE_CHANGED
)
289 DEFINE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN
)
290 DEFINE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP
)
291 DEFINE_EVENT_TYPE(wxEVT_JOY_MOVE
)
292 DEFINE_EVENT_TYPE(wxEVT_JOY_ZMOVE
)
293 DEFINE_EVENT_TYPE(wxEVT_DROP_FILES
)
294 DEFINE_EVENT_TYPE(wxEVT_DRAW_ITEM
)
295 DEFINE_EVENT_TYPE(wxEVT_MEASURE_ITEM
)
296 DEFINE_EVENT_TYPE(wxEVT_COMPARE_ITEM
)
297 DEFINE_EVENT_TYPE(wxEVT_INIT_DIALOG
)
298 DEFINE_EVENT_TYPE(wxEVT_UPDATE_UI
)
301 DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY
)
302 DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT
)
303 DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE
)
305 // Generic command events
306 // Note: a click is a higher-level event than button down/up
307 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LEFT_CLICK
)
308 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LEFT_DCLICK
)
309 DEFINE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_CLICK
)
310 DEFINE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_DCLICK
)
311 DEFINE_EVENT_TYPE(wxEVT_COMMAND_SET_FOCUS
)
312 DEFINE_EVENT_TYPE(wxEVT_COMMAND_KILL_FOCUS
)
313 DEFINE_EVENT_TYPE(wxEVT_COMMAND_ENTER
)
316 DEFINE_EVENT_TYPE(wxEVT_HELP
)
317 DEFINE_EVENT_TYPE(wxEVT_DETAILED_HELP
)
319 #endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
325 wxIdleMode
wxIdleEvent::sm_idleMode
= wxIDLE_PROCESS_ALL
;
327 // ============================================================================
329 // ============================================================================
331 // ----------------------------------------------------------------------------
332 // event initialization
333 // ----------------------------------------------------------------------------
338 static int s_lastUsedEventType
= wxEVT_FIRST
;
340 return s_lastUsedEventType
++;
343 // ----------------------------------------------------------------------------
345 // ----------------------------------------------------------------------------
348 * General wxWidgets events, covering
349 * all interesting things that might happen (button clicking, resizing,
350 * setting text in widgets, etc.).
352 * For each completely new event type, derive a new event class.
356 wxEvent::wxEvent(int theId
, wxEventType commandType
)
358 m_eventType
= commandType
;
359 m_eventObject
= (wxObject
*) NULL
;
363 m_callbackUserData
= (wxObject
*) NULL
;
364 m_isCommandEvent
= false;
365 m_propagationLevel
= wxEVENT_PROPAGATE_NONE
;
368 wxEvent::wxEvent(const wxEvent
&src
)
370 , m_eventObject(src
.m_eventObject
)
371 , m_eventType(src
.m_eventType
)
372 , m_timeStamp(src
.m_timeStamp
)
374 , m_callbackUserData(src
.m_callbackUserData
)
375 , m_propagationLevel(src
.m_propagationLevel
)
376 , m_skipped(src
.m_skipped
)
377 , m_isCommandEvent(src
.m_isCommandEvent
)
391 // 'this' : used in base member initializer list (for m_commandString)
392 #pragma warning(disable:4355)
395 wxCommandEvent::wxCommandEvent(wxEventType commandType
, int theId
)
396 : wxEvent(theId
, commandType
)
398 m_clientData
= (char *) NULL
;
399 m_clientObject
= (wxClientData
*) NULL
;
402 m_isCommandEvent
= true;
404 // the command events are propagated upwards by default
405 m_propagationLevel
= wxEVENT_PROPAGATE_MAX
;
409 #pragma warning(default:4355)
412 wxString
wxCommandEvent::GetString() const
414 if(m_eventType
!= wxEVT_COMMAND_TEXT_UPDATED
|| !m_eventObject
)
419 wxTextCtrl
*txt
= wxDynamicCast(m_eventObject
, wxTextCtrl
);
421 return txt
->GetValue();
423 #endif // wxUSE_TEXTCTRL
433 wxLongLong
wxUpdateUIEvent::sm_lastUpdate
= 0;
436 long wxUpdateUIEvent::sm_updateInterval
= 0;
438 wxUpdateUIMode
wxUpdateUIEvent::sm_updateMode
= wxUPDATE_UI_PROCESS_ALL
;
441 bool wxUpdateUIEvent::CanUpdate(wxWindowBase
*win
)
443 // Don't update if we've switched global updating off
444 // and this window doesn't support updates.
446 (GetMode() == wxUPDATE_UI_PROCESS_SPECIFIED
&&
447 ((win
->GetExtraStyle() & wxWS_EX_PROCESS_UI_UPDATES
) == 0)))
450 if (sm_updateInterval
== -1)
453 if (sm_updateInterval
== 0)
456 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
457 wxLongLong now
= wxGetLocalTimeMillis();
458 if (now
> (sm_lastUpdate
+ sm_updateInterval
))
465 // If we don't have wxStopWatch or wxLongLong, we
466 // should err on the safe side and update now anyway.
471 // Reset the update time to provide a delay until the next
472 // time we should update
473 void wxUpdateUIEvent::ResetUpdateTime()
475 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
476 if (sm_updateInterval
> 0)
478 wxLongLong now
= wxGetLocalTimeMillis();
479 if (now
> (sm_lastUpdate
+ sm_updateInterval
))
491 wxScrollEvent::wxScrollEvent(wxEventType commandType
,
495 : wxCommandEvent(commandType
, id
)
497 m_extraLong
= orient
;
505 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType
,
509 m_eventType
= commandType
;
510 m_extraLong
= orient
;
519 wxMouseEvent::wxMouseEvent(wxEventType commandType
)
521 m_eventType
= commandType
;
524 m_controlDown
= false;
528 m_middleDown
= false;
535 m_linesPerAction
= 0;
539 void wxMouseEvent::Assign(const wxMouseEvent
& event
)
541 m_eventType
= event
.m_eventType
;
546 m_leftDown
= event
.m_leftDown
;
547 m_middleDown
= event
.m_middleDown
;
548 m_rightDown
= event
.m_rightDown
;
549 m_aux1Down
= event
.m_aux1Down
;
550 m_aux2Down
= event
.m_aux2Down
;
552 m_controlDown
= event
.m_controlDown
;
553 m_shiftDown
= event
.m_shiftDown
;
554 m_altDown
= event
.m_altDown
;
555 m_metaDown
= event
.m_metaDown
;
557 m_wheelRotation
= event
.m_wheelRotation
;
558 m_wheelDelta
= event
.m_wheelDelta
;
559 m_linesPerAction
= event
.m_linesPerAction
;
560 m_wheelAxis
= event
.m_wheelAxis
;
563 // return true if was a button dclick event
564 bool wxMouseEvent::ButtonDClick(int but
) const
569 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
572 case wxMOUSE_BTN_ANY
:
573 return (LeftDClick() || MiddleDClick() || RightDClick() ||
574 Aux1DClick() || Aux2DClick());
576 case wxMOUSE_BTN_LEFT
:
579 case wxMOUSE_BTN_MIDDLE
:
580 return MiddleDClick();
582 case wxMOUSE_BTN_RIGHT
:
583 return RightDClick();
585 case wxMOUSE_BTN_AUX1
:
588 case wxMOUSE_BTN_AUX2
:
593 // return true if was a button down event
594 bool wxMouseEvent::ButtonDown(int but
) const
599 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
602 case wxMOUSE_BTN_ANY
:
603 return (LeftDown() || MiddleDown() || RightDown() ||
604 Aux1Down() || Aux2Down());
606 case wxMOUSE_BTN_LEFT
:
609 case wxMOUSE_BTN_MIDDLE
:
612 case wxMOUSE_BTN_RIGHT
:
615 case wxMOUSE_BTN_AUX1
:
618 case wxMOUSE_BTN_AUX2
:
623 // return true if was a button up event
624 bool wxMouseEvent::ButtonUp(int but
) const
629 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
632 case wxMOUSE_BTN_ANY
:
633 return (LeftUp() || MiddleUp() || RightUp() ||
634 Aux1Up() || Aux2Up());
636 case wxMOUSE_BTN_LEFT
:
639 case wxMOUSE_BTN_MIDDLE
:
642 case wxMOUSE_BTN_RIGHT
:
645 case wxMOUSE_BTN_AUX1
:
648 case wxMOUSE_BTN_AUX2
:
653 // return true if the given button is currently changing state
654 bool wxMouseEvent::Button(int but
) const
659 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
662 case wxMOUSE_BTN_ANY
:
663 return ButtonUp(wxMOUSE_BTN_ANY
) ||
664 ButtonDown(wxMOUSE_BTN_ANY
) ||
665 ButtonDClick(wxMOUSE_BTN_ANY
);
667 case wxMOUSE_BTN_LEFT
:
668 return LeftDown() || LeftUp() || LeftDClick();
670 case wxMOUSE_BTN_MIDDLE
:
671 return MiddleDown() || MiddleUp() || MiddleDClick();
673 case wxMOUSE_BTN_RIGHT
:
674 return RightDown() || RightUp() || RightDClick();
676 case wxMOUSE_BTN_AUX1
:
677 return Aux1Down() || Aux1Up() || Aux1DClick();
679 case wxMOUSE_BTN_AUX2
:
680 return Aux2Down() || Aux2Up() || Aux2DClick();
684 bool wxMouseEvent::ButtonIsDown(int but
) const
689 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
692 case wxMOUSE_BTN_ANY
:
693 return LeftIsDown() || MiddleIsDown() || RightIsDown() || Aux1Down() || Aux2Down();
695 case wxMOUSE_BTN_LEFT
:
698 case wxMOUSE_BTN_MIDDLE
:
699 return MiddleIsDown();
701 case wxMOUSE_BTN_RIGHT
:
702 return RightIsDown();
704 case wxMOUSE_BTN_AUX1
:
707 case wxMOUSE_BTN_AUX2
:
712 int wxMouseEvent::GetButton() const
714 for ( int i
= 1; i
< wxMOUSE_BTN_MAX
; i
++ )
722 return wxMOUSE_BTN_NONE
;
725 // Find the logical position of the event given the DC
726 wxPoint
wxMouseEvent::GetLogicalPosition(const wxDC
& dc
) const
728 wxPoint
pt(dc
.DeviceToLogicalX(m_x
), dc
.DeviceToLogicalY(m_y
));
738 wxKeyEvent::wxKeyEvent(wxEventType type
)
742 m_controlDown
= false;
752 wxKeyEvent::wxKeyEvent(const wxKeyEvent
& evt
)
758 m_keyCode
= evt
.m_keyCode
;
760 m_controlDown
= evt
.m_controlDown
;
761 m_shiftDown
= evt
.m_shiftDown
;
762 m_altDown
= evt
.m_altDown
;
763 m_metaDown
= evt
.m_metaDown
;
764 m_scanCode
= evt
.m_scanCode
;
765 m_rawCode
= evt
.m_rawCode
;
766 m_rawFlags
= evt
.m_rawFlags
;
769 m_uniChar
= evt
.m_uniChar
;
773 #if WXWIN_COMPATIBILITY_2_6
774 long wxKeyEvent::KeyCode() const
778 #endif // WXWIN_COMPATIBILITY_2_6
780 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow
*win
)
782 SetEventType(wxEVT_CREATE
);
786 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow
*win
)
788 SetEventType(wxEVT_DESTROY
);
792 wxChildFocusEvent::wxChildFocusEvent(wxWindow
*win
)
793 : wxCommandEvent(wxEVT_CHILD_FOCUS
)
798 // ----------------------------------------------------------------------------
800 // ----------------------------------------------------------------------------
803 wxHelpEvent::Origin
wxHelpEvent::GuessOrigin(Origin origin
)
805 if ( origin
== Origin_Unknown
)
807 // assume that the event comes from the help button if it's not from
808 // keyboard and that pressing F1 always results in the help event
809 origin
= wxGetKeyState(WXK_F1
) ? Origin_Keyboard
: Origin_HelpButton
;
820 // ----------------------------------------------------------------------------
822 // ----------------------------------------------------------------------------
824 static const int EVENT_TYPE_TABLE_INIT_SIZE
= 31; // Not too big not too small...
826 wxEventHashTable
* wxEventHashTable::sm_first
= NULL
;
828 wxEventHashTable::wxEventHashTable(const wxEventTable
&table
)
832 AllocEventTypeTable(EVENT_TYPE_TABLE_INIT_SIZE
);
836 m_next
->m_previous
= this;
840 wxEventHashTable::~wxEventHashTable()
843 m_next
->m_previous
= m_previous
;
845 m_previous
->m_next
= m_next
;
846 if (sm_first
== this)
852 void wxEventHashTable::Clear()
854 for ( size_t i
= 0; i
< m_size
; i
++ )
856 EventTypeTablePointer eTTnode
= m_eventTypeTable
[i
];
860 delete[] m_eventTypeTable
;
861 m_eventTypeTable
= NULL
;
866 #if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
869 void wxEventHashTable::ClearAll()
871 wxEventHashTable
* table
= sm_first
;
875 table
= table
->m_next
;
879 #endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
881 bool wxEventHashTable::HandleEvent(wxEvent
&event
, wxEvtHandler
*self
)
886 m_rebuildHash
= false;
889 if (!m_eventTypeTable
)
892 // Find all entries for the given event type.
893 wxEventType eventType
= event
.GetEventType();
894 const EventTypeTablePointer eTTnode
= m_eventTypeTable
[eventType
% m_size
];
895 if (eTTnode
&& eTTnode
->eventType
== eventType
)
897 // Now start the search for an event handler
898 // that can handle an event with the given ID.
899 const wxEventTableEntryPointerArray
&
900 eventEntryTable
= eTTnode
->eventEntryTable
;
902 const size_t count
= eventEntryTable
.GetCount();
903 for (size_t n
= 0; n
< count
; n
++)
906 ProcessEventIfMatches(*eventEntryTable
[n
], self
, event
) )
916 void wxEventHashTable::InitHashTable()
918 // Loop over the event tables and all its base tables.
919 const wxEventTable
*table
= &m_table
;
922 // Retrieve all valid event handler entries
923 const wxEventTableEntry
*entry
= table
->entries
;
924 while (entry
->m_fn
!= 0)
926 // Add the event entry in the Hash.
932 table
= table
->baseTable
;
935 // Lets free some memory.
937 for(i
= 0; i
< m_size
; i
++)
939 EventTypeTablePointer eTTnode
= m_eventTypeTable
[i
];
942 eTTnode
->eventEntryTable
.Shrink();
947 void wxEventHashTable::AddEntry(const wxEventTableEntry
&entry
)
949 // This might happen 'accidentally' as the app is exiting
950 if (!m_eventTypeTable
)
953 EventTypeTablePointer
*peTTnode
= &m_eventTypeTable
[entry
.m_eventType
% m_size
];
954 EventTypeTablePointer eTTnode
= *peTTnode
;
958 if (eTTnode
->eventType
!= entry
.m_eventType
)
961 GrowEventTypeTable();
962 // Try again to add it.
969 eTTnode
= new EventTypeTable
;
970 eTTnode
->eventType
= entry
.m_eventType
;
974 // Fill all hash entries between entry.m_id and entry.m_lastId...
975 eTTnode
->eventEntryTable
.Add(&entry
);
978 void wxEventHashTable::AllocEventTypeTable(size_t size
)
980 m_eventTypeTable
= new EventTypeTablePointer
[size
];
981 memset((void *)m_eventTypeTable
, 0, sizeof(EventTypeTablePointer
)*size
);
985 void wxEventHashTable::GrowEventTypeTable()
987 size_t oldSize
= m_size
;
988 EventTypeTablePointer
*oldEventTypeTable
= m_eventTypeTable
;
990 // TODO: Search the most optimal grow sequence
991 AllocEventTypeTable(/* GetNextPrime(oldSize) */oldSize
*2+1);
993 for ( size_t i
= 0; i
< oldSize
; /* */ )
995 EventTypeTablePointer eTToldNode
= oldEventTypeTable
[i
];
998 EventTypeTablePointer
*peTTnode
= &m_eventTypeTable
[eTToldNode
->eventType
% m_size
];
999 EventTypeTablePointer eTTnode
= *peTTnode
;
1001 // Check for collision, we don't want any.
1004 GrowEventTypeTable();
1005 continue; // Don't increment the counter,
1006 // as we still need to add this element.
1010 // Get the old value and put it in the new table.
1011 *peTTnode
= oldEventTypeTable
[i
];
1018 delete[] oldEventTypeTable
;
1022 // ----------------------------------------------------------------------------
1024 // ----------------------------------------------------------------------------
1030 wxEvtHandler::wxEvtHandler()
1032 m_nextHandler
= (wxEvtHandler
*) NULL
;
1033 m_previousHandler
= (wxEvtHandler
*) NULL
;
1035 m_dynamicEvents
= (wxList
*) NULL
;
1036 m_pendingEvents
= (wxList
*) NULL
;
1038 # if !defined(__VISAGECPP__)
1039 m_eventsLocker
= new wxCriticalSection
;
1043 // no client data (yet)
1044 m_clientData
= NULL
;
1045 m_clientDataType
= wxClientData_None
;
1048 wxEvtHandler::~wxEvtHandler()
1050 // Takes itself out of the list of handlers
1051 if (m_previousHandler
)
1052 m_previousHandler
->m_nextHandler
= m_nextHandler
;
1055 m_nextHandler
->m_previousHandler
= m_previousHandler
;
1057 if (m_dynamicEvents
)
1059 for ( wxList::iterator it
= m_dynamicEvents
->begin(),
1060 end
= m_dynamicEvents
->end();
1064 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1065 wxEventTableEntry
*entry
= (wxEventTableEntry
*)*it
;
1066 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1067 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)*it
;
1068 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1070 if (entry
->m_callbackUserData
)
1071 delete entry
->m_callbackUserData
;
1074 delete m_dynamicEvents
;
1077 if (m_pendingEvents
)
1078 m_pendingEvents
->DeleteContents(true);
1079 delete m_pendingEvents
;
1082 # if !defined(__VISAGECPP__)
1083 delete m_eventsLocker
;
1086 // Remove us from wxPendingEvents if necessary.
1087 if(wxPendingEventsLocker
)
1088 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
1089 if ( wxPendingEvents
)
1091 // Delete all occurences of this from the list of pending events
1092 while (wxPendingEvents
->DeleteObject(this)) { } // Do nothing
1094 if(wxPendingEventsLocker
)
1095 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
1098 // we only delete object data, not untyped
1099 if ( m_clientDataType
== wxClientData_Object
)
1100 delete m_clientObject
;
1105 bool wxEvtHandler::ProcessThreadEvent(const wxEvent
& event
)
1107 // check that we are really in a child thread
1108 wxASSERT_MSG( !wxThread::IsMain(),
1109 wxT("use ProcessEvent() in main thread") );
1111 AddPendingEvent(event
);
1116 void wxEvtHandler::ClearEventLocker()
1118 #if !defined(__VISAGECPP__)
1119 delete m_eventsLocker
;
1120 m_eventsLocker
= NULL
;
1124 #endif // wxUSE_THREADS
1126 void wxEvtHandler::AddPendingEvent(const wxEvent
& event
)
1128 // 1) Add event to list of pending events of this event handler
1130 wxEvent
*eventCopy
= event
.Clone();
1132 // we must be able to copy the events here so the event class must
1133 // implement Clone() properly instead of just providing a NULL stab for it
1134 wxCHECK_RET( eventCopy
,
1135 _T("events of this type aren't supposed to be posted") );
1137 wxENTER_CRIT_SECT( Lock() );
1139 if ( !m_pendingEvents
)
1140 m_pendingEvents
= new wxList
;
1142 m_pendingEvents
->Append(eventCopy
);
1144 wxLEAVE_CRIT_SECT( Lock() );
1146 // 2) Add this event handler to list of event handlers that
1147 // have pending events.
1149 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
1151 if ( !wxPendingEvents
)
1152 wxPendingEvents
= new wxList
;
1153 wxPendingEvents
->Append(this);
1155 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
1157 // 3) Inform the system that new pending events are somewhere,
1158 // and that these should be processed in idle time.
1162 void wxEvtHandler::ProcessPendingEvents()
1164 // this method is only called by wxApp if this handler does have
1166 wxCHECK_RET( m_pendingEvents
,
1167 wxT("Please call wxApp::ProcessPendingEvents() instead") );
1169 wxENTER_CRIT_SECT( Lock() );
1171 // we leave the loop once we have processed all events that were present at
1172 // the start of ProcessPendingEvents because otherwise we could get into
1173 // infinite loop if the pending event handler execution resulted in another
1174 // event being posted
1175 size_t n
= m_pendingEvents
->size();
1176 for ( wxList::compatibility_iterator node
= m_pendingEvents
->GetFirst();
1178 node
= m_pendingEvents
->GetFirst() )
1180 wxEvent
*event
= (wxEvent
*)node
->GetData();
1182 // It's importan we remove event from list before processing it.
1183 // Else a nested event loop, for example from a modal dialog, might
1184 // process the same event again.
1186 m_pendingEvents
->Erase(node
);
1188 wxLEAVE_CRIT_SECT( Lock() );
1190 ProcessEvent(*event
);
1194 wxENTER_CRIT_SECT( Lock() );
1200 wxLEAVE_CRIT_SECT( Lock() );
1207 wxEvtHandler::ProcessEventIfMatches(const wxEventTableEntryBase
& entry
,
1208 wxEvtHandler
*handler
,
1211 int tableId1
= entry
.m_id
,
1212 tableId2
= entry
.m_lastId
;
1214 // match only if the event type is the same and the id is either -1 in
1215 // the event table (meaning "any") or the event id matches the id
1216 // specified in the event table either exactly or by falling into
1217 // range between first and last
1218 if ((tableId1
== wxID_ANY
) ||
1219 (tableId2
== wxID_ANY
&& tableId1
== event
.GetId()) ||
1220 (tableId2
!= wxID_ANY
&&
1221 (event
.GetId() >= tableId1
&& event
.GetId() <= tableId2
)))
1224 event
.m_callbackUserData
= entry
.m_callbackUserData
;
1226 #if wxUSE_EXCEPTIONS
1229 // call the handler via wxApp method which allows the user to catch
1230 // any exceptions which may be thrown by any handler in the program
1232 wxTheApp
->HandleEvent(handler
, (wxEventFunction
)entry
.m_fn
, event
);
1235 #endif // wxUSE_EXCEPTIONS
1237 // no need for an extra virtual function call
1238 (handler
->*((wxEventFunction
) (entry
.m_fn
)))(event
);
1241 if (!event
.GetSkipped())
1248 bool wxEvtHandler::TryParent(wxEvent
& event
)
1250 if ( wxTheApp
&& (this != wxTheApp
) )
1252 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
1253 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
1254 // processed appropriately via SearchEventTable.
1255 if ( event
.GetEventType() != wxEVT_IDLE
)
1257 if ( wxTheApp
->ProcessEvent(event
) )
1265 bool wxEvtHandler::ProcessEvent(wxEvent
& event
)
1267 // allow the application to hook into event processing
1270 int rc
= wxTheApp
->FilterEvent(event
);
1273 wxASSERT_MSG( rc
== 1 || rc
== 0,
1274 _T("unexpected wxApp::FilterEvent return value") );
1278 //else: proceed normally
1281 // An event handler can be enabled or disabled
1282 if ( GetEvtHandlerEnabled() )
1284 // if we have a validator, it has higher priority than our own event
1286 if ( TryValidator(event
) )
1289 // Handle per-instance dynamic event tables first
1290 if ( m_dynamicEvents
&& SearchDynamicEventTable(event
) )
1293 // Then static per-class event tables
1294 if ( GetEventHashTable().HandleEvent(event
, this) )
1298 // Try going down the event handler chain
1299 if ( GetNextHandler() )
1301 // notice that we shouldn't let the parent have the event even if the
1302 // next handler does not process it because it will have already passed
1303 // it to the parent in this case
1304 return GetNextHandler()->ProcessEvent(event
);
1307 // Finally propagate the event upwards the window chain and/or to the
1308 // application object as necessary
1309 return TryParent(event
);
1313 bool wxEvtHandler::SearchEventTable(wxEventTable
& table
, wxEvent
& event
)
1315 const wxEventType eventType
= event
.GetEventType();
1316 for ( int i
= 0; table
.entries
[i
].m_fn
!= 0; i
++ )
1318 const wxEventTableEntry
& entry
= table
.entries
[i
];
1319 if ( eventType
== entry
.m_eventType
)
1321 if ( ProcessEventIfMatches(entry
, this, event
) )
1329 void wxEvtHandler::Connect( int id
, int lastId
,
1331 wxObjectEventFunction func
,
1333 wxEvtHandler
* eventSink
)
1335 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1336 wxEventTableEntry
*entry
= new wxEventTableEntry
;
1337 entry
->m_eventType
= eventType
;
1339 entry
->m_lastId
= lastId
;
1341 entry
->m_callbackUserData
= userData
;
1342 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1343 wxDynamicEventTableEntry
*entry
=
1344 new wxDynamicEventTableEntry(eventType
, id
, lastId
, func
, userData
, eventSink
);
1345 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1347 if (!m_dynamicEvents
)
1348 m_dynamicEvents
= new wxList
;
1350 // Insert at the front of the list so most recent additions are found first
1351 m_dynamicEvents
->Insert( (wxObject
*) entry
);
1354 bool wxEvtHandler::Disconnect( int id
, int lastId
, wxEventType eventType
,
1355 wxObjectEventFunction func
,
1357 wxEvtHandler
* eventSink
)
1359 if (!m_dynamicEvents
)
1362 wxList::compatibility_iterator node
= m_dynamicEvents
->GetFirst();
1365 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1366 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->GetData();
1367 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1368 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)node
->GetData();
1369 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1371 if ((entry
->m_id
== id
) &&
1372 ((entry
->m_lastId
== lastId
) || (lastId
== wxID_ANY
)) &&
1373 ((entry
->m_eventType
== eventType
) || (eventType
== wxEVT_NULL
)) &&
1374 ((entry
->m_fn
== func
) || (func
== (wxObjectEventFunction
)NULL
)) &&
1375 ((entry
->m_eventSink
== eventSink
) || (eventSink
== (wxEvtHandler
*)NULL
)) &&
1376 ((entry
->m_callbackUserData
== userData
) || (userData
== (wxObject
*)NULL
)))
1378 if (entry
->m_callbackUserData
)
1379 delete entry
->m_callbackUserData
;
1380 m_dynamicEvents
->Erase( node
);
1384 node
= node
->GetNext();
1389 bool wxEvtHandler::SearchDynamicEventTable( wxEvent
& event
)
1391 wxCHECK_MSG( m_dynamicEvents
, false,
1392 wxT("caller should check that we have dynamic events") );
1394 wxList::compatibility_iterator node
= m_dynamicEvents
->GetFirst();
1397 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1398 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->GetData();
1399 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1400 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)node
->GetData();
1401 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1403 // get next node before (maybe) calling the event handler as it could
1404 // call Disconnect() invalidating the current node
1405 node
= node
->GetNext();
1407 if ((event
.GetEventType() == entry
->m_eventType
) && (entry
->m_fn
!= 0))
1409 wxEvtHandler
*handler
=
1410 #if !WXWIN_COMPATIBILITY_EVENT_TYPES
1411 entry
->m_eventSink
? entry
->m_eventSink
1416 if ( ProcessEventIfMatches(*entry
, handler
, event
) )
1426 void wxEvtHandler::DoSetClientObject( wxClientData
*data
)
1428 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
1429 wxT("can't have both object and void client data") );
1431 if ( m_clientObject
)
1432 delete m_clientObject
;
1434 m_clientObject
= data
;
1435 m_clientDataType
= wxClientData_Object
;
1438 wxClientData
*wxEvtHandler::DoGetClientObject() const
1440 // it's not an error to call GetClientObject() on a window which doesn't
1441 // have client data at all - NULL will be returned
1442 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
1443 wxT("this window doesn't have object client data") );
1445 return m_clientObject
;
1448 void wxEvtHandler::DoSetClientData( void *data
)
1450 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
1451 wxT("can't have both object and void client data") );
1453 m_clientData
= data
;
1454 m_clientDataType
= wxClientData_Void
;
1457 void *wxEvtHandler::DoGetClientData() const
1459 // it's not an error to call GetClientData() on a window which doesn't have
1460 // client data at all - NULL will be returned
1461 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
1462 wxT("this window doesn't have void client data") );
1464 return m_clientData
;
1467 #endif // wxUSE_BASE
1471 // Find a window with the focus, that is also a descendant of the given window.
1472 // This is used to determine the window to initially send commands to.
1473 wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
)
1475 // Process events starting with the window with the focus, if any.
1476 wxWindow
* focusWin
= wxWindow::FindFocus();
1477 wxWindow
* win
= focusWin
;
1479 // Check if this is a descendant of this frame.
1480 // If not, win will be set to NULL.
1483 if (win
== ancestor
)
1486 win
= win
->GetParent();
1488 if (win
== (wxWindow
*) NULL
)
1489 focusWin
= (wxWindow
*) NULL
;
1494 // ----------------------------------------------------------------------------
1496 // ----------------------------------------------------------------------------
1498 wxEventBlocker::wxEventBlocker(wxWindow
*win
, wxEventType type
)
1500 wxCHECK_RET(win
, wxT("Null window given to wxEventBlocker"));
1505 m_window
->PushEventHandler(this);
1508 wxEventBlocker::~wxEventBlocker()
1510 wxEvtHandler
*popped
= m_window
->PopEventHandler(false);
1511 wxCHECK_RET(popped
== this,
1512 wxT("Don't push other event handlers into a window managed by wxEventBlocker!"));
1515 bool wxEventBlocker::ProcessEvent(wxEvent
& event
)
1517 // should this event be blocked?
1518 for ( size_t i
= 0; i
< m_eventsToBlock
.size(); i
++ )
1520 wxEventType t
= (wxEventType
)m_eventsToBlock
[i
];
1521 if ( t
== wxEVT_ANY
|| t
== event
.GetEventType() )
1522 return true; // yes, it should: mark this event as processed