1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/app.cpp
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "app.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
27 #if defined(__BORLANDC__)
35 #include "wx/gdicmn.h"
38 #include "wx/cursor.h"
40 #include "wx/palette.h"
42 #include "wx/dialog.h"
43 #include "wx/msgdlg.h"
45 #include "wx/dynarray.h"
46 #include "wx/wxchar.h"
51 #include "wx/apptrait.h"
52 #include "wx/filename.h"
53 #include "wx/module.h"
54 #include "wx/dynlib.h"
57 #include "wx/tooltip.h"
58 #endif // wxUSE_TOOLTIPS
60 // We don't support OLE
67 // ---------------------------------------------------------------------------
69 // ---------------------------------------------------------------------------
71 extern wxList WXDLLEXPORT wxPendingDelete
;
73 // NB: all "NoRedraw" classes must have the same names as the "normal" classes
74 // with NR suffix - wxWindow::MSWCreate() supposes this
75 const wxChar
*wxCanvasClassName
= wxT("wxWindowClass");
76 const wxChar
*wxCanvasClassNameNR
= wxT("wxWindowClassNR");
77 const wxChar
*wxMDIFrameClassName
= wxT("wxMDIFrameClass");
78 const wxChar
*wxMDIFrameClassNameNoRedraw
= wxT("wxMDIFrameClassNR");
79 const wxChar
*wxMDIChildFrameClassName
= wxT("wxMDIChildFrameClass");
80 const wxChar
*wxMDIChildFrameClassNameNoRedraw
= wxT("wxMDIChildFrameClassNR");
82 // ----------------------------------------------------------------------------
84 // ----------------------------------------------------------------------------
86 // ===========================================================================
87 // wxGUIAppTraits implementation
88 // ===========================================================================
90 // private class which we use to pass parameters from BeforeChildWaitLoop() to
91 // AfterChildWaitLoop()
92 struct ChildWaitLoopData
94 ChildWaitLoopData(wxWindowDisabler
*wd_
, wxWindow
*winActive_
)
97 winActive
= winActive_
;
100 wxWindowDisabler
*wd
;
104 void *wxGUIAppTraits::BeforeChildWaitLoop()
109 void wxGUIAppTraits::AlwaysYield()
114 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig
)
118 bool wxGUIAppTraits::DoMessageFromThreadWait()
123 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
125 static wxToolkitInfo info
;
126 wxToolkitInfo
& baseInfo
= wxAppTraits::GetToolkitInfo();
127 info
.versionMajor
= baseInfo
.versionMajor
;
128 info
.versionMinor
= baseInfo
.versionMinor
;
129 info
.os
= baseInfo
.os
;
130 info
.shortName
= _T("palmos");
131 info
.name
= _T("wxPalmOS");
132 #ifdef __WXUNIVERSAL__
133 info
.shortName
<< _T("univ");
134 info
.name
<< _T("/wxUniversal");
139 // ===========================================================================
140 // wxApp implementation
141 // ===========================================================================
143 int wxApp::m_nCmdShow
= 0;
145 // ---------------------------------------------------------------------------
147 // ---------------------------------------------------------------------------
149 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
151 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
152 EVT_IDLE(wxApp::OnIdle
)
153 EVT_END_SESSION(wxApp::OnEndSession
)
154 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
157 // class to ensure that wxAppBase::CleanUp() is called if our Initialize()
159 class wxCallBaseCleanup
162 wxCallBaseCleanup(wxApp
*app
) : m_app(app
) { }
163 ~wxCallBaseCleanup() { if ( m_app
) m_app
->wxAppBase::CleanUp(); }
165 void Dismiss() { m_app
= NULL
; }
172 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
174 if ( !wxAppBase::Initialize(argc
, argv
) )
177 // ensure that base cleanup is done if we return too early
178 wxCallBaseCleanup
callBaseCleanup(this);
180 wxWinHandleHash
= new wxWinHashTable(wxKEY_INTEGER
, 100);
182 callBaseCleanup
.Dismiss();
187 // ---------------------------------------------------------------------------
188 // RegisterWindowClasses
189 // ---------------------------------------------------------------------------
191 // TODO we should only register classes really used by the app. For this it
192 // would be enough to just delay the class registration until an attempt
193 // to create a window of this class is made.
194 bool wxApp::RegisterWindowClasses()
199 // ---------------------------------------------------------------------------
200 // UnregisterWindowClasses
201 // ---------------------------------------------------------------------------
203 bool wxApp::UnregisterWindowClasses()
209 void wxApp::CleanUp()
211 // all objects pending for deletion must be deleted first, otherwise we
212 // would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
213 // call wouldn't succeed as long as any windows still exist), so call the
214 // base class method first and only then do our clean up
215 wxAppBase::CleanUp();
217 // for an EXE the classes are unregistered when it terminates but DLL may
218 // be loaded several times (load/unload/load) into the same process in
219 // which case the registration will fail after the first time if we don't
220 // unregister the classes now
221 UnregisterWindowClasses();
223 delete wxWinHandleHash
;
224 wxWinHandleHash
= NULL
;
227 // ----------------------------------------------------------------------------
229 // ----------------------------------------------------------------------------
233 m_printMode
= wxPRINT_WINDOWS
;
238 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
239 // don't come from main(), so we have to free them
243 // m_argv elements were allocated by wxStrdup()
247 // but m_argv itself -- using new[]
251 // ----------------------------------------------------------------------------
252 // wxApp idle handling
253 // ----------------------------------------------------------------------------
255 void wxApp::OnIdle(wxIdleEvent
& event
)
257 wxAppBase::OnIdle(event
);
260 void wxApp::WakeUpIdle()
264 // ----------------------------------------------------------------------------
265 // other wxApp event hanlders
266 // ----------------------------------------------------------------------------
268 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
271 GetTopWindow()->Close(true);
274 // Default behaviour: close the application with prompts. The
275 // user can veto the close, and therefore the end session.
276 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
280 if (!GetTopWindow()->Close(!event
.CanVeto()))
285 // ----------------------------------------------------------------------------
287 // ----------------------------------------------------------------------------
290 int wxApp::GetComCtl32Version()
295 // Yield to incoming messages
297 bool wxApp::Yield(bool onlyIfNeeded
)
304 // ----------------------------------------------------------------------------
305 // exception handling
306 // ----------------------------------------------------------------------------
308 bool wxApp::OnExceptionInMainLoop()
313 #endif // wxUSE_EXCEPTIONS