X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7214297d16aed4c160c1cbef6b19f153ca065ab7..ec5d85fbd58bf6ef774e3d93b9e38d9f90b42d40:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index a1123fdf19..2f4f8be170 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -80,8 +80,8 @@ #if wxUSE_THREADS /* To put pending event handlers */ -extern wxList wxPendingEvents; -extern wxCriticalSection wxPendingEventsLocker; +extern wxList *wxPendingEvents; +extern wxCriticalSection *wxPendingEventsLocker; #endif /* @@ -105,6 +105,22 @@ wxEvent::wxEvent(int theId) m_isCommandEvent = FALSE; } +wxObject *wxEvent::Clone() const +{ + wxEvent *event = (wxEvent *)wxObject::Clone(); + + event->m_eventType = m_eventType; + event->m_eventObject = m_eventObject; + event->m_eventHandle = m_eventHandle; + event->m_timeStamp = m_timeStamp; + event->m_id = m_id; + event->m_skipped = m_skipped; + event->m_callbackUserData = m_callbackUserData; + event->m_isCommandEvent = m_isCommandEvent; + + return event; +} + /* * Command events * @@ -118,7 +134,7 @@ wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId) m_extraLong = 0; m_commandInt = 0; m_id = theId; - m_commandString = (char *) NULL; + m_commandString = (wxChar *) NULL; m_isCommandEvent = TRUE; } @@ -171,7 +187,7 @@ bool wxMouseEvent::ButtonDClick(int but) const case 3: return RightDClick(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDClick"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDClick")); } return FALSE; @@ -192,7 +208,7 @@ bool wxMouseEvent::ButtonDown(int but) const case 3: return RightDown(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDown"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDown")); } return FALSE; @@ -212,7 +228,7 @@ bool wxMouseEvent::ButtonUp(int but) const case 3: return RightUp(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonUp"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonUp")); } return FALSE; @@ -231,7 +247,7 @@ bool wxMouseEvent::Button(int but) const case 3: return (RightDown() || RightUp() || RightDClick()); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::Button"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::Button")); } return FALSE; @@ -249,7 +265,7 @@ bool wxMouseEvent::ButtonIsDown(int but) const case 3: return RightIsDown(); default: - wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonIsDown"); + wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonIsDown")); } return FALSE; @@ -317,10 +333,10 @@ wxEvtHandler::~wxEvtHandler() delete m_dynamicEvents; }; +#if wxUSE_THREADS if (m_pendingEvents) delete m_pendingEvents; -#if wxUSE_THREADS delete m_eventsLocker; #endif } @@ -337,14 +353,13 @@ bool wxEvtHandler::ProcessThreadEvent(wxEvent& event) if (m_pendingEvents == NULL) m_pendingEvents = new wxList(); - event_main = (wxEvent *)event.GetClassInfo()->CreateObject(); - *event_main = event; + event_main = (wxEvent *)event.Clone(); m_pendingEvents->Append(event_main); - wxPendingEventsLocker.Enter(); - wxPendingEvents.Append(this); - wxPendingEventsLocker.Leave(); + wxPendingEventsLocker->Enter(); + wxPendingEvents->Append(this); + wxPendingEventsLocker->Leave(); return TRUE; } @@ -511,7 +526,7 @@ void wxEvtHandler::Connect( int id, int lastId, bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) { wxCHECK_MSG( m_dynamicEvents, FALSE, - "caller should check that we have dynamic events" ); + _T("caller should check that we have dynamic events") ); int commandId = event.GetId(); @@ -555,3 +570,26 @@ bool wxEvtHandler::OnClose() } #endif // WXWIN_COMPATIBILITY +// Find a window with the focus, that is also a descendant of the given window. +// This is used to determine the window to initially send commands to. +wxWindow* wxFindFocusDescendant(wxWindow* ancestor) +{ + // Process events starting with the window with the focus, if any. + wxWindow* focusWin = wxWindow::FindFocus(); + wxWindow* win = focusWin; + + // Check if this is a descendant of this frame. + // If not, win will be set to NULL. + while (win) + { + if (win == ancestor) + break; + else + win = win->GetParent(); + } + if (win == (wxWindow*) NULL) + focusWin = (wxWindow*) NULL; + + return focusWin; +} +