2004-07-30 18:54:31 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/msw/evtloop.h
|
|
|
|
// Purpose: wxEventLoop class for MSW
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2004-07-31
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2003-2004 Vadim Zeitlin <vadim@wxwindows.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_MSW_EVTLOOP_H_
|
|
|
|
#define _WX_MSW_EVTLOOP_H_
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
#if wxUSE_GUI
|
2009-02-15 14:34:58 -05:00
|
|
|
#include "wx/dynarray.h"
|
|
|
|
#include "wx/msw/wrapwin.h"
|
2006-01-15 05:13:40 -05:00
|
|
|
#include "wx/window.h"
|
2007-05-14 19:43:39 -04:00
|
|
|
#endif
|
2006-01-15 05:13:40 -05:00
|
|
|
|
2004-07-30 18:54:31 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxEventLoop
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxMSWEventLoopBase : public wxEventLoopManual
|
2004-07-30 18:54:31 -04:00
|
|
|
{
|
|
|
|
public:
|
2007-05-14 19:43:39 -04:00
|
|
|
wxMSWEventLoopBase();
|
2004-07-30 18:54:31 -04:00
|
|
|
|
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual bool Pending() const;
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
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);
|
2008-12-26 17:28:34 -05:00
|
|
|
|
|
|
|
// 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);
|
2007-05-14 19:43:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#if wxUSE_GUI
|
|
|
|
|
2009-02-26 09:15:20 -05:00
|
|
|
WX_DECLARE_EXPORTED_OBJARRAY(MSG, wxMSGArray);
|
2009-02-15 09:25:08 -05:00
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxMSWEventLoopBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxGUIEventLoop() { }
|
|
|
|
|
|
|
|
// process a single message: calls PreProcessMessage() before dispatching
|
|
|
|
// it
|
|
|
|
virtual void ProcessMessage(WXMSG *msg);
|
2004-07-30 18:54:31 -04:00
|
|
|
|
|
|
|
// preprocess a message, return true if processed (i.e. no further
|
|
|
|
// dispatching required)
|
|
|
|
virtual bool PreProcessMessage(WXMSG *msg);
|
|
|
|
|
2005-07-15 18:57:49 -04:00
|
|
|
// set the critical window: this is the window such that all the events
|
|
|
|
// except those to this window (and its children) stop to be processed
|
|
|
|
// (typical examples: assert or crash report dialog)
|
|
|
|
//
|
|
|
|
// calling this function with NULL argument restores the normal event
|
|
|
|
// handling
|
2005-07-18 09:36:31 -04:00
|
|
|
static void SetCriticalWindow(wxWindowMSW *win) { ms_winCritical = win; }
|
2005-07-15 18:57:49 -04:00
|
|
|
|
|
|
|
// return true if there is no critical window or if this window is [a child
|
|
|
|
// of] the critical one
|
2005-07-18 09:36:31 -04:00
|
|
|
static bool AllowProcessing(wxWindowMSW *win)
|
2005-07-15 18:57:49 -04:00
|
|
|
{
|
|
|
|
return !ms_winCritical || IsChildOfCriticalWindow(win);
|
|
|
|
}
|
|
|
|
|
2006-01-12 20:31:37 -05:00
|
|
|
// override/implement base class virtuals
|
2007-05-14 19:43:39 -04:00
|
|
|
virtual bool Dispatch();
|
2008-12-26 17:28:34 -05:00
|
|
|
virtual int DispatchTimeout(unsigned long timeout);
|
2006-01-12 20:31:37 -05:00
|
|
|
virtual void WakeUp();
|
2009-02-15 09:25:08 -05:00
|
|
|
virtual bool YieldFor(long eventsToProcess);
|
2007-05-14 19:43:39 -04:00
|
|
|
|
|
|
|
protected:
|
2006-01-12 20:31:37 -05:00
|
|
|
virtual void OnNextIteration();
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
private:
|
2005-07-15 18:57:49 -04:00
|
|
|
// check if the given window is a child of ms_winCritical (which must be
|
|
|
|
// non NULL)
|
2005-07-18 09:36:31 -04:00
|
|
|
static bool IsChildOfCriticalWindow(wxWindowMSW *win);
|
2005-07-15 18:57:49 -04:00
|
|
|
|
2009-02-15 09:25:08 -05:00
|
|
|
// array of messages used for temporary storage by YieldFor()
|
|
|
|
wxMSGArray m_arrMSG;
|
2005-07-15 18:57:49 -04:00
|
|
|
|
|
|
|
// critical window or NULL
|
2005-07-18 09:36:31 -04:00
|
|
|
static wxWindowMSW *ms_winCritical;
|
2004-07-30 18:54:31 -04:00
|
|
|
};
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
#else // !wxUSE_GUI
|
|
|
|
|
2007-07-15 15:33:16 -04:00
|
|
|
#if wxUSE_CONSOLE_EVENTLOOP
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxMSWEventLoopBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxConsoleEventLoop() { }
|
|
|
|
|
|
|
|
// override/implement base class virtuals
|
|
|
|
virtual bool Dispatch();
|
2008-12-26 17:28:34 -05:00
|
|
|
virtual int DispatchTimeout(unsigned long timeout);
|
2007-05-14 19:43:39 -04:00
|
|
|
virtual void WakeUp();
|
2009-02-15 09:54:31 -05:00
|
|
|
virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
|
2007-05-14 19:43:39 -04:00
|
|
|
|
2008-12-26 17:28:34 -05:00
|
|
|
// MSW-specific function to process a single message
|
|
|
|
virtual void ProcessMessage(WXMSG *msg);
|
2007-05-14 19:43:39 -04:00
|
|
|
};
|
|
|
|
|
2007-07-15 15:33:16 -04:00
|
|
|
#endif // wxUSE_CONSOLE_EVENTLOOP
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
#endif // wxUSE_GUI/!wxUSE_GUI
|
|
|
|
|
2004-07-30 18:54:31 -04:00
|
|
|
#endif // _WX_MSW_EVTLOOP_H_
|