]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/evtloop.h
Skeleton for generic Drag code
[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/window.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // wxEventLoop
21 // ----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_BASE wxMSWEventLoopBase : public wxEventLoopManual
24 {
25 public:
26 wxMSWEventLoopBase();
27
28 // implement base class pure virtuals
29 virtual bool Pending() const;
30
31 protected:
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);
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);
39 };
40
41 #if wxUSE_GUI
42
43 class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxMSWEventLoopBase
44 {
45 public:
46 wxGUIEventLoop() { }
47
48 // process a single message: calls PreProcessMessage() before dispatching
49 // it
50 virtual void ProcessMessage(WXMSG *msg);
51
52 // preprocess a message, return true if processed (i.e. no further
53 // dispatching required)
54 virtual bool PreProcessMessage(WXMSG *msg);
55
56 // set the critical window: this is the window such that all the events
57 // except those to this window (and its children) stop to be processed
58 // (typical examples: assert or crash report dialog)
59 //
60 // calling this function with NULL argument restores the normal event
61 // handling
62 static void SetCriticalWindow(wxWindowMSW *win) { ms_winCritical = win; }
63
64 // return true if there is no critical window or if this window is [a child
65 // of] the critical one
66 static bool AllowProcessing(wxWindowMSW *win)
67 {
68 return !ms_winCritical || IsChildOfCriticalWindow(win);
69 }
70
71 // override/implement base class virtuals
72 virtual bool Dispatch();
73 virtual int DispatchTimeout(unsigned long timeout);
74 virtual void WakeUp();
75
76 protected:
77 virtual void OnNextIteration();
78
79 private:
80 // check if the given window is a child of ms_winCritical (which must be
81 // non NULL)
82 static bool IsChildOfCriticalWindow(wxWindowMSW *win);
83
84
85 // critical window or NULL
86 static wxWindowMSW *ms_winCritical;
87 };
88
89 #else // !wxUSE_GUI
90
91 #if wxUSE_CONSOLE_EVENTLOOP
92
93 class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxMSWEventLoopBase
94 {
95 public:
96 wxConsoleEventLoop() { }
97
98 // override/implement base class virtuals
99 virtual bool Dispatch();
100 virtual int DispatchTimeout(unsigned long timeout);
101 virtual void WakeUp();
102
103 // MSW-specific function to process a single message
104 virtual void ProcessMessage(WXMSG *msg);
105 };
106
107 #endif // wxUSE_CONSOLE_EVENTLOOP
108
109 #endif // wxUSE_GUI/!wxUSE_GUI
110
111 #endif // _WX_MSW_EVTLOOP_H_