1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/evtloop.h
3 // Purpose: wxEventLoop class for MSW
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003-2004 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_EVTLOOP_H_
13 #define _WX_MSW_EVTLOOP_H_
16 #include "wx/dynarray.h"
17 #include "wx/msw/wrapwin.h"
18 #include "wx/window.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class WXDLLIMPEXP_BASE wxMSWEventLoopBase
: public wxEventLoopManual
30 // implement base class pure virtuals
31 virtual bool Pending() const;
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
);
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
);
45 WX_DECLARE_OBJARRAY(MSG
, wxMSGArray
);
47 class WXDLLIMPEXP_CORE wxGUIEventLoop
: public wxMSWEventLoopBase
52 // process a single message: calls PreProcessMessage() before dispatching
54 virtual void ProcessMessage(WXMSG
*msg
);
56 // preprocess a message, return true if processed (i.e. no further
57 // dispatching required)
58 virtual bool PreProcessMessage(WXMSG
*msg
);
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)
64 // calling this function with NULL argument restores the normal event
66 static void SetCriticalWindow(wxWindowMSW
*win
) { ms_winCritical
= win
; }
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
)
72 return !ms_winCritical
|| IsChildOfCriticalWindow(win
);
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
);
82 virtual void OnNextIteration();
85 // check if the given window is a child of ms_winCritical (which must be
87 static bool IsChildOfCriticalWindow(wxWindowMSW
*win
);
89 // array of messages used for temporary storage by YieldFor()
92 // critical window or NULL
93 static wxWindowMSW
*ms_winCritical
;
98 #if wxUSE_CONSOLE_EVENTLOOP
100 class WXDLLIMPEXP_BASE wxConsoleEventLoop
: public wxMSWEventLoopBase
103 wxConsoleEventLoop() { }
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; }
111 // MSW-specific function to process a single message
112 virtual void ProcessMessage(WXMSG
*msg
);
115 #endif // wxUSE_CONSOLE_EVENTLOOP
117 #endif // wxUSE_GUI/!wxUSE_GUI
119 #endif // _WX_MSW_EVTLOOP_H_