]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/evtloop.h
build fix
[wxWidgets.git] / include / wx / msw / evtloop.h
CommitLineData
3754265e
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/evtloop.h
3// Purpose: wxEventLoop class for MSW
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 2004-07-31
7// RCS-ID: $Id$
8// Copyright: (c) 2003-2004 Vadim Zeitlin <vadim@wxwindows.org>
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MSW_EVTLOOP_H_
13#define _WX_MSW_EVTLOOP_H_
14
b46b1d59 15#if wxUSE_GUI
cafed236 16#include "wx/window.h"
b46b1d59 17#endif
cafed236 18
3754265e
VZ
19// ----------------------------------------------------------------------------
20// wxEventLoop
21// ----------------------------------------------------------------------------
22
b46b1d59 23class WXDLLIMPEXP_BASE wxMSWEventLoopBase : public wxEventLoopManual
3754265e
VZ
24{
25public:
b46b1d59 26 wxMSWEventLoopBase();
3754265e
VZ
27
28 // implement base class pure virtuals
3754265e 29 virtual bool Pending() const;
3754265e 30
b46b1d59
VZ
31protected:
32 // get the next message from queue and return true or return false if we
33 // got WM_QUIT or an error occurred
34 bool GetNextMessage(WXMSG *msg);
9af42efd
VZ
35
36 // same as above but with a timeout and return value can be -1 meaning that
37 // time out expired in addition to
38 int GetNextMessageTimeout(WXMSG *msg, unsigned long timeout);
b46b1d59
VZ
39};
40
41#if wxUSE_GUI
42
dde19c21
FM
43WX_DECLARE_OBJARRAY(MSG, wxMSGArray);
44
b46b1d59
VZ
45class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxMSWEventLoopBase
46{
47public:
48 wxGUIEventLoop() { }
49
50 // process a single message: calls PreProcessMessage() before dispatching
51 // it
52 virtual void ProcessMessage(WXMSG *msg);
3754265e
VZ
53
54 // preprocess a message, return true if processed (i.e. no further
55 // dispatching required)
56 virtual bool PreProcessMessage(WXMSG *msg);
57
a7b7500c
VZ
58 // set the critical window: this is the window such that all the events
59 // except those to this window (and its children) stop to be processed
60 // (typical examples: assert or crash report dialog)
61 //
62 // calling this function with NULL argument restores the normal event
63 // handling
b4626104 64 static void SetCriticalWindow(wxWindowMSW *win) { ms_winCritical = win; }
a7b7500c
VZ
65
66 // return true if there is no critical window or if this window is [a child
67 // of] the critical one
b4626104 68 static bool AllowProcessing(wxWindowMSW *win)
a7b7500c
VZ
69 {
70 return !ms_winCritical || IsChildOfCriticalWindow(win);
71 }
72
b80e8ac9 73 // override/implement base class virtuals
b46b1d59 74 virtual bool Dispatch();
9af42efd 75 virtual int DispatchTimeout(unsigned long timeout);
b80e8ac9 76 virtual void WakeUp();
dde19c21 77 virtual bool YieldFor(long eventsToProcess);
b46b1d59
VZ
78
79protected:
b80e8ac9
VZ
80 virtual void OnNextIteration();
81
b46b1d59 82private:
a7b7500c
VZ
83 // check if the given window is a child of ms_winCritical (which must be
84 // non NULL)
b4626104 85 static bool IsChildOfCriticalWindow(wxWindowMSW *win);
a7b7500c 86
dde19c21
FM
87 // array of messages used for temporary storage by YieldFor()
88 wxMSGArray m_arrMSG;
a7b7500c
VZ
89
90 // critical window or NULL
b4626104 91 static wxWindowMSW *ms_winCritical;
3754265e
VZ
92};
93
b46b1d59
VZ
94#else // !wxUSE_GUI
95
61478ea0
VZ
96#if wxUSE_CONSOLE_EVENTLOOP
97
b46b1d59
VZ
98class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxMSWEventLoopBase
99{
100public:
101 wxConsoleEventLoop() { }
102
103 // override/implement base class virtuals
104 virtual bool Dispatch();
9af42efd 105 virtual int DispatchTimeout(unsigned long timeout);
b46b1d59 106 virtual void WakeUp();
a8519f65 107 virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
b46b1d59 108
9af42efd
VZ
109 // MSW-specific function to process a single message
110 virtual void ProcessMessage(WXMSG *msg);
b46b1d59
VZ
111};
112
61478ea0
VZ
113#endif // wxUSE_CONSOLE_EVENTLOOP
114
b46b1d59
VZ
115#endif // wxUSE_GUI/!wxUSE_GUI
116
3754265e 117#endif // _WX_MSW_EVTLOOP_H_