]>
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
6 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_EVTLOOPSRC_H_
11 #define _WX_EVTLOOPSRC_H_
13 // Include the header to get wxUSE_EVENTLOOP_SOURCE definition from it.
14 #include "wx/evtloop.h"
16 // ----------------------------------------------------------------------------
17 // wxEventLoopSource: a source of events which may be added to wxEventLoop
18 // ----------------------------------------------------------------------------
20 // TODO: refactor wxSocket under Unix to reuse wxEventLoopSource instead of
21 // duplicating much of its logic
23 // TODO: freeze the API and document it
25 #if wxUSE_EVENTLOOP_SOURCE
27 #define wxTRACE_EVT_SOURCE "EventSource"
29 // handler used to process events on event loop sources
30 class wxEventLoopSourceHandler
33 // called when descriptor is available for non-blocking read
34 virtual void OnReadWaiting() = 0;
36 // called when descriptor is available for non-blocking write
37 virtual void OnWriteWaiting() = 0;
39 // called when there is exception on descriptor
40 virtual void OnExceptionWaiting() = 0;
42 // virtual dtor for the base class
43 virtual ~wxEventLoopSourceHandler() { }
46 // flags describing which kind of IO events we're interested in
49 wxEVENT_SOURCE_INPUT
= 0x01,
50 wxEVENT_SOURCE_OUTPUT
= 0x02,
51 wxEVENT_SOURCE_EXCEPTION
= 0x04,
52 wxEVENT_SOURCE_ALL
= wxEVENT_SOURCE_INPUT
|
53 wxEVENT_SOURCE_OUTPUT
|
54 wxEVENT_SOURCE_EXCEPTION
57 // wxEventLoopSource itself is an ABC and can't be created directly, currently
58 // the only way to create it is by using wxEventLoop::AddSourceForFD().
59 class wxEventLoopSource
62 // dtor is pure virtual because it must be overridden to remove the source
63 // from the event loop monitoring it
64 virtual ~wxEventLoopSource() = 0;
66 void SetHandler(wxEventLoopSourceHandler
* handler
) { m_handler
= handler
; }
67 wxEventLoopSourceHandler
* GetHandler() const { return m_handler
; }
69 void SetFlags(int flags
) { m_flags
= flags
; }
70 int GetFlags() const { return m_flags
; }
73 // ctor is only used by the derived classes
74 wxEventLoopSource(wxEventLoopSourceHandler
*handler
, int flags
)
80 wxEventLoopSourceHandler
* m_handler
;
83 wxDECLARE_NO_COPY_CLASS(wxEventLoopSource
);
86 inline wxEventLoopSource::~wxEventLoopSource() { }
89 #include "wx/unix/evtloopsrc.h"
92 #if defined(__WXGTK20__)
93 #include "wx/gtk/evtloopsrc.h"
96 #if defined(__DARWIN__)
97 #include "wx/osx/evtloopsrc.h"
100 #endif // wxUSE_EVENTLOOP_SOURCE
102 #endif // _WX_EVTLOOPSRC_H_