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"
50 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
51 // must define these static for VA or else you get multiply defined symbols everywhere
52 const wxEventType wxEVT_NULL
= 0;
53 const wxEventType wxEVT_FIRST
= 10000;
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;
76 /* Sockets send events, too */
77 const wxEventType wxEVT_SOCKET
= wxEVT_FIRST
+ 50;
78 const wxEventType wxEVT_TIMER
= wxEVT_FIRST
+ 80;
80 /* Mouse event types */
81 const wxEventType wxEVT_LEFT_DOWN
= wxEVT_FIRST
+ 100;
82 const wxEventType wxEVT_LEFT_UP
= wxEVT_FIRST
+ 101;
83 const wxEventType wxEVT_MIDDLE_DOWN
= wxEVT_FIRST
+ 102;
84 const wxEventType wxEVT_MIDDLE_UP
= wxEVT_FIRST
+ 103;
85 const wxEventType wxEVT_RIGHT_DOWN
= wxEVT_FIRST
+ 104;
86 const wxEventType wxEVT_RIGHT_UP
= wxEVT_FIRST
+ 105;
87 const wxEventType wxEVT_MOTION
= wxEVT_FIRST
+ 106;
88 const wxEventType wxEVT_ENTER_WINDOW
= wxEVT_FIRST
+ 107;
89 const wxEventType wxEVT_LEAVE_WINDOW
= wxEVT_FIRST
+ 108;
90 const wxEventType wxEVT_LEFT_DCLICK
= wxEVT_FIRST
+ 109;
91 const wxEventType wxEVT_MIDDLE_DCLICK
= wxEVT_FIRST
+ 110;
92 const wxEventType wxEVT_RIGHT_DCLICK
= wxEVT_FIRST
+ 111;
93 const wxEventType wxEVT_SET_FOCUS
= wxEVT_FIRST
+ 112;
94 const wxEventType wxEVT_KILL_FOCUS
= wxEVT_FIRST
+ 113;
96 /* Non-client mouse events */
97 const wxEventType wxEVT_NC_LEFT_DOWN
= wxEVT_FIRST
+ 200;
98 const wxEventType wxEVT_NC_LEFT_UP
= wxEVT_FIRST
+ 201;
99 const wxEventType wxEVT_NC_MIDDLE_DOWN
= wxEVT_FIRST
+ 202;
100 const wxEventType wxEVT_NC_MIDDLE_UP
= wxEVT_FIRST
+ 203;
101 const wxEventType wxEVT_NC_RIGHT_DOWN
= wxEVT_FIRST
+ 204;
102 const wxEventType wxEVT_NC_RIGHT_UP
= wxEVT_FIRST
+ 205;
103 const wxEventType wxEVT_NC_MOTION
= wxEVT_FIRST
+ 206;
104 const wxEventType wxEVT_NC_ENTER_WINDOW
= wxEVT_FIRST
+ 207;
105 const wxEventType wxEVT_NC_LEAVE_WINDOW
= wxEVT_FIRST
+ 208;
106 const wxEventType wxEVT_NC_LEFT_DCLICK
= wxEVT_FIRST
+ 209;
107 const wxEventType wxEVT_NC_MIDDLE_DCLICK
= wxEVT_FIRST
+ 210;
108 const wxEventType wxEVT_NC_RIGHT_DCLICK
= wxEVT_FIRST
+ 211;
110 /* Character input event type */
111 const wxEventType wxEVT_CHAR
= wxEVT_FIRST
+ 212;
112 const wxEventType wxEVT_CHAR_HOOK
= wxEVT_FIRST
+ 213;
113 const wxEventType wxEVT_NAVIGATION_KEY
= wxEVT_FIRST
+ 214;
114 const wxEventType wxEVT_KEY_DOWN
= wxEVT_FIRST
+ 215;
115 const wxEventType wxEVT_KEY_UP
= wxEVT_FIRST
+ 216;
118 * wxScrollbar and wxSlider event identifiers
120 const wxEventType wxEVT_SCROLL_TOP
= wxEVT_FIRST
+ 300;
121 const wxEventType wxEVT_SCROLL_BOTTOM
= wxEVT_FIRST
+ 301;
122 const wxEventType wxEVT_SCROLL_LINEUP
= wxEVT_FIRST
+ 302;
123 const wxEventType wxEVT_SCROLL_LINEDOWN
= wxEVT_FIRST
+ 303;
124 const wxEventType wxEVT_SCROLL_PAGEUP
= wxEVT_FIRST
+ 304;
125 const wxEventType wxEVT_SCROLL_PAGEDOWN
= wxEVT_FIRST
+ 305;
126 const wxEventType wxEVT_SCROLL_THUMBTRACK
= wxEVT_FIRST
+ 306;
129 * Scroll events from wxWindow
131 const wxEventType wxEVT_SCROLLWIN_TOP
= wxEVT_FIRST
+ 320;
132 const wxEventType wxEVT_SCROLLWIN_BOTTOM
= wxEVT_FIRST
+ 321;
133 const wxEventType wxEVT_SCROLLWIN_LINEUP
= wxEVT_FIRST
+ 322;
134 const wxEventType wxEVT_SCROLLWIN_LINEDOWN
= wxEVT_FIRST
+ 323;
135 const wxEventType wxEVT_SCROLLWIN_PAGEUP
= wxEVT_FIRST
+ 324;
136 const wxEventType wxEVT_SCROLLWIN_PAGEDOWN
= wxEVT_FIRST
+ 325;
137 const wxEventType wxEVT_SCROLLWIN_THUMBTRACK
= wxEVT_FIRST
+ 326;
142 const wxEventType wxEVT_SIZE
= wxEVT_FIRST
+ 400;
143 const wxEventType wxEVT_MOVE
= wxEVT_FIRST
+ 401;
144 const wxEventType wxEVT_CLOSE_WINDOW
= wxEVT_FIRST
+ 402;
145 const wxEventType wxEVT_END_SESSION
= wxEVT_FIRST
+ 403;
146 const wxEventType wxEVT_QUERY_END_SESSION
= wxEVT_FIRST
+ 404;
147 const wxEventType wxEVT_ACTIVATE_APP
= wxEVT_FIRST
+ 405;
148 const wxEventType wxEVT_POWER
= wxEVT_FIRST
+ 406;
149 const wxEventType wxEVT_ACTIVATE
= wxEVT_FIRST
+ 409;
150 const wxEventType wxEVT_CREATE
= wxEVT_FIRST
+ 410;
151 const wxEventType wxEVT_DESTROY
= wxEVT_FIRST
+ 411;
152 const wxEventType wxEVT_SHOW
= wxEVT_FIRST
+ 412;
153 const wxEventType wxEVT_ICONIZE
= wxEVT_FIRST
+ 413;
154 const wxEventType wxEVT_MAXIMIZE
= wxEVT_FIRST
+ 414;
155 const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED
= wxEVT_FIRST
+ 415;
156 const wxEventType wxEVT_PAINT
= wxEVT_FIRST
+ 416;
157 const wxEventType wxEVT_ERASE_BACKGROUND
= wxEVT_FIRST
+ 417;
158 const wxEventType wxEVT_NC_PAINT
= wxEVT_FIRST
+ 418;
159 const wxEventType wxEVT_PAINT_ICON
= wxEVT_FIRST
+ 419;
160 const wxEventType wxEVT_MENU_CHAR
= wxEVT_FIRST
+ 420;
161 const wxEventType wxEVT_MENU_INIT
= wxEVT_FIRST
+ 421;
162 const wxEventType wxEVT_MENU_HIGHLIGHT
= wxEVT_FIRST
+ 422;
163 const wxEventType wxEVT_POPUP_MENU_INIT
= wxEVT_FIRST
+ 423;
164 const wxEventType wxEVT_CONTEXT_MENU
= wxEVT_FIRST
+ 424;
165 const wxEventType wxEVT_SYS_COLOUR_CHANGED
= wxEVT_FIRST
+ 425;
166 const wxEventType wxEVT_SETTING_CHANGED
= wxEVT_FIRST
+ 426;
167 const wxEventType wxEVT_QUERY_NEW_PALETTE
= wxEVT_FIRST
+ 427;
168 const wxEventType wxEVT_PALETTE_CHANGED
= wxEVT_FIRST
+ 428;
169 const wxEventType wxEVT_JOY_BUTTON_DOWN
= wxEVT_FIRST
+ 429;
170 const wxEventType wxEVT_JOY_BUTTON_UP
= wxEVT_FIRST
+ 430;
171 const wxEventType wxEVT_JOY_MOVE
= wxEVT_FIRST
+ 431;
172 const wxEventType wxEVT_JOY_ZMOVE
= wxEVT_FIRST
+ 432;
173 const wxEventType wxEVT_DROP_FILES
= wxEVT_FIRST
+ 433;
174 const wxEventType wxEVT_DRAW_ITEM
= wxEVT_FIRST
+ 434;
175 const wxEventType wxEVT_MEASURE_ITEM
= wxEVT_FIRST
+ 435;
176 const wxEventType wxEVT_COMPARE_ITEM
= wxEVT_FIRST
+ 436;
177 const wxEventType wxEVT_INIT_DIALOG
= wxEVT_FIRST
+ 437;
178 const wxEventType wxEVT_IDLE
= wxEVT_FIRST
+ 438;
179 const wxEventType wxEVT_UPDATE_UI
= wxEVT_FIRST
+ 439;
182 const wxEventType wxEVT_END_PROCESS
= wxEVT_FIRST
+ 440;
185 const wxEventType wxEVT_DIALUP_CONNECTED
= wxEVT_FIRST
+ 450;
186 const wxEventType wxEVT_DIALUP_DISCONNECTED
= wxEVT_FIRST
+ 451;
188 /* Generic command events */
189 /* Note: a click is a higher-level event than button down/up */
190 const wxEventType wxEVT_COMMAND_LEFT_CLICK
= wxEVT_FIRST
+ 500;
191 const wxEventType wxEVT_COMMAND_LEFT_DCLICK
= wxEVT_FIRST
+ 501;
192 const wxEventType wxEVT_COMMAND_RIGHT_CLICK
= wxEVT_FIRST
+ 502;
193 const wxEventType wxEVT_COMMAND_RIGHT_DCLICK
= wxEVT_FIRST
+ 503;
194 const wxEventType wxEVT_COMMAND_SET_FOCUS
= wxEVT_FIRST
+ 504;
195 const wxEventType wxEVT_COMMAND_KILL_FOCUS
= wxEVT_FIRST
+ 505;
196 const wxEventType wxEVT_COMMAND_ENTER
= wxEVT_FIRST
+ 506;
198 /* Tree control event types */
199 const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG
= wxEVT_FIRST
+ 600;
200 const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG
= wxEVT_FIRST
+ 601;
201 const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
= wxEVT_FIRST
+ 602;
202 const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT
= wxEVT_FIRST
+ 603;
203 const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM
= wxEVT_FIRST
+ 604;
204 const wxEventType wxEVT_COMMAND_TREE_GET_INFO
= wxEVT_FIRST
+ 605;
205 const wxEventType wxEVT_COMMAND_TREE_SET_INFO
= wxEVT_FIRST
+ 606;
206 const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED
= wxEVT_FIRST
+ 607;
207 const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING
= wxEVT_FIRST
+ 608;
208 const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED
= wxEVT_FIRST
+ 609;
209 const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING
= wxEVT_FIRST
+ 610;
210 const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED
= wxEVT_FIRST
+ 611;
211 const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING
= wxEVT_FIRST
+ 612;
212 const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN
= wxEVT_FIRST
+ 613;
213 const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED
= wxEVT_FIRST
+ 614;
214 const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK
= wxEVT_FIRST
+ 615;
215 const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK
= wxEVT_FIRST
+ 616;
217 /* List control event types */
218 const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG
= wxEVT_FIRST
+ 700;
219 const wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG
= wxEVT_FIRST
+ 701;
220 const wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
= wxEVT_FIRST
+ 702;
221 const wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT
= wxEVT_FIRST
+ 703;
222 const wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM
= wxEVT_FIRST
+ 704;
223 const wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
= wxEVT_FIRST
+ 705;
224 const wxEventType wxEVT_COMMAND_LIST_GET_INFO
= wxEVT_FIRST
+ 706;
225 const wxEventType wxEVT_COMMAND_LIST_SET_INFO
= wxEVT_FIRST
+ 707;
226 const wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED
= wxEVT_FIRST
+ 708;
227 const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED
= wxEVT_FIRST
+ 709;
228 const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN
= wxEVT_FIRST
+ 710;
229 const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM
= wxEVT_FIRST
+ 711;
230 const wxEventType wxEVT_COMMAND_LIST_COL_CLICK
= wxEVT_FIRST
+ 712;
231 const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
= wxEVT_FIRST
+ 713;
232 const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
= wxEVT_FIRST
+ 714;
233 const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED
= wxEVT_FIRST
+ 715;
235 /* Tab and notebook control event types */
236 const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED
= wxEVT_FIRST
+ 800;
237 const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING
= wxEVT_FIRST
+ 801;
238 const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
= wxEVT_FIRST
+ 802;
239 const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
= wxEVT_FIRST
+ 803;
241 /* Splitter events */
242 const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
= wxEVT_FIRST
+ 850;
243 const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
= wxEVT_FIRST
+ 851;
244 const wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
= wxEVT_FIRST
+ 852;
245 const wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT
= wxEVT_FIRST
+ 853;
248 const wxEventType wxEVT_WIZARD_PAGE_CHANGED
= wxEVT_FIRST
+ 900;
249 const wxEventType wxEVT_WIZARD_PAGE_CHANGING
= wxEVT_FIRST
+ 901;
250 const wxEventType wxEVT_WIZARD_CANCEL
= wxEVT_FIRST
+ 902;
252 /* Calendar events */
253 const wxEventType wxEVT_CALENDAR_SEL_CHANGED
= wxEVT_FIRST
+ 950;
254 const wxEventType wxEVT_CALENDAR_DAY_CHANGED
= wxEVT_FIRST
+ 951;
255 const wxEventType wxEVT_CALENDAR_MONTH_CHANGED
= wxEVT_FIRST
+ 952;
256 const wxEventType wxEVT_CALENDAR_YEAR_CHANGED
= wxEVT_FIRST
+ 953;
257 const wxEventType wxEVT_CALENDAR_DOUBLECLICKED
= wxEVT_FIRST
+ 954;
258 const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED
= wxEVT_FIRST
+ 955;
260 const wxEventType wxEVT_USER_FIRST
= wxEVT_FIRST
+ 2000;
263 // ----------------------------------------------------------------------------
265 // ----------------------------------------------------------------------------
267 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler
, wxObject
)
268 IMPLEMENT_ABSTRACT_CLASS(wxEvent
, wxObject
)
269 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent
, wxEvent
)
272 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent
, wxEvent
)
273 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent
, wxCommandEvent
)
274 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent
, wxCommandEvent
)
275 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent
, wxEvent
)
276 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent
, wxEvent
)
277 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent
, wxEvent
)
278 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent
, wxEvent
)
279 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent
, wxEvent
)
280 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent
, wxEvent
)
281 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent
, wxEvent
)
282 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent
, wxEvent
)
283 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent
, wxEvent
)
284 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent
, wxEvent
)
285 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent
, wxEvent
)
286 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent
, wxEvent
)
287 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent
, wxEvent
)
288 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent
, wxEvent
)
289 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent
, wxEvent
)
290 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent
, wxEvent
)
291 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent
, wxEvent
)
292 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent
, wxEvent
)
293 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent
, wxCommandEvent
)
294 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent
, wxCommandEvent
)
295 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent
, wxEvent
)
296 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent
, wxEvent
)
297 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent
, wxEvent
)
298 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent
, wxEvent
)
301 const wxEventTable
*wxEvtHandler::GetEventTable() const
302 { return &wxEvtHandler::sm_eventTable
; }
304 const wxEventTable
wxEvtHandler::sm_eventTable
=
305 { (const wxEventTable
*)NULL
, &wxEvtHandler::sm_eventTableEntries
[0] };
307 const wxEventTableEntry
wxEvtHandler::sm_eventTableEntries
[] =
308 { { 0, 0, 0, (wxObjectEventFunction
) NULL
, (wxObject
*) NULL
} };
311 // ----------------------------------------------------------------------------
313 // ----------------------------------------------------------------------------
315 // To put pending event handlers
316 wxList
*wxPendingEvents
= (wxList
*)NULL
;
319 // protects wxPendingEvents list
320 wxCriticalSection
*wxPendingEventsLocker
= (wxCriticalSection
*)NULL
;
323 // ============================================================================
325 // ============================================================================
327 // ----------------------------------------------------------------------------
329 // ----------------------------------------------------------------------------
332 * General wxWindows events, covering
333 * all interesting things that might happen (button clicking, resizing,
334 * setting text in widgets, etc.).
336 * For each completely new event type, derive a new event class.
340 wxEvent::wxEvent(int theId
)
342 m_eventType
= wxEVT_NULL
;
343 m_eventObject
= (wxObject
*) NULL
;
347 m_callbackUserData
= (wxObject
*) NULL
;
348 m_isCommandEvent
= FALSE
;
351 void wxEvent::CopyObject(wxObject
& object_dest
) const
353 wxEvent
*obj
= (wxEvent
*)&object_dest
;
354 wxObject::CopyObject(object_dest
);
356 obj
->m_eventType
= m_eventType
;
357 obj
->m_eventObject
= m_eventObject
;
358 obj
->m_timeStamp
= m_timeStamp
;
360 obj
->m_skipped
= m_skipped
;
361 obj
->m_callbackUserData
= m_callbackUserData
;
362 obj
->m_isCommandEvent
= m_isCommandEvent
;
372 wxCommandEvent::wxCommandEvent(wxEventType commandType
, int theId
)
374 m_eventType
= commandType
;
375 m_clientData
= (char *) NULL
;
376 m_clientObject
= (wxClientData
*) NULL
;
380 m_commandString
= wxEmptyString
;
381 m_isCommandEvent
= TRUE
;
384 void wxCommandEvent::CopyObject(wxObject
& obj_d
) const
386 wxCommandEvent
*obj
= (wxCommandEvent
*)&obj_d
;
388 wxEvent::CopyObject(obj_d
);
390 obj
->m_clientData
= m_clientData
;
391 obj
->m_clientObject
= m_clientObject
;
392 obj
->m_extraLong
= m_extraLong
;
393 obj
->m_commandInt
= m_commandInt
;
394 obj
->m_commandString
= m_commandString
;
401 void wxNotifyEvent::CopyObject(wxObject
& obj_d
) const
403 wxNotifyEvent
*obj
= (wxNotifyEvent
*)&obj_d
;
405 wxEvent::CopyObject(obj_d
);
407 if (!m_bAllow
) obj
->Veto();
414 wxScrollEvent::wxScrollEvent(wxEventType commandType
,
418 : wxCommandEvent(commandType
, id
)
420 m_extraLong
= orient
;
422 m_isScrolling
= TRUE
;
425 void wxScrollEvent::CopyObject(wxObject
& obj_d
) const
427 wxScrollEvent
*obj
= (wxScrollEvent
*)&obj_d
;
429 wxCommandEvent::CopyObject(obj_d
);
431 obj
->m_isScrolling
= m_isScrolling
;
438 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType
,
442 m_eventType
= commandType
;
443 m_extraLong
= orient
;
445 m_isScrolling
= TRUE
;
448 void wxScrollWinEvent::CopyObject(wxObject
& obj_d
) const
450 wxScrollWinEvent
*obj
= (wxScrollWinEvent
*)&obj_d
;
452 wxEvent::CopyObject(obj_d
);
454 obj
->m_extraLong
= m_extraLong
;
455 obj
->m_commandInt
= m_commandInt
;
456 obj
->m_isScrolling
= m_isScrolling
;
464 wxMouseEvent::wxMouseEvent(wxEventType commandType
)
466 m_eventType
= commandType
;
469 m_controlDown
= FALSE
;
473 m_middleDown
= FALSE
;
478 void wxMouseEvent::CopyObject(wxObject
& obj_d
) const
480 wxMouseEvent
*obj
= (wxMouseEvent
*)&obj_d
;
482 wxEvent::CopyObject(obj_d
);
484 obj
->m_metaDown
= m_metaDown
;
485 obj
->m_altDown
= m_altDown
;
486 obj
->m_controlDown
= m_controlDown
;
487 obj
->m_shiftDown
= m_shiftDown
;
488 obj
->m_leftDown
= m_leftDown
;
489 obj
->m_rightDown
= m_rightDown
;
490 obj
->m_middleDown
= m_middleDown
;
495 // True if was a button dclick event (1 = left, 2 = middle, 3 = right)
496 // or any button dclick event (but = -1)
497 bool wxMouseEvent::ButtonDClick(int but
) const
502 return (LeftDClick() || MiddleDClick() || RightDClick());
506 return MiddleDClick();
508 return RightDClick();
510 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
516 // True if was a button down event (1 = left, 2 = middle, 3 = right)
517 // or any button down event (but = -1)
518 bool wxMouseEvent::ButtonDown(int but
) const
523 return (LeftDown() || MiddleDown() || RightDown());
531 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
537 // True if was a button up event (1 = left, 2 = middle, 3 = right)
538 // or any button up event (but = -1)
539 bool wxMouseEvent::ButtonUp(int but
) const
543 return (LeftUp() || MiddleUp() || RightUp());
551 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
557 // True if the given button is currently changing state
558 bool wxMouseEvent::Button(int but
) const
562 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
564 return (LeftDown() || LeftUp() || LeftDClick());
566 return (MiddleDown() || MiddleUp() || MiddleDClick());
568 return (RightDown() || RightUp() || RightDClick());
570 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
576 bool wxMouseEvent::ButtonIsDown(int but
) const
580 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
584 return MiddleIsDown();
586 return RightIsDown();
588 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
594 // Find the logical position of the event given the DC
595 wxPoint
wxMouseEvent::GetLogicalPosition(const wxDC
& dc
) const
597 wxPoint
pt(dc
.DeviceToLogicalX(m_x
), dc
.DeviceToLogicalY(m_y
));
607 wxKeyEvent::wxKeyEvent(wxEventType type
)
611 m_controlDown
= FALSE
;
618 void wxKeyEvent::CopyObject(wxObject
& obj_d
) const
620 wxKeyEvent
*obj
= (wxKeyEvent
*)&obj_d
;
621 wxEvent::CopyObject(obj_d
);
625 obj
->m_keyCode
= m_keyCode
;
627 obj
->m_shiftDown
= m_shiftDown
;
628 obj
->m_controlDown
= m_controlDown
;
629 obj
->m_metaDown
= m_metaDown
;
630 obj
->m_altDown
= m_altDown
;
631 obj
->m_keyCode
= m_keyCode
;
639 void wxSizeEvent::CopyObject(wxObject
& obj_d
) const
641 wxSizeEvent
*obj
= (wxSizeEvent
*)&obj_d
;
642 wxEvent::CopyObject(obj_d
);
644 obj
->m_size
= m_size
;
647 void wxMoveEvent::CopyObject(wxObject
& obj_d
) const
649 wxMoveEvent
*obj
= (wxMoveEvent
*)&obj_d
;
650 wxEvent::CopyObject(obj_d
);
655 void wxEraseEvent::CopyObject(wxObject
& obj_d
) const
657 wxEraseEvent
*obj
= (wxEraseEvent
*)&obj_d
;
658 wxEvent::CopyObject(obj_d
);
663 void wxActivateEvent::CopyObject(wxObject
& obj_d
) const
665 wxActivateEvent
*obj
= (wxActivateEvent
*)&obj_d
;
666 wxEvent::CopyObject(obj_d
);
668 obj
->m_active
= m_active
;
671 void wxMenuEvent::CopyObject(wxObject
& obj_d
) const
673 wxMenuEvent
*obj
= (wxMenuEvent
*)&obj_d
;
674 wxEvent::CopyObject(obj_d
);
676 obj
->m_menuId
= m_menuId
;
679 void wxCloseEvent::CopyObject(wxObject
& obj_d
) const
681 wxCloseEvent
*obj
= (wxCloseEvent
*)&obj_d
;
682 wxEvent::CopyObject(obj_d
);
684 obj
->m_loggingOff
= m_loggingOff
;
685 obj
->m_veto
= m_veto
;
686 #if WXWIN_COMPATIBILITY
687 obj
->m_force
= m_force
;
689 obj
->m_canVeto
= m_canVeto
;
692 void wxShowEvent::CopyObject(wxObject
& obj_d
) const
694 wxShowEvent
*obj
= (wxShowEvent
*)&obj_d
;
695 wxEvent::CopyObject(obj_d
);
697 obj
->m_show
= m_show
;
700 void wxJoystickEvent::CopyObject(wxObject
& obj_d
) const
702 wxJoystickEvent
*obj
= (wxJoystickEvent
*)&obj_d
;
703 wxEvent::CopyObject(obj_d
);
706 obj
->m_zPosition
= m_zPosition
;
707 obj
->m_buttonChange
= m_buttonChange
;
708 obj
->m_buttonState
= m_buttonState
;
709 obj
->m_joyStick
= m_joyStick
;
712 void wxDropFilesEvent::CopyObject(wxObject
& obj_d
) const
714 wxDropFilesEvent
*obj
= (wxDropFilesEvent
*)&obj_d
;
715 wxEvent::CopyObject(obj_d
);
717 obj
->m_noFiles
= m_noFiles
;
719 // TODO: Problem with obj->m_files. It should be deallocated by the
720 // destructor of the event.
723 void wxUpdateUIEvent::CopyObject(wxObject
&obj_d
) const
725 wxUpdateUIEvent
*obj
= (wxUpdateUIEvent
*)&obj_d
;
726 wxEvent::CopyObject(obj_d
);
728 obj
->m_checked
= m_checked
;
729 obj
->m_enabled
= m_enabled
;
730 obj
->m_text
= m_text
;
731 obj
->m_setText
= m_setText
;
732 obj
->m_setChecked
= m_setChecked
;
733 obj
->m_setEnabled
= m_setEnabled
;
736 void wxPaletteChangedEvent::CopyObject(wxObject
&obj_d
) const
738 wxPaletteChangedEvent
*obj
= (wxPaletteChangedEvent
*)&obj_d
;
739 wxEvent::CopyObject(obj_d
);
741 obj
->m_changedWindow
= m_changedWindow
;
744 void wxQueryNewPaletteEvent::CopyObject(wxObject
& obj_d
) const
746 wxQueryNewPaletteEvent
*obj
= (wxQueryNewPaletteEvent
*)&obj_d
;
747 wxEvent::CopyObject(obj_d
);
749 obj
->m_paletteRealized
= m_paletteRealized
;
752 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow
*win
)
755 SetEventType(wxEVT_CREATE
);
759 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow
*win
)
762 SetEventType(wxEVT_DESTROY
);
768 void wxIdleEvent::CopyObject(wxObject
& obj_d
) const
770 wxIdleEvent
*obj
= (wxIdleEvent
*)&obj_d
;
771 wxEvent::CopyObject(obj_d
);
773 obj
->m_requestMore
= m_requestMore
;
780 wxEvtHandler::wxEvtHandler()
782 m_nextHandler
= (wxEvtHandler
*) NULL
;
783 m_previousHandler
= (wxEvtHandler
*) NULL
;
785 m_dynamicEvents
= (wxList
*) NULL
;
787 m_pendingEvents
= (wxList
*) NULL
;
789 # if !defined(__VISAGECPP__)
790 m_eventsLocker
= new wxCriticalSection
;
795 wxEvtHandler::~wxEvtHandler()
797 // Takes itself out of the list of handlers
798 if (m_previousHandler
)
799 m_previousHandler
->m_nextHandler
= m_nextHandler
;
802 m_nextHandler
->m_previousHandler
= m_previousHandler
;
806 wxNode
*node
= m_dynamicEvents
->First();
809 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
810 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
814 delete m_dynamicEvents
;
817 delete m_pendingEvents
;
820 # if !defined(__VISAGECPP__)
821 delete m_eventsLocker
;
828 bool wxEvtHandler::ProcessThreadEvent(wxEvent
& event
)
830 // check that we are really in a child thread
831 wxASSERT_MSG( !wxThread::IsMain(),
832 wxT("use ProcessEvent() in main thread") );
834 AddPendingEvent(event
);
839 #endif // wxUSE_THREADS
841 void wxEvtHandler::AddPendingEvent(wxEvent
& event
)
843 // 1) Add event to list of pending events of this event handler
845 #if defined(__VISAGECPP__)
846 wxENTER_CRIT_SECT( m_eventsLocker
);
848 wxENTER_CRIT_SECT( *m_eventsLocker
);
851 if ( !m_pendingEvents
)
852 m_pendingEvents
= new wxList
;
854 wxEvent
*event2
= (wxEvent
*)event
.Clone();
856 m_pendingEvents
->Append(event2
);
858 #if defined(__VISAGECPP__)
859 wxLEAVE_CRIT_SECT( m_eventsLocker
);
861 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
864 // 2) Add this event handler to list of event handlers that
865 // have pending events.
867 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
869 if ( !wxPendingEvents
)
870 wxPendingEvents
= new wxList
;
871 wxPendingEvents
->Append(this);
873 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
875 // 3) Inform the system that new pending events are somwehere,
876 // and that these should be processed in idle time.
880 void wxEvtHandler::ProcessPendingEvents()
882 #if defined(__VISAGECPP__)
883 wxENTER_CRIT_SECT( m_eventsLocker
);
885 wxENTER_CRIT_SECT( *m_eventsLocker
);
888 wxNode
*node
= m_pendingEvents
->First();
891 wxEvent
*event
= (wxEvent
*)node
->Data();
894 // In ProcessEvent, new events might get added and
895 // we can safely leave the crtical section here.
896 #if defined(__VISAGECPP__)
897 wxLEAVE_CRIT_SECT( m_eventsLocker
);
899 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
901 ProcessEvent(*event
);
903 #if defined(__VISAGECPP__)
904 wxENTER_CRIT_SECT( m_eventsLocker
);
906 wxENTER_CRIT_SECT( *m_eventsLocker
);
909 node
= m_pendingEvents
->First();
912 #if defined(__VISAGECPP__)
913 wxLEAVE_CRIT_SECT( m_eventsLocker
);
915 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
923 bool wxEvtHandler::ProcessEvent(wxEvent
& event
)
926 // check that our flag corresponds to reality
927 wxASSERT( m_isWindow
== IsKindOf(CLASSINFO(wxWindow
)) );
930 // An event handler can be enabled or disabled
931 if ( GetEvtHandlerEnabled() )
936 What is this? When using GUI threads, a non main
937 threads can send an event and process it itself.
938 This breaks GTK's GUI threads, so please explain.
941 // Check whether we are in a child thread.
942 if ( !wxThread::IsMain() )
943 return ProcessThreadEvent(event
);
946 // Handle per-instance dynamic event tables first
947 if ( m_dynamicEvents
&& SearchDynamicEventTable(event
) )
950 // Then static per-class event tables
951 const wxEventTable
*table
= GetEventTable();
953 #if wxUSE_GUI && wxUSE_VALIDATORS
954 // Try the associated validator first, if this is a window.
955 // Problem: if the event handler of the window has been replaced,
956 // this wxEvtHandler may no longer be a window.
957 // Therefore validators won't be processed if the handler
958 // has been replaced with SetEventHandler.
959 // THIS CAN BE CURED if PushEventHandler is used instead of
960 // SetEventHandler, and then processing will be passed down the
961 // chain of event handlers.
964 wxWindow
*win
= (wxWindow
*)this;
966 // Can only use the validator of the window which
967 // is receiving the event
968 if ( win
== event
.GetEventObject() )
970 wxValidator
*validator
= win
->GetValidator();
971 if ( validator
&& validator
->ProcessEvent(event
) )
979 // Search upwards through the inheritance hierarchy
982 if ( SearchEventTable((wxEventTable
&)*table
, event
) )
984 table
= table
->baseTable
;
988 // Try going down the event handler chain
989 if ( GetNextHandler() )
991 if ( GetNextHandler()->ProcessEvent(event
) )
996 // Carry on up the parent-child hierarchy,
997 // but only if event is a command event: it wouldn't
998 // make sense for a parent to receive a child's size event, for example
999 if ( m_isWindow
&& event
.IsCommandEvent() )
1001 wxWindow
*win
= (wxWindow
*)this;
1002 wxWindow
*parent
= win
->GetParent();
1003 if (parent
&& !parent
->IsBeingDeleted())
1004 return parent
->GetEventHandler()->ProcessEvent(event
);
1008 // Last try - application object.
1009 if ( wxTheApp
&& (this != wxTheApp
) )
1011 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
1012 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
1013 // processed appropriately via SearchEventTable.
1014 if ( event
.GetEventType() != wxEVT_IDLE
)
1016 if ( wxTheApp
->ProcessEvent(event
) )
1024 bool wxEvtHandler::SearchEventTable(wxEventTable
& table
, wxEvent
& event
)
1027 int commandId
= event
.GetId();
1029 // BC++ doesn't like while (table.entries[i].m_fn)
1032 while (table
.entries
[i
].m_fn
!= 0)
1034 while (table
.entries
[i
].m_fn
!= 0L)
1037 if ((event
.GetEventType() == table
.entries
[i
].m_eventType
) &&
1038 (table
.entries
[i
].m_id
== -1 || // Match, if event spec says any id will do (id == -1)
1039 (table
.entries
[i
].m_lastId
== -1 && commandId
== table
.entries
[i
].m_id
) ||
1040 (table
.entries
[i
].m_lastId
!= -1 &&
1041 (commandId
>= table
.entries
[i
].m_id
&& commandId
<= table
.entries
[i
].m_lastId
))))
1044 event
.m_callbackUserData
= table
.entries
[i
].m_callbackUserData
;
1046 (this->*((wxEventFunction
) (table
.entries
[i
].m_fn
)))(event
);
1048 if ( event
.GetSkipped() )
1058 void wxEvtHandler::Connect( int id
, int lastId
,
1059 wxEventType eventType
,
1060 wxObjectEventFunction func
,
1061 wxObject
*userData
)
1063 wxEventTableEntry
*entry
= new wxEventTableEntry
;
1065 entry
->m_lastId
= lastId
;
1066 entry
->m_eventType
= eventType
;
1068 entry
->m_callbackUserData
= userData
;
1070 if (!m_dynamicEvents
)
1071 m_dynamicEvents
= new wxList
;
1073 m_dynamicEvents
->Append( (wxObject
*) entry
);
1076 bool wxEvtHandler::Disconnect( int id
, int lastId
, wxEventType eventType
,
1077 wxObjectEventFunction func
,
1078 wxObject
*userData
)
1080 if (!m_dynamicEvents
)
1083 wxNode
*node
= m_dynamicEvents
->First();
1086 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
1087 if ((entry
->m_id
== id
) &&
1088 ((entry
->m_lastId
== lastId
) || (lastId
== -1)) &&
1089 ((entry
->m_eventType
== eventType
) || (eventType
== wxEVT_NULL
)) &&
1090 ((entry
->m_fn
== func
) || (func
== (wxObjectEventFunction
)NULL
)) &&
1091 ((entry
->m_callbackUserData
== userData
) || (userData
== (wxObject
*)NULL
)))
1093 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
1094 m_dynamicEvents
->DeleteNode( node
);
1098 node
= node
->Next();
1103 bool wxEvtHandler::SearchDynamicEventTable( wxEvent
& event
)
1105 wxCHECK_MSG( m_dynamicEvents
, FALSE
,
1106 wxT("caller should check that we have dynamic events") );
1108 int commandId
= event
.GetId();
1110 wxNode
*node
= m_dynamicEvents
->First();
1113 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
1117 // Match, if event spec says any id will do (id == -1)
1118 if ( (event
.GetEventType() == entry
->m_eventType
) &&
1119 (entry
->m_id
== -1 ||
1120 (entry
->m_lastId
== -1 && commandId
== entry
->m_id
) ||
1121 (entry
->m_lastId
!= -1 &&
1122 (commandId
>= entry
->m_id
&& commandId
<= entry
->m_lastId
))) )
1125 event
.m_callbackUserData
= entry
->m_callbackUserData
;
1127 (this->*((wxEventFunction
) (entry
->m_fn
)))(event
);
1129 if (event
.GetSkipped())
1135 node
= node
->Next();
1140 #if WXWIN_COMPATIBILITY
1141 bool wxEvtHandler::OnClose()
1143 if (GetNextHandler())
1144 return GetNextHandler()->OnClose();
1148 #endif // WXWIN_COMPATIBILITY
1152 // Find a window with the focus, that is also a descendant of the given window.
1153 // This is used to determine the window to initially send commands to.
1154 wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
)
1156 // Process events starting with the window with the focus, if any.
1157 wxWindow
* focusWin
= wxWindow::FindFocus();
1158 wxWindow
* win
= focusWin
;
1160 // Check if this is a descendant of this frame.
1161 // If not, win will be set to NULL.
1164 if (win
== ancestor
)
1167 win
= win
->GetParent();
1169 if (win
== (wxWindow
*) NULL
)
1170 focusWin
= (wxWindow
*) NULL
;