X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a5bbc2027867925c38024ad1025ac1e04d1bf473..209ce629ac70e21ba2239c36a9c2ad7571964ce2:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index c254930217..68a17045f2 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -48,10 +48,10 @@ #if wxUSE_BASE IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) + IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent) #endif // wxUSE_BASE #if wxUSE_GUI - IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) @@ -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 @@ -172,9 +173,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_COMBOBOX_SELECTED) 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) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED) // Mouse event types DEFINE_EVENT_TYPE(wxEVT_LEFT_DOWN) @@ -310,6 +309,8 @@ DEFINE_EVENT_TYPE(wxEVT_DETAILED_HELP) #if wxUSE_BASE +wxIdleMode wxIdleEvent::sm_idleMode = wxIDLE_PROCESS_ALL; + // ============================================================================ // implementation // ============================================================================ @@ -352,7 +353,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 +381,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; @@ -473,25 +471,6 @@ void wxUpdateUIEvent::ResetUpdateTime() #endif } -/* - * Idle events - */ - -wxIdleMode wxIdleEvent::sm_idleMode = wxIDLE_PROCESS_ALL; - -// Can we send an idle event? -bool wxIdleEvent::CanSend(wxWindow* win) -{ - // Don't update if we've switched global updating off - // and this window doesn't support updates. - if (win && - (GetMode() == wxIDLE_PROCESS_SPECIFIED && - ((win->GetExtraStyle() & wxWS_EX_PROCESS_IDLE) == 0))) - return false; - - return true; -} - /* * Scroll events */ @@ -539,6 +518,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 +540,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 @@ -1028,9 +1009,10 @@ wxEvtHandler::~wxEvtHandler() if (m_dynamicEvents) { - wxList::iterator it = m_dynamicEvents->begin(), - en = m_dynamicEvents->end(); - for (;it != en; ++it) + for ( wxList::iterator it = m_dynamicEvents->begin(), + end = m_dynamicEvents->end(); + it != end; + ++it ) { #if WXWIN_COMPATIBILITY_EVENT_TYPES wxEventTableEntry *entry = (wxEventTableEntry*)*it; @@ -1460,4 +1442,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