]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/evtloop.h
d6e632fa7c1fcbcbfefc5d85f3821a32ea160e06
[wxWidgets.git] / include / wx / gtk / evtloop.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/evtloop.h
3 // Purpose: wxGTK event loop implementation
4 // Author: Vadim Zeitlin
5 // Created: 2008-12-27
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_GTK_EVTLOOP_H_
12 #define _WX_GTK_EVTLOOP_H_
13
14 // ----------------------------------------------------------------------------
15 // wxGUIEventLoop for wxGTK
16 // ----------------------------------------------------------------------------
17
18 typedef union _GdkEvent GdkEvent;
19
20 #if wxUSE_EVENTLOOP_SOURCE
21 // maps event loop sources to gtk source ids
22 WX_DECLARE_HASH_MAP(wxUnixEventLoopSource*, int, wxPointerHash, wxPointerEqual,
23 wxEventLoopSourceIdMap);
24 #endif
25
26 class WXDLLIMPEXP_BASE wxGUIEventLoop : public wxEventLoopBase
27 {
28 public:
29 typedef wxUnixEventLoopSource Source;
30
31 wxGUIEventLoop();
32
33 virtual int Run();
34 virtual void Exit(int rc = 0);
35 virtual bool Pending() const;
36 virtual bool Dispatch();
37 virtual int DispatchTimeout(unsigned long timeout);
38 virtual void WakeUp();
39 virtual bool YieldFor(long eventsToProcess);
40
41 void StoreGdkEventForLaterProcessing(GdkEvent* ev)
42 { m_arrGdkEvents.Add(ev); }
43
44 #if wxUSE_EVENTLOOP_SOURCE
45 virtual wxUnixEventLoopSource* CreateSource() const
46 {
47 return new wxUnixEventLoopSource();
48 }
49
50 virtual wxUnixEventLoopSource* CreateSource(int res,
51 wxEventLoopSourceHandler* handler,
52 int flags) const
53 {
54 return new wxUnixEventLoopSource(res, handler, flags);
55 }
56 #endif
57
58 protected:
59 #if wxUSE_EVENTLOOP_SOURCE
60 // adding/removing sources
61 virtual bool DoAddSource(wxAbstractEventLoopSource* source);
62 virtual bool DoRemoveSource(wxAbstractEventLoopSource* source);
63
64 // map of event loop sources gtk ids
65 wxEventLoopSourceIdMap m_sourceIdMap;
66 #endif
67
68 // the exit code of this event loop
69 int m_exitcode;
70
71 // used to temporarily store events in DoYield()
72 wxArrayPtrVoid m_arrGdkEvents;
73
74 wxDECLARE_NO_COPY_CLASS(wxGUIEventLoop);
75 };
76
77 #endif // _WX_GTK_EVTLOOP_H_