]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/evtloopsrc.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/evtloopsrc.h
3 // Purpose: declaration of wxEventLoopSource class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_EVTLOOPSRC_H_
12 #define _WX_EVTLOOPSRC_H_
14 // ----------------------------------------------------------------------------
15 // wxEventLoopSource: a source of events which may be added to wxEventLoop
16 // ----------------------------------------------------------------------------
18 // TODO: refactor wxSocket under Unix to reuse wxEventLoopSource instead of
19 // duplicating much of its logic
21 // TODO: freeze the API and document it
23 #if wxUSE_EVENTLOOP_SOURCE
25 #define wxTRACE_EVT_SOURCE "EventSource"
27 // handler used to process events on event loop sources
28 class wxEventLoopSourceHandler
31 // called when descriptor is available for non-blocking read
32 virtual void OnReadWaiting() = 0;
34 // called when descriptor is available for non-blocking write
35 virtual void OnWriteWaiting() = 0;
37 // called when there is exception on descriptor
38 virtual void OnExceptionWaiting() = 0;
40 // virtual dtor for the base class
41 virtual ~wxEventLoopSourceHandler() { }
44 // flags describing which kind of IO events we're interested in
47 wxEVENT_SOURCE_INPUT
= 0x01,
48 wxEVENT_SOURCE_OUTPUT
= 0x02,
49 wxEVENT_SOURCE_EXCEPTION
= 0x04,
50 wxEVENT_SOURCE_ALL
= wxEVENT_SOURCE_INPUT
|
51 wxEVENT_SOURCE_OUTPUT
|
52 wxEVENT_SOURCE_EXCEPTION
,
55 // wxEventLoopSource itself is an ABC and can't be created directly, currently
56 // the only way to create it is by using wxEventLoop::AddSourceForFD().
57 class wxEventLoopSource
60 // dtor is pure virtual because it must be overridden to remove the source
61 // from the event loop monitoring it
62 virtual ~wxEventLoopSource() = 0;
64 void SetHandler(wxEventLoopSourceHandler
* handler
) { m_handler
= handler
; }
65 wxEventLoopSourceHandler
* GetHandler() const { return m_handler
; }
67 void SetFlags(int flags
) { m_flags
= flags
; }
68 int GetFlags() const { return m_flags
; }
71 // ctor is only used by the derived classes
72 wxEventLoopSource(wxEventLoopSourceHandler
*handler
, int flags
)
78 wxEventLoopSourceHandler
* m_handler
;
81 wxDECLARE_NO_COPY_CLASS(wxEventLoopSource
);
84 inline wxEventLoopSource::~wxEventLoopSource() { }
87 #include "wx/unix/evtloopsrc.h"
90 #if defined(__WXGTK20__)
91 #include "wx/gtk/evtloopsrc.h"
92 #elif defined(__WXOSX__)
93 #include "wx/osx/evtloopsrc.h"
96 #endif // wxUSE_EVENTLOOP_SOURCE
98 #endif // _WX_EVTLOOPSRC_H_