]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/app.cpp
fixing compilo for 10.5
[wxWidgets.git] / src / palmos / app.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/app.cpp
ffecfa5a 3// Purpose: wxApp
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/08/04
e2731512 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
ffecfa5a
JS
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#if defined(__BORLANDC__)
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
ad9835c9 28 #include "wx/dynarray.h"
ffecfa5a
JS
29 #include "wx/frame.h"
30 #include "wx/app.h"
31 #include "wx/utils.h"
32 #include "wx/gdicmn.h"
33 #include "wx/pen.h"
34 #include "wx/brush.h"
35 #include "wx/cursor.h"
36 #include "wx/icon.h"
37 #include "wx/palette.h"
38 #include "wx/dc.h"
39 #include "wx/dialog.h"
40 #include "wx/msgdlg.h"
41 #include "wx/intl.h"
ffecfa5a 42 #include "wx/wxchar.h"
ffecfa5a
JS
43 #include "wx/log.h"
44#endif
45
46#include "wx/apptrait.h"
47#include "wx/filename.h"
48#include "wx/module.h"
49#include "wx/dynlib.h"
50
51#if wxUSE_TOOLTIPS
52 #include "wx/tooltip.h"
53#endif // wxUSE_TOOLTIPS
54
55// We don't support OLE
56#undef wxUSE_OLE
57#define wxUSE_OLE 0
58
59#include <string.h>
60#include <ctype.h>
61
62// ---------------------------------------------------------------------------
63// global variables
64// ---------------------------------------------------------------------------
65
ffecfa5a
JS
66// NB: all "NoRedraw" classes must have the same names as the "normal" classes
67// with NR suffix - wxWindow::MSWCreate() supposes this
68const wxChar *wxCanvasClassName = wxT("wxWindowClass");
69const wxChar *wxCanvasClassNameNR = wxT("wxWindowClassNR");
70const wxChar *wxMDIFrameClassName = wxT("wxMDIFrameClass");
71const wxChar *wxMDIFrameClassNameNoRedraw = wxT("wxMDIFrameClassNR");
72const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass");
73const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR");
74
75// ----------------------------------------------------------------------------
76// private functions
77// ----------------------------------------------------------------------------
78
79// ===========================================================================
80// wxGUIAppTraits implementation
81// ===========================================================================
82
83// private class which we use to pass parameters from BeforeChildWaitLoop() to
84// AfterChildWaitLoop()
85struct ChildWaitLoopData
86{
87 ChildWaitLoopData(wxWindowDisabler *wd_, wxWindow *winActive_)
88 {
89 wd = wd_;
90 winActive = winActive_;
91 }
92
93 wxWindowDisabler *wd;
94 wxWindow *winActive;
95};
96
97void *wxGUIAppTraits::BeforeChildWaitLoop()
98{
99 return NULL;
100}
101
102void wxGUIAppTraits::AlwaysYield()
103{
104 wxYield();
105}
106
107void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig)
108{
109}
110
111bool wxGUIAppTraits::DoMessageFromThreadWait()
112{
113 return false;
114}
115
116wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
117{
118 static wxToolkitInfo info;
119 wxToolkitInfo& baseInfo = wxAppTraits::GetToolkitInfo();
120 info.versionMajor = baseInfo.versionMajor;
121 info.versionMinor = baseInfo.versionMinor;
122 info.os = baseInfo.os;
4055ed82
WS
123 info.shortName = _T("palmos");
124 info.name = _T("wxPalmOS");
ffecfa5a
JS
125#ifdef __WXUNIVERSAL__
126 info.shortName << _T("univ");
127 info.name << _T("/wxUniversal");
128#endif
129 return info;
130}
131
132// ===========================================================================
133// wxApp implementation
134// ===========================================================================
135
136int wxApp::m_nCmdShow = 0;
137
138// ---------------------------------------------------------------------------
139// wxWin macros
140// ---------------------------------------------------------------------------
141
142IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
143
144BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
145 EVT_IDLE(wxApp::OnIdle)
146 EVT_END_SESSION(wxApp::OnEndSession)
147 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
148END_EVENT_TABLE()
149
150// class to ensure that wxAppBase::CleanUp() is called if our Initialize()
151// fails
152class wxCallBaseCleanup
153{
154public:
155 wxCallBaseCleanup(wxApp *app) : m_app(app) { }
156 ~wxCallBaseCleanup() { if ( m_app ) m_app->wxAppBase::CleanUp(); }
157
158 void Dismiss() { m_app = NULL; }
159
160private:
161 wxApp *m_app;
162};
163
164//// Initialize
165bool wxApp::Initialize(int& argc, wxChar **argv)
166{
167 if ( !wxAppBase::Initialize(argc, argv) )
168 return false;
169
170 // ensure that base cleanup is done if we return too early
171 wxCallBaseCleanup callBaseCleanup(this);
172
173 wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
174
175 callBaseCleanup.Dismiss();
176
177 return true;
178}
179
180// ---------------------------------------------------------------------------
181// RegisterWindowClasses
182// ---------------------------------------------------------------------------
183
184// TODO we should only register classes really used by the app. For this it
185// would be enough to just delay the class registration until an attempt
186// to create a window of this class is made.
187bool wxApp::RegisterWindowClasses()
188{
4055ed82 189 return true;
ffecfa5a
JS
190}
191
192// ---------------------------------------------------------------------------
193// UnregisterWindowClasses
194// ---------------------------------------------------------------------------
195
196bool wxApp::UnregisterWindowClasses()
197{
4055ed82 198 bool retval = true;
ffecfa5a
JS
199 return retval;
200}
201
202void wxApp::CleanUp()
203{
204 // all objects pending for deletion must be deleted first, otherwise we
205 // would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
206 // call wouldn't succeed as long as any windows still exist), so call the
207 // base class method first and only then do our clean up
208 wxAppBase::CleanUp();
209
210 // for an EXE the classes are unregistered when it terminates but DLL may
211 // be loaded several times (load/unload/load) into the same process in
212 // which case the registration will fail after the first time if we don't
213 // unregister the classes now
214 UnregisterWindowClasses();
215
216 delete wxWinHandleHash;
217 wxWinHandleHash = NULL;
218}
219
220// ----------------------------------------------------------------------------
221// wxApp ctor/dtor
222// ----------------------------------------------------------------------------
223
224wxApp::wxApp()
225{
226 m_printMode = wxPRINT_WINDOWS;
227}
228
229wxApp::~wxApp()
230{
231 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
232 // don't come from main(), so we have to free them
233
234 while ( argc )
235 {
236 // m_argv elements were allocated by wxStrdup()
237 free(argv[--argc]);
238 }
239
240 // but m_argv itself -- using new[]
241 delete [] argv;
242}
243
244// ----------------------------------------------------------------------------
245// wxApp idle handling
246// ----------------------------------------------------------------------------
247
248void wxApp::OnIdle(wxIdleEvent& event)
249{
250 wxAppBase::OnIdle(event);
251}
252
253void wxApp::WakeUpIdle()
254{
255}
256
257// ----------------------------------------------------------------------------
258// other wxApp event hanlders
259// ----------------------------------------------------------------------------
260
261void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
262{
263 if (GetTopWindow())
4055ed82 264 GetTopWindow()->Close(true);
ffecfa5a
JS
265}
266
267// Default behaviour: close the application with prompts. The
268// user can veto the close, and therefore the end session.
269void wxApp::OnQueryEndSession(wxCloseEvent& event)
270{
271 if (GetTopWindow())
272 {
273 if (!GetTopWindow()->Close(!event.CanVeto()))
4055ed82 274 event.Veto(true);
ffecfa5a
JS
275 }
276}
277
278// ----------------------------------------------------------------------------
279// miscellaneous
280// ----------------------------------------------------------------------------
281
282/* static */
283int wxApp::GetComCtl32Version()
284{
285 return 0;
286}
287
288// Yield to incoming messages
289
290bool wxApp::Yield(bool onlyIfNeeded)
291{
292 return true;
293}
294
295#if wxUSE_EXCEPTIONS
296
297// ----------------------------------------------------------------------------
298// exception handling
299// ----------------------------------------------------------------------------
300
301bool wxApp::OnExceptionInMainLoop()
302{
303 return true;
304}
305
306#endif // wxUSE_EXCEPTIONS