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;
79 /* Mouse event types */
80 const wxEventType wxEVT_LEFT_DOWN
= wxEVT_FIRST
+ 100;
81 const wxEventType wxEVT_LEFT_UP
= wxEVT_FIRST
+ 101;
82 const wxEventType wxEVT_MIDDLE_DOWN
= wxEVT_FIRST
+ 102;
83 const wxEventType wxEVT_MIDDLE_UP
= wxEVT_FIRST
+ 103;
84 const wxEventType wxEVT_RIGHT_DOWN
= wxEVT_FIRST
+ 104;
85 const wxEventType wxEVT_RIGHT_UP
= wxEVT_FIRST
+ 105;
86 const wxEventType wxEVT_MOTION
= wxEVT_FIRST
+ 106;
87 const wxEventType wxEVT_ENTER_WINDOW
= wxEVT_FIRST
+ 107;
88 const wxEventType wxEVT_LEAVE_WINDOW
= wxEVT_FIRST
+ 108;
89 const wxEventType wxEVT_LEFT_DCLICK
= wxEVT_FIRST
+ 109;
90 const wxEventType wxEVT_MIDDLE_DCLICK
= wxEVT_FIRST
+ 110;
91 const wxEventType wxEVT_RIGHT_DCLICK
= wxEVT_FIRST
+ 111;
92 const wxEventType wxEVT_SET_FOCUS
= wxEVT_FIRST
+ 112;
93 const wxEventType wxEVT_KILL_FOCUS
= wxEVT_FIRST
+ 113;
95 /* Non-client mouse events */
96 const wxEventType wxEVT_NC_LEFT_DOWN
= wxEVT_FIRST
+ 200;
97 const wxEventType wxEVT_NC_LEFT_UP
= wxEVT_FIRST
+ 201;
98 const wxEventType wxEVT_NC_MIDDLE_DOWN
= wxEVT_FIRST
+ 202;
99 const wxEventType wxEVT_NC_MIDDLE_UP
= wxEVT_FIRST
+ 203;
100 const wxEventType wxEVT_NC_RIGHT_DOWN
= wxEVT_FIRST
+ 204;
101 const wxEventType wxEVT_NC_RIGHT_UP
= wxEVT_FIRST
+ 205;
102 const wxEventType wxEVT_NC_MOTION
= wxEVT_FIRST
+ 206;
103 const wxEventType wxEVT_NC_ENTER_WINDOW
= wxEVT_FIRST
+ 207;
104 const wxEventType wxEVT_NC_LEAVE_WINDOW
= wxEVT_FIRST
+ 208;
105 const wxEventType wxEVT_NC_LEFT_DCLICK
= wxEVT_FIRST
+ 209;
106 const wxEventType wxEVT_NC_MIDDLE_DCLICK
= wxEVT_FIRST
+ 210;
107 const wxEventType wxEVT_NC_RIGHT_DCLICK
= wxEVT_FIRST
+ 211;
109 /* Character input event type */
110 const wxEventType wxEVT_CHAR
= wxEVT_FIRST
+ 212;
111 const wxEventType wxEVT_CHAR_HOOK
= wxEVT_FIRST
+ 213;
112 const wxEventType wxEVT_NAVIGATION_KEY
= wxEVT_FIRST
+ 214;
113 const wxEventType wxEVT_KEY_DOWN
= wxEVT_FIRST
+ 215;
114 const wxEventType wxEVT_KEY_UP
= wxEVT_FIRST
+ 216;
117 * wxScrollbar and wxSlider event identifiers
119 const wxEventType wxEVT_SCROLL_TOP
= wxEVT_FIRST
+ 300;
120 const wxEventType wxEVT_SCROLL_BOTTOM
= wxEVT_FIRST
+ 301;
121 const wxEventType wxEVT_SCROLL_LINEUP
= wxEVT_FIRST
+ 302;
122 const wxEventType wxEVT_SCROLL_LINEDOWN
= wxEVT_FIRST
+ 303;
123 const wxEventType wxEVT_SCROLL_PAGEUP
= wxEVT_FIRST
+ 304;
124 const wxEventType wxEVT_SCROLL_PAGEDOWN
= wxEVT_FIRST
+ 305;
125 const wxEventType wxEVT_SCROLL_THUMBTRACK
= wxEVT_FIRST
+ 306;
128 * Scroll events from wxWindow
130 const wxEventType wxEVT_SCROLLWIN_TOP
= wxEVT_FIRST
+ 320;
131 const wxEventType wxEVT_SCROLLWIN_BOTTOM
= wxEVT_FIRST
+ 321;
132 const wxEventType wxEVT_SCROLLWIN_LINEUP
= wxEVT_FIRST
+ 322;
133 const wxEventType wxEVT_SCROLLWIN_LINEDOWN
= wxEVT_FIRST
+ 323;
134 const wxEventType wxEVT_SCROLLWIN_PAGEUP
= wxEVT_FIRST
+ 324;
135 const wxEventType wxEVT_SCROLLWIN_PAGEDOWN
= wxEVT_FIRST
+ 325;
136 const wxEventType wxEVT_SCROLLWIN_THUMBTRACK
= wxEVT_FIRST
+ 326;
141 const wxEventType wxEVT_SIZE
= wxEVT_FIRST
+ 400;
142 const wxEventType wxEVT_MOVE
= wxEVT_FIRST
+ 401;
143 const wxEventType wxEVT_CLOSE_WINDOW
= wxEVT_FIRST
+ 402;
144 const wxEventType wxEVT_END_SESSION
= wxEVT_FIRST
+ 403;
145 const wxEventType wxEVT_QUERY_END_SESSION
= wxEVT_FIRST
+ 404;
146 const wxEventType wxEVT_ACTIVATE_APP
= wxEVT_FIRST
+ 405;
147 const wxEventType wxEVT_POWER
= wxEVT_FIRST
+ 406;
148 const wxEventType wxEVT_ACTIVATE
= wxEVT_FIRST
+ 409;
149 const wxEventType wxEVT_CREATE
= wxEVT_FIRST
+ 410;
150 const wxEventType wxEVT_DESTROY
= wxEVT_FIRST
+ 411;
151 const wxEventType wxEVT_SHOW
= wxEVT_FIRST
+ 412;
152 const wxEventType wxEVT_ICONIZE
= wxEVT_FIRST
+ 413;
153 const wxEventType wxEVT_MAXIMIZE
= wxEVT_FIRST
+ 414;
154 const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED
= wxEVT_FIRST
+ 415;
155 const wxEventType wxEVT_PAINT
= wxEVT_FIRST
+ 416;
156 const wxEventType wxEVT_ERASE_BACKGROUND
= wxEVT_FIRST
+ 417;
157 const wxEventType wxEVT_NC_PAINT
= wxEVT_FIRST
+ 418;
158 const wxEventType wxEVT_PAINT_ICON
= wxEVT_FIRST
+ 419;
159 const wxEventType wxEVT_MENU_CHAR
= wxEVT_FIRST
+ 420;
160 const wxEventType wxEVT_MENU_INIT
= wxEVT_FIRST
+ 421;
161 const wxEventType wxEVT_MENU_HIGHLIGHT
= wxEVT_FIRST
+ 422;
162 const wxEventType wxEVT_POPUP_MENU_INIT
= wxEVT_FIRST
+ 423;
163 const wxEventType wxEVT_CONTEXT_MENU
= wxEVT_FIRST
+ 424;
164 const wxEventType wxEVT_SYS_COLOUR_CHANGED
= wxEVT_FIRST
+ 425;
165 const wxEventType wxEVT_SETTING_CHANGED
= wxEVT_FIRST
+ 426;
166 const wxEventType wxEVT_QUERY_NEW_PALETTE
= wxEVT_FIRST
+ 427;
167 const wxEventType wxEVT_PALETTE_CHANGED
= wxEVT_FIRST
+ 428;
168 const wxEventType wxEVT_JOY_BUTTON_DOWN
= wxEVT_FIRST
+ 429;
169 const wxEventType wxEVT_JOY_BUTTON_UP
= wxEVT_FIRST
+ 430;
170 const wxEventType wxEVT_JOY_MOVE
= wxEVT_FIRST
+ 431;
171 const wxEventType wxEVT_JOY_ZMOVE
= wxEVT_FIRST
+ 432;
172 const wxEventType wxEVT_DROP_FILES
= wxEVT_FIRST
+ 433;
173 const wxEventType wxEVT_DRAW_ITEM
= wxEVT_FIRST
+ 434;
174 const wxEventType wxEVT_MEASURE_ITEM
= wxEVT_FIRST
+ 435;
175 const wxEventType wxEVT_COMPARE_ITEM
= wxEVT_FIRST
+ 436;
176 const wxEventType wxEVT_INIT_DIALOG
= wxEVT_FIRST
+ 437;
177 const wxEventType wxEVT_IDLE
= wxEVT_FIRST
+ 438;
178 const wxEventType wxEVT_UPDATE_UI
= wxEVT_FIRST
+ 439;
181 const wxEventType wxEVT_END_PROCESS
= wxEVT_FIRST
+ 440;
184 const wxEventType wxEVT_DIALUP_CONNECTED
= wxEVT_FIRST
+ 450;
185 const wxEventType wxEVT_DIALUP_DISCONNECTED
= wxEVT_FIRST
+ 451;
187 /* Generic command events */
188 /* Note: a click is a higher-level event than button down/up */
189 const wxEventType wxEVT_COMMAND_LEFT_CLICK
= wxEVT_FIRST
+ 500;
190 const wxEventType wxEVT_COMMAND_LEFT_DCLICK
= wxEVT_FIRST
+ 501;
191 const wxEventType wxEVT_COMMAND_RIGHT_CLICK
= wxEVT_FIRST
+ 502;
192 const wxEventType wxEVT_COMMAND_RIGHT_DCLICK
= wxEVT_FIRST
+ 503;
193 const wxEventType wxEVT_COMMAND_SET_FOCUS
= wxEVT_FIRST
+ 504;
194 const wxEventType wxEVT_COMMAND_KILL_FOCUS
= wxEVT_FIRST
+ 505;
195 const wxEventType wxEVT_COMMAND_ENTER
= wxEVT_FIRST
+ 506;
197 /* Tree control event types */
198 const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG
= wxEVT_FIRST
+ 600;
199 const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG
= wxEVT_FIRST
+ 601;
200 const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
= wxEVT_FIRST
+ 602;
201 const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT
= wxEVT_FIRST
+ 603;
202 const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM
= wxEVT_FIRST
+ 604;
203 const wxEventType wxEVT_COMMAND_TREE_GET_INFO
= wxEVT_FIRST
+ 605;
204 const wxEventType wxEVT_COMMAND_TREE_SET_INFO
= wxEVT_FIRST
+ 606;
205 const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED
= wxEVT_FIRST
+ 607;
206 const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING
= wxEVT_FIRST
+ 608;
207 const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED
= wxEVT_FIRST
+ 609;
208 const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING
= wxEVT_FIRST
+ 610;
209 const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED
= wxEVT_FIRST
+ 611;
210 const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING
= wxEVT_FIRST
+ 612;
211 const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN
= wxEVT_FIRST
+ 613;
212 const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED
= wxEVT_FIRST
+ 614;
213 const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK
= wxEVT_FIRST
+ 615;
214 const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK
= wxEVT_FIRST
+ 616;
216 /* List control event types */
217 const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG
= wxEVT_FIRST
+ 700;
218 const wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG
= wxEVT_FIRST
+ 701;
219 const wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
= wxEVT_FIRST
+ 702;
220 const wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT
= wxEVT_FIRST
+ 703;
221 const wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM
= wxEVT_FIRST
+ 704;
222 const wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
= wxEVT_FIRST
+ 705;
223 const wxEventType wxEVT_COMMAND_LIST_GET_INFO
= wxEVT_FIRST
+ 706;
224 const wxEventType wxEVT_COMMAND_LIST_SET_INFO
= wxEVT_FIRST
+ 707;
225 const wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED
= wxEVT_FIRST
+ 708;
226 const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED
= wxEVT_FIRST
+ 709;
227 const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN
= wxEVT_FIRST
+ 710;
228 const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM
= wxEVT_FIRST
+ 711;
229 const wxEventType wxEVT_COMMAND_LIST_COL_CLICK
= wxEVT_FIRST
+ 712;
230 const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
= wxEVT_FIRST
+ 713;
231 const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
= wxEVT_FIRST
+ 714;
232 const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED
= wxEVT_FIRST
+ 715;
234 /* Tab and notebook control event types */
235 const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED
= wxEVT_FIRST
+ 800;
236 const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING
= wxEVT_FIRST
+ 801;
237 const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
= wxEVT_FIRST
+ 802;
238 const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
= wxEVT_FIRST
+ 803;
240 /* Splitter events */
241 const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
= wxEVT_FIRST
+ 850;
242 const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
= wxEVT_FIRST
+ 851;
243 const wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
= wxEVT_FIRST
+ 852;
244 const wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT
= wxEVT_FIRST
+ 853;
247 const wxEventType wxEVT_WIZARD_PAGE_CHANGED
= wxEVT_FIRST
+ 900;
248 const wxEventType wxEVT_WIZARD_PAGE_CHANGING
= wxEVT_FIRST
+ 901;
249 const wxEventType wxEVT_WIZARD_CANCEL
= wxEVT_FIRST
+ 902;
251 /* Calendar events */
252 const wxEventType wxEVT_CALENDAR_SEL_CHANGED
= wxEVT_FIRST
+ 950;
253 const wxEventType wxEVT_CALENDAR_DAY_CHANGED
= wxEVT_FIRST
+ 951;
254 const wxEventType wxEVT_CALENDAR_MONTH_CHANGED
= wxEVT_FIRST
+ 952;
255 const wxEventType wxEVT_CALENDAR_YEAR_CHANGED
= wxEVT_FIRST
+ 953;
256 const wxEventType wxEVT_CALENDAR_DOUBLECLICKED
= wxEVT_FIRST
+ 954;
257 const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED
= wxEVT_FIRST
+ 955;
259 const wxEventType wxEVT_USER_FIRST
= wxEVT_FIRST
+ 2000;
262 // ----------------------------------------------------------------------------
264 // ----------------------------------------------------------------------------
266 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler
, wxObject
)
267 IMPLEMENT_ABSTRACT_CLASS(wxEvent
, wxObject
)
268 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent
, wxEvent
)
271 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent
, wxEvent
)
272 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent
, wxCommandEvent
)
273 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent
, wxCommandEvent
)
274 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent
, wxEvent
)
275 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent
, wxEvent
)
276 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent
, wxEvent
)
277 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent
, wxEvent
)
278 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent
, wxEvent
)
279 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent
, wxEvent
)
280 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent
, wxEvent
)
281 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent
, wxEvent
)
282 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent
, wxEvent
)
283 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent
, wxEvent
)
284 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent
, wxEvent
)
285 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent
, wxEvent
)
286 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent
, wxEvent
)
287 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent
, wxEvent
)
288 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent
, wxEvent
)
289 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent
, wxEvent
)
290 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent
, wxEvent
)
291 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent
, wxEvent
)
292 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent
, wxCommandEvent
)
293 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent
, wxCommandEvent
)
294 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent
, wxEvent
)
295 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent
, wxEvent
)
296 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent
, wxEvent
)
297 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent
, wxEvent
)
300 const wxEventTable
*wxEvtHandler::GetEventTable() const
301 { return &wxEvtHandler::sm_eventTable
; }
303 const wxEventTable
wxEvtHandler::sm_eventTable
=
304 { (const wxEventTable
*)NULL
, &wxEvtHandler::sm_eventTableEntries
[0] };
306 const wxEventTableEntry
wxEvtHandler::sm_eventTableEntries
[] =
307 { { 0, 0, 0, (wxObjectEventFunction
) NULL
, (wxObject
*) NULL
} };
310 // ----------------------------------------------------------------------------
312 // ----------------------------------------------------------------------------
314 // To put pending event handlers
315 wxList
*wxPendingEvents
= (wxList
*)NULL
;
318 // protects wxPendingEvents list
319 wxCriticalSection
*wxPendingEventsLocker
= (wxCriticalSection
*)NULL
;
322 // ============================================================================
324 // ============================================================================
326 // ----------------------------------------------------------------------------
328 // ----------------------------------------------------------------------------
331 * General wxWindows events, covering
332 * all interesting things that might happen (button clicking, resizing,
333 * setting text in widgets, etc.).
335 * For each completely new event type, derive a new event class.
339 wxEvent::wxEvent(int theId
)
341 m_eventType
= wxEVT_NULL
;
342 m_eventObject
= (wxObject
*) NULL
;
346 m_callbackUserData
= (wxObject
*) NULL
;
347 m_isCommandEvent
= FALSE
;
350 void wxEvent::CopyObject(wxObject
& object_dest
) const
352 wxEvent
*obj
= (wxEvent
*)&object_dest
;
353 wxObject::CopyObject(object_dest
);
355 obj
->m_eventType
= m_eventType
;
356 obj
->m_eventObject
= m_eventObject
;
357 obj
->m_timeStamp
= m_timeStamp
;
359 obj
->m_skipped
= m_skipped
;
360 obj
->m_callbackUserData
= m_callbackUserData
;
361 obj
->m_isCommandEvent
= m_isCommandEvent
;
371 wxCommandEvent::wxCommandEvent(wxEventType commandType
, int theId
)
373 m_eventType
= commandType
;
374 m_clientData
= (char *) NULL
;
375 m_clientObject
= (wxClientData
*) NULL
;
379 m_commandString
= wxEmptyString
;
380 m_isCommandEvent
= TRUE
;
383 void wxCommandEvent::CopyObject(wxObject
& obj_d
) const
385 wxCommandEvent
*obj
= (wxCommandEvent
*)&obj_d
;
387 wxEvent::CopyObject(obj_d
);
389 obj
->m_clientData
= m_clientData
;
390 obj
->m_clientObject
= m_clientObject
;
391 obj
->m_extraLong
= m_extraLong
;
392 obj
->m_commandInt
= m_commandInt
;
393 obj
->m_commandString
= m_commandString
;
400 void wxNotifyEvent::CopyObject(wxObject
& obj_d
) const
402 wxNotifyEvent
*obj
= (wxNotifyEvent
*)&obj_d
;
404 wxEvent::CopyObject(obj_d
);
406 if (!m_bAllow
) obj
->Veto();
413 wxScrollEvent::wxScrollEvent(wxEventType commandType
,
417 : wxCommandEvent(commandType
, id
)
419 m_extraLong
= orient
;
421 m_isScrolling
= TRUE
;
424 void wxScrollEvent::CopyObject(wxObject
& obj_d
) const
426 wxScrollEvent
*obj
= (wxScrollEvent
*)&obj_d
;
428 wxCommandEvent::CopyObject(obj_d
);
430 obj
->m_isScrolling
= m_isScrolling
;
437 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType
,
441 m_eventType
= commandType
;
442 m_extraLong
= orient
;
444 m_isScrolling
= TRUE
;
447 void wxScrollWinEvent::CopyObject(wxObject
& obj_d
) const
449 wxScrollWinEvent
*obj
= (wxScrollWinEvent
*)&obj_d
;
451 wxEvent::CopyObject(obj_d
);
453 obj
->m_extraLong
= m_extraLong
;
454 obj
->m_commandInt
= m_commandInt
;
455 obj
->m_isScrolling
= m_isScrolling
;
463 wxMouseEvent::wxMouseEvent(wxEventType commandType
)
465 m_eventType
= commandType
;
468 m_controlDown
= FALSE
;
472 m_middleDown
= FALSE
;
477 void wxMouseEvent::CopyObject(wxObject
& obj_d
) const
479 wxMouseEvent
*obj
= (wxMouseEvent
*)&obj_d
;
481 wxEvent::CopyObject(obj_d
);
483 obj
->m_metaDown
= m_metaDown
;
484 obj
->m_altDown
= m_altDown
;
485 obj
->m_controlDown
= m_controlDown
;
486 obj
->m_shiftDown
= m_shiftDown
;
487 obj
->m_leftDown
= m_leftDown
;
488 obj
->m_rightDown
= m_rightDown
;
489 obj
->m_middleDown
= m_middleDown
;
494 // True if was a button dclick event (1 = left, 2 = middle, 3 = right)
495 // or any button dclick event (but = -1)
496 bool wxMouseEvent::ButtonDClick(int but
) const
501 return (LeftDClick() || MiddleDClick() || RightDClick());
505 return MiddleDClick();
507 return RightDClick();
509 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
515 // True if was a button down event (1 = left, 2 = middle, 3 = right)
516 // or any button down event (but = -1)
517 bool wxMouseEvent::ButtonDown(int but
) const
522 return (LeftDown() || MiddleDown() || RightDown());
530 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
536 // True if was a button up event (1 = left, 2 = middle, 3 = right)
537 // or any button up event (but = -1)
538 bool wxMouseEvent::ButtonUp(int but
) const
542 return (LeftUp() || MiddleUp() || RightUp());
550 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
556 // True if the given button is currently changing state
557 bool wxMouseEvent::Button(int but
) const
561 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
563 return (LeftDown() || LeftUp() || LeftDClick());
565 return (MiddleDown() || MiddleUp() || MiddleDClick());
567 return (RightDown() || RightUp() || RightDClick());
569 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
575 bool wxMouseEvent::ButtonIsDown(int but
) const
579 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
583 return MiddleIsDown();
585 return RightIsDown();
587 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
593 // Find the logical position of the event given the DC
594 wxPoint
wxMouseEvent::GetLogicalPosition(const wxDC
& dc
) const
596 wxPoint
pt(dc
.DeviceToLogicalX(m_x
), dc
.DeviceToLogicalY(m_y
));
606 wxKeyEvent::wxKeyEvent(wxEventType type
)
610 m_controlDown
= FALSE
;
617 void wxKeyEvent::CopyObject(wxObject
& obj_d
) const
619 wxKeyEvent
*obj
= (wxKeyEvent
*)&obj_d
;
620 wxEvent::CopyObject(obj_d
);
624 obj
->m_keyCode
= m_keyCode
;
626 obj
->m_shiftDown
= m_shiftDown
;
627 obj
->m_controlDown
= m_controlDown
;
628 obj
->m_metaDown
= m_metaDown
;
629 obj
->m_altDown
= m_altDown
;
630 obj
->m_keyCode
= m_keyCode
;
638 void wxSizeEvent::CopyObject(wxObject
& obj_d
) const
640 wxSizeEvent
*obj
= (wxSizeEvent
*)&obj_d
;
641 wxEvent::CopyObject(obj_d
);
643 obj
->m_size
= m_size
;
646 void wxMoveEvent::CopyObject(wxObject
& obj_d
) const
648 wxMoveEvent
*obj
= (wxMoveEvent
*)&obj_d
;
649 wxEvent::CopyObject(obj_d
);
654 void wxEraseEvent::CopyObject(wxObject
& obj_d
) const
656 wxEraseEvent
*obj
= (wxEraseEvent
*)&obj_d
;
657 wxEvent::CopyObject(obj_d
);
662 void wxActivateEvent::CopyObject(wxObject
& obj_d
) const
664 wxActivateEvent
*obj
= (wxActivateEvent
*)&obj_d
;
665 wxEvent::CopyObject(obj_d
);
667 obj
->m_active
= m_active
;
670 void wxMenuEvent::CopyObject(wxObject
& obj_d
) const
672 wxMenuEvent
*obj
= (wxMenuEvent
*)&obj_d
;
673 wxEvent::CopyObject(obj_d
);
675 obj
->m_menuId
= m_menuId
;
678 void wxCloseEvent::CopyObject(wxObject
& obj_d
) const
680 wxCloseEvent
*obj
= (wxCloseEvent
*)&obj_d
;
681 wxEvent::CopyObject(obj_d
);
683 obj
->m_loggingOff
= m_loggingOff
;
684 obj
->m_veto
= m_veto
;
685 #if WXWIN_COMPATIBILITY
686 obj
->m_force
= m_force
;
688 obj
->m_canVeto
= m_canVeto
;
691 void wxShowEvent::CopyObject(wxObject
& obj_d
) const
693 wxShowEvent
*obj
= (wxShowEvent
*)&obj_d
;
694 wxEvent::CopyObject(obj_d
);
696 obj
->m_show
= m_show
;
699 void wxJoystickEvent::CopyObject(wxObject
& obj_d
) const
701 wxJoystickEvent
*obj
= (wxJoystickEvent
*)&obj_d
;
702 wxEvent::CopyObject(obj_d
);
705 obj
->m_zPosition
= m_zPosition
;
706 obj
->m_buttonChange
= m_buttonChange
;
707 obj
->m_buttonState
= m_buttonState
;
708 obj
->m_joyStick
= m_joyStick
;
711 void wxDropFilesEvent::CopyObject(wxObject
& obj_d
) const
713 wxDropFilesEvent
*obj
= (wxDropFilesEvent
*)&obj_d
;
714 wxEvent::CopyObject(obj_d
);
716 obj
->m_noFiles
= m_noFiles
;
718 // TODO: Problem with obj->m_files. It should be deallocated by the
719 // destructor of the event.
722 void wxUpdateUIEvent::CopyObject(wxObject
&obj_d
) const
724 wxUpdateUIEvent
*obj
= (wxUpdateUIEvent
*)&obj_d
;
725 wxEvent::CopyObject(obj_d
);
727 obj
->m_checked
= m_checked
;
728 obj
->m_enabled
= m_enabled
;
729 obj
->m_text
= m_text
;
730 obj
->m_setText
= m_setText
;
731 obj
->m_setChecked
= m_setChecked
;
732 obj
->m_setEnabled
= m_setEnabled
;
735 void wxPaletteChangedEvent::CopyObject(wxObject
&obj_d
) const
737 wxPaletteChangedEvent
*obj
= (wxPaletteChangedEvent
*)&obj_d
;
738 wxEvent::CopyObject(obj_d
);
740 obj
->m_changedWindow
= m_changedWindow
;
743 void wxQueryNewPaletteEvent::CopyObject(wxObject
& obj_d
) const
745 wxQueryNewPaletteEvent
*obj
= (wxQueryNewPaletteEvent
*)&obj_d
;
746 wxEvent::CopyObject(obj_d
);
748 obj
->m_paletteRealized
= m_paletteRealized
;
751 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow
*win
)
754 SetEventType(wxEVT_CREATE
);
758 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow
*win
)
761 SetEventType(wxEVT_DESTROY
);
767 void wxIdleEvent::CopyObject(wxObject
& obj_d
) const
769 wxIdleEvent
*obj
= (wxIdleEvent
*)&obj_d
;
770 wxEvent::CopyObject(obj_d
);
772 obj
->m_requestMore
= m_requestMore
;
779 wxEvtHandler::wxEvtHandler()
781 m_nextHandler
= (wxEvtHandler
*) NULL
;
782 m_previousHandler
= (wxEvtHandler
*) NULL
;
784 m_dynamicEvents
= (wxList
*) NULL
;
786 m_pendingEvents
= (wxList
*) NULL
;
788 # if !defined(__VISAGECPP__)
789 m_eventsLocker
= new wxCriticalSection
;
794 wxEvtHandler::~wxEvtHandler()
796 // Takes itself out of the list of handlers
797 if (m_previousHandler
)
798 m_previousHandler
->m_nextHandler
= m_nextHandler
;
801 m_nextHandler
->m_previousHandler
= m_previousHandler
;
805 wxNode
*node
= m_dynamicEvents
->First();
808 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
809 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
813 delete m_dynamicEvents
;
816 delete m_pendingEvents
;
819 # if !defined(__VISAGECPP__)
820 delete m_eventsLocker
;
827 bool wxEvtHandler::ProcessThreadEvent(wxEvent
& event
)
829 // check that we are really in a child thread
830 wxASSERT_MSG( !wxThread::IsMain(),
831 wxT("use ProcessEvent() in main thread") );
833 AddPendingEvent(event
);
838 #endif // wxUSE_THREADS
840 void wxEvtHandler::AddPendingEvent(wxEvent
& event
)
842 // 1) Add event to list of pending events of this event handler
844 #if defined(__VISAGECPP__)
845 wxENTER_CRIT_SECT( m_eventsLocker
);
847 wxENTER_CRIT_SECT( *m_eventsLocker
);
850 if ( !m_pendingEvents
)
851 m_pendingEvents
= new wxList
;
853 wxEvent
*event2
= (wxEvent
*)event
.Clone();
855 m_pendingEvents
->Append(event2
);
857 #if defined(__VISAGECPP__)
858 wxLEAVE_CRIT_SECT( m_eventsLocker
);
860 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
863 // 2) Add this event handler to list of event handlers that
864 // have pending events.
866 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
868 if ( !wxPendingEvents
)
869 wxPendingEvents
= new wxList
;
870 wxPendingEvents
->Append(this);
872 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
874 // 3) Inform the system that new pending events are somwehere,
875 // and that these should be processed in idle time.
879 void wxEvtHandler::ProcessPendingEvents()
881 #if defined(__VISAGECPP__)
882 wxENTER_CRIT_SECT( m_eventsLocker
);
884 wxENTER_CRIT_SECT( *m_eventsLocker
);
887 wxNode
*node
= m_pendingEvents
->First();
890 wxEvent
*event
= (wxEvent
*)node
->Data();
893 // In ProcessEvent, new events might get added and
894 // we can safely leave the crtical section here.
895 #if defined(__VISAGECPP__)
896 wxLEAVE_CRIT_SECT( m_eventsLocker
);
898 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
900 ProcessEvent(*event
);
902 #if defined(__VISAGECPP__)
903 wxENTER_CRIT_SECT( m_eventsLocker
);
905 wxENTER_CRIT_SECT( *m_eventsLocker
);
908 node
= m_pendingEvents
->First();
911 #if defined(__VISAGECPP__)
912 wxLEAVE_CRIT_SECT( m_eventsLocker
);
914 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
922 bool wxEvtHandler::ProcessEvent(wxEvent
& event
)
925 // check that our flag corresponds to reality
926 wxASSERT( m_isWindow
== IsKindOf(CLASSINFO(wxWindow
)) );
929 // An event handler can be enabled or disabled
930 if ( GetEvtHandlerEnabled() )
935 What is this? When using GUI threads, a non main
936 threads can send an event and process it itself.
937 This breaks GTK's GUI threads, so please explain.
940 // Check whether we are in a child thread.
941 if ( !wxThread::IsMain() )
942 return ProcessThreadEvent(event
);
945 // Handle per-instance dynamic event tables first
946 if ( m_dynamicEvents
&& SearchDynamicEventTable(event
) )
949 // Then static per-class event tables
950 const wxEventTable
*table
= GetEventTable();
952 #if wxUSE_GUI && wxUSE_VALIDATORS
953 // Try the associated validator first, if this is a window.
954 // Problem: if the event handler of the window has been replaced,
955 // this wxEvtHandler may no longer be a window.
956 // Therefore validators won't be processed if the handler
957 // has been replaced with SetEventHandler.
958 // THIS CAN BE CURED if PushEventHandler is used instead of
959 // SetEventHandler, and then processing will be passed down the
960 // chain of event handlers.
963 wxWindow
*win
= (wxWindow
*)this;
965 // Can only use the validator of the window which
966 // is receiving the event
967 if ( win
== event
.GetEventObject() )
969 wxValidator
*validator
= win
->GetValidator();
970 if ( validator
&& validator
->ProcessEvent(event
) )
978 // Search upwards through the inheritance hierarchy
981 if ( SearchEventTable((wxEventTable
&)*table
, event
) )
983 table
= table
->baseTable
;
987 // Try going down the event handler chain
988 if ( GetNextHandler() )
990 if ( GetNextHandler()->ProcessEvent(event
) )
995 // Carry on up the parent-child hierarchy,
996 // but only if event is a command event: it wouldn't
997 // make sense for a parent to receive a child's size event, for example
998 if ( m_isWindow
&& event
.IsCommandEvent() )
1000 wxWindow
*win
= (wxWindow
*)this;
1001 wxWindow
*parent
= win
->GetParent();
1002 if (parent
&& !parent
->IsBeingDeleted())
1003 return parent
->GetEventHandler()->ProcessEvent(event
);
1007 // Last try - application object.
1008 if ( wxTheApp
&& (this != wxTheApp
) )
1010 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
1011 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
1012 // processed appropriately via SearchEventTable.
1013 if ( event
.GetEventType() != wxEVT_IDLE
)
1015 if ( wxTheApp
->ProcessEvent(event
) )
1023 bool wxEvtHandler::SearchEventTable(wxEventTable
& table
, wxEvent
& event
)
1026 int commandId
= event
.GetId();
1028 // BC++ doesn't like while (table.entries[i].m_fn)
1031 while (table
.entries
[i
].m_fn
!= 0)
1033 while (table
.entries
[i
].m_fn
!= 0L)
1036 if ((event
.GetEventType() == table
.entries
[i
].m_eventType
) &&
1037 (table
.entries
[i
].m_id
== -1 || // Match, if event spec says any id will do (id == -1)
1038 (table
.entries
[i
].m_lastId
== -1 && commandId
== table
.entries
[i
].m_id
) ||
1039 (table
.entries
[i
].m_lastId
!= -1 &&
1040 (commandId
>= table
.entries
[i
].m_id
&& commandId
<= table
.entries
[i
].m_lastId
))))
1043 event
.m_callbackUserData
= table
.entries
[i
].m_callbackUserData
;
1045 (this->*((wxEventFunction
) (table
.entries
[i
].m_fn
)))(event
);
1047 if ( event
.GetSkipped() )
1057 void wxEvtHandler::Connect( int id
, int lastId
,
1058 wxEventType eventType
,
1059 wxObjectEventFunction func
,
1060 wxObject
*userData
)
1062 wxEventTableEntry
*entry
= new wxEventTableEntry
;
1064 entry
->m_lastId
= lastId
;
1065 entry
->m_eventType
= eventType
;
1067 entry
->m_callbackUserData
= userData
;
1069 if (!m_dynamicEvents
)
1070 m_dynamicEvents
= new wxList
;
1072 m_dynamicEvents
->Append( (wxObject
*) entry
);
1075 bool wxEvtHandler::Disconnect( int id
, int lastId
, wxEventType eventType
,
1076 wxObjectEventFunction func
,
1077 wxObject
*userData
)
1079 if (!m_dynamicEvents
)
1082 wxNode
*node
= m_dynamicEvents
->First();
1085 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
1086 if ((entry
->m_id
== id
) &&
1087 ((entry
->m_lastId
== lastId
) || (lastId
== -1)) &&
1088 ((entry
->m_eventType
== eventType
) || (eventType
== wxEVT_NULL
)) &&
1089 ((entry
->m_fn
== func
) || (func
== (wxObjectEventFunction
)NULL
)) &&
1090 ((entry
->m_callbackUserData
== userData
) || (userData
== (wxObject
*)NULL
)))
1092 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
1093 m_dynamicEvents
->DeleteNode( node
);
1097 node
= node
->Next();
1102 bool wxEvtHandler::SearchDynamicEventTable( wxEvent
& event
)
1104 wxCHECK_MSG( m_dynamicEvents
, FALSE
,
1105 wxT("caller should check that we have dynamic events") );
1107 int commandId
= event
.GetId();
1109 wxNode
*node
= m_dynamicEvents
->First();
1112 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
1116 // Match, if event spec says any id will do (id == -1)
1117 if ( (event
.GetEventType() == entry
->m_eventType
) &&
1118 (entry
->m_id
== -1 ||
1119 (entry
->m_lastId
== -1 && commandId
== entry
->m_id
) ||
1120 (entry
->m_lastId
!= -1 &&
1121 (commandId
>= entry
->m_id
&& commandId
<= entry
->m_lastId
))) )
1124 event
.m_callbackUserData
= entry
->m_callbackUserData
;
1126 (this->*((wxEventFunction
) (entry
->m_fn
)))(event
);
1128 if (event
.GetSkipped())
1134 node
= node
->Next();
1139 #if WXWIN_COMPATIBILITY
1140 bool wxEvtHandler::OnClose()
1142 if (GetNextHandler())
1143 return GetNextHandler()->OnClose();
1147 #endif // WXWIN_COMPATIBILITY
1151 // Find a window with the focus, that is also a descendant of the given window.
1152 // This is used to determine the window to initially send commands to.
1153 wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
)
1155 // Process events starting with the window with the focus, if any.
1156 wxWindow
* focusWin
= wxWindow::FindFocus();
1157 wxWindow
* win
= focusWin
;
1159 // Check if this is a descendant of this frame.
1160 // If not, win will be set to NULL.
1163 if (win
== ancestor
)
1166 win
= win
->GetParent();
1168 if (win
== (wxWindow
*) NULL
)
1169 focusWin
= (wxWindow
*) NULL
;