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
)
87 const wxEventTable
*wxEvtHandler::GetEventTable() const
88 { return &wxEvtHandler::sm_eventTable
; }
90 const wxEventTable
wxEvtHandler::sm_eventTable
=
91 { (const wxEventTable
*)NULL
, &wxEvtHandler::sm_eventTableEntries
[0] };
93 const wxEventTableEntry
wxEvtHandler::sm_eventTableEntries
[] =
94 { { 0, 0, 0, (wxObjectEventFunction
) NULL
, (wxObject
*) NULL
} };
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 // To put pending event handlers
102 wxList
*wxPendingEvents
= (wxList
*)NULL
;
105 // protects wxPendingEvents list
106 wxCriticalSection
*wxPendingEventsLocker
= (wxCriticalSection
*)NULL
;
109 // ============================================================================
111 // ============================================================================
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
118 * General wxWindows events, covering
119 * all interesting things that might happen (button clicking, resizing,
120 * setting text in widgets, etc.).
122 * For each completely new event type, derive a new event class.
126 wxEvent::wxEvent(int theId
)
128 m_eventType
= wxEVT_NULL
;
129 m_eventObject
= (wxObject
*) NULL
;
133 m_callbackUserData
= (wxObject
*) NULL
;
134 m_isCommandEvent
= FALSE
;
137 void wxEvent::CopyObject(wxObject
& object_dest
) const
139 wxEvent
*obj
= (wxEvent
*)&object_dest
;
140 wxObject::CopyObject(object_dest
);
142 obj
->m_eventType
= m_eventType
;
143 obj
->m_eventObject
= m_eventObject
;
144 obj
->m_timeStamp
= m_timeStamp
;
146 obj
->m_skipped
= m_skipped
;
147 obj
->m_callbackUserData
= m_callbackUserData
;
148 obj
->m_isCommandEvent
= m_isCommandEvent
;
158 wxCommandEvent::wxCommandEvent(wxEventType commandType
, int theId
)
160 m_eventType
= commandType
;
161 m_clientData
= (char *) NULL
;
162 m_clientObject
= (wxClientData
*) NULL
;
166 m_commandString
= wxEmptyString
;
167 m_isCommandEvent
= TRUE
;
170 void wxCommandEvent::CopyObject(wxObject
& obj_d
) const
172 wxCommandEvent
*obj
= (wxCommandEvent
*)&obj_d
;
174 wxEvent::CopyObject(obj_d
);
176 obj
->m_clientData
= m_clientData
;
177 obj
->m_clientObject
= m_clientObject
;
178 obj
->m_extraLong
= m_extraLong
;
179 obj
->m_commandInt
= m_commandInt
;
180 obj
->m_commandString
= m_commandString
;
187 void wxNotifyEvent::CopyObject(wxObject
& obj_d
) const
189 wxNotifyEvent
*obj
= (wxNotifyEvent
*)&obj_d
;
191 wxEvent::CopyObject(obj_d
);
193 if (!m_bAllow
) obj
->Veto();
200 wxScrollEvent::wxScrollEvent(wxEventType commandType
,
204 : wxCommandEvent(commandType
, id
)
206 m_extraLong
= orient
;
208 m_isScrolling
= TRUE
;
211 void wxScrollEvent::CopyObject(wxObject
& obj_d
) const
213 wxScrollEvent
*obj
= (wxScrollEvent
*)&obj_d
;
215 wxCommandEvent::CopyObject(obj_d
);
217 obj
->m_isScrolling
= m_isScrolling
;
224 wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType
,
228 m_eventType
= commandType
;
229 m_extraLong
= orient
;
231 m_isScrolling
= TRUE
;
234 void wxScrollWinEvent::CopyObject(wxObject
& obj_d
) const
236 wxScrollWinEvent
*obj
= (wxScrollWinEvent
*)&obj_d
;
238 wxEvent::CopyObject(obj_d
);
240 obj
->m_extraLong
= m_extraLong
;
241 obj
->m_commandInt
= m_commandInt
;
242 obj
->m_isScrolling
= m_isScrolling
;
250 wxMouseEvent::wxMouseEvent(wxEventType commandType
)
252 m_eventType
= commandType
;
255 m_controlDown
= FALSE
;
259 m_middleDown
= FALSE
;
264 void wxMouseEvent::CopyObject(wxObject
& obj_d
) const
266 wxMouseEvent
*obj
= (wxMouseEvent
*)&obj_d
;
268 wxEvent::CopyObject(obj_d
);
270 obj
->m_metaDown
= m_metaDown
;
271 obj
->m_altDown
= m_altDown
;
272 obj
->m_controlDown
= m_controlDown
;
273 obj
->m_shiftDown
= m_shiftDown
;
274 obj
->m_leftDown
= m_leftDown
;
275 obj
->m_rightDown
= m_rightDown
;
276 obj
->m_middleDown
= m_middleDown
;
281 // True if was a button dclick event (1 = left, 2 = middle, 3 = right)
282 // or any button dclick event (but = -1)
283 bool wxMouseEvent::ButtonDClick(int but
) const
288 return (LeftDClick() || MiddleDClick() || RightDClick());
292 return MiddleDClick();
294 return RightDClick();
296 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
302 // True if was a button down event (1 = left, 2 = middle, 3 = right)
303 // or any button down event (but = -1)
304 bool wxMouseEvent::ButtonDown(int but
) const
309 return (LeftDown() || MiddleDown() || RightDown());
317 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
323 // True if was a button up event (1 = left, 2 = middle, 3 = right)
324 // or any button up event (but = -1)
325 bool wxMouseEvent::ButtonUp(int but
) const
329 return (LeftUp() || MiddleUp() || RightUp());
337 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
343 // True if the given button is currently changing state
344 bool wxMouseEvent::Button(int but
) const
348 return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
350 return (LeftDown() || LeftUp() || LeftDClick());
352 return (MiddleDown() || MiddleUp() || MiddleDClick());
354 return (RightDown() || RightUp() || RightDClick());
356 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
362 bool wxMouseEvent::ButtonIsDown(int but
) const
366 return (LeftIsDown() || MiddleIsDown() || RightIsDown());
370 return MiddleIsDown();
372 return RightIsDown();
374 wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
380 // Find the logical position of the event given the DC
381 wxPoint
wxMouseEvent::GetLogicalPosition(const wxDC
& dc
) const
383 wxPoint
pt(dc
.DeviceToLogicalX(m_x
), dc
.DeviceToLogicalY(m_y
));
393 wxKeyEvent::wxKeyEvent(wxEventType type
)
397 m_controlDown
= FALSE
;
404 void wxKeyEvent::CopyObject(wxObject
& obj_d
) const
406 wxKeyEvent
*obj
= (wxKeyEvent
*)&obj_d
;
407 wxEvent::CopyObject(obj_d
);
411 obj
->m_keyCode
= m_keyCode
;
413 obj
->m_shiftDown
= m_shiftDown
;
414 obj
->m_controlDown
= m_controlDown
;
415 obj
->m_metaDown
= m_metaDown
;
416 obj
->m_altDown
= m_altDown
;
417 obj
->m_keyCode
= m_keyCode
;
425 void wxSizeEvent::CopyObject(wxObject
& obj_d
) const
427 wxSizeEvent
*obj
= (wxSizeEvent
*)&obj_d
;
428 wxEvent::CopyObject(obj_d
);
430 obj
->m_size
= m_size
;
433 void wxMoveEvent::CopyObject(wxObject
& obj_d
) const
435 wxMoveEvent
*obj
= (wxMoveEvent
*)&obj_d
;
436 wxEvent::CopyObject(obj_d
);
441 void wxEraseEvent::CopyObject(wxObject
& obj_d
) const
443 wxEraseEvent
*obj
= (wxEraseEvent
*)&obj_d
;
444 wxEvent::CopyObject(obj_d
);
449 void wxActivateEvent::CopyObject(wxObject
& obj_d
) const
451 wxActivateEvent
*obj
= (wxActivateEvent
*)&obj_d
;
452 wxEvent::CopyObject(obj_d
);
454 obj
->m_active
= m_active
;
457 void wxMenuEvent::CopyObject(wxObject
& obj_d
) const
459 wxMenuEvent
*obj
= (wxMenuEvent
*)&obj_d
;
460 wxEvent::CopyObject(obj_d
);
462 obj
->m_menuId
= m_menuId
;
465 void wxCloseEvent::CopyObject(wxObject
& obj_d
) const
467 wxCloseEvent
*obj
= (wxCloseEvent
*)&obj_d
;
468 wxEvent::CopyObject(obj_d
);
470 obj
->m_loggingOff
= m_loggingOff
;
471 obj
->m_veto
= m_veto
;
472 #if WXWIN_COMPATIBILITY
473 obj
->m_force
= m_force
;
475 obj
->m_canVeto
= m_canVeto
;
478 void wxShowEvent::CopyObject(wxObject
& obj_d
) const
480 wxShowEvent
*obj
= (wxShowEvent
*)&obj_d
;
481 wxEvent::CopyObject(obj_d
);
483 obj
->m_show
= m_show
;
486 void wxJoystickEvent::CopyObject(wxObject
& obj_d
) const
488 wxJoystickEvent
*obj
= (wxJoystickEvent
*)&obj_d
;
489 wxEvent::CopyObject(obj_d
);
492 obj
->m_zPosition
= m_zPosition
;
493 obj
->m_buttonChange
= m_buttonChange
;
494 obj
->m_buttonState
= m_buttonState
;
495 obj
->m_joyStick
= m_joyStick
;
498 void wxDropFilesEvent::CopyObject(wxObject
& obj_d
) const
500 wxDropFilesEvent
*obj
= (wxDropFilesEvent
*)&obj_d
;
501 wxEvent::CopyObject(obj_d
);
503 obj
->m_noFiles
= m_noFiles
;
505 // TODO: Problem with obj->m_files. It should be deallocated by the
506 // destructor of the event.
509 void wxUpdateUIEvent::CopyObject(wxObject
&obj_d
) const
511 wxUpdateUIEvent
*obj
= (wxUpdateUIEvent
*)&obj_d
;
512 wxEvent::CopyObject(obj_d
);
514 obj
->m_checked
= m_checked
;
515 obj
->m_enabled
= m_enabled
;
516 obj
->m_text
= m_text
;
517 obj
->m_setText
= m_setText
;
518 obj
->m_setChecked
= m_setChecked
;
519 obj
->m_setEnabled
= m_setEnabled
;
522 void wxPaletteChangedEvent::CopyObject(wxObject
&obj_d
) const
524 wxPaletteChangedEvent
*obj
= (wxPaletteChangedEvent
*)&obj_d
;
525 wxEvent::CopyObject(obj_d
);
527 obj
->m_changedWindow
= m_changedWindow
;
530 void wxQueryNewPaletteEvent::CopyObject(wxObject
& obj_d
) const
532 wxQueryNewPaletteEvent
*obj
= (wxQueryNewPaletteEvent
*)&obj_d
;
533 wxEvent::CopyObject(obj_d
);
535 obj
->m_paletteRealized
= m_paletteRealized
;
538 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow
*win
)
541 SetEventType(wxEVT_CREATE
);
545 wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow
*win
)
548 SetEventType(wxEVT_DESTROY
);
554 void wxIdleEvent::CopyObject(wxObject
& obj_d
) const
556 wxIdleEvent
*obj
= (wxIdleEvent
*)&obj_d
;
557 wxEvent::CopyObject(obj_d
);
559 obj
->m_requestMore
= m_requestMore
;
566 wxEvtHandler::wxEvtHandler()
568 m_nextHandler
= (wxEvtHandler
*) NULL
;
569 m_previousHandler
= (wxEvtHandler
*) NULL
;
571 m_dynamicEvents
= (wxList
*) NULL
;
573 m_pendingEvents
= (wxList
*) NULL
;
575 # if !defined(__VISAGECPP__)
576 m_eventsLocker
= new wxCriticalSection
;
581 wxEvtHandler::~wxEvtHandler()
583 // Takes itself out of the list of handlers
584 if (m_previousHandler
)
585 m_previousHandler
->m_nextHandler
= m_nextHandler
;
588 m_nextHandler
->m_previousHandler
= m_previousHandler
;
592 wxNode
*node
= m_dynamicEvents
->First();
595 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
596 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
600 delete m_dynamicEvents
;
603 delete m_pendingEvents
;
606 # if !defined(__VISAGECPP__)
607 delete m_eventsLocker
;
614 bool wxEvtHandler::ProcessThreadEvent(wxEvent
& event
)
616 // check that we are really in a child thread
617 wxASSERT_MSG( !wxThread::IsMain(),
618 wxT("use ProcessEvent() in main thread") );
620 AddPendingEvent(event
);
625 #endif // wxUSE_THREADS
627 void wxEvtHandler::AddPendingEvent(wxEvent
& event
)
629 // 1) Add event to list of pending events of this event handler
631 #if defined(__VISAGECPP__)
632 wxENTER_CRIT_SECT( m_eventsLocker
);
634 wxENTER_CRIT_SECT( *m_eventsLocker
);
637 if ( !m_pendingEvents
)
638 m_pendingEvents
= new wxList
;
640 wxEvent
*event2
= (wxEvent
*)event
.Clone();
642 m_pendingEvents
->Append(event2
);
644 #if defined(__VISAGECPP__)
645 wxLEAVE_CRIT_SECT( m_eventsLocker
);
647 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
650 // 2) Add this event handler to list of event handlers that
651 // have pending events.
653 wxENTER_CRIT_SECT(*wxPendingEventsLocker
);
655 if ( !wxPendingEvents
)
656 wxPendingEvents
= new wxList
;
657 wxPendingEvents
->Append(this);
659 wxLEAVE_CRIT_SECT(*wxPendingEventsLocker
);
661 // 3) Inform the system that new pending events are somwehere,
662 // and that these should be processed in idle time.
666 void wxEvtHandler::ProcessPendingEvents()
668 #if defined(__VISAGECPP__)
669 wxENTER_CRIT_SECT( m_eventsLocker
);
671 wxENTER_CRIT_SECT( *m_eventsLocker
);
674 wxNode
*node
= m_pendingEvents
->First();
677 wxEvent
*event
= (wxEvent
*)node
->Data();
680 // In ProcessEvent, new events might get added and
681 // we can safely leave the crtical section here.
682 #if defined(__VISAGECPP__)
683 wxLEAVE_CRIT_SECT( m_eventsLocker
);
685 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
687 ProcessEvent(*event
);
689 #if defined(__VISAGECPP__)
690 wxENTER_CRIT_SECT( m_eventsLocker
);
692 wxENTER_CRIT_SECT( *m_eventsLocker
);
695 node
= m_pendingEvents
->First();
698 #if defined(__VISAGECPP__)
699 wxLEAVE_CRIT_SECT( m_eventsLocker
);
701 wxLEAVE_CRIT_SECT( *m_eventsLocker
);
709 bool wxEvtHandler::ProcessEvent(wxEvent
& event
)
712 // check that our flag corresponds to reality
713 wxASSERT( m_isWindow
== IsKindOf(CLASSINFO(wxWindow
)) );
716 // An event handler can be enabled or disabled
717 if ( GetEvtHandlerEnabled() )
722 What is this? When using GUI threads, a non main
723 threads can send an event and process it itself.
724 This breaks GTK's GUI threads, so please explain.
727 // Check whether we are in a child thread.
728 if ( !wxThread::IsMain() )
729 return ProcessThreadEvent(event
);
732 // Handle per-instance dynamic event tables first
733 if ( m_dynamicEvents
&& SearchDynamicEventTable(event
) )
736 // Then static per-class event tables
737 const wxEventTable
*table
= GetEventTable();
739 #if wxUSE_GUI && wxUSE_VALIDATORS
740 // Try the associated validator first, if this is a window.
741 // Problem: if the event handler of the window has been replaced,
742 // this wxEvtHandler may no longer be a window.
743 // Therefore validators won't be processed if the handler
744 // has been replaced with SetEventHandler.
745 // THIS CAN BE CURED if PushEventHandler is used instead of
746 // SetEventHandler, and then processing will be passed down the
747 // chain of event handlers.
750 wxWindow
*win
= (wxWindow
*)this;
752 // Can only use the validator of the window which
753 // is receiving the event
754 if ( win
== event
.GetEventObject() )
756 wxValidator
*validator
= win
->GetValidator();
757 if ( validator
&& validator
->ProcessEvent(event
) )
765 // Search upwards through the inheritance hierarchy
768 if ( SearchEventTable((wxEventTable
&)*table
, event
) )
770 table
= table
->baseTable
;
774 // Try going down the event handler chain
775 if ( GetNextHandler() )
777 if ( GetNextHandler()->ProcessEvent(event
) )
782 // Carry on up the parent-child hierarchy,
783 // but only if event is a command event: it wouldn't
784 // make sense for a parent to receive a child's size event, for example
785 if ( m_isWindow
&& event
.IsCommandEvent() )
787 wxWindow
*win
= (wxWindow
*)this;
788 wxWindow
*parent
= win
->GetParent();
789 if (parent
&& !parent
->IsBeingDeleted())
790 return parent
->GetEventHandler()->ProcessEvent(event
);
794 // Last try - application object.
795 if ( wxTheApp
&& (this != wxTheApp
) )
797 // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
798 // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
799 // processed appropriately via SearchEventTable.
800 if ( event
.GetEventType() != wxEVT_IDLE
)
802 if ( wxTheApp
->ProcessEvent(event
) )
810 bool wxEvtHandler::SearchEventTable(wxEventTable
& table
, wxEvent
& event
)
813 int commandId
= event
.GetId();
815 // BC++ doesn't like while (table.entries[i].m_fn)
818 while (table
.entries
[i
].m_fn
!= 0)
820 while (table
.entries
[i
].m_fn
!= 0L)
823 if ((event
.GetEventType() == table
.entries
[i
].m_eventType
) &&
824 (table
.entries
[i
].m_id
== -1 || // Match, if event spec says any id will do (id == -1)
825 (table
.entries
[i
].m_lastId
== -1 && commandId
== table
.entries
[i
].m_id
) ||
826 (table
.entries
[i
].m_lastId
!= -1 &&
827 (commandId
>= table
.entries
[i
].m_id
&& commandId
<= table
.entries
[i
].m_lastId
))))
830 event
.m_callbackUserData
= table
.entries
[i
].m_callbackUserData
;
832 (this->*((wxEventFunction
) (table
.entries
[i
].m_fn
)))(event
);
834 if ( event
.GetSkipped() )
844 void wxEvtHandler::Connect( int id
, int lastId
,
845 wxEventType eventType
,
846 wxObjectEventFunction func
,
849 wxEventTableEntry
*entry
= new wxEventTableEntry
;
851 entry
->m_lastId
= lastId
;
852 entry
->m_eventType
= eventType
;
854 entry
->m_callbackUserData
= userData
;
856 if (!m_dynamicEvents
)
857 m_dynamicEvents
= new wxList
;
859 m_dynamicEvents
->Append( (wxObject
*) entry
);
862 bool wxEvtHandler::Disconnect( int id
, int lastId
, wxEventType eventType
,
863 wxObjectEventFunction func
,
866 if (!m_dynamicEvents
)
869 wxNode
*node
= m_dynamicEvents
->First();
872 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
873 if ((entry
->m_id
== id
) &&
874 ((entry
->m_lastId
== lastId
) || (lastId
== -1)) &&
875 ((entry
->m_eventType
== eventType
) || (eventType
== wxEVT_NULL
)) &&
876 ((entry
->m_fn
== func
) || (func
== (wxObjectEventFunction
)NULL
)) &&
877 ((entry
->m_callbackUserData
== userData
) || (userData
== (wxObject
*)NULL
)))
879 if (entry
->m_callbackUserData
) delete entry
->m_callbackUserData
;
880 m_dynamicEvents
->DeleteNode( node
);
889 bool wxEvtHandler::SearchDynamicEventTable( wxEvent
& event
)
891 wxCHECK_MSG( m_dynamicEvents
, FALSE
,
892 wxT("caller should check that we have dynamic events") );
894 int commandId
= event
.GetId();
896 wxNode
*node
= m_dynamicEvents
->First();
899 wxEventTableEntry
*entry
= (wxEventTableEntry
*)node
->Data();
903 // Match, if event spec says any id will do (id == -1)
904 if ( (event
.GetEventType() == entry
->m_eventType
) &&
905 (entry
->m_id
== -1 ||
906 (entry
->m_lastId
== -1 && commandId
== entry
->m_id
) ||
907 (entry
->m_lastId
!= -1 &&
908 (commandId
>= entry
->m_id
&& commandId
<= entry
->m_lastId
))) )
911 event
.m_callbackUserData
= entry
->m_callbackUserData
;
913 (this->*((wxEventFunction
) (entry
->m_fn
)))(event
);
915 if (event
.GetSkipped())
926 #if WXWIN_COMPATIBILITY
927 bool wxEvtHandler::OnClose()
929 if (GetNextHandler())
930 return GetNextHandler()->OnClose();
934 #endif // WXWIN_COMPATIBILITY
938 // Find a window with the focus, that is also a descendant of the given window.
939 // This is used to determine the window to initially send commands to.
940 wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
)
942 // Process events starting with the window with the focus, if any.
943 wxWindow
* focusWin
= wxWindow::FindFocus();
944 wxWindow
* win
= focusWin
;
946 // Check if this is a descendant of this frame.
947 // If not, win will be set to NULL.
953 win
= win
->GetParent();
955 if (win
== (wxWindow
*) NULL
)
956 focusWin
= (wxWindow
*) NULL
;