]> git.saurik.com Git - wxWidgets.git/blame - src/common/event.cpp
added GetBorder(flags)
[wxWidgets.git] / src / common / event.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: event.cpp
3// Purpose: Event classes
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
55d99c7a 8// Copyright: (c) Julian Smart
e90c1d2a 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
8e193f38
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
c801d85f 20#ifdef __GNUG__
0b746ba8 21 #pragma implementation "event.h"
c801d85f
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
0b746ba8 28 #pragma hdrstop
c801d85f
KB
29#endif
30
31#ifndef WX_PRECOMP
0b746ba8 32 #include "wx/defs.h"
0b746ba8 33 #include "wx/app.h"
e90c1d2a
VZ
34 #include "wx/list.h"
35
36 #if wxUSE_GUI
37 #include "wx/control.h"
38 #include "wx/utils.h"
39 #include "wx/dc.h"
40 #endif // wxUSE_GUI
c801d85f
KB
41#endif
42
43#include "wx/event.h"
e90c1d2a
VZ
44
45#if wxUSE_GUI
46 #include "wx/validate.h"
47#endif // wxUSE_GUI
c801d85f 48
8e193f38
VZ
49// ----------------------------------------------------------------------------
50// wxWin macros
51// ----------------------------------------------------------------------------
52
3ed2104c
VZ
53#if wxUSE_BASE
54 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
55 IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
56#endif // wxUSE_BASE
e90c1d2a 57
23f681ec 58#if wxUSE_GUI
6b55490a 59 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
23f681ec
VZ
60 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent)
61 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent)
62 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent)
63 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent, wxEvent)
64 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent)
65 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent)
66 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent)
67 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent)
1e6feb95 68 IMPLEMENT_DYNAMIC_CLASS(wxNcPaintEvent, wxEvent)
23f681ec
VZ
69 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent)
70 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent)
71 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent)
456bc6d9 72 IMPLEMENT_DYNAMIC_CLASS(wxChildFocusEvent, wxCommandEvent)
23f681ec
VZ
73 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent)
74 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent)
75 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent)
76 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent)
77 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent)
78 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent)
79 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent)
80 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent)
81 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent)
8e72b8b5 82 IMPLEMENT_DYNAMIC_CLASS(wxSetCursorEvent, wxEvent)
23f681ec 83 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent)
574c939e 84 IMPLEMENT_DYNAMIC_CLASS(wxDisplayChangedEvent, wxEvent)
23f681ec
VZ
85 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent)
86 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent)
87 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent)
88 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent, wxEvent)
89 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent, wxEvent)
90 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent)
b96340e6 91 IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent, wxCommandEvent)
69231000 92 IMPLEMENT_DYNAMIC_CLASS(wxContextMenuEvent, wxCommandEvent)
a5e84126 93 IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureChangedEvent, wxEvent)
23f681ec 94#endif // wxUSE_GUI
0b746ba8 95
3ed2104c
VZ
96#if wxUSE_BASE
97
23f681ec
VZ
98const wxEventTable *wxEvtHandler::GetEventTable() const
99 { return &wxEvtHandler::sm_eventTable; }
0b746ba8 100
23f681ec
VZ
101const wxEventTable wxEvtHandler::sm_eventTable =
102 { (const wxEventTable *)NULL, &wxEvtHandler::sm_eventTableEntries[0] };
0b746ba8 103
23f681ec 104const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] =
9aaf9bed 105 { DECLARE_EVENT_TABLE_ENTRY(wxEVT_NULL, 0, 0, (wxObjectEventFunction)NULL, NULL) };
c801d85f 106
8e193f38
VZ
107// ----------------------------------------------------------------------------
108// global variables
109// ----------------------------------------------------------------------------
110
111// To put pending event handlers
112wxList *wxPendingEvents = (wxList *)NULL;
113
7214297d 114#if wxUSE_THREADS
8e193f38
VZ
115 // protects wxPendingEvents list
116 wxCriticalSection *wxPendingEventsLocker = (wxCriticalSection *)NULL;
7214297d
GL
117#endif
118
cbee8f8d
VZ
119#if !WXWIN_COMPATIBILITY_EVENT_TYPES
120
2e4df4bf
VZ
121// common event types are defined here, other event types are defined by the
122// components which use them
c15d9c85
VS
123
124const wxEventType wxEVT_FIRST = 10000;
125const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
2e4df4bf 126
461697c2 127DEFINE_EVENT_TYPE(wxEVT_NULL)
886dd7d2
VZ
128DEFINE_EVENT_TYPE(wxEVT_IDLE)
129DEFINE_EVENT_TYPE(wxEVT_SOCKET)
130
131#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
132
133#endif // wxUSE_BASE
134
135#if wxUSE_GUI
136
137#if !WXWIN_COMPATIBILITY_EVENT_TYPES
138
2e4df4bf
VZ
139DEFINE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED)
140DEFINE_EVENT_TYPE(wxEVT_COMMAND_CHECKBOX_CLICKED)
141DEFINE_EVENT_TYPE(wxEVT_COMMAND_CHOICE_SELECTED)
142DEFINE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED)
143DEFINE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED)
144DEFINE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED)
2e4df4bf
VZ
145DEFINE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED)
146DEFINE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED)
147DEFINE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED)
148DEFINE_EVENT_TYPE(wxEVT_COMMAND_RADIOBUTTON_SELECTED)
149DEFINE_EVENT_TYPE(wxEVT_COMMAND_SCROLLBAR_UPDATED)
150DEFINE_EVENT_TYPE(wxEVT_COMMAND_VLBOX_SELECTED)
151DEFINE_EVENT_TYPE(wxEVT_COMMAND_COMBOBOX_SELECTED)
152DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_RCLICKED)
153DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER)
154DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED)
0b5eceb6
VZ
155
156// Sockets and timers send events, too
2e4df4bf 157DEFINE_EVENT_TYPE(wxEVT_TIMER)
0b5eceb6
VZ
158
159// Mouse event types
2e4df4bf
VZ
160DEFINE_EVENT_TYPE(wxEVT_LEFT_DOWN)
161DEFINE_EVENT_TYPE(wxEVT_LEFT_UP)
162DEFINE_EVENT_TYPE(wxEVT_MIDDLE_DOWN)
163DEFINE_EVENT_TYPE(wxEVT_MIDDLE_UP)
164DEFINE_EVENT_TYPE(wxEVT_RIGHT_DOWN)
165DEFINE_EVENT_TYPE(wxEVT_RIGHT_UP)
166DEFINE_EVENT_TYPE(wxEVT_MOTION)
167DEFINE_EVENT_TYPE(wxEVT_ENTER_WINDOW)
168DEFINE_EVENT_TYPE(wxEVT_LEAVE_WINDOW)
169DEFINE_EVENT_TYPE(wxEVT_LEFT_DCLICK)
170DEFINE_EVENT_TYPE(wxEVT_MIDDLE_DCLICK)
171DEFINE_EVENT_TYPE(wxEVT_RIGHT_DCLICK)
172DEFINE_EVENT_TYPE(wxEVT_SET_FOCUS)
173DEFINE_EVENT_TYPE(wxEVT_KILL_FOCUS)
456bc6d9 174DEFINE_EVENT_TYPE(wxEVT_CHILD_FOCUS)
d2c52078 175DEFINE_EVENT_TYPE(wxEVT_MOUSEWHEEL)
0b5eceb6
VZ
176
177// Non-client mouse events
2e4df4bf
VZ
178DEFINE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN)
179DEFINE_EVENT_TYPE(wxEVT_NC_LEFT_UP)
180DEFINE_EVENT_TYPE(wxEVT_NC_MIDDLE_DOWN)
181DEFINE_EVENT_TYPE(wxEVT_NC_MIDDLE_UP)
182DEFINE_EVENT_TYPE(wxEVT_NC_RIGHT_DOWN)
183DEFINE_EVENT_TYPE(wxEVT_NC_RIGHT_UP)
184DEFINE_EVENT_TYPE(wxEVT_NC_MOTION)
185DEFINE_EVENT_TYPE(wxEVT_NC_ENTER_WINDOW)
186DEFINE_EVENT_TYPE(wxEVT_NC_LEAVE_WINDOW)
187DEFINE_EVENT_TYPE(wxEVT_NC_LEFT_DCLICK)
188DEFINE_EVENT_TYPE(wxEVT_NC_MIDDLE_DCLICK)
189DEFINE_EVENT_TYPE(wxEVT_NC_RIGHT_DCLICK)
0b5eceb6
VZ
190
191// Character input event type
2e4df4bf
VZ
192DEFINE_EVENT_TYPE(wxEVT_CHAR)
193DEFINE_EVENT_TYPE(wxEVT_CHAR_HOOK)
194DEFINE_EVENT_TYPE(wxEVT_NAVIGATION_KEY)
195DEFINE_EVENT_TYPE(wxEVT_KEY_DOWN)
196DEFINE_EVENT_TYPE(wxEVT_KEY_UP)
0b5eceb6
VZ
197
198// Set cursor event
2e4df4bf 199DEFINE_EVENT_TYPE(wxEVT_SET_CURSOR)
0b5eceb6
VZ
200
201// wxScrollbar and wxSlider event identifiers
2e4df4bf
VZ
202DEFINE_EVENT_TYPE(wxEVT_SCROLL_TOP)
203DEFINE_EVENT_TYPE(wxEVT_SCROLL_BOTTOM)
204DEFINE_EVENT_TYPE(wxEVT_SCROLL_LINEUP)
205DEFINE_EVENT_TYPE(wxEVT_SCROLL_LINEDOWN)
206DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP)
207DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN)
208DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK)
209DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE)
e8b669d3 210DEFINE_EVENT_TYPE(wxEVT_SCROLL_ENDSCROLL)
0b5eceb6
VZ
211
212// Scroll events from wxWindow
2e4df4bf
VZ
213DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP)
214DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_BOTTOM)
215DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEUP)
216DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_LINEDOWN)
217DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEUP)
218DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_PAGEDOWN)
219DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBTRACK)
220DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBRELEASE)
0b5eceb6
VZ
221
222// System events
2e4df4bf 223DEFINE_EVENT_TYPE(wxEVT_SIZE)
5706de1c 224DEFINE_EVENT_TYPE(wxEVT_SIZING)
2e4df4bf 225DEFINE_EVENT_TYPE(wxEVT_MOVE)
5706de1c 226DEFINE_EVENT_TYPE(wxEVT_MOVING)
2e4df4bf
VZ
227DEFINE_EVENT_TYPE(wxEVT_CLOSE_WINDOW)
228DEFINE_EVENT_TYPE(wxEVT_END_SESSION)
229DEFINE_EVENT_TYPE(wxEVT_QUERY_END_SESSION)
230DEFINE_EVENT_TYPE(wxEVT_ACTIVATE_APP)
231DEFINE_EVENT_TYPE(wxEVT_POWER)
232DEFINE_EVENT_TYPE(wxEVT_ACTIVATE)
233DEFINE_EVENT_TYPE(wxEVT_CREATE)
234DEFINE_EVENT_TYPE(wxEVT_DESTROY)
235DEFINE_EVENT_TYPE(wxEVT_SHOW)
236DEFINE_EVENT_TYPE(wxEVT_ICONIZE)
237DEFINE_EVENT_TYPE(wxEVT_MAXIMIZE)
238DEFINE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED)
239DEFINE_EVENT_TYPE(wxEVT_PAINT)
240DEFINE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND)
241DEFINE_EVENT_TYPE(wxEVT_NC_PAINT)
242DEFINE_EVENT_TYPE(wxEVT_PAINT_ICON)
ccef86c7
VZ
243DEFINE_EVENT_TYPE(wxEVT_MENU_OPEN)
244DEFINE_EVENT_TYPE(wxEVT_MENU_CLOSE)
2e4df4bf 245DEFINE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT)
2e4df4bf
VZ
246DEFINE_EVENT_TYPE(wxEVT_CONTEXT_MENU)
247DEFINE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED)
574c939e 248DEFINE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED)
2e4df4bf
VZ
249DEFINE_EVENT_TYPE(wxEVT_SETTING_CHANGED)
250DEFINE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE)
251DEFINE_EVENT_TYPE(wxEVT_PALETTE_CHANGED)
252DEFINE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN)
253DEFINE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP)
254DEFINE_EVENT_TYPE(wxEVT_JOY_MOVE)
255DEFINE_EVENT_TYPE(wxEVT_JOY_ZMOVE)
256DEFINE_EVENT_TYPE(wxEVT_DROP_FILES)
257DEFINE_EVENT_TYPE(wxEVT_DRAW_ITEM)
258DEFINE_EVENT_TYPE(wxEVT_MEASURE_ITEM)
259DEFINE_EVENT_TYPE(wxEVT_COMPARE_ITEM)
260DEFINE_EVENT_TYPE(wxEVT_INIT_DIALOG)
2e4df4bf 261DEFINE_EVENT_TYPE(wxEVT_UPDATE_UI)
0b5eceb6
VZ
262
263// Generic command events
264// Note: a click is a higher-level event than button down/up
2e4df4bf
VZ
265DEFINE_EVENT_TYPE(wxEVT_COMMAND_LEFT_CLICK)
266DEFINE_EVENT_TYPE(wxEVT_COMMAND_LEFT_DCLICK)
267DEFINE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_CLICK)
268DEFINE_EVENT_TYPE(wxEVT_COMMAND_RIGHT_DCLICK)
269DEFINE_EVENT_TYPE(wxEVT_COMMAND_SET_FOCUS)
270DEFINE_EVENT_TYPE(wxEVT_COMMAND_KILL_FOCUS)
271DEFINE_EVENT_TYPE(wxEVT_COMMAND_ENTER)
0b5eceb6
VZ
272
273// Help events
2e4df4bf
VZ
274DEFINE_EVENT_TYPE(wxEVT_HELP)
275DEFINE_EVENT_TYPE(wxEVT_DETAILED_HELP)
6164f93c
VZ
276
277#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
278
886dd7d2
VZ
279#endif // wxUSE_GUI
280
281#if wxUSE_BASE
282
6164f93c
VZ
283// ============================================================================
284// implementation
285// ============================================================================
0b5eceb6 286
0b5eceb6
VZ
287// ----------------------------------------------------------------------------
288// event initialization
289// ----------------------------------------------------------------------------
290
291int wxNewEventType()
292{
293 // MT-FIXME
294 static int s_lastUsedEventType = wxEVT_FIRST;
295
cbee8f8d
VZ
296#if WXWIN_COMPATIBILITY_2
297 // check that we don't overlap with the user-defined types: if it does
298 // happen, the best solution is probably to update the existing code to
299 // use wxNewEventType() instead of wxEVT_USER_FIRST
6164f93c
VZ
300 //
301 // due to the uncertainty
cbee8f8d
VZ
302 wxASSERT_MSG( s_lastUsedEventType < wxEVT_USER_FIRST - 1,
303 _T("possible event type conflict") );
304#endif // WXWIN_COMPATIBILITY_2
305
0b5eceb6
VZ
306 return s_lastUsedEventType++;
307}
308
8e193f38
VZ
309// ----------------------------------------------------------------------------
310// wxEvent
311// ----------------------------------------------------------------------------
312
c801d85f
KB
313/*
314 * General wxWindows events, covering
315 * all interesting things that might happen (button clicking, resizing,
316 * setting text in widgets, etc.).
317 *
318 * For each completely new event type, derive a new event class.
319 *
320 */
321
8e72b8b5 322wxEvent::wxEvent(int theId, wxEventType commandType )
c801d85f 323{
8e72b8b5 324 m_eventType = commandType;
0b746ba8 325 m_eventObject = (wxObject *) NULL;
0b746ba8
VZ
326 m_timeStamp = 0;
327 m_id = theId;
328 m_skipped = FALSE;
329 m_callbackUserData = (wxObject *) NULL;
193bf013 330 m_isCommandEvent = FALSE;
c801d85f
KB
331}
332
8e72b8b5 333wxEvent::wxEvent(const wxEvent &src)
e6a6feba
GD
334 : wxObject()
335 , m_eventObject(src.m_eventObject)
336 , m_eventType(src.m_eventType)
337 , m_timeStamp(src.m_timeStamp)
338 , m_id(src.m_id)
339 , m_callbackUserData(src.m_callbackUserData)
340 , m_skipped(src.m_skipped)
341 , m_isCommandEvent(src.m_isCommandEvent)
a737331d 342{
a737331d
GL
343}
344
3ed2104c
VZ
345#endif // wxUSE_BASE
346
e90c1d2a
VZ
347#if wxUSE_GUI
348
c801d85f
KB
349/*
350 * Command events
351 *
352 */
353
7798a18e 354wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId)
e6a6feba 355 : wxEvent(theId, commandType)
c801d85f 356{
0b746ba8
VZ
357 m_clientData = (char *) NULL;
358 m_clientObject = (wxClientData *) NULL;
359 m_extraLong = 0;
360 m_commandInt = 0;
04392d70 361 m_commandString = wxEmptyString;
193bf013 362 m_isCommandEvent = TRUE;
c801d85f
KB
363}
364
365/*
366 * Scroll events
367 */
368
0b746ba8
VZ
369wxScrollEvent::wxScrollEvent(wxEventType commandType,
370 int id,
371 int pos,
372 int orient)
e6a6feba 373 : wxCommandEvent(commandType, id)
c801d85f 374{
0b746ba8
VZ
375 m_extraLong = orient;
376 m_commandInt = pos;
c801d85f
KB
377}
378
d1367c3d
RR
379/*
380 * ScrollWin events
381 */
382
383wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType,
384 int pos,
385 int orient)
d1367c3d 386{
c5b42c87 387 m_eventType = commandType;
d1367c3d
RR
388 m_extraLong = orient;
389 m_commandInt = pos;
390}
391
c801d85f
KB
392/*
393 * Mouse events
394 *
395 */
396
7798a18e 397wxMouseEvent::wxMouseEvent(wxEventType commandType)
c801d85f 398{
0b746ba8
VZ
399 m_eventType = commandType;
400 m_metaDown = FALSE;
401 m_altDown = FALSE;
402 m_controlDown = FALSE;
403 m_shiftDown = FALSE;
404 m_leftDown = FALSE;
405 m_rightDown = FALSE;
406 m_middleDown = FALSE;
407 m_x = 0;
408 m_y = 0;
d2c52078
RD
409 m_wheelRotation = 0;
410 m_wheelDelta = 0;
411 m_linesPerAction = 0;
c801d85f
KB
412}
413
abcbaea7
VZ
414void wxMouseEvent::Assign(const wxMouseEvent& event)
415{
9a1725c4 416 m_eventType = event.m_eventType;
92309201 417
abcbaea7
VZ
418 m_x = event.m_x;
419 m_y = event.m_y;
420
421 m_leftDown = event.m_leftDown;
422 m_middleDown = event.m_middleDown;
423 m_rightDown = event.m_rightDown;
424
425 m_controlDown = event.m_controlDown;
426 m_shiftDown = event.m_shiftDown;
427 m_altDown = event.m_altDown;
428 m_metaDown = event.m_metaDown;
429
430 m_wheelRotation = event.m_wheelRotation;
431 m_wheelDelta = event.m_wheelDelta;
432 m_linesPerAction = event.m_linesPerAction;
433}
434
c801d85f
KB
435// True if was a button dclick event (1 = left, 2 = middle, 3 = right)
436// or any button dclick event (but = -1)
437bool wxMouseEvent::ButtonDClick(int but) const
438{
0b746ba8
VZ
439 switch (but)
440 {
441 case -1:
442 return (LeftDClick() || MiddleDClick() || RightDClick());
443 case 1:
444 return LeftDClick();
445 case 2:
446 return MiddleDClick();
447 case 3:
448 return RightDClick();
449 default:
223d09f6 450 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
0b746ba8
VZ
451 }
452
453 return FALSE;
c801d85f
KB
454}
455
456// True if was a button down event (1 = left, 2 = middle, 3 = right)
457// or any button down event (but = -1)
458bool wxMouseEvent::ButtonDown(int but) const
459{
0b746ba8
VZ
460 switch (but)
461 {
462 case -1:
463 return (LeftDown() || MiddleDown() || RightDown());
464 case 1:
465 return LeftDown();
466 case 2:
467 return MiddleDown();
468 case 3:
469 return RightDown();
470 default:
223d09f6 471 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
0b746ba8
VZ
472 }
473
474 return FALSE;
c801d85f
KB
475}
476
477// True if was a button up event (1 = left, 2 = middle, 3 = right)
478// or any button up event (but = -1)
479bool wxMouseEvent::ButtonUp(int but) const
480{
1e6feb95
VZ
481 switch (but)
482 {
0b746ba8
VZ
483 case -1:
484 return (LeftUp() || MiddleUp() || RightUp());
485 case 1:
486 return LeftUp();
487 case 2:
488 return MiddleUp();
489 case 3:
490 return RightUp();
491 default:
223d09f6 492 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
0b746ba8
VZ
493 }
494
495 return FALSE;
c801d85f
KB
496}
497
498// True if the given button is currently changing state
499bool wxMouseEvent::Button(int but) const
500{
1e6feb95
VZ
501 switch (but)
502 {
0b746ba8 503 case -1:
72cdf4c9 504 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
0b746ba8
VZ
505 case 1:
506 return (LeftDown() || LeftUp() || LeftDClick());
507 case 2:
508 return (MiddleDown() || MiddleUp() || MiddleDClick());
509 case 3:
510 return (RightDown() || RightUp() || RightDClick());
511 default:
223d09f6 512 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
0b746ba8
VZ
513 }
514
515 return FALSE;
c801d85f
KB
516}
517
518bool wxMouseEvent::ButtonIsDown(int but) const
519{
1e6feb95
VZ
520 switch (but)
521 {
0b746ba8
VZ
522 case -1:
523 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
524 case 1:
525 return LeftIsDown();
526 case 2:
527 return MiddleIsDown();
528 case 3:
529 return RightIsDown();
530 default:
223d09f6 531 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
0b746ba8
VZ
532 }
533
534 return FALSE;
c801d85f
KB
535}
536
1e6feb95
VZ
537int wxMouseEvent::GetButton() const
538{
539 for ( int i = 1; i <= 3; i++ )
540 {
541 if ( Button(i) )
542 {
543 return i;
544 }
545 }
546
547 return -1;
548}
549
c801d85f
KB
550// Find the logical position of the event given the DC
551wxPoint wxMouseEvent::GetLogicalPosition(const wxDC& dc) const
552{
0757d27c
JS
553 wxPoint pt(dc.DeviceToLogicalX(m_x), dc.DeviceToLogicalY(m_y));
554 return pt;
c801d85f
KB
555}
556
557
558/*
8e72b8b5 559 * Keyboard event
c801d85f
KB
560 *
561 */
562
7798a18e 563wxKeyEvent::wxKeyEvent(wxEventType type)
c801d85f 564{
0b746ba8
VZ
565 m_eventType = type;
566 m_shiftDown = FALSE;
567 m_controlDown = FALSE;
568 m_metaDown = FALSE;
569 m_altDown = FALSE;
570 m_keyCode = 0;
b0e813a0 571 m_scanCode = 0;
2b5f62a0
VZ
572#if wxUSE_UNICODE
573 m_uniChar = 0;
574#endif
c801d85f
KB
575}
576
92309201 577wxKeyEvent::wxKeyEvent(const wxKeyEvent& evt)
2b5f62a0
VZ
578 : wxEvent(evt)
579{
580 m_x = evt.m_x;
581 m_y = evt.m_y;
582
583 m_keyCode = evt.m_keyCode;
584
585 m_controlDown = evt.m_controlDown;
586 m_shiftDown = evt.m_shiftDown;
587 m_altDown = evt.m_altDown;
588 m_metaDown = evt.m_metaDown;
589 m_scanCode = evt.m_scanCode;
590 m_rawCode = evt.m_rawCode;
591 m_rawFlags = evt.m_rawFlags;
92309201 592
2b5f62a0
VZ
593#if wxUSE_UNICODE
594 m_uniChar = evt.m_uniChar;
595#endif
596}
12a3f227
RL
597
598long wxKeyEvent::KeyCode() const
599{
600 return m_keyCode;
601}
602
42e69d6b 603wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win)
42e69d6b 604{
cfe17b74 605 SetEventType(wxEVT_CREATE);
42e69d6b
VZ
606 SetEventObject(win);
607}
608
609wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow *win)
42e69d6b 610{
cfe17b74 611 SetEventType(wxEVT_DESTROY);
42e69d6b
VZ
612 SetEventObject(win);
613}
614
456bc6d9
VZ
615wxChildFocusEvent::wxChildFocusEvent(wxWindow *win)
616 : wxCommandEvent(wxEVT_CHILD_FOCUS)
617{
618 SetEventObject(win);
619}
620
dd070522
VZ
621#endif // wxUSE_GUI
622
456bc6d9
VZ
623// ----------------------------------------------------------------------------
624// wxEvtHandler
625// ----------------------------------------------------------------------------
626
3ed2104c
VZ
627#if wxUSE_BASE
628
c801d85f
KB
629/*
630 * Event handler
631 */
632
0b746ba8 633wxEvtHandler::wxEvtHandler()
c801d85f 634{
0b746ba8
VZ
635 m_nextHandler = (wxEvtHandler *) NULL;
636 m_previousHandler = (wxEvtHandler *) NULL;
637 m_enabled = TRUE;
638 m_dynamicEvents = (wxList *) NULL;
8e193f38 639 m_pendingEvents = (wxList *) NULL;
7214297d 640#if wxUSE_THREADS
41404da7 641# if !defined(__VISAGECPP__)
8e193f38 642 m_eventsLocker = new wxCriticalSection;
41404da7 643# endif
7214297d 644#endif
b88c44e7
RD
645 // no client data (yet)
646 m_clientData = NULL;
647 m_clientDataType = wxClientData_None;
c801d85f
KB
648}
649
0b746ba8 650wxEvtHandler::~wxEvtHandler()
c801d85f 651{
0b746ba8
VZ
652 // Takes itself out of the list of handlers
653 if (m_previousHandler)
654 m_previousHandler->m_nextHandler = m_nextHandler;
655
656 if (m_nextHandler)
657 m_nextHandler->m_previousHandler = m_previousHandler;
658
659 if (m_dynamicEvents)
fe71f65c 660 {
b1d4dd7a 661 wxNode *node = m_dynamicEvents->GetFirst();
0b746ba8
VZ
662 while (node)
663 {
2e4df4bf 664#if WXWIN_COMPATIBILITY_EVENT_TYPES
b1d4dd7a 665 wxEventTableEntry *entry = (wxEventTableEntry*)node->GetData();
2e4df4bf 666#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
b1d4dd7a 667 wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
2e4df4bf
VZ
668#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
669
670 if (entry->m_callbackUserData)
671 delete entry->m_callbackUserData;
0b746ba8 672 delete entry;
b1d4dd7a 673 node = node->GetNext();
0b746ba8
VZ
674 }
675 delete m_dynamicEvents;
676 };
7214297d 677
8e193f38 678 delete m_pendingEvents;
7214297d 679
8e193f38 680#if wxUSE_THREADS
41404da7 681# if !defined(__VISAGECPP__)
7214297d 682 delete m_eventsLocker;
41404da7 683# endif
083f7497
JS
684
685 // Remove us from wxPendingEvents if necessary.
686 if(wxPendingEventsLocker)
687 wxENTER_CRIT_SECT(*wxPendingEventsLocker);
688 if ( wxPendingEvents ) {
689 wxPendingEvents->DeleteObject(this);
690 }
691 if(wxPendingEventsLocker)
692 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
7214297d 693#endif
b88c44e7
RD
694
695 // we only delete object data, not untyped
696 if ( m_clientDataType == wxClientData_Object )
697 delete m_clientObject;
c801d85f
KB
698}
699
7214297d 700#if wxUSE_THREADS
aadbdf11 701
7214297d
GL
702bool wxEvtHandler::ProcessThreadEvent(wxEvent& event)
703{
7214297d 704 // check that we are really in a child thread
8e193f38
VZ
705 wxASSERT_MSG( !wxThread::IsMain(),
706 wxT("use ProcessEvent() in main thread") );
707
708 AddPendingEvent(event);
7214297d 709
8e193f38
VZ
710 return TRUE;
711}
712
713#endif // wxUSE_THREADS
714
715void wxEvtHandler::AddPendingEvent(wxEvent& event)
716{
16c1f79c
RR
717 // 1) Add event to list of pending events of this event handler
718
7a5c8ac4
VZ
719 wxEvent *eventCopy = event.Clone();
720
721 // we must be able to copy the events here so the event class must
722 // implement Clone() properly instead of just providing a NULL stab for it
723 wxCHECK_RET( eventCopy,
724 _T("events of this type aren't supposed to be posted") );
725
16c1f79c
RR
726#if defined(__VISAGECPP__)
727 wxENTER_CRIT_SECT( m_eventsLocker);
728#else
729 wxENTER_CRIT_SECT( *m_eventsLocker);
730#endif
731
8e193f38
VZ
732 if ( !m_pendingEvents )
733 m_pendingEvents = new wxList;
7214297d 734
7a5c8ac4 735 m_pendingEvents->Append(eventCopy);
7214297d 736
16c1f79c
RR
737#if defined(__VISAGECPP__)
738 wxLEAVE_CRIT_SECT( m_eventsLocker);
739#else
740 wxLEAVE_CRIT_SECT( *m_eventsLocker);
741#endif
742
743 // 2) Add this event handler to list of event handlers that
744 // have pending events.
cfe17b74 745
b568d04f 746 wxENTER_CRIT_SECT(*wxPendingEventsLocker);
72cdf4c9 747
8e193f38
VZ
748 if ( !wxPendingEvents )
749 wxPendingEvents = new wxList;
4d3a259a 750 wxPendingEvents->Append(this);
72cdf4c9 751
ce6d2511 752 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
6164f93c 753
16c1f79c
RR
754 // 3) Inform the system that new pending events are somwehere,
755 // and that these should be processed in idle time.
bf9e3e73 756 wxWakeUpIdle();
7214297d
GL
757}
758
759void wxEvtHandler::ProcessPendingEvents()
760{
41404da7 761#if defined(__VISAGECPP__)
16c1f79c 762 wxENTER_CRIT_SECT( m_eventsLocker);
b568d04f 763#else
16c1f79c 764 wxENTER_CRIT_SECT( *m_eventsLocker);
41404da7 765#endif
8e193f38 766
b1d4dd7a 767 wxNode *node = m_pendingEvents->GetFirst();
8e193f38
VZ
768 while ( node )
769 {
b1d4dd7a 770 wxEvent *event = (wxEvent *)node->GetData();
16c1f79c 771 delete node;
cfe17b74 772
16c1f79c 773 // In ProcessEvent, new events might get added and
6164f93c 774 // we can safely leave the crtical section here.
16c1f79c
RR
775#if defined(__VISAGECPP__)
776 wxLEAVE_CRIT_SECT( m_eventsLocker);
777#else
778 wxLEAVE_CRIT_SECT( *m_eventsLocker);
779#endif
8e193f38 780 ProcessEvent(*event);
9779893b 781 delete event;
16c1f79c
RR
782#if defined(__VISAGECPP__)
783 wxENTER_CRIT_SECT( m_eventsLocker);
784#else
785 wxENTER_CRIT_SECT( *m_eventsLocker);
786#endif
cfe17b74 787
b1d4dd7a 788 node = m_pendingEvents->GetFirst();
7214297d 789 }
cfe17b74 790
16c1f79c
RR
791#if defined(__VISAGECPP__)
792 wxLEAVE_CRIT_SECT( m_eventsLocker);
793#else
794 wxLEAVE_CRIT_SECT( *m_eventsLocker);
795#endif
7214297d 796}
7214297d 797
c801d85f
KB
798/*
799 * Event table stuff
800 */
801
4caf847c 802bool wxEvtHandler::TryParent(wxEvent& event)
c801d85f 803{
4caf847c 804 if ( wxTheApp && (this != wxTheApp) )
9154d8cf 805 {
4caf847c
VZ
806 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
807 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
808 // processed appropriately via SearchEventTable.
809 if ( event.GetEventType() != wxEVT_IDLE )
810 {
811 if ( wxTheApp->ProcessEvent(event) )
812 return TRUE;
813 }
9154d8cf
VZ
814 }
815
4caf847c
VZ
816 return FALSE;
817}
0b746ba8 818
4caf847c
VZ
819bool wxEvtHandler::ProcessEvent(wxEvent& event)
820{
9154d8cf
VZ
821 // allow the application to hook into event processing
822 if ( wxTheApp )
823 {
824 int rc = wxTheApp->FilterEvent(event);
825 if ( rc != -1 )
826 {
827 wxASSERT_MSG( rc == 1 || rc == 0,
828 _T("unexpected wxApp::FilterEvent return value") );
829
830 return rc != 0;
831 }
832 //else: proceed normally
833 }
834
8e193f38 835 // An event handler can be enabled or disabled
0b746ba8 836 if ( GetEvtHandlerEnabled() )
c801d85f 837 {
22c2307c
VZ
838 // if we have a validator, it has higher priority than our own event
839 // table
4caf847c
VZ
840#if wxUSE_VALIDATORS
841 if ( TryValidator(event) )
842 return TRUE;
843#endif // wxUSE_VALIDATORS
844
22c2307c
VZ
845 // Handle per-instance dynamic event tables first
846 if ( m_dynamicEvents && SearchDynamicEventTable(event) )
847 return TRUE;
0b746ba8 848
22c2307c
VZ
849 // Then static per-class event tables (and search upwards through the
850 // inheritance hierarchy)
851 for ( const wxEventTable *table = GetEventTable();
852 table;
853 table = table->baseTable )
0b746ba8 854 {
193bf013 855 if ( SearchEventTable((wxEventTable&)*table, event) )
0b746ba8 856 return TRUE;
0b746ba8 857 }
c801d85f
KB
858 }
859
0b746ba8
VZ
860 // Try going down the event handler chain
861 if ( GetNextHandler() )
c801d85f 862 {
0b746ba8
VZ
863 if ( GetNextHandler()->ProcessEvent(event) )
864 return TRUE;
c801d85f 865 }
c801d85f 866
22c2307c
VZ
867 // Finally propagate the event upwards the window chain and/or to the
868 // application object as necessary
4caf847c 869 return TryParent(event);
c801d85f
KB
870}
871
872bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
873{
68662769
VZ
874 wxEventType eventType = event.GetEventType();
875 int eventId = event.GetId();
0b746ba8 876
68662769
VZ
877 // BC++ doesn't like testing for m_fn without != 0
878 for ( int i = 0; table.entries[i].m_fn != 0; i++ )
c801d85f 879 {
6e58645e
VZ
880 // the line using reference exposes a bug in gcc: although it _seems_
881 // to work, it leads to weird crashes later on during program
882 // execution
883#ifdef __GNUG__
884 wxEventTableEntry entry = table.entries[i];
885#else
68662769 886 const wxEventTableEntry& entry = table.entries[i];
6e58645e 887#endif
68662769
VZ
888
889 // match only if the event type is the same and the id is either -1 in
890 // the event table (meaning "any") or the event id matches the id
891 // specified in the event table either exactly or by falling into
892 // range between first and last
893 if ( eventType == entry.m_eventType )
0b746ba8 894 {
68662769
VZ
895 int tableId1 = entry.m_id,
896 tableId2 = entry.m_lastId;
897
898 if ( (tableId1 == -1) ||
899 (tableId2 == -1 && eventId == tableId1) ||
900 (tableId2 != -1 &&
901 (eventId >= tableId1 && eventId <= tableId2)) )
902 {
903 event.Skip(FALSE);
904 event.m_callbackUserData = entry.m_callbackUserData;
0b746ba8 905
68662769 906 (this->*((wxEventFunction) (entry.m_fn)))(event);
0b746ba8 907
68662769
VZ
908 return !event.GetSkipped();
909 }
0b746ba8 910 }
c801d85f 911 }
68662769 912
0b746ba8 913 return FALSE;
c801d85f 914}
97d7bfb8 915
debe6624 916void wxEvtHandler::Connect( int id, int lastId,
77d4384e 917 int eventType,
0b746ba8 918 wxObjectEventFunction func,
65b17727
JS
919 wxObject *userData,
920 wxEvtHandler* eventSink )
fe71f65c 921{
cbee8f8d 922#if WXWIN_COMPATIBILITY_EVENT_TYPES
2e4df4bf 923 wxEventTableEntry *entry = new wxEventTableEntry;
cbee8f8d
VZ
924 entry->m_eventType = eventType;
925 entry->m_id = id;
926 entry->m_lastId = lastId;
927 entry->m_fn = func;
928 entry->m_callbackUserData = userData;
929#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
0b5eceb6 930 wxDynamicEventTableEntry *entry =
65b17727 931 new wxDynamicEventTableEntry(eventType, id, lastId, func, userData, eventSink);
cbee8f8d 932#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
0b746ba8
VZ
933
934 if (!m_dynamicEvents)
935 m_dynamicEvents = new wxList;
936
92309201
RD
937 // Insert at the front of the list so most recent additions are found first
938 m_dynamicEvents->Insert( (wxObject*) entry );
fe71f65c 939}
97d7bfb8
RR
940
941bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
942 wxObjectEventFunction func,
65b17727
JS
943 wxObject *userData,
944 wxEvtHandler* eventSink )
97d7bfb8
RR
945{
946 if (!m_dynamicEvents)
947 return FALSE;
cfe17b74 948
b1d4dd7a 949 wxNode *node = m_dynamicEvents->GetFirst();
97d7bfb8
RR
950 while (node)
951 {
2e4df4bf 952#if WXWIN_COMPATIBILITY_EVENT_TYPES
b1d4dd7a 953 wxEventTableEntry *entry = (wxEventTableEntry*)node->GetData();
2e4df4bf 954#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
b1d4dd7a 955 wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
2e4df4bf
VZ
956#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
957
97d7bfb8
RR
958 if ((entry->m_id == id) &&
959 ((entry->m_lastId == lastId) || (lastId == -1)) &&
960 ((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
961 ((entry->m_fn == func) || (func == (wxObjectEventFunction)NULL)) &&
65b17727 962 ((entry->m_eventSink == eventSink) || (eventSink == (wxEvtHandler*)NULL)) &&
97d7bfb8
RR
963 ((entry->m_callbackUserData == userData) || (userData == (wxObject*)NULL)))
964 {
2e4df4bf
VZ
965 if (entry->m_callbackUserData)
966 delete entry->m_callbackUserData;
97d7bfb8
RR
967 m_dynamicEvents->DeleteNode( node );
968 delete entry;
969 return TRUE;
970 }
b1d4dd7a 971 node = node->GetNext();
97d7bfb8
RR
972 }
973 return FALSE;
974}
fe71f65c
RR
975
976bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
977{
193bf013 978 wxCHECK_MSG( m_dynamicEvents, FALSE,
223d09f6 979 wxT("caller should check that we have dynamic events") );
0b746ba8
VZ
980
981 int commandId = event.GetId();
982
b1d4dd7a 983 wxNode *node = m_dynamicEvents->GetFirst();
0b746ba8 984 while (node)
fe71f65c 985 {
2e4df4bf 986#if WXWIN_COMPATIBILITY_EVENT_TYPES
b1d4dd7a 987 wxEventTableEntry *entry = (wxEventTableEntry*)node->GetData();
2e4df4bf 988#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
b1d4dd7a 989 wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
2e4df4bf 990#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
0b746ba8
VZ
991
992 if (entry->m_fn)
993 {
994 // Match, if event spec says any id will do (id == -1)
995 if ( (event.GetEventType() == entry->m_eventType) &&
996 (entry->m_id == -1 ||
997 (entry->m_lastId == -1 && commandId == entry->m_id) ||
998 (entry->m_lastId != -1 &&
999 (commandId >= entry->m_id && commandId <= entry->m_lastId))) )
1000 {
1001 event.Skip(FALSE);
1002 event.m_callbackUserData = entry->m_callbackUserData;
1003
65b17727
JS
1004#if !WXWIN_COMPATIBILITY_EVENT_TYPES
1005 if (entry->m_eventSink)
1006 ((entry->m_eventSink)->*((wxEventFunction) (entry->m_fn)))(event);
1007 else
1008#endif
1009 (this->*((wxEventFunction) (entry->m_fn)))(event);
0b746ba8 1010
92309201 1011 if ( ! event.GetSkipped() )
0b746ba8
VZ
1012 return TRUE;
1013 }
1014 }
b1d4dd7a 1015 node = node->GetNext();
7b678698 1016 }
0b746ba8 1017 return FALSE;
fe71f65c
RR
1018};
1019
b88c44e7
RD
1020void wxEvtHandler::DoSetClientObject( wxClientData *data )
1021{
1022 wxASSERT_MSG( m_clientDataType != wxClientData_Void,
1023 wxT("can't have both object and void client data") );
1024
1025 if ( m_clientObject )
1026 delete m_clientObject;
1027
1028 m_clientObject = data;
1029 m_clientDataType = wxClientData_Object;
1030}
1031
1032wxClientData *wxEvtHandler::DoGetClientObject() const
1033{
1034 // it's not an error to call GetClientObject() on a window which doesn't
1035 // have client data at all - NULL will be returned
1036 wxASSERT_MSG( m_clientDataType != wxClientData_Void,
1037 wxT("this window doesn't have object client data") );
1038
1039 return m_clientObject;
1040}
1041
1042void wxEvtHandler::DoSetClientData( void *data )
1043{
1044 wxASSERT_MSG( m_clientDataType != wxClientData_Object,
1045 wxT("can't have both object and void client data") );
1046
1047 m_clientData = data;
1048 m_clientDataType = wxClientData_Void;
1049}
1050
1051void *wxEvtHandler::DoGetClientData() const
1052{
1053 // it's not an error to call GetClientData() on a window which doesn't have
1054 // client data at all - NULL will be returned
1055 wxASSERT_MSG( m_clientDataType != wxClientData_Object,
1056 wxT("this window doesn't have void client data") );
1057
1058 return m_clientData;
1059}
1060
1061
e3065973 1062#if WXWIN_COMPATIBILITY
0b746ba8 1063bool wxEvtHandler::OnClose()
c801d85f 1064{
0b746ba8
VZ
1065 if (GetNextHandler())
1066 return GetNextHandler()->OnClose();
1067 else
1068 return FALSE;
c801d85f 1069}
193bf013 1070#endif // WXWIN_COMPATIBILITY
e3065973 1071
4caf847c
VZ
1072#endif // wxUSE_BASE
1073
e90c1d2a
VZ
1074#if wxUSE_GUI
1075
e702ff0f
JS
1076// Find a window with the focus, that is also a descendant of the given window.
1077// This is used to determine the window to initially send commands to.
1078wxWindow* wxFindFocusDescendant(wxWindow* ancestor)
1079{
1080 // Process events starting with the window with the focus, if any.
1081 wxWindow* focusWin = wxWindow::FindFocus();
1082 wxWindow* win = focusWin;
1083
1084 // Check if this is a descendant of this frame.
1085 // If not, win will be set to NULL.
1086 while (win)
1087 {
1088 if (win == ancestor)
1089 break;
1090 else
1091 win = win->GetParent();
1092 }
1093 if (win == (wxWindow*) NULL)
1094 focusWin = (wxWindow*) NULL;
1095
1096 return focusWin;
1097}
1098
e90c1d2a 1099#endif // wxUSE_GUI