- wxBuffer = new wxChar[BUFSIZ + 512];
-
- wxClassInfo::InitializeClasses();
- wxSystemSettings::Init();
- wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
- wxTheColourDatabase->Initialize();
- wxInitializeStockLists();
- wxInitializeStockObjects();
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
- return TRUE;
+ if ( !wxAppBase::OnInitGui() )
+ return false;
+
+#ifdef __WXDEBUG__
+ // MGL redirects stdout and stderr to physical console, so lets redirect
+ // it to file in debug build. Do it only when WXSTDERR environment variable is set
+ wxString redirect;
+ if ( wxGetEnv(wxT("WXSTDERR"), &redirect) )
+ freopen(redirect.mb_str(), "wt", stderr);
+#endif // __WXDEBUG__
+
+ wxLog *oldLog = wxLog::SetActiveTarget(new wxLogGui);
+ if ( oldLog ) delete oldLog;
+
+ return true;
+}
+
+bool wxApp::Initialize(int& argc, wxChar **argv)
+{
+#ifdef __DJGPP__
+ // VS: disable long filenames under DJGPP as the very first thing,
+ // since SciTech MGL doesn't like them much...
+ wxSetEnv(wxT("LFN"), wxT("N"));
+#endif
+
+ // intialize MGL before creating wxFontsManager since it uses MGL funcs
+ if ( MGL_init(".", NULL) == 0 )
+ {
+ wxLogError(_("Cannot initialize SciTech MGL!"));
+ return false;
+ }
+
+ if ( !wxAppBase::Initialize(argc, argv) )
+ {
+ MGL_exit();
+ return false;
+ }
+
+#if wxUSE_INTL
+ wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
+#endif
+
+ return true;