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"
44 #include "wx/module.h"
47 #include "wx/apptrait.h"
48 #include "wx/filename.h"
49 #include "wx/dynlib.h"
50 #include "wx/evtloop.h"
53 #include "wx/tooltip.h"
54 #endif // wxUSE_TOOLTIPS
56 // We don't support OLE
63 // ---------------------------------------------------------------------------
65 // ---------------------------------------------------------------------------
67 // NB: all "NoRedraw" classes must have the same names as the "normal" classes
68 // with NR suffix - wxWindow::MSWCreate() supposes this
69 const wxChar
*wxCanvasClassName
= wxT("wxWindowClass");
70 const wxChar
*wxCanvasClassNameNR
= wxT("wxWindowClassNR");
71 const wxChar
*wxMDIFrameClassName
= wxT("wxMDIFrameClass");
72 const wxChar
*wxMDIFrameClassNameNoRedraw
= wxT("wxMDIFrameClassNR");
73 const wxChar
*wxMDIChildFrameClassName
= wxT("wxMDIChildFrameClass");
74 const wxChar
*wxMDIChildFrameClassNameNoRedraw
= wxT("wxMDIChildFrameClassNR");
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 // ===========================================================================
81 // wxGUIAppTraits implementation
82 // ===========================================================================
84 // private class which we use to pass parameters from BeforeChildWaitLoop() to
85 // AfterChildWaitLoop()
86 struct ChildWaitLoopData
88 ChildWaitLoopData(wxWindowDisabler
*wd_
, wxWindow
*winActive_
)
91 winActive
= winActive_
;
98 void *wxGUIAppTraits::BeforeChildWaitLoop()
103 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig
)
107 bool wxGUIAppTraits::DoMessageFromThreadWait()
112 wxPortId
wxGUIAppTraits::GetToolkitVersion(int *majVer
, int *minVer
) const
114 // TODO: how to get PalmOS GUI system version ?
115 return wxPORT_PALMOS
;
119 wxTimerImpl
* wxGUIAppTraits::CreateTimerImpl(wxTimer
*timer
)
121 return new wxPalmOSTimerImpl(timer
);
123 #endif // wxUSE_TIMER
125 wxEventLoopBase
* wxGUIAppTraits::CreateEventLoop()
127 return new wxEventLoop
;
129 // ===========================================================================
130 // wxApp implementation
131 // ===========================================================================
133 int wxApp::m_nCmdShow
= 0;
135 // ---------------------------------------------------------------------------
137 // ---------------------------------------------------------------------------
139 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
141 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
142 EVT_END_SESSION(wxApp::OnEndSession
)
143 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
146 // class to ensure that wxAppBase::CleanUp() is called if our Initialize()
148 class wxCallBaseCleanup
151 wxCallBaseCleanup(wxApp
*app
) : m_app(app
) { }
152 ~wxCallBaseCleanup() { if ( m_app
) m_app
->wxAppBase::CleanUp(); }
154 void Dismiss() { m_app
= NULL
; }
161 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
163 if ( !wxAppBase::Initialize(argc
, argv
) )
166 // ensure that base cleanup is done if we return too early
167 wxCallBaseCleanup
callBaseCleanup(this);
169 wxWinHandleHash
= new wxWinHashTable(wxKEY_INTEGER
, 100);
171 callBaseCleanup
.Dismiss();
176 // ---------------------------------------------------------------------------
177 // RegisterWindowClasses
178 // ---------------------------------------------------------------------------
180 // TODO we should only register classes really used by the app. For this it
181 // would be enough to just delay the class registration until an attempt
182 // to create a window of this class is made.
183 bool wxApp::RegisterWindowClasses()
188 // ---------------------------------------------------------------------------
189 // UnregisterWindowClasses
190 // ---------------------------------------------------------------------------
192 bool wxApp::UnregisterWindowClasses()
198 void wxApp::CleanUp()
200 // all objects pending for deletion must be deleted first, otherwise we
201 // would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
202 // call wouldn't succeed as long as any windows still exist), so call the
203 // base class method first and only then do our clean up
204 wxAppBase::CleanUp();
206 // for an EXE the classes are unregistered when it terminates but DLL may
207 // be loaded several times (load/unload/load) into the same process in
208 // which case the registration will fail after the first time if we don't
209 // unregister the classes now
210 UnregisterWindowClasses();
212 wxDELETE(wxWinHandleHash
);
215 // ----------------------------------------------------------------------------
217 // ----------------------------------------------------------------------------
221 m_printMode
= wxPRINT_WINDOWS
;
228 // src/palmos/main.cpp
229 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
230 // don't come from main(), so we have to free them
233 // m_argv elements were allocated by wxStrdup()
234 if (argv_tmp
[--argc
]) {
235 free((void *)(argv_tmp
[--argc
]));
238 // but m_argv itself -- using new[]
243 // ----------------------------------------------------------------------------
244 // wxApp idle handling
245 // ----------------------------------------------------------------------------
247 void wxApp::WakeUpIdle()
251 // ----------------------------------------------------------------------------
252 // other wxApp event hanlders
253 // ----------------------------------------------------------------------------
255 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
258 GetTopWindow()->Close(true);
261 // Default behaviour: close the application with prompts. The
262 // user can veto the close, and therefore the end session.
263 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
267 if (!GetTopWindow()->Close(!event
.CanVeto()))
272 // ----------------------------------------------------------------------------
274 // ----------------------------------------------------------------------------
277 int wxApp::GetComCtl32Version()
284 // ----------------------------------------------------------------------------
285 // exception handling
286 // ----------------------------------------------------------------------------
288 bool wxApp::OnExceptionInMainLoop()
293 #endif // wxUSE_EXCEPTIONS