#include "wx/log.h"
+#if wxUSE_GUI
+ #include "wx/nonownedwnd.h"
+#endif
+
#include "wx/osx/private.h"
// ============================================================================
wxGUIEventLoop::wxGUIEventLoop()
{
- m_sleepTime = 0.0;
-}
-
-void wxGUIEventLoop::WakeUp()
-{
- extern void wxMacWakeUp();
-
- wxMacWakeUp();
-}
-
-bool wxGUIEventLoop::Pending() const
-{
- 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;
}
-bool wxGUIEventLoop::Dispatch()
+void wxGUIEventLoop::DoRun()
{
- if ( !wxTheApp )
- return false;
-
- wxMacAutoreleasePool autoreleasepool;
-
-/*
- if(UIEvent *event = [[UIApplication sharedApplication]
- nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate dateWithTimeIntervalSinceNow: m_sleepTime]
- inMode:NSDefaultRunLoopMode
- dequeue: YES])
+ if ( IsMain() )
{
- m_sleepTime = 0.0;
- [[UIApplication sharedApplication] sendEvent: event];
+ wxMacAutoreleasePool pool;
+ const char* appname = "app";
+ UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" );
}
- else
-*/
+ else
{
- if ( wxTheApp->ProcessIdle() )
- m_sleepTime = 0.0 ;
- else
- {
- m_sleepTime = 1.0;
-#if wxUSE_THREADS
- wxMutexGuiLeave();
- wxMilliSleep(20);
- wxMutexGuiEnter();
-#endif
- }
+ wxCFEventLoop::DoRun();
}
-
- return true;
}
-bool wxGUIEventLoop::YieldFor(long eventsToProcess)
+int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout)
{
-#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::DoDispatchTimeout(timeout);
+}
- m_isInsideYield = true;
- m_eventsToProcessInsideYield = eventsToProcess;
+void wxGUIEventLoop::DoStop()
+{
+ return wxCFEventLoop::DoStop();
+}
+// 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<wxNonOwnedWindow*> (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
}