]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/palmos/evtloop.cpp | |
3 | // Purpose: implements wxEventLoop for Palm OS | |
4 | // Author: William Osborne - minimal working wxPalmOS port | |
5 | // Modified by: | |
6 | // Created: 10.14.04 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) William Osborne | |
9 | // License: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #ifndef WX_PRECOMP | |
28 | #include "wx/window.h" | |
29 | #include "wx/app.h" | |
30 | #endif //WX_PRECOMP | |
31 | ||
32 | #include "wx/evtloop.h" | |
33 | ||
34 | #include "wx/tooltip.h" | |
35 | #include "wx/except.h" | |
36 | #include "wx/ptr_scpd.h" | |
37 | ||
38 | #if wxUSE_THREADS | |
39 | #include "wx/thread.h" | |
40 | ||
41 | // define the array of MSG strutures | |
42 | WX_DECLARE_OBJARRAY(MSG, wxMsgArray); | |
43 | ||
44 | #include "wx/arrimpl.cpp" | |
45 | ||
46 | WX_DEFINE_OBJARRAY(wxMsgArray); | |
47 | #endif // wxUSE_THREADS | |
48 | ||
49 | #include <Event.h> | |
50 | #include <SystemMgr.h> | |
51 | #include <Menu.h> | |
52 | #include <Form.h> | |
53 | ||
54 | // ---------------------------------------------------------------------------- | |
55 | // helper class | |
56 | // ---------------------------------------------------------------------------- | |
57 | ||
58 | // this object sets the wxEventLoop given to the ctor as the currently active | |
59 | // one and unsets it in its dtor | |
60 | class wxEventLoopActivator | |
61 | { | |
62 | public: | |
63 | wxEventLoopActivator(wxEventLoop **pActive, | |
64 | wxEventLoop *evtLoop) | |
65 | { | |
66 | m_pActive = pActive; | |
67 | m_evtLoopOld = *pActive; | |
68 | *pActive = evtLoop; | |
69 | } | |
70 | ||
71 | ~wxEventLoopActivator() | |
72 | { | |
73 | // restore the previously active event loop | |
74 | *m_pActive = m_evtLoopOld; | |
75 | } | |
76 | ||
77 | private: | |
78 | wxEventLoop *m_evtLoopOld; | |
79 | wxEventLoop **m_pActive; | |
80 | }; | |
81 | ||
82 | // ============================================================================ | |
83 | // wxEventLoop implementation | |
84 | // ============================================================================ | |
85 | ||
86 | wxEventLoop *wxEventLoopBase::ms_activeLoop = NULL; | |
87 | ||
88 | // ---------------------------------------------------------------------------- | |
89 | // ctor/dtor | |
90 | // ---------------------------------------------------------------------------- | |
91 | ||
92 | wxEventLoop::wxEventLoop() | |
93 | { | |
94 | m_shouldExit = false; | |
95 | m_exitcode = 0; | |
96 | } | |
97 | ||
98 | // ---------------------------------------------------------------------------- | |
99 | // wxEventLoop message processing | |
100 | // ---------------------------------------------------------------------------- | |
101 | ||
102 | void wxEventLoop::ProcessMessage(WXMSG *msg) | |
103 | { | |
104 | } | |
105 | ||
106 | bool wxEventLoop::PreProcessMessage(WXMSG *msg) | |
107 | { | |
108 | return false; | |
109 | } | |
110 | ||
111 | // ---------------------------------------------------------------------------- | |
112 | // wxEventLoop running and exiting | |
113 | // ---------------------------------------------------------------------------- | |
114 | ||
115 | bool wxEventLoop::IsRunning() const | |
116 | { | |
117 | return true; | |
118 | } | |
119 | ||
120 | int wxEventLoop::Run() | |
121 | { | |
122 | status_t error; | |
123 | EventType event; | |
124 | ||
125 | do { | |
126 | wxTheApp && wxTheApp->ProcessIdle(); | |
127 | ||
128 | EvtGetEvent(&event, evtWaitForever); | |
129 | ||
130 | if (SysHandleEvent(&event)) | |
131 | continue; | |
132 | ||
133 | if (MenuHandleEvent(0, &event, &error)) | |
134 | continue; | |
135 | ||
136 | FrmDispatchEvent(&event); | |
137 | ||
138 | } while (event.eType != appStopEvent); | |
139 | ||
140 | return 0; | |
141 | } | |
142 | ||
143 | void wxEventLoop::Exit(int rc) | |
144 | { | |
145 | FrmCloseAllForms(); | |
146 | ||
147 | EventType AppStop; | |
148 | AppStop.eType=appStopEvent; | |
149 | EvtAddEventToQueue(&AppStop); | |
150 | } | |
151 | ||
152 | // ---------------------------------------------------------------------------- | |
153 | // wxEventLoop message processing dispatching | |
154 | // ---------------------------------------------------------------------------- | |
155 | ||
156 | bool wxEventLoop::Pending() const | |
157 | { | |
158 | return false; | |
159 | } | |
160 | ||
161 | bool wxEventLoop::Dispatch() | |
162 | { | |
163 | return false; | |
164 | } | |
165 |