2008-06-11 12:30:48 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2010-07-13 09:29:58 -04:00
|
|
|
// Name: wx/osx/evtloop.h
|
|
|
|
// Purpose: simply forwards to wx/osx/carbon/evtloop.h or
|
|
|
|
// wx/osx/cocoa/evtloop.h for consistency with the other Mac
|
|
|
|
// headers
|
2008-06-11 12:30:48 -04:00
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2006-01-12
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-10-22 07:36:35 -04:00
|
|
|
#ifndef _WX_OSX_EVTLOOP_H_
|
|
|
|
#define _WX_OSX_EVTLOOP_H_
|
2008-06-11 12:30:48 -04:00
|
|
|
|
2010-03-15 15:31:57 -04:00
|
|
|
DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoop );
|
|
|
|
DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopObserver );
|
2009-10-22 07:36:35 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxCFEventLoop : public wxEventLoopBase
|
2009-10-22 07:36:35 -04:00
|
|
|
{
|
|
|
|
public:
|
2010-03-15 11:40:47 -04:00
|
|
|
wxCFEventLoop();
|
|
|
|
virtual ~wxCFEventLoop();
|
|
|
|
|
|
|
|
// enters a loop calling OnNextIteration(), Pending() and Dispatch() and
|
|
|
|
// terminating when Exit() is called
|
|
|
|
virtual int Run();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
// sets the "should exit" flag and wakes up the loop so that it terminates
|
|
|
|
// soon
|
|
|
|
virtual void Exit(int rc = 0);
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
// return true if any events are available
|
|
|
|
virtual bool Pending() const;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
// dispatch a single event, return false if we should exit from the loop
|
|
|
|
virtual bool Dispatch();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
// same as Dispatch() but doesn't wait for longer than the specified (in
|
|
|
|
// ms) timeout, return true if an event was processed, false if we should
|
|
|
|
// exit the loop or -1 if timeout expired
|
|
|
|
virtual int DispatchTimeout(unsigned long timeout);
|
|
|
|
|
|
|
|
// implement this to wake up the loop: usually done by posting a dummy event
|
|
|
|
// to it (can be called from non main thread)
|
|
|
|
virtual void WakeUp();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
virtual bool YieldFor(long eventsToProcess);
|
|
|
|
|
2009-10-22 07:36:35 -04:00
|
|
|
#if wxUSE_EVENTLOOP_SOURCE
|
|
|
|
virtual wxEventLoopSource *
|
|
|
|
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
|
|
|
|
#endif // wxUSE_EVENTLOOP_SOURCE
|
|
|
|
|
2010-03-15 15:31:57 -04:00
|
|
|
void ObserverCallBack(CFRunLoopObserverRef observer, int activity);
|
|
|
|
|
2009-10-22 07:36:35 -04:00
|
|
|
protected:
|
|
|
|
// get the currently executing CFRunLoop
|
2010-03-15 11:40:47 -04:00
|
|
|
virtual CFRunLoopRef CFGetCurrentRunLoop() const;
|
|
|
|
|
|
|
|
virtual int DoDispatchTimeout(unsigned long timeout);
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-17 03:14:03 -04:00
|
|
|
virtual void DoRun();
|
2010-03-15 11:40:47 -04:00
|
|
|
|
2010-03-17 03:14:03 -04:00
|
|
|
virtual void DoStop();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
// should we exit the loop?
|
|
|
|
bool m_shouldExit;
|
|
|
|
|
|
|
|
// the loop exit code
|
|
|
|
int m_exitcode;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-17 04:05:04 -04:00
|
|
|
// cfrunloop
|
|
|
|
CFRunLoopRef m_runLoop;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 15:31:57 -04:00
|
|
|
// runloop observer
|
|
|
|
CFRunLoopObserverRef m_runLoopObserver;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-15 11:40:47 -04:00
|
|
|
private:
|
|
|
|
// process all already pending events and dispatch a new one (blocking
|
|
|
|
// until it appears in the event queue if necessary)
|
|
|
|
//
|
|
|
|
// returns the return value of DoDispatchTimeout()
|
|
|
|
int DoProcessEvents();
|
2009-10-22 07:36:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#if wxUSE_GUI
|
2010-03-17 03:14:03 -04:00
|
|
|
|
|
|
|
#ifdef __WXOSX_COCOA__
|
|
|
|
#include "wx/osx/cocoa/evtloop.h"
|
|
|
|
#else
|
|
|
|
#include "wx/osx/carbon/evtloop.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
|
|
|
|
{
|
|
|
|
public:
|
2010-04-08 05:46:36 -04:00
|
|
|
wxModalEventLoop(wxWindow *modalWindow);
|
|
|
|
wxModalEventLoop(WXWindow modalNativeWindow);
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-17 03:14:03 -04:00
|
|
|
protected:
|
|
|
|
virtual void DoRun();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-17 03:14:03 -04:00
|
|
|
virtual void DoStop();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-03-17 03:14:03 -04:00
|
|
|
// (in case) the modal window for this event loop
|
|
|
|
wxNonOwnedWindow* m_modalWindow;
|
2010-04-08 05:46:36 -04:00
|
|
|
WXWindow m_modalNativeWindow;
|
2010-03-17 03:14:03 -04:00
|
|
|
};
|
|
|
|
|
2009-10-22 07:36:35 -04:00
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
|
|
|
#endif // _WX_OSX_EVTLOOP_H_
|