+#if wxUSE_GUI
+ // check that our flag corresponds to reality
+ wxASSERT( m_isWindow == IsKindOf(CLASSINFO(wxWindow)) );
+#endif // wxUSE_GUI
+
+ // An event handler can be enabled or disabled
+ if ( GetEvtHandlerEnabled() )
+ {
+
+#if 0
+/*
+ What is this? When using GUI threads, a non main
+ threads can send an event and process it itself.
+ This breaks GTK's GUI threads, so please explain.
+*/
+
+ // Check whether we are in a child thread.
+ if ( !wxThread::IsMain() )
+ return ProcessThreadEvent(event);
+#endif
+
+ // Handle per-instance dynamic event tables first
+ if ( m_dynamicEvents && SearchDynamicEventTable(event) )
+ return TRUE;
+
+ // Then static per-class event tables
+ const wxEventTable *table = GetEventTable();
+
+#if wxUSE_GUI && wxUSE_VALIDATORS
+ // Try the associated validator first, if this is a window.
+ // Problem: if the event handler of the window has been replaced,
+ // this wxEvtHandler may no longer be a window.
+ // Therefore validators won't be processed if the handler
+ // has been replaced with SetEventHandler.
+ // THIS CAN BE CURED if PushEventHandler is used instead of
+ // SetEventHandler, and then processing will be passed down the
+ // chain of event handlers.
+ if (m_isWindow)
+ {
+ wxWindow *win = (wxWindow *)this;
+
+ // Can only use the validator of the window which
+ // is receiving the event
+ if ( win == event.GetEventObject() )
+ {
+ wxValidator *validator = win->GetValidator();
+ if ( validator && validator->ProcessEvent(event) )
+ {
+ return TRUE;
+ }
+ }
+ }
+#endif
+
+ // Search upwards through the inheritance hierarchy
+ while (table)
+ {
+ if ( SearchEventTable((wxEventTable&)*table, event) )
+ return TRUE;
+ table = table->baseTable;
+ }
+ }
+
+ // Try going down the event handler chain
+ if ( GetNextHandler() )
+ {
+ if ( GetNextHandler()->ProcessEvent(event) )
+ return TRUE;
+ }
+
+#if wxUSE_GUI
+ // Carry on up the parent-child hierarchy,
+ // but only if event is a command event: it wouldn't
+ // make sense for a parent to receive a child's size event, for example
+ if ( m_isWindow && event.IsCommandEvent() )
+ {
+ wxWindow *win = (wxWindow *)this;
+ wxWindow *parent = win->GetParent();
+ if (parent && !parent->IsBeingDeleted())
+ return parent->GetEventHandler()->ProcessEvent(event);
+ }
+#endif // wxUSE_GUI
+
+ // Last try - application object.
+ if ( wxTheApp && (this != wxTheApp) )
+ {
+ // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always
+ // swallow it. wxEVT_IDLE is sent explicitly to wxApp so it will be
+ // processed appropriately via SearchEventTable.
+ if ( event.GetEventType() != wxEVT_IDLE )
+ {
+ if ( wxTheApp->ProcessEvent(event) )
+ return TRUE;
+ }
+ }
+