-
- wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction();
-
- wxObject *test_app = app_ini();
-
- wxTheApp = (wxApp*) test_app;
- }
-
- if (!wxTheApp)
- {
- printf( "wxWindows error: wxTheApp == NULL\n" );
- return 0;
- }
-
- wxTheApp->argc = argc;
- wxTheApp->argv = argv;
-
- char name[200];
- strcpy( name, argv[0] );
- strcpy( name, wxFileNameFromPath(name) );
- wxStripExtension( name );
- wxTheApp->SetAppName( name );
-
- gtk_set_locale();
-
- gtk_init( &argc, &argv );
-
- GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
-
- for (int i = 0; i < 64; i++)
- {
- GdkColor col;
- col.red = g_palette[i*3 + 0] << 8;
- col.green = g_palette[i*3 + 1] << 8;
- col.blue = g_palette[i*3 + 2] << 8;
- col.pixel = 0;
-
- gdk_color_alloc( cmap, &col );
- }
-
- gtk_widget_push_colormap( cmap );
-
- gtk_widget_set_default_colormap( cmap );
-
- wxApp::CommonInit();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
-
- wxTheApp->OnInitGui();
-
- // Here frames insert themselves automatically
- // into wxTopLevelWindows by getting created
- // in OnInit().
-
- if (!wxTheApp->OnInit()) return 0;
-
- wxTheApp->m_initialized = (wxTopLevelWindows.Number() > 0);
-
- int retValue = 0;
-
- if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
-
- wxTheApp->DeletePendingObjects();
-
- wxTheApp->OnExit();
-
- wxModule::CleanUpModules();
-
- wxApp::CommonCleanUp();
-
- wxDELETE(wxTheApp);
-
- wxClassInfo::CleanUpClasses();
-
- delete[] wxBuffer;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
-
- if (wxDebugContext::CountObjectsLeft() > 0)
- {
- wxLogDebug("There were memory leaks.\n");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-// wxDebugContext::SetStream(NULL, NULL);
-
-#endif
-
- wxLog *oldLog = wxLog::SetActiveTarget( NULL );
- if (oldLog) delete oldLog;
-
-
- return retValue;