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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
23 #if defined(__BORLANDC__)
28 #include "wx/dynarray.h"
32 #include "wx/gdicmn.h"
35 #include "wx/cursor.h"
37 #include "wx/palette.h"
39 #include "wx/dialog.h"
40 #include "wx/msgdlg.h"
42 #include "wx/wxchar.h"
47 #include "wx/apptrait.h"
48 #include "wx/filename.h"
49 #include "wx/module.h"
50 #include "wx/dynlib.h"
53 #include "wx/tooltip.h"
54 #endif // wxUSE_TOOLTIPS
56 // We don't support OLE
63 // ---------------------------------------------------------------------------
65 // ---------------------------------------------------------------------------
67 extern wxList WXDLLEXPORT wxPendingDelete
;
69 // NB: all "NoRedraw" classes must have the same names as the "normal" classes
70 // with NR suffix - wxWindow::MSWCreate() supposes this
71 const wxChar
*wxCanvasClassName
= wxT("wxWindowClass");
72 const wxChar
*wxCanvasClassNameNR
= wxT("wxWindowClassNR");
73 const wxChar
*wxMDIFrameClassName
= wxT("wxMDIFrameClass");
74 const wxChar
*wxMDIFrameClassNameNoRedraw
= wxT("wxMDIFrameClassNR");
75 const wxChar
*wxMDIChildFrameClassName
= wxT("wxMDIChildFrameClass");
76 const wxChar
*wxMDIChildFrameClassNameNoRedraw
= wxT("wxMDIChildFrameClassNR");
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
82 // ===========================================================================
83 // wxGUIAppTraits implementation
84 // ===========================================================================
86 // private class which we use to pass parameters from BeforeChildWaitLoop() to
87 // AfterChildWaitLoop()
88 struct ChildWaitLoopData
90 ChildWaitLoopData(wxWindowDisabler
*wd_
, wxWindow
*winActive_
)
93 winActive
= winActive_
;
100 void *wxGUIAppTraits::BeforeChildWaitLoop()
105 void wxGUIAppTraits::AlwaysYield()
110 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig
)
114 bool wxGUIAppTraits::DoMessageFromThreadWait()
119 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
121 static wxToolkitInfo info
;
122 wxToolkitInfo
& baseInfo
= wxAppTraits::GetToolkitInfo();
123 info
.versionMajor
= baseInfo
.versionMajor
;
124 info
.versionMinor
= baseInfo
.versionMinor
;
125 info
.os
= baseInfo
.os
;
126 info
.shortName
= _T("palmos");
127 info
.name
= _T("wxPalmOS");
128 #ifdef __WXUNIVERSAL__
129 info
.shortName
<< _T("univ");
130 info
.name
<< _T("/wxUniversal");
135 // ===========================================================================
136 // wxApp implementation
137 // ===========================================================================
139 int wxApp::m_nCmdShow
= 0;
141 // ---------------------------------------------------------------------------
143 // ---------------------------------------------------------------------------
145 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
147 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
148 EVT_IDLE(wxApp::OnIdle
)
149 EVT_END_SESSION(wxApp::OnEndSession
)
150 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
153 // class to ensure that wxAppBase::CleanUp() is called if our Initialize()
155 class wxCallBaseCleanup
158 wxCallBaseCleanup(wxApp
*app
) : m_app(app
) { }
159 ~wxCallBaseCleanup() { if ( m_app
) m_app
->wxAppBase::CleanUp(); }
161 void Dismiss() { m_app
= NULL
; }
168 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
170 if ( !wxAppBase::Initialize(argc
, argv
) )
173 // ensure that base cleanup is done if we return too early
174 wxCallBaseCleanup
callBaseCleanup(this);
176 wxWinHandleHash
= new wxWinHashTable(wxKEY_INTEGER
, 100);
178 callBaseCleanup
.Dismiss();
183 // ---------------------------------------------------------------------------
184 // RegisterWindowClasses
185 // ---------------------------------------------------------------------------
187 // TODO we should only register classes really used by the app. For this it
188 // would be enough to just delay the class registration until an attempt
189 // to create a window of this class is made.
190 bool wxApp::RegisterWindowClasses()
195 // ---------------------------------------------------------------------------
196 // UnregisterWindowClasses
197 // ---------------------------------------------------------------------------
199 bool wxApp::UnregisterWindowClasses()
205 void wxApp::CleanUp()
207 // all objects pending for deletion must be deleted first, otherwise we
208 // would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
209 // call wouldn't succeed as long as any windows still exist), so call the
210 // base class method first and only then do our clean up
211 wxAppBase::CleanUp();
213 // for an EXE the classes are unregistered when it terminates but DLL may
214 // be loaded several times (load/unload/load) into the same process in
215 // which case the registration will fail after the first time if we don't
216 // unregister the classes now
217 UnregisterWindowClasses();
219 delete wxWinHandleHash
;
220 wxWinHandleHash
= NULL
;
223 // ----------------------------------------------------------------------------
225 // ----------------------------------------------------------------------------
229 m_printMode
= wxPRINT_WINDOWS
;
234 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
235 // don't come from main(), so we have to free them
239 // m_argv elements were allocated by wxStrdup()
243 // but m_argv itself -- using new[]
247 // ----------------------------------------------------------------------------
248 // wxApp idle handling
249 // ----------------------------------------------------------------------------
251 void wxApp::OnIdle(wxIdleEvent
& event
)
253 wxAppBase::OnIdle(event
);
256 void wxApp::WakeUpIdle()
260 // ----------------------------------------------------------------------------
261 // other wxApp event hanlders
262 // ----------------------------------------------------------------------------
264 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
267 GetTopWindow()->Close(true);
270 // Default behaviour: close the application with prompts. The
271 // user can veto the close, and therefore the end session.
272 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
276 if (!GetTopWindow()->Close(!event
.CanVeto()))
281 // ----------------------------------------------------------------------------
283 // ----------------------------------------------------------------------------
286 int wxApp::GetComCtl32Version()
291 // Yield to incoming messages
293 bool wxApp::Yield(bool onlyIfNeeded
)
300 // ----------------------------------------------------------------------------
301 // exception handling
302 // ----------------------------------------------------------------------------
304 bool wxApp::OnExceptionInMainLoop()
309 #endif // wxUSE_EXCEPTIONS