X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c200f9a3b7003a6ef27f079672b7d165b04a59b7..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/osx/iphone/evtloop.mm diff --git a/src/osx/iphone/evtloop.mm b/src/osx/iphone/evtloop.mm index 0b1831b970..8986ef5fa3 100644 --- a/src/osx/iphone/evtloop.mm +++ b/src/osx/iphone/evtloop.mm @@ -4,7 +4,7 @@ // Author: Vadim Zeitlin, Stefan Csomor // Modified by: // Created: 2006-01-12 -// RCS-ID: $Id: evtloop.cpp 54845 2008-07-30 14:52:41Z SC $ +// RCS-ID: $Id$ // Copyright: (c) 2006 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -32,6 +32,10 @@ #include "wx/log.h" +#if wxUSE_GUI + #include "wx/nonownedwnd.h" +#endif + #include "wx/osx/private.h" // ============================================================================ @@ -77,121 +81,67 @@ static int CalculateUIEventMaskFromEventCategory(wxEventCategory cat) wxGUIEventLoop::wxGUIEventLoop() { - m_sleepTime = 0.0; } -void wxGUIEventLoop::WakeUp() +void wxGUIEventLoop::DoRun() { - extern void wxMacWakeUp(); - - wxMacWakeUp(); + if ( IsMain() ) + { + wxMacAutoreleasePool pool; + const char* appname = "app"; + UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" ); + } + else + { + wxCFEventLoop::DoRun(); + } } -CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const +int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout) { - return CFRunLoopGetCurrent(); + return wxCFEventLoop::DoDispatchTimeout(timeout); } -bool wxGUIEventLoop::Pending() const +void wxGUIEventLoop::DoStop() { - wxMacAutoreleasePool autoreleasepool; - // a pointer to the event is returned if there is one, or nil if not - /* - return [[UIApplication sharedApplication] - nextEventMatchingMask: NSAnyEventMask - untilDate: nil - inMode: NSDefaultRunLoopMode - dequeue: NO]; - */ - return false; + return wxCFEventLoop::DoStop(); } -bool wxGUIEventLoop::Dispatch() +CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const { - if ( !wxTheApp ) - return false; - - wxMacAutoreleasePool autoreleasepool; - -/* - if(UIEvent *event = [[UIApplication sharedApplication] - nextEventMatchingMask:NSAnyEventMask - untilDate:[NSDate dateWithTimeIntervalSinceNow: m_sleepTime] - inMode:NSDefaultRunLoopMode - dequeue: YES]) - { - m_sleepTime = 0.0; - [[UIApplication sharedApplication] sendEvent: event]; - } - else -*/ - { - if ( wxTheApp->ProcessIdle() ) - m_sleepTime = 0.0 ; - else - { - m_sleepTime = 1.0; -#if wxUSE_THREADS - wxMutexGuiLeave(); - wxMilliSleep(20); - wxMutexGuiEnter(); -#endif - } - } - - return true; + return wxCFEventLoop::CFGetCurrentRunLoop(); } -bool wxGUIEventLoop::YieldFor(long eventsToProcess) +void wxGUIEventLoop::WakeUp() { -#if wxUSE_THREADS - // Yielding from a non-gui thread needs to bail out, otherwise we end up - // possibly sending events in the thread too. - if ( !wxThread::IsMain() ) - { - return true; - } -#endif // wxUSE_THREADS + return wxCFEventLoop::WakeUp(); +} - m_isInsideYield = true; - m_eventsToProcessInsideYield = eventsToProcess; +// TODO move into a evtloop_osx.cpp -#if wxUSE_LOG - // disable log flushing from here because a call to wxYield() shouldn't - // normally result in message boxes popping up &c - wxLog::Suspend(); -#endif // wxUSE_LOG +wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow) +{ + m_modalWindow = dynamic_cast (modalWindow); + wxASSERT_MSG( m_modalWindow != NULL, "must pass in a toplevel window for modal event loop" ); + m_modalNativeWindow = m_modalWindow->GetWXWindow(); +} - // process all pending events: - while ( Pending() ) - Dispatch(); +wxModalEventLoop::wxModalEventLoop(WXWindow modalNativeWindow) +{ + m_modalWindow = NULL; + wxASSERT_MSG( modalNativeWindow != NULL, "must pass in a toplevel window for modal event loop" ); + m_modalNativeWindow = modalNativeWindow; +} - // it's necessary to call ProcessIdle() to update the frames sizes which - // might have been changed (it also will update other things set from - // OnUpdateUI() which is a nice (and desired) side effect) - while ( ProcessIdle() ) {} +// END move into a evtloop_osx.cpp -#if wxUSE_LOG - wxLog::Resume(); -#endif // wxUSE_LOG - m_isInsideYield = false; - return true; +void wxModalEventLoop::DoRun() +{ + // presentModalViewController:animated: } -int wxGUIEventLoop::DispatchTimeout(unsigned long timeout) +void wxModalEventLoop::DoStop() { - wxMacAutoreleasePool autoreleasepool; -/* - UIEvent *event = [[UIApplication sharedApplication] - nextEventMatchingMask:NSAnyEventMask - untilDate:[NSDate dateWithTimeIntervalSinceNow: timeout/1000] - inMode:NSDefaultRunLoopMode - dequeue: YES]; - if ( !event ) - return -1; - - [NSApp sendEvent: event]; -*/ - return true; + // (void)dismissModalViewControllerAnimated:(BOOL)animated }