1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Event classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "event.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
37 #include "wx/control.h"
46 #include "wx/validate.h"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler
, wxObject
)
54 IMPLEMENT_ABSTRACT_CLASS(wxEvent
, wxObject
)
55 IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent
, wxEvent
)
58 IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent
, wxEvent
)
59 IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent
, wxCommandEvent
)
60 IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent
, wxCommandEvent
)
61 IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent
, wxEvent
)
62 IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent
, wxEvent
)
63 IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent
, wxEvent
)
64 IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent
, wxEvent
)
65 IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent
, wxEvent
)
66 IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent
, wxEvent
)
67 IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent
, wxEvent
)
68 IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent
, wxEvent
)
69 IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent
, wxEvent
)
70 IMPLEMENT_DYNAMIC_CLASS(wxShowEvent
, wxEvent
)
71 IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent
, wxEvent
)
72 IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent
, wxEvent
)
73 IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent
, wxEvent
)
74 IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent
, wxEvent
)
75 IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent
, wxEvent
)
76 IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent
, wxEvent
)
77 IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent
, wxEvent
)
78 IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent
, wxEvent
)
79 IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent
, wxCommandEvent
)
80 IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent
, wxCommandEvent
)
81 IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent
, wxEvent
)
82 IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent
, wxEvent
)
83 IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent
, wxEvent
)
84 IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent
, wxEvent
)
85 IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent
, wxCommandEvent
)
88 const wxEventTable
*wxEvtHandler::GetEventTable() const
89 { return &wxEvtHandler::sm_eventTable
; }
91 const wxEventTable
wxEvtHandler::sm_eventTable
=
92 { (const wxEventTable
*)NULL
, &wxEvtHandler::sm_eventTableEntries
[0] };
94 const wxEventTableEntry
wxEvtHandler::sm_eventTableEntries
[] =
95 { { 0, 0, 0, (wxObjectEventFunction
) NULL
, (wxObject
*) NULL
} };
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
102 // To put pending event handlers
103 wxList
*wxPendingEvents
= (wxList
*)NULL
;
106 // protects wxPendingEvents list
107 wxCriticalSection
*wxPendingEventsLocker
= (wxCriticalSection
*)NULL
;
110 // ============================================================================
112 // ============================================================================
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
119 * General wxWindows events, covering
120 * all interesting things that might happen (button clicking, resizing,
121 * setting text in widgets, etc.).
123 * For each completely new event type, derive a new event class.
127 wxEvent::wxEvent(int theId
)
129 m_eventType
= wxEVT_NULL
;
130 m_eventObject
= (wxObject
*) NULL
;
134 m_callbackUserData
= (wxObject
*) NULL
;
135 m_isCommandEvent
= FALSE
;
138 void wxEvent::CopyObject(wxObject
& object_dest
) const
140 wxEvent
*obj
= (wxEvent
*)&object_dest
;
141 wxObject::CopyObject(object_dest
);
143 obj
->m_eventType
= m_eventType
;
144 obj
->m_eventObject
= m_eventObject
;
145 obj
->m_timeStamp
= m_timeStamp
;
147 obj
->m_skipped
= m_skipped
;
148 obj
->m_callbackUserData
= m_callbackUserData
;
149 obj
->m_isCommandEvent
= m_isCommandEvent
;
159 wxCommandEvent::wxCommandEvent(wxEventType commandType
, int theId
)
161 m_eventType
= commandType
;
162 m_clientData
= (char *) NULL
;
163 m_clientObject
= (wxClientData
*) NULL
;
167 m_commandString
= wxEmptyString
;
168 m_isCommandEvent
= TRUE
;
171 void wxCommandEvent::CopyObject(wxObject
& obj_d
) const
173 wxCommandEvent
*obj
= (wxCommandEvent
*)&obj_d
;
175 wxEvent::CopyObject(obj_d
);
177 obj
->m_clientData
= m_clientData
;
178 obj
->m_clientObject
= m_clientObject
;
179 obj
->m_extraLong
= m_extraLong
;
180 obj
->m_commandInt
= m_commandInt
;
181 obj
->m_commandString
= m_commandString
;
188 void wxNotifyEvent::CopyObject(wxObject
& obj_d
) const
190 wxNotifyEvent
*obj
= (wxNotifyEvent
*)&obj_d
;
192 wxEvent::CopyObject(obj_d
);
194 if (!m_bAllow
) obj
->Veto();
201 wxScrollEvent::wxScrollEvent(wxEventType commandType
,
205 : wxCommandEvent(commandType
, id
)
207 m_extraLong
= orient
;
215 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType
,
219 m_eventType
= commandType
;
220 m_extraLong
= orient
;
224 void wxScrollWinEvent::CopyObject(wxObject
& obj_d
) const
226 wxScrollWinEvent
*obj
= (wxScrollWinEvent
*)&obj_d
;
228 wxEvent::CopyObject(obj_d
);
230 obj
->m_extraLong
= m_extraLong
;
231 obj
->m_commandInt
= m_commandInt
;
239 wxMouseEvent::wxMouseEvent(wxEventType commandType
)
241 m_eventType
= commandType
;
244 m_controlDown
= FALSE
;
248 m_middleDown
= FALSE
;
253 void wxMouseEvent::CopyObject(wxObject
& obj_d
) const
255 wxMouseEvent
*obj
= (wxMouseEvent
*)&obj_d
;
257 wxEvent::CopyObject(obj_d
);
259 obj
->m_metaDown
= m_metaDown
;
260 obj
->m_altDown
= m_altDown
;
261 obj
->m_controlDown
= m_controlDown
;
262 obj
->m_shiftDown
= m_shiftDown
;
263 obj
->m_leftDown
= m_leftDown
;
264 obj
->m_rightDown
= m_rightDown
;
265 obj
->m_middleDown
= m_middleDown
;
270 // True if was a button dclick event (1 = left, 2 = middle, 3 = right)
271 // or any button dclick event (but = -1)
272 bool wxMouseEvent::ButtonDClick(int but
) const
277 return (LeftDClick() || MiddleDClick() || RightDClick());
281 return MiddleDClick();
283 return RightDClick();
285 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
291 // True if was a button down event (1 = left, 2 = middle, 3 = right)
292 // or any button down event (but = -1)
293 bool wxMouseEvent::ButtonDown(int but
) const
298 return (LeftDown() || MiddleDown() || RightDown());
306 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
312 // True if was a button up event (1 = left, 2 = middle, 3 = right)
313 // or any button up event (but = -1)
314 bool wxMouseEvent::ButtonUp(int but
) const
318 return (LeftUp() || MiddleUp() || RightUp());
326 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
332 // True if the given button is currently changing state
333 bool wxMouseEvent::Button(int but
) const
337 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
339 return (LeftDown() || LeftUp() || LeftDClick());
341 return (MiddleDown() || MiddleUp() || MiddleDClick());
343 return (RightDown() || RightUp() || RightDClick());
345 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
351 bool wxMouseEvent::ButtonIsDown(int but
) const
355 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
359 return MiddleIsDown();
361 return RightIsDown();
363 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
369 // Find the logical position of the event given the DC
370 wxPoint
wxMouseEvent::GetLogicalPosition(const wxDC
& dc
) const
372 wxPoint
pt(dc
.DeviceToLogicalX(m_x
), dc
.DeviceToLogicalY(m_y
));
382 wxKeyEvent::wxKeyEvent(wxEventType type
)
386 m_controlDown
= FALSE
;
393 void wxKeyEvent::CopyObject(wxObject
& obj_d
) const
395 wxKeyEvent
*obj
= (wxKeyEvent
*)&obj_d
;
396 wxEvent::CopyObject(obj_d
);
400 obj
->m_keyCode
= m_keyCode
;
402 obj
->m_shiftDown
= m_shiftDown
;
403 obj
->m_controlDown
= m_controlDown
;
404 obj
->m_metaDown
= m_metaDown
;
405 obj
->m_altDown
= m_altDown
;
406 obj
->m_keyCode
= m_keyCode
;
414 void wxSizeEvent::CopyObject(wxObject
& obj_d
) const
416 wxSizeEvent
*obj
= (wxSizeEvent
*)&obj_d
;
417 wxEvent::CopyObject(obj_d
);
419 obj
->m_size
= m_size
;
422 void wxMoveEvent::CopyObject(wxObject
& obj_d
) const
424 wxMoveEvent
*obj
= (wxMoveEvent
*)&obj_d
;
425 wxEvent::CopyObject(obj_d
);
430 void wxEraseEvent::CopyObject(wxObject
& obj_d
) const
432 wxEraseEvent
*obj
= (wxEraseEvent
*)&obj_d
;
433 wxEvent::CopyObject(obj_d
);
438 void wxActivateEvent::CopyObject(wxObject
& obj_d
) const
440 wxActivateEvent
*obj
= (wxActivateEvent
*)&obj_d
;
441 wxEvent::CopyObject(obj_d
);
443 obj
->m_active
= m_active
;
446 void wxMenuEvent::CopyObject(wxObject
& obj_d
) const
448 wxMenuEvent
*obj
= (wxMenuEvent
*)&obj_d
;
449 wxEvent::CopyObject(obj_d
);
451 obj
->m_menuId
= m_menuId
;
454 void wxCloseEvent::CopyObject(wxObject
& obj_d
) const
456 wxCloseEvent
*obj
= (wxCloseEvent
*)&obj_d
;
457 wxEvent::CopyObject(obj_d
);
459 obj
->m_loggingOff
= m_loggingOff
;
460 obj
->m_veto
= m_veto
;
461 #if WXWIN_COMPATIBILITY
462 obj
->m_force
= m_force
;
464 obj
->m_canVeto
= m_canVeto
;
467 void wxShowEvent::CopyObject(wxObject
& obj_d
) const
469 wxShowEvent
*obj
= (wxShowEvent
*)&obj_d
;
470 wxEvent::CopyObject(obj_d
);
472 obj
->m_show
= m_show
;
475 void wxJoystickEvent::CopyObject(wxObject
& obj_d
) const
477 wxJoystickEvent
*obj
= (wxJoystickEvent
*)&obj_d
;
478 wxEvent::CopyObject(obj_d
);
481 obj
->m_zPosition
= m_zPosition
;
482 obj
->m_buttonChange
= m_buttonChange
;
483 obj
->m_buttonState
= m_buttonState
;
484 obj
->m_joyStick
= m_joyStick
;
487 void wxDropFilesEvent::CopyObject(wxObject
& obj_d
) const
489 wxDropFilesEvent
*obj
= (wxDropFilesEvent
*)&obj_d
;
490 wxEvent::CopyObject(obj_d
);
492 obj
->m_noFiles
= m_noFiles
;
494 // TODO: Problem with obj->m_files. It should be deallocated by the
495 // destructor of the event.
498 void wxUpdateUIEvent::CopyObject(wxObject
&obj_d
) const
500 wxUpdateUIEvent
*obj
= (wxUpdateUIEvent
*)&obj_d
;
501 wxEvent::CopyObject(obj_d
);
503 obj
->m_checked
= m_checked
;
504 obj
->m_enabled
= m_enabled
;
505 obj
->m_text
= m_text
;
506 obj
->m_setText
= m_setText
;
507 obj
->m_setChecked
= m_setChecked
;
508 obj
->m_setEnabled
= m_setEnabled
;
511 void wxPaletteChangedEvent::CopyObject(wxObject
&obj_d
) const
513 wxPaletteChangedEvent
*obj
= (wxPaletteChangedEvent
*)&obj_d
;
514 wxEvent::CopyObject(obj_d
);
516 obj
->m_changedWindow
= m_changedWindow
;
519 void wxQueryNewPaletteEvent::CopyObject(wxObject
& obj_d
) const
521 wxQueryNewPaletteEvent
*obj
= (wxQueryNewPaletteEvent
*)&obj_d
;
522 wxEvent::CopyObject(obj_d
);
524 obj
->m_paletteRealized
= m_paletteRealized
;
527 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow
*win
)
529 SetEventType(wxEVT_CREATE
);
533 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow
*win
)
535 SetEventType(wxEVT_DESTROY
);
541 void wxIdleEvent::CopyObject(wxObject
& obj_d
) const
543 wxIdleEvent
*obj
= (wxIdleEvent
*)&obj_d
;
544 wxEvent::CopyObject(obj_d
);
546 obj
->m_requestMore
= m_requestMore
;
553 wxEvtHandler::wxEvtHandler()
555 m_nextHandler
= (wxEvtHandler
*) NULL
;
556 m_previousHandler
= (wxEvtHandler
*) NULL
;
558 m_dynamicEvents
= (wxList
*) NULL
;
560 m_pendingEvents
= (wxList
*) NULL
;
562 # if !defined(__VISAGECPP__)
563 m_eventsLocker
= new wxCriticalSection
;
568 wxEvtHandler::~wxEvtHandler()
570 // Takes itself out of the list of handlers
571 if (m_previousHandler
)
572 m_previousHandler
->m_nextHandler
= m_nextHandler
;
575 m_nextHandler
->m_previousHandler
= m_previousHandler
;
579 wxNode
*node
= m_dynamicEvents
->First();
582 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
583 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
587 delete m_dynamicEvents
;
590 delete m_pendingEvents
;
593 # if !defined(__VISAGECPP__)
594 delete m_eventsLocker
;
601 bool wxEvtHandler::ProcessThreadEvent(wxEvent
& event
)
603 // check that we are really in a child thread
604 wxASSERT_MSG( !wxThread::IsMain(),
605 wxT("use ProcessEvent() in main thread") );
607 AddPendingEvent(event
);
612 #endif // wxUSE_THREADS
614 void wxEvtHandler::AddPendingEvent(wxEvent
& event
)
616 // 1) Add event to list of pending events of this event handler
618 #if defined(__VISAGECPP__)
619 wxENTER_CRIT_SECT( m_eventsLocker
);
621 wxENTER_CRIT_SECT( *m_eventsLocker
);
624 if ( !m_pendingEvents
)
625 m_pendingEvents
= new wxList
;
627 wxEvent
*event2
= (wxEvent
*)event
.Clone();
629 m_pendingEvents
->Append(event2
);
631 #if defined(__VISAGECPP__)
632 wxLEAVE_CRIT_SECT( m_eventsLocker
);
634 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
637 // 2) Add this event handler to list of event handlers that
638 // have pending events.
640 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
642 if ( !wxPendingEvents
)
643 wxPendingEvents
= new wxList
;
644 wxPendingEvents
->Append(this);
646 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
648 // 3) Inform the system that new pending events are somwehere,
649 // and that these should be processed in idle time.
653 void wxEvtHandler::ProcessPendingEvents()
655 #if defined(__VISAGECPP__)
656 wxENTER_CRIT_SECT( m_eventsLocker
);
658 wxENTER_CRIT_SECT( *m_eventsLocker
);
661 wxNode
*node
= m_pendingEvents
->First();
664 wxEvent
*event
= (wxEvent
*)node
->Data();
667 // In ProcessEvent, new events might get added and
668 // we can safely leave the crtical section here.
669 #if defined(__VISAGECPP__)
670 wxLEAVE_CRIT_SECT( m_eventsLocker
);
672 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
674 ProcessEvent(*event
);
676 #if defined(__VISAGECPP__)
677 wxENTER_CRIT_SECT( m_eventsLocker
);
679 wxENTER_CRIT_SECT( *m_eventsLocker
);
682 node
= m_pendingEvents
->First();
685 #if defined(__VISAGECPP__)
686 wxLEAVE_CRIT_SECT( m_eventsLocker
);
688 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
696 bool wxEvtHandler::ProcessEvent(wxEvent
& event
)
699 // check that our flag corresponds to reality
700 wxASSERT( m_isWindow
== IsKindOf(CLASSINFO(wxWindow
)) );
703 // An event handler can be enabled or disabled
704 if ( GetEvtHandlerEnabled() )
709 What is this? When using GUI threads, a non main
710 threads can send an event and process it itself.
711 This breaks GTK's GUI threads, so please explain.
714 // Check whether we are in a child thread.
715 if ( !wxThread::IsMain() )
716 return ProcessThreadEvent(event
);
719 // Handle per-instance dynamic event tables first
720 if ( m_dynamicEvents
&& SearchDynamicEventTable(event
) )
723 // Then static per-class event tables
724 const wxEventTable
*table
= GetEventTable();
726 #if wxUSE_GUI && wxUSE_VALIDATORS
727 // Try the associated validator first, if this is a window.
728 // Problem: if the event handler of the window has been replaced,
729 // this wxEvtHandler may no longer be a window.
730 // Therefore validators won't be processed if the handler
731 // has been replaced with SetEventHandler.
732 // THIS CAN BE CURED if PushEventHandler is used instead of
733 // SetEventHandler, and then processing will be passed down the
734 // chain of event handlers.
737 wxWindow
*win
= (wxWindow
*)this;
739 // Can only use the validator of the window which
740 // is receiving the event
741 if ( win
== event
.GetEventObject() )
743 wxValidator
*validator
= win
->GetValidator();
744 if ( validator
&& validator
->ProcessEvent(event
) )
752 // Search upwards through the inheritance hierarchy
755 if ( SearchEventTable((wxEventTable
&)*table
, event
) )
757 table
= table
->baseTable
;
761 // Try going down the event handler chain
762 if ( GetNextHandler() )
764 if ( GetNextHandler()->ProcessEvent(event
) )
769 // Carry on up the parent-child hierarchy,
770 // but only if event is a command event: it wouldn't
771 // make sense for a parent to receive a child's size event, for example
772 if ( m_isWindow
&& event
.IsCommandEvent() )
774 wxWindow
*win
= (wxWindow
*)this;
775 wxWindow
*parent
= win
->GetParent();
776 if (parent
&& !parent
->IsBeingDeleted())
777 return parent
->GetEventHandler()->ProcessEvent(event
);
781 // Last try - application object.
782 if ( wxTheApp
&& (this != wxTheApp
) )
784 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
785 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
786 // processed appropriately via SearchEventTable.
787 if ( event
.GetEventType() != wxEVT_IDLE
)
789 if ( wxTheApp
->ProcessEvent(event
) )
797 bool wxEvtHandler::SearchEventTable(wxEventTable
& table
, wxEvent
& event
)
799 wxEventType eventType
= event
.GetEventType();
800 int eventId
= event
.GetId();
802 // BC++ doesn't like testing for m_fn without != 0
803 for ( int i
= 0; table
.entries
[i
].m_fn
!= 0; i
++ )
805 // the line using reference exposes a bug in gcc: although it _seems_
806 // to work, it leads to weird crashes later on during program
809 wxEventTableEntry entry
= table
.entries
[i
];
811 const wxEventTableEntry
& entry
= table
.entries
[i
];
814 // match only if the event type is the same and the id is either -1 in
815 // the event table (meaning "any") or the event id matches the id
816 // specified in the event table either exactly or by falling into
817 // range between first and last
818 if ( eventType
== entry
.m_eventType
)
820 int tableId1
= entry
.m_id
,
821 tableId2
= entry
.m_lastId
;
823 if ( (tableId1
== -1) ||
824 (tableId2
== -1 && eventId
== tableId1
) ||
826 (eventId
>= tableId1
&& eventId
<= tableId2
)) )
829 event
.m_callbackUserData
= entry
.m_callbackUserData
;
831 (this->*((wxEventFunction
) (entry
.m_fn
)))(event
);
833 return !event
.GetSkipped();
841 void wxEvtHandler::Connect( int id
, int lastId
,
842 wxEventType eventType
,
843 wxObjectEventFunction func
,
846 wxEventTableEntry
*entry
= new wxEventTableEntry
;
848 entry
->m_lastId
= lastId
;
849 entry
->m_eventType
= eventType
;
851 entry
->m_callbackUserData
= userData
;
853 if (!m_dynamicEvents
)
854 m_dynamicEvents
= new wxList
;
856 m_dynamicEvents
->Append( (wxObject
*) entry
);
859 bool wxEvtHandler::Disconnect( int id
, int lastId
, wxEventType eventType
,
860 wxObjectEventFunction func
,
863 if (!m_dynamicEvents
)
866 wxNode
*node
= m_dynamicEvents
->First();
869 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
870 if ((entry
->m_id
== id
) &&
871 ((entry
->m_lastId
== lastId
) || (lastId
== -1)) &&
872 ((entry
->m_eventType
== eventType
) || (eventType
== wxEVT_NULL
)) &&
873 ((entry
->m_fn
== func
) || (func
== (wxObjectEventFunction
)NULL
)) &&
874 ((entry
->m_callbackUserData
== userData
) || (userData
== (wxObject
*)NULL
)))
876 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
877 m_dynamicEvents
->DeleteNode( node
);
886 bool wxEvtHandler::SearchDynamicEventTable( wxEvent
& event
)
888 wxCHECK_MSG( m_dynamicEvents
, FALSE
,
889 wxT("caller should check that we have dynamic events") );
891 int commandId
= event
.GetId();
893 wxNode
*node
= m_dynamicEvents
->First();
896 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
900 // Match, if event spec says any id will do (id == -1)
901 if ( (event
.GetEventType() == entry
->m_eventType
) &&
902 (entry
->m_id
== -1 ||
903 (entry
->m_lastId
== -1 && commandId
== entry
->m_id
) ||
904 (entry
->m_lastId
!= -1 &&
905 (commandId
>= entry
->m_id
&& commandId
<= entry
->m_lastId
))) )
908 event
.m_callbackUserData
= entry
->m_callbackUserData
;
910 (this->*((wxEventFunction
) (entry
->m_fn
)))(event
);
912 if (event
.GetSkipped())
923 #if WXWIN_COMPATIBILITY
924 bool wxEvtHandler::OnClose()
926 if (GetNextHandler())
927 return GetNextHandler()->OnClose();
931 #endif // WXWIN_COMPATIBILITY
935 // Find a window with the focus, that is also a descendant of the given window.
936 // This is used to determine the window to initially send commands to.
937 wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
)
939 // Process events starting with the window with the focus, if any.
940 wxWindow
* focusWin
= wxWindow::FindFocus();
941 wxWindow
* win
= focusWin
;
943 // Check if this is a descendant of this frame.
944 // If not, win will be set to NULL.
950 win
= win
->GetParent();
952 if (win
== (wxWindow
*) NULL
)
953 focusWin
= (wxWindow
*) NULL
;