added wxEventLoop::DispatchTimeout()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-26 22:28:34 +00:00
parent aa8cbe0b64
commit 9af42efda6
14 changed files with 216 additions and 38 deletions

View File

@@ -27,6 +27,7 @@ public:
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
// returns DirectFB event buffer used by wx
static wxIDirectFBEventBufferPtr GetDirectFBEventBuffer();

View File

@@ -31,6 +31,7 @@ public:
// using it
virtual bool IsOk() const { return true; }
// start the event loop, return the exit code when it is finished
virtual int Run() = 0;
@@ -43,6 +44,12 @@ public:
// dispatch a single event, return false if we should exit from the loop
virtual bool Dispatch() = 0;
// 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) = 0;
// return currently active (running) event loop, may be NULL
static wxEventLoopBase *GetActive() { return ms_activeLoop; }
@@ -121,6 +128,8 @@ protected:
#include "wx/dfb/evtloop.h"
#else // other platform
#define wxNEEDS_GENERIC_DISPATCH_TIMEOUT
class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl;
class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxEventLoopBase
@@ -133,6 +142,7 @@ public:
virtual void Exit(int rc = 0);
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual void WakeUp() { }
protected:

View File

@@ -32,6 +32,10 @@ protected:
// get the next message from queue and return true or return false if we
// got WM_QUIT or an error occurred
bool GetNextMessage(WXMSG *msg);
// same as above but with a timeout and return value can be -1 meaning that
// time out expired in addition to
int GetNextMessageTimeout(WXMSG *msg, unsigned long timeout);
};
#if wxUSE_GUI
@@ -66,6 +70,7 @@ public:
// override/implement base class virtuals
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual void WakeUp();
protected:
@@ -92,8 +97,12 @@ public:
// override/implement base class virtuals
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual void WakeUp();
// MSW-specific function to process a single message
virtual void ProcessMessage(WXMSG *msg);
protected:
virtual void OnNextIteration();
};

View File

@@ -12,17 +12,25 @@
#ifndef _WX_MAC_CARBON_EVTLOOP_H_
#define _WX_MAC_CARBON_EVTLOOP_H_
class OpaqueEventRef;
typedef OpaqueEventRef *EventRef;
class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxEventLoopManual
{
public:
wxGUIEventLoop();
// implement/override base class pure virtual
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
// implement base class pure virtual
virtual void WakeUp();
private:
// dispatch an event and release it
void DispatchAndReleaseEvent(EventRef event);
double m_sleepTime;
};

View File

@@ -26,6 +26,7 @@ public:
virtual void Exit(int rc = 0);
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual bool IsRunning() const;
// MSW-specific methods

View File

@@ -29,6 +29,7 @@ public:
// implement base class pure virtuals
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual void WakeUp();
virtual bool IsOk() const { return m_dispatcher != NULL; }