]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/evtloop.h
Finally fixed control scrolling
[wxWidgets.git] / include / wx / unix / evtloop.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/unix/evtloop.h
3 // Purpose: declares wxEventLoop class
4 // Author: Lukasz Michalski (lm@zork.pl)
5 // Created: 2007-05-07
6 // RCS-ID: $Id$
7 // Copyright: (c) 2007 Lukasz Michalski
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_UNIX_EVTLOOP_H_
12 #define _WX_UNIX_EVTLOOP_H_
13
14 #include "wx/private/fdiodispatcher.h"
15 #include "wx/unix/private/timer.h"
16 #include "wx/unix/pipe.h"
17
18 // ----------------------------------------------------------------------------
19 // wxEventLoop
20 // ----------------------------------------------------------------------------
21
22 class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxEventLoopManual
23 {
24 public:
25 // initialize the event loop, use IsOk() to check if we were successful
26 wxConsoleEventLoop();
27
28 // implement base class pure virtuals
29 virtual bool Pending() const;
30 virtual bool Dispatch();
31 virtual void WakeUp();
32 virtual bool IsOk() const { return m_dispatcher != NULL; }
33
34 protected:
35 virtual void OnNextIteration();
36
37 private:
38 // pipe used for wake up messages: when a child thread wants to wake up
39 // the event loop in the main thread it writes to this pipe
40 class PipeIOHandler : public wxFDIOHandler
41 {
42 public:
43 // default ctor does nothing, call Create() to really initialize the
44 // object
45 PipeIOHandler() { }
46
47 bool Create();
48
49 // this method can be, and normally is, called from another thread
50 void WakeUp();
51
52 int GetReadFd() { return m_pipe[wxPipe::Read]; }
53
54 // implement wxFDIOHandler pure virtual methods
55 virtual void OnReadWaiting();
56 virtual void OnWriteWaiting() { }
57 virtual void OnExceptionWaiting() { }
58
59 private:
60 wxPipe m_pipe;
61 };
62
63 PipeIOHandler m_wakeupPipe;
64
65 // either wxSelectDispatcher or wxEpollDispatcher
66 wxFDIODispatcher *m_dispatcher;
67
68 DECLARE_NO_COPY_CLASS(wxConsoleEventLoop)
69 };
70
71 #endif // _WX_UNIX_EVTLOOP_H_