1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: app.cpp
|
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-10-24 20:25:36 +00:00
|
|
|
// Id: $Id$
|
1998-10-24 17:12:05 +00:00
|
|
|
// Copyright: (c) 1998 Robert Roebling, Julian Smart
|
1998-05-20 14:01:55 +00:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "app.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
#include "wx/utils.h"
|
|
|
|
#include "wx/intl.h"
|
|
|
|
#include "wx/log.h"
|
1998-07-24 19:05:25 +00:00
|
|
|
#include "wx/memory.h"
|
1998-08-07 15:09:04 +00:00
|
|
|
#include "wx/font.h"
|
|
|
|
#include "wx/settings.h"
|
1998-08-15 12:06:45 +00:00
|
|
|
#include "wx/resource.h"
|
1998-11-25 17:55:08 +00:00
|
|
|
#include "wx/module.h"
|
1998-12-06 17:33:01 +00:00
|
|
|
#include "wx/image.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
#include "unistd.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// global data
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-08-23 03:22:56 +00:00
|
|
|
wxApp *wxTheApp = (wxApp *) NULL;
|
1998-05-20 14:01:55 +00:00
|
|
|
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
|
|
|
|
|
|
|
extern wxList wxPendingDelete;
|
1998-08-07 15:09:04 +00:00
|
|
|
extern wxResourceCache *wxTheResourceCache;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-10-24 17:12:05 +00:00
|
|
|
unsigned char g_palette[64*3] =
|
|
|
|
{
|
|
|
|
0x0, 0x0, 0x0,
|
|
|
|
0xff, 0xff, 0xff,
|
|
|
|
0xff, 0x0, 0x0,
|
|
|
|
0xff, 0xff, 0x0,
|
|
|
|
0x0, 0xff, 0x0,
|
|
|
|
0x0, 0x0, 0xff,
|
|
|
|
0x0, 0xff, 0xff,
|
|
|
|
0x99, 0x99, 0x99,
|
|
|
|
0xff, 0x88, 0x0,
|
|
|
|
0x88, 0x0, 0x0,
|
|
|
|
0x0, 0x88, 0x88,
|
|
|
|
0x88, 0x88, 0x0,
|
|
|
|
0xff, 0xcc, 0x97,
|
|
|
|
0xbb, 0xbb, 0xbb,
|
|
|
|
0x9f, 0x6b, 0x42,
|
|
|
|
0x55, 0x55, 0x55,
|
|
|
|
0xdd, 0xdd, 0xdd,
|
|
|
|
0x77, 0x77, 0x77,
|
|
|
|
0x33, 0x33, 0x33,
|
|
|
|
0xcc, 0x0, 0x0,
|
|
|
|
0xff, 0x44, 0x0,
|
|
|
|
0xff, 0xcc, 0x0,
|
|
|
|
0xcc, 0xcc, 0x0,
|
|
|
|
0x60, 0x60, 0x0,
|
|
|
|
0x0, 0x43, 0x0,
|
|
|
|
0x0, 0x7f, 0x0,
|
|
|
|
0x0, 0xcc, 0x0,
|
|
|
|
0x0, 0x44, 0x44,
|
|
|
|
0x0, 0x0, 0x44,
|
|
|
|
0x0, 0x0, 0x88,
|
|
|
|
0xef, 0xb1, 0x7b,
|
|
|
|
0xdf, 0x98, 0x5f,
|
|
|
|
0xbf, 0x87, 0x56,
|
|
|
|
0x7f, 0x57, 0x26,
|
|
|
|
0x5f, 0x39, 0xc,
|
|
|
|
0x3f, 0x1c, 0x0,
|
|
|
|
0x21, 0x0, 0x0,
|
|
|
|
0x0, 0x43, 0x87,
|
|
|
|
0x2d, 0x70, 0xaf,
|
|
|
|
0x5a, 0x9e, 0xd7,
|
|
|
|
0x87, 0xcc, 0xff,
|
|
|
|
0xff, 0xe0, 0xba,
|
|
|
|
0x21, 0x43, 0xf,
|
|
|
|
0x3d, 0x5d, 0x25,
|
|
|
|
0x59, 0x78, 0x3a,
|
|
|
|
0x75, 0x93, 0x4f,
|
|
|
|
0x91, 0xae, 0x64,
|
|
|
|
0xad, 0xc8, 0x7a,
|
|
|
|
0xf0, 0xa8, 0xef,
|
|
|
|
0xd0, 0x88, 0xd0,
|
|
|
|
0xaf, 0x66, 0xaf,
|
|
|
|
0x8e, 0x44, 0x8e,
|
|
|
|
0x6d, 0x22, 0x6d,
|
|
|
|
0x4b, 0x0, 0x4b,
|
|
|
|
0xff, 0xc0, 0xbc,
|
|
|
|
0xff, 0x93, 0x91,
|
|
|
|
0xff, 0x66, 0x67,
|
|
|
|
0xd8, 0xf2, 0xbf,
|
|
|
|
0xff, 0xc9, 0x68,
|
|
|
|
0xff, 0x96, 0x67,
|
|
|
|
0xa5, 0x60, 0xff,
|
|
|
|
0x51, 0xff, 0x99,
|
|
|
|
0x3f, 0xa5, 0x63,
|
|
|
|
0x98, 0x90, 0x67
|
|
|
|
};
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// local functions
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
extern void wxFlushResources(void);
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// global functions
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void wxExit(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_main_quit();
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
bool wxYield(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
while (gtk_events_pending() > 0) gtk_main_iteration();
|
|
|
|
return TRUE;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxApp
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
|
|
|
|
|
1998-06-03 19:06:13 +00:00
|
|
|
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
|
|
|
EVT_IDLE(wxApp::OnIdle)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
if (wxTheApp) while (wxTheApp->ProcessIdle()) {}
|
|
|
|
usleep( 10000 );
|
|
|
|
return TRUE;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
wxApp::wxApp()
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
m_idleTag = 0;
|
|
|
|
m_topWindow = (wxWindow *) NULL;
|
|
|
|
m_exitOnFrameDelete = TRUE;
|
|
|
|
wxTheApp = this;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
wxApp::~wxApp(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_idle_remove( m_idleTag );
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
bool wxApp::OnInit(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
return TRUE;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
bool wxApp::OnInitGui(void)
|
1998-08-18 19:57:02 +00:00
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
m_idleTag = gtk_idle_add( wxapp_idle_callback, NULL );
|
|
|
|
return TRUE;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-08-18 19:57:02 +00:00
|
|
|
int wxApp::OnRun(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
return MainLoop();
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-06-03 19:06:13 +00:00
|
|
|
bool wxApp::ProcessIdle(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
wxIdleEvent event;
|
|
|
|
event.SetEventObject( this );
|
|
|
|
ProcessEvent( event );
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
return event.MoreRequested();
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-06-03 19:06:13 +00:00
|
|
|
|
|
|
|
void wxApp::OnIdle( wxIdleEvent &event )
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
static bool inOnIdle = FALSE;
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
// Avoid recursion (via ProcessEvent default case)
|
|
|
|
if (inOnIdle)
|
|
|
|
return;
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
inOnIdle = TRUE;
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
// 'Garbage' collection of windows deleted with Close().
|
|
|
|
DeletePendingObjects();
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
// flush the logged messages if any
|
|
|
|
wxLog *pLog = wxLog::GetActiveTarget();
|
|
|
|
if (pLog != NULL && pLog->HasPendingMessages())
|
|
|
|
pLog->Flush();
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
// Send OnIdle events to all windows
|
|
|
|
bool needMore = SendIdleEvents();
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (needMore)
|
|
|
|
event.RequestMore(TRUE);
|
1998-06-03 19:06:13 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
inOnIdle = FALSE;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-06-03 19:06:13 +00:00
|
|
|
|
|
|
|
bool wxApp::SendIdleEvents(void)
|
|
|
|
{
|
|
|
|
bool needMore = FALSE;
|
1998-12-01 12:55:09 +00:00
|
|
|
|
|
|
|
wxNode* node = wxTopLevelWindows.First();
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
wxWindow* win = (wxWindow*) node->Data();
|
|
|
|
if (SendIdleEvents(win))
|
1998-06-03 19:06:13 +00:00
|
|
|
needMore = TRUE;
|
1998-12-01 12:55:09 +00:00
|
|
|
node = node->Next();
|
|
|
|
}
|
1998-06-03 19:06:13 +00:00
|
|
|
return needMore;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-06-03 19:06:13 +00:00
|
|
|
|
|
|
|
bool wxApp::SendIdleEvents( wxWindow* win )
|
|
|
|
{
|
|
|
|
bool needMore = FALSE;
|
|
|
|
|
|
|
|
wxIdleEvent event;
|
|
|
|
event.SetEventObject(win);
|
|
|
|
win->ProcessEvent(event);
|
|
|
|
|
|
|
|
if (event.MoreRequested())
|
|
|
|
needMore = TRUE;
|
|
|
|
|
|
|
|
wxNode* node = win->GetChildren()->First();
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
wxWindow* win = (wxWindow*) node->Data();
|
|
|
|
if (SendIdleEvents(win))
|
|
|
|
needMore = TRUE;
|
|
|
|
|
|
|
|
node = node->Next();
|
|
|
|
}
|
|
|
|
return needMore ;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
int wxApp::OnExit(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
return 0;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
int wxApp::MainLoop(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_main();
|
|
|
|
return 0;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
void wxApp::ExitMainLoop(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_main_quit();
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
bool wxApp::Initialized(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
return m_initialized;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-08-18 19:57:02 +00:00
|
|
|
bool wxApp::Pending(void)
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
return FALSE;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-08-18 19:57:02 +00:00
|
|
|
void wxApp::Dispatch(void)
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
void wxApp::DeletePendingObjects(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
wxNode *node = wxPendingDelete.First();
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
wxObject *obj = (wxObject *)node->Data();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
delete obj;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (wxPendingDelete.Member(obj))
|
|
|
|
delete node;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
node = wxPendingDelete.First();
|
|
|
|
}
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
wxWindow *wxApp::GetTopWindow(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
if (m_topWindow) return m_topWindow;
|
|
|
|
wxNode *node = wxTopLevelWindows.First();
|
|
|
|
if (!node) return (wxWindow *) NULL;
|
|
|
|
return (wxWindow*)node->Data();
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
void wxApp::SetTopWindow( wxWindow *win )
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
m_topWindow = win;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
void wxApp::CommonInit(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_RESOURCES
|
1998-05-20 14:01:55 +00:00
|
|
|
(void) wxGetResource("wxWindows", "OsVersion", &wxOsVersion);
|
|
|
|
#endif
|
|
|
|
*/
|
1998-08-07 15:09:04 +00:00
|
|
|
wxSystemSettings::Init();
|
|
|
|
wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
|
|
|
|
|
|
|
|
wxTheFontNameDirectory = new wxFontNameDirectory;
|
|
|
|
wxTheFontNameDirectory->Initialize();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
|
|
|
|
wxTheColourDatabase->Initialize();
|
1998-08-07 15:09:04 +00:00
|
|
|
|
|
|
|
wxInitializeStockLists();
|
1998-05-20 14:01:55 +00:00
|
|
|
wxInitializeStockObjects();
|
|
|
|
|
1998-08-15 12:06:45 +00:00
|
|
|
wxInitializeResourceSystem();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-11-06 08:50:52 +00:00
|
|
|
wxImage::InitStandardHandlers();
|
|
|
|
|
|
|
|
// g_globalCursor = new wxCursor;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
void wxApp::CommonCleanUp(void)
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
wxDELETE(wxTheColourDatabase);
|
|
|
|
wxDELETE(wxTheFontNameDirectory);
|
|
|
|
wxDeleteStockObjects();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxFlushResources();
|
1998-08-07 15:09:04 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxDELETE(wxTheResourceCache);
|
1998-08-07 15:09:04 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxDeleteStockLists();
|
1998-08-07 15:09:04 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxCleanUpResourceSystem();
|
1998-11-06 08:50:52 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxImage::CleanUpHandlers();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxSystemSettings::Done();
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
wxLog *wxApp::CreateLogTarget()
|
|
|
|
{
|
|
|
|
return new wxLogGui;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxEntry
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int wxEntry( int argc, char *argv[] )
|
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
wxBuffer = new char[BUFSIZ + 512];
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxClassInfo::InitializeClasses();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-11-22 22:32:53 +00:00
|
|
|
/* Debug stream no longer used
|
1998-11-09 11:57:05 +00:00
|
|
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
1998-07-24 19:05:25 +00:00
|
|
|
|
|
|
|
streambuf* sBuf = new wxDebugStreamBuf;
|
|
|
|
ostream* oStr = new ostream(sBuf) ;
|
|
|
|
wxDebugContext::SetStream(oStr, sBuf);
|
|
|
|
#endif
|
1998-11-22 22:32:53 +00:00
|
|
|
*/
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (!wxTheApp)
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-12-01 12:55:09 +00:00
|
|
|
if (!wxApp::GetInitializerFunction())
|
|
|
|
{
|
|
|
|
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
|
|
|
return 0;
|
|
|
|
}
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxObject *test_app = app_ini();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxTheApp = (wxApp*) test_app;
|
|
|
|
}
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (!wxTheApp)
|
|
|
|
{
|
|
|
|
printf( "wxWindows error: wxTheApp == NULL\n" );
|
|
|
|
return 0;
|
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxTheApp->argc = argc;
|
|
|
|
wxTheApp->argv = argv;
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
char name[200];
|
|
|
|
strcpy( name, argv[0] );
|
|
|
|
strcpy( name, wxFileNameFromPath(name) );
|
|
|
|
wxStripExtension( name );
|
|
|
|
wxTheApp->SetAppName( name );
|
1998-09-11 09:05:26 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_set_locale();
|
1998-09-01 14:29:21 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_init( &argc, &argv );
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
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;
|
1998-10-24 17:12:05 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
gdk_color_alloc( cmap, &col );
|
|
|
|
}
|
1998-10-24 17:12:05 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_widget_push_colormap( cmap );
|
1998-10-24 17:12:05 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
gtk_widget_set_default_colormap( cmap );
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxApp::CommonInit();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxModule::RegisterModules();
|
|
|
|
if (!wxModule::InitializeModules()) return FALSE;
|
1998-11-25 17:55:08 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxTheApp->OnInitGui();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
// Here frames insert themselves automatically
|
|
|
|
// into wxTopLevelWindows by getting created
|
|
|
|
// in OnInit().
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (!wxTheApp->OnInit()) return 0;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxTheApp->m_initialized = (wxTopLevelWindows.Number() > 0);
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
int retValue = 0;
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxTheApp->DeletePendingObjects();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxTheApp->OnExit();
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxModule::CleanUpModules();
|
1998-11-25 17:55:08 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxApp::CommonCleanUp();
|
1998-08-07 15:09:04 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
delete wxTheApp;
|
|
|
|
wxTheApp = (wxApp*) NULL;
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxClassInfo::CleanUpClasses();
|
1998-09-11 09:05:26 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
delete[] wxBuffer;
|
1998-09-11 09:05:26 +00:00
|
|
|
|
1998-11-09 11:57:05 +00:00
|
|
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
1998-09-11 09:05:26 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
if (wxDebugContext::CountObjectsLeft() > 0)
|
|
|
|
{
|
|
|
|
wxLogDebug("There were memory leaks.\n");
|
|
|
|
wxDebugContext::Dump();
|
|
|
|
wxDebugContext::PrintStatistics();
|
|
|
|
}
|
1998-11-22 22:32:53 +00:00
|
|
|
// wxDebugContext::SetStream(NULL, NULL);
|
1998-09-11 09:05:26 +00:00
|
|
|
|
1998-07-24 19:05:25 +00:00
|
|
|
#endif
|
1998-08-18 19:57:02 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
wxLog *oldLog = wxLog::SetActiveTarget( NULL );
|
|
|
|
if (oldLog) delete oldLog;
|
1998-11-22 22:32:53 +00:00
|
|
|
|
1998-12-01 12:55:09 +00:00
|
|
|
return retValue;
|
1998-08-16 19:39:29 +00:00
|
|
|
}
|
1998-05-28 22:05:55 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// main()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-08-18 19:57:02 +00:00
|
|
|
#if defined(AIX) || defined(AIX4) || defined(____HPUX__) || defined(NOMAIN)
|
1998-05-28 22:05:55 +00:00
|
|
|
|
|
|
|
// main in IMPLEMENT_WX_MAIN in IMPLEMENT_APP in app.h
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|