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