X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03f3617bf36573a7c368614191444364267ed718..15cac64f7564d48c274c6490774a77bd8c09f808:/include/wx/event.h?ds=sidebyside diff --git a/include/wx/event.h b/include/wx/event.h index a4d22914f7..42c5406b13 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -94,6 +94,11 @@ typedef int wxEventType; // generate a new unique event type extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); +// FIXME: currently the new events code is disabled because it creates too +// many problems, it should be reenabled a.s.a.p. or removed +#undef wxEVENTS_COMPATIBILITY_2_8 +#define wxEVENTS_COMPATIBILITY_2_8 1 + // macros to create an event type depending on whether type safe events are // enabled. @@ -105,10 +110,10 @@ extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); extern const expdecl wxEventType name; #define wxDEFINE_EVENT_REFERENCE( name, type, value ) \ - const wxEventType &name( value ); + const wxEventType& name = value; #define wxDECLARE_EXPORTED_EVENT_REFERENCE( expdecl, name, type ) \ - extern const expdecl wxEventType &name; + extern const expdecl wxEventType& name; #define wxDECLARE_LOCAL_EVENT( name, type ) \ wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type ) @@ -244,18 +249,19 @@ private: wxObjectEventFunction m_method; }; -// Create a functor for the legacy events: handler can be NULL +// Create a functor for the legacy events: handler can be NULL and its default +// value is used by the event table macros inline wxObjectEventFunctor * -wxNewEventFunctor(wxEventType WXUNUSED(evtType), +wxNewEventFunctor(const wxEventType& WXUNUSED(evtType), wxObjectEventFunction method, - wxEvtHandler *handler) + wxEvtHandler *handler = NULL) { return new wxObjectEventFunctor(method, handler); } inline wxObjectEventFunctor -wxConstructEventFunctor(wxEventType WXUNUSED(evtType), +wxConstructEventFunctor(const wxEventType& WXUNUSED(evtType), wxObjectEventFunction method, wxEvtHandler *handler) { @@ -712,7 +718,7 @@ public: void Skip(bool skip = true) { m_skipped = skip; } bool GetSkipped() const { return m_skipped; } - // this function is used to create a copy of the event polymorphically and + // This function is used to create a copy of the event polymorphically and // all derived classes must implement it because otherwise wxPostEvent() // for them wouldn't work (it needs to do a copy of the event) virtual wxEvent *Clone() const = 0; @@ -741,6 +747,20 @@ public: m_propagationLevel = propagationLevel; } + + // This is for internal use only and is only called by + // wxEvtHandler::ProcessEvent() to check whether it's the first time this + // event is being processed + bool WasProcessed() + { + if ( m_wasProcessed ) + return true; + + m_wasProcessed = true; + + return false; + } + protected: wxObject* m_eventObject; wxEventType m_eventType; @@ -762,6 +782,12 @@ protected: bool m_skipped; bool m_isCommandEvent; + // initially false but becomes true as soon as WasProcessed() is called for + // the first time, as this is done only by ProcessEvent() it explains the + // variable name: it becomes true after ProcessEvent() was called at least + // once for this event + bool m_wasProcessed; + protected: wxEvent(const wxEvent&); // for implementing Clone() wxEvent& operator=(const wxEvent&); // for derived classes operator=() @@ -3075,12 +3101,7 @@ public: void OnSinkDestroyed( wxEvtHandler *sink ); - // The method processing the event in this event handler (or rather in this - // event handler chain as it also tries the next handler and so on), i.e. - // it returns true if we processed this event or false if we didn't but - // does not call TryParent() in the latter case. It also doesn't call - // wxApp::FilterEvent() before processing it, this is supposed to be done - // by the public ProcessEvent() only once for every event we handle. + // The method tries to process the event in this event handler. // // It is meant to be called from ProcessEvent() only and is not virtual, // additional event handlers can be hooked into the normal event processing