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
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
#if wxUSE_GUI
|
|
|
|
|
|
|
|
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();
|
2006-01-12 20:31:37 -05:00
|
|
|
virtual void WakeUp();
|
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
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxMSWEventLoopBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxConsoleEventLoop() { }
|
|
|
|
|
|
|
|
// override/implement base class virtuals
|
|
|
|
virtual bool Dispatch();
|
|
|
|
virtual void WakeUp();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void OnNextIteration();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_GUI/!wxUSE_GUI
|
|
|
|
|
2004-07-30 18:54:31 -04:00
|
|
|
#endif // _WX_MSW_EVTLOOP_H_
|