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/window.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 class WXDLLIMPEXP_BASE wxMSWEventLoopBase
: public wxEventLoopManual
28 // implement base class pure virtuals
29 virtual bool Pending() const;
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
);
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
);
43 WX_DECLARE_OBJARRAY(MSG
, wxMSGArray
);
45 class WXDLLIMPEXP_CORE wxGUIEventLoop
: public wxMSWEventLoopBase
50 // process a single message: calls PreProcessMessage() before dispatching
52 virtual void ProcessMessage(WXMSG
*msg
);
54 // preprocess a message, return true if processed (i.e. no further
55 // dispatching required)
56 virtual bool PreProcessMessage(WXMSG
*msg
);
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)
62 // calling this function with NULL argument restores the normal event
64 static void SetCriticalWindow(wxWindowMSW
*win
) { ms_winCritical
= win
; }
66 // return true if there is no critical window or if this window is [a child
67 // of] the critical one
68 static bool AllowProcessing(wxWindowMSW
*win
)
70 return !ms_winCritical
|| IsChildOfCriticalWindow(win
);
73 // override/implement base class virtuals
74 virtual bool Dispatch();
75 virtual int DispatchTimeout(unsigned long timeout
);
76 virtual void WakeUp();
77 virtual bool YieldFor(long eventsToProcess
);
80 virtual void OnNextIteration();
83 // check if the given window is a child of ms_winCritical (which must be
85 static bool IsChildOfCriticalWindow(wxWindowMSW
*win
);
87 // array of messages used for temporary storage by YieldFor()
90 // critical window or NULL
91 static wxWindowMSW
*ms_winCritical
;
96 #if wxUSE_CONSOLE_EVENTLOOP
98 class WXDLLIMPEXP_BASE wxConsoleEventLoop
: public wxMSWEventLoopBase
101 wxConsoleEventLoop() { }
103 // override/implement base class virtuals
104 virtual bool Dispatch();
105 virtual int DispatchTimeout(unsigned long timeout
);
106 virtual void WakeUp();
107 virtual bool YieldFor(long WXUNUSED(eventsToProcess
)) { return true; }
109 // MSW-specific function to process a single message
110 virtual void ProcessMessage(WXMSG
*msg
);
113 #endif // wxUSE_CONSOLE_EVENTLOOP
115 #endif // wxUSE_GUI/!wxUSE_GUI
117 #endif // _WX_MSW_EVTLOOP_H_