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"
46 #include "wx/apptrait.h"
47 #include "wx/filename.h"
48 #include "wx/module.h"
49 #include "wx/dynlib.h"
52 #include "wx/tooltip.h"
53 #endif // wxUSE_TOOLTIPS
55 // We don't support OLE
62 // ---------------------------------------------------------------------------
64 // ---------------------------------------------------------------------------
66 extern wxList WXDLLEXPORT wxPendingDelete
;
68 // NB: all "NoRedraw" classes must have the same names as the "normal" classes
69 // with NR suffix - wxWindow::MSWCreate() supposes this
70 const wxChar
*wxCanvasClassName
= wxT("wxWindowClass");
71 const wxChar
*wxCanvasClassNameNR
= wxT("wxWindowClassNR");
72 const wxChar
*wxMDIFrameClassName
= wxT("wxMDIFrameClass");
73 const wxChar
*wxMDIFrameClassNameNoRedraw
= wxT("wxMDIFrameClassNR");
74 const wxChar
*wxMDIChildFrameClassName
= wxT("wxMDIChildFrameClass");
75 const wxChar
*wxMDIChildFrameClassNameNoRedraw
= wxT("wxMDIChildFrameClassNR");
77 // ----------------------------------------------------------------------------
79 // ----------------------------------------------------------------------------
81 // ===========================================================================
82 // wxGUIAppTraits implementation
83 // ===========================================================================
85 // private class which we use to pass parameters from BeforeChildWaitLoop() to
86 // AfterChildWaitLoop()
87 struct ChildWaitLoopData
89 ChildWaitLoopData(wxWindowDisabler
*wd_
, wxWindow
*winActive_
)
92 winActive
= winActive_
;
99 void *wxGUIAppTraits::BeforeChildWaitLoop()
104 void wxGUIAppTraits::AlwaysYield()
109 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig
)
113 bool wxGUIAppTraits::DoMessageFromThreadWait()
118 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
120 static wxToolkitInfo info
;
121 wxToolkitInfo
& baseInfo
= wxAppTraits::GetToolkitInfo();
122 info
.versionMajor
= baseInfo
.versionMajor
;
123 info
.versionMinor
= baseInfo
.versionMinor
;
124 info
.os
= baseInfo
.os
;
125 info
.shortName
= _T("palmos");
126 info
.name
= _T("wxPalmOS");
127 #ifdef __WXUNIVERSAL__
128 info
.shortName
<< _T("univ");
129 info
.name
<< _T("/wxUniversal");
134 // ===========================================================================
135 // wxApp implementation
136 // ===========================================================================
138 int wxApp::m_nCmdShow
= 0;
140 // ---------------------------------------------------------------------------
142 // ---------------------------------------------------------------------------
144 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
146 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
147 EVT_IDLE(wxApp::OnIdle
)
148 EVT_END_SESSION(wxApp::OnEndSession
)
149 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
152 // class to ensure that wxAppBase::CleanUp() is called if our Initialize()
154 class wxCallBaseCleanup
157 wxCallBaseCleanup(wxApp
*app
) : m_app(app
) { }
158 ~wxCallBaseCleanup() { if ( m_app
) m_app
->wxAppBase::CleanUp(); }
160 void Dismiss() { m_app
= NULL
; }
167 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
169 if ( !wxAppBase::Initialize(argc
, argv
) )
172 // ensure that base cleanup is done if we return too early
173 wxCallBaseCleanup
callBaseCleanup(this);
175 wxWinHandleHash
= new wxWinHashTable(wxKEY_INTEGER
, 100);
177 callBaseCleanup
.Dismiss();
182 // ---------------------------------------------------------------------------
183 // RegisterWindowClasses
184 // ---------------------------------------------------------------------------
186 // TODO we should only register classes really used by the app. For this it
187 // would be enough to just delay the class registration until an attempt
188 // to create a window of this class is made.
189 bool wxApp::RegisterWindowClasses()
194 // ---------------------------------------------------------------------------
195 // UnregisterWindowClasses
196 // ---------------------------------------------------------------------------
198 bool wxApp::UnregisterWindowClasses()
204 void wxApp::CleanUp()
206 // all objects pending for deletion must be deleted first, otherwise we
207 // would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
208 // call wouldn't succeed as long as any windows still exist), so call the
209 // base class method first and only then do our clean up
210 wxAppBase::CleanUp();
212 // for an EXE the classes are unregistered when it terminates but DLL may
213 // be loaded several times (load/unload/load) into the same process in
214 // which case the registration will fail after the first time if we don't
215 // unregister the classes now
216 UnregisterWindowClasses();
218 delete wxWinHandleHash
;
219 wxWinHandleHash
= NULL
;
222 // ----------------------------------------------------------------------------
224 // ----------------------------------------------------------------------------
228 m_printMode
= wxPRINT_WINDOWS
;
233 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
234 // don't come from main(), so we have to free them
238 // m_argv elements were allocated by wxStrdup()
242 // but m_argv itself -- using new[]
246 // ----------------------------------------------------------------------------
247 // wxApp idle handling
248 // ----------------------------------------------------------------------------
250 void wxApp::OnIdle(wxIdleEvent
& event
)
252 wxAppBase::OnIdle(event
);
255 void wxApp::WakeUpIdle()
259 // ----------------------------------------------------------------------------
260 // other wxApp event hanlders
261 // ----------------------------------------------------------------------------
263 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
266 GetTopWindow()->Close(true);
269 // Default behaviour: close the application with prompts. The
270 // user can veto the close, and therefore the end session.
271 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
275 if (!GetTopWindow()->Close(!event
.CanVeto()))
280 // ----------------------------------------------------------------------------
282 // ----------------------------------------------------------------------------
285 int wxApp::GetComCtl32Version()
290 // Yield to incoming messages
292 bool wxApp::Yield(bool onlyIfNeeded
)
299 // ----------------------------------------------------------------------------
300 // exception handling
301 // ----------------------------------------------------------------------------
303 bool wxApp::OnExceptionInMainLoop()
308 #endif // wxUSE_EXCEPTIONS