+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)) )
+ {
+ wxString msg;
+ wxString libDebug, progDebug;
+
+ if (isDebug)
+ libDebug = wxT("debug");
+ else
+ libDebug = wxT("no debug");
+
+ if (opts.m_isDebug)
+ progDebug = wxT("debug");
+ else
+ progDebug = wxT("no debug");
+
+ msg.Printf(_T("Mismatch between the program and library build versions detected.\nThe library used %d.%d (%s), and your program used %d.%d (%s)."),
+ verMaj, verMin, libDebug.c_str(), opts.m_verMaj, opts.m_verMin, progDebug.c_str());
+
+ wxLogFatalError(msg);
+
+ // normally wxLogFatalError doesn't return
+ return FALSE;
+ }
+#undef wxCMP
+
+ return TRUE;
+}
+
+#ifdef __WXDEBUG__
+
+static void LINKAGEMODE SetTraceMasks()
+{
+#if wxUSE_LOG
+ wxString mask;
+ if ( wxGetEnv(wxT("WXTRACE"), &mask) )
+ {
+ wxStringTokenizer tkn(mask, wxT(","));
+ while ( tkn.HasMoreTokens() )
+ wxLog::AddTraceMask(tkn.GetNextToken());
+ }
+#endif // wxUSE_LOG
+}
+
+// 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
+}
+
+
+void wxAssert(int cond,
+ const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg)
+{
+ if ( !cond )
+ wxOnAssert(szFile, nLine, szCond, szMsg);
+}
+
+// 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 wxUSE_THREADS
+ // if we are not in the main thread,
+ // output the assert directly and trap since dialogs cannot be displayed
+ if (!wxThread::IsMain()) {
+ wxStrcat(szBuf, wxT(" [in child thread]"));
+#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
+ wxStrcat(szBuf, wxT("\r\n"));
+ OutputDebugString(szBuf);
+#else
+ // send to stderr
+ wxFprintf(stderr, wxT("%s\n"), szBuf);
+ fflush(stderr);
+#endif
+ // He-e-e-e-elp!! we're asserting in a child thread
+ wxTrap();
+ }
+#endif // wxUSE_THREADS
+
+ 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
+