X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fa150e233fa449ee270ac26ecf074f5c40acb1e..8bd37efca7eb0de7cdf72167e138f9cabd9b6750:/src/common/event.cpp?ds=inline diff --git a/src/common/event.cpp b/src/common/event.cpp index abca39a4b7..e04611b837 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -147,6 +147,7 @@ const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; DEFINE_EVENT_TYPE(wxEVT_NULL) DEFINE_EVENT_TYPE(wxEVT_IDLE) DEFINE_EVENT_TYPE(wxEVT_SOCKET) +DEFINE_EVENT_TYPE(wxEVT_TIMER) #endif // !WXWIN_COMPATIBILITY_EVENT_TYPES @@ -173,9 +174,6 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_RCLICKED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER) DEFINE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED) -// Sockets and timers send events, too -DEFINE_EVENT_TYPE(wxEVT_TIMER) - // Mouse event types DEFINE_EVENT_TYPE(wxEVT_LEFT_DOWN) DEFINE_EVENT_TYPE(wxEVT_LEFT_UP) @@ -352,7 +350,7 @@ wxEvent::wxEvent(int theId, wxEventType commandType ) } wxEvent::wxEvent(const wxEvent &src) - : wxObject() + : wxObject(src) , m_eventObject(src.m_eventObject) , m_eventType(src.m_eventType) , m_timeStamp(src.m_timeStamp) @@ -380,9 +378,6 @@ wxEvent::wxEvent(const wxEvent &src) wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId) : wxEvent(theId, commandType) -#if WXWIN_COMPATIBILITY_2_4 - , m_commandString(this) -#endif { m_clientData = (char *) NULL; m_clientObject = (wxClientData *) NULL; @@ -539,6 +534,7 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType) m_wheelRotation = 0; m_wheelDelta = 0; m_linesPerAction = 0; + m_wheelAxis = 0; } void wxMouseEvent::Assign(const wxMouseEvent& event) @@ -560,6 +556,7 @@ void wxMouseEvent::Assign(const wxMouseEvent& event) m_wheelRotation = event.m_wheelRotation; m_wheelDelta = event.m_wheelDelta; m_linesPerAction = event.m_linesPerAction; + m_wheelAxis = event.m_wheelAxis; } // return true if was a button dclick event @@ -1011,9 +1008,6 @@ wxEvtHandler::wxEvtHandler() m_eventsLocker = new wxCriticalSection; # endif #endif - // reentrace not allowed by default - m_reentranceAllowed = false; - m_eventHandlingInProgress = false; // no client data (yet) m_clientData = NULL; @@ -1140,9 +1134,6 @@ void wxEvtHandler::ProcessPendingEvents() wxCHECK_RET( m_pendingEvents, wxT("Please call wxApp::ProcessPendingEvents() instead") ); - // eventhandling is now in progess - m_eventHandlingInProgress = true; - wxENTER_CRIT_SECT( Lock() ); // we leave the loop once we have processed all events that were present at @@ -1166,9 +1157,6 @@ void wxEvtHandler::ProcessPendingEvents() ProcessEvent(*event); - // eventhandling no longer in progess - m_eventHandlingInProgress = false; - delete event; wxENTER_CRIT_SECT( Lock() ); @@ -1469,4 +1457,38 @@ wxWindow* wxFindFocusDescendant(wxWindow* ancestor) return focusWin; } +// ---------------------------------------------------------------------------- +// wxEventBlocker +// ---------------------------------------------------------------------------- + +wxEventBlocker::wxEventBlocker(wxWindow *win, wxEventType type) +{ + wxCHECK_RET(win, wxT("Null window given to wxEventBlocker")); + + m_window = win; + + Block(type); + m_window->PushEventHandler(this); +} + +wxEventBlocker::~wxEventBlocker() +{ + wxEvtHandler *popped = m_window->PopEventHandler(false); + wxCHECK_RET(popped == this, + wxT("Don't push other event handlers into a window managed by wxEventBlocker!")); +} + +bool wxEventBlocker::ProcessEvent(wxEvent& event) +{ + // should this event be blocked? + for ( size_t i = 0; i < m_eventsToBlock.size(); i++ ) + { + wxEventType t = (wxEventType)m_eventsToBlock[i]; + if ( t == wxEVT_ANY || t == event.GetEventType() ) + return true; // yes, it should: mark this event as processed + } + + return false; +} + #endif // wxUSE_GUI