+
+bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
+{
+#if wxUSE_LOG
+ if ( parser.Found(OPTION_VERBOSE) )
+ {
+ wxLog::SetVerbose(TRUE);
+ }
+#endif // wxUSE_LOG
+
+#ifdef __WXUNIVERSAL__
+ wxString themeName;
+ if ( parser.Found(OPTION_THEME, &themeName) )
+ {
+ wxTheme *theme = wxTheme::Create(themeName);
+ if ( !theme )
+ {
+ wxLogError(_("Unsupported theme '%s'."), themeName.c_str());
+
+ return FALSE;
+ }
+
+ wxTheme::Set(theme);
+ }
+#endif // __WXUNIVERSAL__
+
+#if defined(__WXMGL__)
+ wxString modeDesc;
+ if ( parser.Found(OPTION_MODE, &modeDesc) )
+ {
+ unsigned w, h, bpp;
+ if ( wxSscanf(modeDesc.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3 )
+ {
+ wxLogError(_("Invalid display mode specification '%s'."), modeDesc.c_str());
+
+ return FALSE;
+ }
+
+ if ( !SetDisplayMode(wxDisplayModeInfo(w, h, bpp)) )
+ return FALSE;
+ }
+#endif // __WXMGL__
+
+ return TRUE;
+}
+
+bool wxAppBase::OnCmdLineHelp(wxCmdLineParser& parser)
+{
+ parser.Usage();
+
+ return FALSE;
+}
+
+bool wxAppBase::OnCmdLineError(wxCmdLineParser& parser)
+{
+ parser.Usage();
+
+ return FALSE;
+}
+
+#endif // wxUSE_CMDLINE_PARSER
+
+// ----------------------------------------------------------------------------
+// debugging support
+// ----------------------------------------------------------------------------
+
+/* static */
+bool wxAppBase::CheckBuildOptions(const wxBuildOptions& opts)
+{
+#define wxCMP(what) (what == opts.m_ ## what)
+
+ bool
+#ifdef __WXDEBUG__
+ isDebug = TRUE;
+#else
+ isDebug = FALSE;
+#endif
+
+ int verMaj = wxMAJOR_VERSION,
+ verMin = wxMINOR_VERSION;
+
+ if ( !(wxCMP(isDebug) && wxCMP(verMaj) && wxCMP(verMin)) )
+ {
+ wxLogFatalError(_T("Mismatch between the program and library build ")
+ _T("versions detected."));
+
+ // normally wxLogFatalError doesn't return
+ return FALSE;
+ }
+#undef wxCMP
+
+ return TRUE;
+}
+
+#ifdef __WXDEBUG__
+
+static void LINKAGEMODE SetTraceMasks()
+{
+ wxString mask;
+ if ( wxGetEnv(wxT("WXTRACE"), &mask) )
+ {
+ wxStringTokenizer tkn(mask, wxT(","));
+ while ( tkn.HasMoreTokens() )
+ wxLog::AddTraceMask(tkn.GetNextToken());
+ }
+}
+
+// wxASSERT() helper
+bool wxAssertIsEqual(int x, int y)
+{
+ return x == y;
+}
+
+// break into the debugger
+void wxTrap()
+{
+#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
+ DebugBreak();
+#elif defined(__WXMAC__) && !defined(__DARWIN__)
+#if __powerc
+ Debugger();
+#else
+ SysBreak();
+#endif
+#elif defined(__UNIX__)
+ raise(SIGTRAP);
+#else
+ // TODO
+#endif // Win/Unix
+}
+
+// show the assert modal dialog
+static
+void ShowAssertDialog(const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg)
+{
+ // this variable can be set to true to suppress "assert failure" messages
+ static bool s_bNoAsserts = FALSE;
+
+ wxChar szBuf[4096];
+
+ // make life easier for people using VC++ IDE by using this format: like
+ // this, clicking on the message will take us immediately to the place of
+ // the failed assert
+ wxSnprintf(szBuf, WXSIZEOF(szBuf),
+ wxT("%s(%d): assert \"%s\" failed"),
+ szFile, nLine, szCond);
+
+ if ( szMsg != NULL )
+ {
+ wxStrcat(szBuf, wxT(": "));
+ wxStrcat(szBuf, szMsg);
+ }
+ else // no message given
+ {
+ wxStrcat(szBuf, wxT("."));
+ }
+
+ if ( !s_bNoAsserts )
+ {
+ // send it to the normal log destination
+ wxLogDebug(szBuf);
+
+#if (wxUSE_GUI && wxUSE_MSGDLG) || defined(__WXMSW__)
+ // this message is intentionally not translated - it is for
+ // developpers only
+ wxStrcat(szBuf, wxT("\nDo you want to stop the program?\nYou can also choose [Cancel] to suppress further warnings."));
+
+ // use the native message box if available: this is more robust than
+ // using our own
+#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
+ switch ( ::MessageBox(NULL, szBuf, _T("Debug"),
+ MB_YESNOCANCEL | MB_ICONSTOP ) )
+ {
+ case IDYES:
+ wxTrap();
+ break;
+
+ case IDCANCEL:
+ s_bNoAsserts = TRUE;
+ break;
+
+ //case IDNO: nothing to do
+ }
+#else // !MSW
+ switch ( wxMessageBox(szBuf, wxT("Debug"),
+ wxYES_NO | wxCANCEL | wxICON_STOP ) )
+ {
+ case wxYES:
+ wxTrap();
+ break;
+
+ case wxCANCEL:
+ s_bNoAsserts = TRUE;
+ break;
+
+ //case wxNO: nothing to do
+ }
+#endif // GUI or MSW
+
+#else // !GUI
+ wxTrap();
+#endif // GUI/!GUI
+ }
+}
+
+// this function is called when an assert fails
+void wxOnAssert(const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg)
+{
+ // FIXME MT-unsafe
+ static bool s_bInAssert = FALSE;
+
+ if ( s_bInAssert )
+ {
+ // He-e-e-e-elp!! we're trapped in endless loop
+ wxTrap();
+
+ s_bInAssert = FALSE;
+
+ return;
+ }
+
+ s_bInAssert = TRUE;
+
+ if ( !wxTheApp )
+ {
+ // by default, show the assert dialog box - we can't customize this
+ // behaviour
+ ShowAssertDialog(szFile, nLine, szCond, szMsg);
+ }
+ else
+ {
+ // let the app process it as it wants
+ wxTheApp->OnAssert(szFile, nLine, szCond, szMsg);
+ }
+
+ s_bInAssert = FALSE;
+}
+
+void wxAppBase::OnAssert(const wxChar *file,
+ int line,
+ const wxChar *cond,
+ const wxChar *msg)
+{
+ ShowAssertDialog(file, line, cond, msg);
+}
+
+#endif //WXDEBUG
+