X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b46b1d59d6f69ad80dcf5955375578a6504d100a..76e7cfab8fdb0c7862fd07e427af54181717fc62:/src/os2/evtloop.cpp diff --git a/src/os2/evtloop.cpp b/src/os2/evtloop.cpp index da4a396c41..0267057888 100644 --- a/src/os2/evtloop.cpp +++ b/src/os2/evtloop.cpp @@ -4,9 +4,8 @@ // Author: Vadim Zeitlin // Modified by: // Created: 01.06.01 -// RCS-ID: $Id$ // Copyright: (c) 2001 Vadim Zeitlin -// License: wxWindows licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -33,7 +32,7 @@ #include "wx/evtloop.h" #include "wx/tooltip.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/os2/private.h" #include "wx/os2/private/timer.h" // for wxTimerProc @@ -206,7 +205,7 @@ bool wxEventLoopImpl::SendIdleMessage() wxGUIEventLoop::~wxGUIEventLoop() { - wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") ); + wxASSERT_MSG( !m_impl, wxT("should have been deleted in Run()") ); } ////////////////////////////////////////////////////////////////////////////// @@ -241,7 +240,7 @@ private: int wxGUIEventLoop::Run() { // event loops are not recursive, you need to create another loop! - wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") ); + wxCHECK_MSG( !IsRunning(), -1, wxT("can't reenter a message loop") ); // SendIdleMessage() and Dispatch() below may throw so the code here should // be exception-safe, hence we must use local objects for all actions we @@ -285,7 +284,7 @@ int wxGUIEventLoop::Run() void wxGUIEventLoop::Exit(int rc) { - wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") ); + wxCHECK_RET( IsRunning(), wxT("can't call Exit() if not running") ); m_impl->SetExitCode(rc); @@ -304,7 +303,7 @@ bool wxGUIEventLoop::Pending() const bool wxGUIEventLoop::Dispatch() { - wxCHECK_MSG( IsRunning(), false, _T("can't call Dispatch() if not running") ); + wxCHECK_MSG( IsRunning(), false, wxT("can't call Dispatch() if not running") ); QMSG msg; BOOL bRc = ::WinGetMsg(vHabmain, &msg, (HWND) NULL, 0, 0); @@ -365,3 +364,53 @@ bool wxGUIEventLoop::Dispatch() return true; } + +// +// Yield to incoming messages +// +bool wxGUIEventLoop::YieldFor(long eventsToProcess) +{ + HAB vHab = 0; + QMSG vMsg; + + // + // Disable log flushing from here because a call to wxYield() shouldn't + // normally result in message boxes popping up &c + // + wxLog::Suspend(); + + m_isInsideYield = true; + m_eventsToProcessInsideYield = eventsToProcess; + + // + // We want to go back to the main message loop + // if we see a WM_QUIT. (?) + // + while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT) + { + // TODO: implement event filtering using the eventsToProcess mask + +#if wxUSE_THREADS + wxMutexGuiLeaveOrEnter(); +#endif // wxUSE_THREADS + if (!wxTheApp->Dispatch()) + break; + } + + // + // If they are pending events, we must process them. + // + if (wxTheApp) + { + wxTheApp->ProcessPendingEvents(); + wxTheApp->HandleSockets(); + } + + // + // Let the logs be flashed again + // + wxLog::Resume(); + m_isInsideYield = false; + + return true; +} // end of wxYield