evtloop.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/evtloop.h
  3. // Purpose: wxEventLoop class for wxMSW port
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 2004-07-31
  7. // Copyright: (c) 2003-2004 Vadim Zeitlin <vadim@wxwindows.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MSW_EVTLOOP_H_
  11. #define _WX_MSW_EVTLOOP_H_
  12. #include "wx/dynarray.h"
  13. #include "wx/msw/wrapwin.h"
  14. #include "wx/window.h"
  15. #include "wx/msw/evtloopconsole.h" // for wxMSWEventLoopBase
  16. // ----------------------------------------------------------------------------
  17. // wxEventLoop
  18. // ----------------------------------------------------------------------------
  19. WX_DECLARE_EXPORTED_OBJARRAY(MSG, wxMSGArray);
  20. class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxMSWEventLoopBase
  21. {
  22. public:
  23. wxGUIEventLoop() { }
  24. // process a single message: calls PreProcessMessage() before dispatching
  25. // it
  26. virtual void ProcessMessage(WXMSG *msg);
  27. // preprocess a message, return true if processed (i.e. no further
  28. // dispatching required)
  29. virtual bool PreProcessMessage(WXMSG *msg);
  30. // set the critical window: this is the window such that all the events
  31. // except those to this window (and its children) stop to be processed
  32. // (typical examples: assert or crash report dialog)
  33. //
  34. // calling this function with NULL argument restores the normal event
  35. // handling
  36. static void SetCriticalWindow(wxWindowMSW *win) { ms_winCritical = win; }
  37. // return true if there is no critical window or if this window is [a child
  38. // of] the critical one
  39. static bool AllowProcessing(wxWindowMSW *win)
  40. {
  41. return !ms_winCritical || IsChildOfCriticalWindow(win);
  42. }
  43. // override/implement base class virtuals
  44. virtual bool Dispatch();
  45. virtual int DispatchTimeout(unsigned long timeout);
  46. virtual void WakeUp();
  47. virtual bool YieldFor(long eventsToProcess);
  48. protected:
  49. virtual void OnNextIteration();
  50. private:
  51. // check if the given window is a child of ms_winCritical (which must be
  52. // non NULL)
  53. static bool IsChildOfCriticalWindow(wxWindowMSW *win);
  54. // array of messages used for temporary storage by YieldFor()
  55. wxMSGArray m_arrMSG;
  56. // critical window or NULL
  57. static wxWindowMSW *ms_winCritical;
  58. };
  59. #endif // _WX_MSW_EVTLOOP_H_