// wxWin macros
// ----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
+#if wxUSE_BASE
+ IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
+ IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
+#endif // wxUSE_BASE
#if wxUSE_GUI
IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureChangedEvent, wxEvent)
#endif // wxUSE_GUI
+#if wxUSE_BASE
+
const wxEventTable *wxEvtHandler::GetEventTable() const
{ return &wxEvtHandler::sm_eventTable; }
// System events
DEFINE_EVENT_TYPE(wxEVT_SIZE)
+DEFINE_EVENT_TYPE(wxEVT_SIZING)
DEFINE_EVENT_TYPE(wxEVT_MOVE)
+DEFINE_EVENT_TYPE(wxEVT_MOVING)
DEFINE_EVENT_TYPE(wxEVT_CLOSE_WINDOW)
DEFINE_EVENT_TYPE(wxEVT_END_SESSION)
DEFINE_EVENT_TYPE(wxEVT_QUERY_END_SESSION)
{
}
+#endif // wxUSE_BASE
+
#if wxUSE_GUI
/*
// wxEvtHandler
// ----------------------------------------------------------------------------
+#if wxUSE_BASE
+
/*
* Event handler
*/
m_previousHandler = (wxEvtHandler *) NULL;
m_enabled = TRUE;
m_dynamicEvents = (wxList *) NULL;
- m_isWindow = FALSE;
m_pendingEvents = (wxList *) NULL;
#if wxUSE_THREADS
# if !defined(__VISAGECPP__)
# if !defined(__VISAGECPP__)
delete m_eventsLocker;
# endif
+
+ // Remove us from wxPendingEvents if necessary.
+ if(wxPendingEventsLocker)
+ wxENTER_CRIT_SECT(*wxPendingEventsLocker);
+ if ( wxPendingEvents ) {
+ wxPendingEvents->DeleteObject(this);
+ }
+ if(wxPendingEventsLocker)
+ wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
#endif
// we only delete object data, not untyped
* Event table stuff
*/
-bool wxEvtHandler::ProcessEvent(wxEvent& event)
+bool wxEvtHandler::TryParent(wxEvent& event)
{
-#if wxUSE_GUI
-
- // We have to use the actual window or processing events from
- // wxWindowNative destructor won't work (we don't see the wxWindow class)
-#ifdef __WXDEBUG__
- // check that our flag corresponds to reality
- wxClassInfo* info = NULL;
-#ifdef __WXUNIVERSAL__
-# if defined(__WXMSW__)
- info = CLASSINFO(wxWindowMSW);
-# elif defined(__WXGTK__)
- info = CLASSINFO(wxWindowGTK);
-# elif defined(__WXX11__)
- info = CLASSINFO(wxWindowX11);
-# elif defined(__WXMGL__)
- info = CLASSINFO(wxWindowMGL);
-# elif defined(__WXPM__)
- info = CLASSINFO(wxWindowOS2);
-# elif defined(__WXMAC__)
- info = CLASSINFO(wxWindowMac);
-# elif defined(__WXMOTIF__)
- info = CLASSINFO(wxWindowMotif);
-# endif
-#else
- info = CLASSINFO(wxWindow);
-#endif
-
- if ( m_isWindow != IsKindOf(info) )
+ if ( wxTheApp && (this != wxTheApp) )
{
- wxString msg = GetClassInfo()->GetClassName();
- msg += _T(" should [not] be a window but it is [not]");
-
- wxFAIL_MSG( msg );
+ // 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;
+ }
}
-#endif // __WXDEBUG__
-
-#endif // wxUSE_GUI
+ return FALSE;
+}
+bool wxEvtHandler::ProcessEvent(wxEvent& event)
+{
// allow the application to hook into event processing
if ( wxTheApp )
{
// 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
+ // if we have a validator, it has higher priority than our own event
+ // table
+#if wxUSE_VALIDATORS
+ if ( TryValidator(event) )
+ return TRUE;
+#endif // wxUSE_VALIDATORS
// 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)
+ // Then static per-class event tables (and search upwards through the
+ // inheritance hierarchy)
+ for ( const wxEventTable *table = GetEventTable();
+ table;
+ table = table->baseTable )
{
if ( SearchEventTable((wxEventTable&)*table, event) )
return TRUE;
- table = table->baseTable;
}
}
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;
-
- // honour the requests to stop propagation at this window: this is
- // used by the dialogs, for example, to prevent processing the events
- // from the dialog controls in the parent frame which rarely, if ever,
- // makes sense
- if ( !(win->GetExtraStyle() & wxWS_EX_BLOCK_EVENTS) )
- {
- 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;
- }
- }
-
- return FALSE;
+ // Finally propagate the event upwards the window chain and/or to the
+ // application object as necessary
+ return TryParent(event);
}
bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
}
#endif // WXWIN_COMPATIBILITY
+#endif // wxUSE_BASE
+
#if wxUSE_GUI
// Find a window with the focus, that is also a descendant of the given window.