]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/evtloop.h
Add wxToolBarToolBase, missing flags, etc.
[wxWidgets.git] / include / wx / msw / evtloop.h
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
15 #if wxUSE_GUI
16 #include "wx/dynarray.h"
17 #include "wx/msw/wrapwin.h"
18 #include "wx/window.h"
19 #endif
20
21 // ----------------------------------------------------------------------------
22 // wxEventLoop
23 // ----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_BASE wxMSWEventLoopBase : public wxEventLoopManual
26 {
27 public:
28 wxMSWEventLoopBase();
29
30 // implement base class pure virtuals
31 virtual bool Pending() const;
32
33 protected:
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);
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);
41 };
42
43 #if wxUSE_GUI
44
45 WX_DECLARE_EXPORTED_OBJARRAY(MSG, wxMSGArray);
46
47 class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxMSWEventLoopBase
48 {
49 public:
50 wxGUIEventLoop() { }
51
52 // process a single message: calls PreProcessMessage() before dispatching
53 // it
54 virtual void ProcessMessage(WXMSG *msg);
55
56 // preprocess a message, return true if processed (i.e. no further
57 // dispatching required)
58 virtual bool PreProcessMessage(WXMSG *msg);
59
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
66 static void SetCriticalWindow(wxWindowMSW *win) { ms_winCritical = win; }
67
68 // return true if there is no critical window or if this window is [a child
69 // of] the critical one
70 static bool AllowProcessing(wxWindowMSW *win)
71 {
72 return !ms_winCritical || IsChildOfCriticalWindow(win);
73 }
74
75 // override/implement base class virtuals
76 virtual bool Dispatch();
77 virtual int DispatchTimeout(unsigned long timeout);
78 virtual void WakeUp();
79 virtual bool YieldFor(long eventsToProcess);
80
81 protected:
82 virtual void OnNextIteration();
83
84 private:
85 // check if the given window is a child of ms_winCritical (which must be
86 // non NULL)
87 static bool IsChildOfCriticalWindow(wxWindowMSW *win);
88
89 // array of messages used for temporary storage by YieldFor()
90 wxMSGArray m_arrMSG;
91
92 // critical window or NULL
93 static wxWindowMSW *ms_winCritical;
94 };
95
96 #else // !wxUSE_GUI
97
98 #if wxUSE_CONSOLE_EVENTLOOP
99
100 class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxMSWEventLoopBase
101 {
102 public:
103 wxConsoleEventLoop() { }
104
105 // override/implement base class virtuals
106 virtual bool Dispatch();
107 virtual int DispatchTimeout(unsigned long timeout);
108 virtual void WakeUp();
109 virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
110
111 // MSW-specific function to process a single message
112 virtual void ProcessMessage(WXMSG *msg);
113 };
114
115 #endif // wxUSE_CONSOLE_EVENTLOOP
116
117 #endif // wxUSE_GUI/!wxUSE_GUI
118
119 #endif // _WX_MSW_EVTLOOP_H_