#endif // wxUSE_GUI
#include "wx/build.h"
+#include "wx/init.h"
class WXDLLEXPORT wxApp;
class WXDLLEXPORT wxAppTraits;
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
+ // This is the very first function called for a newly created wxApp object,
+ // it is used by the library to do the global initialization. If, for some
+ // reason, you must override it (instead of just overriding OnInit(), as
+ // usual, for app-specific initializations), do not forget to call the base
+ // class version!
+ virtual bool Initialize(int argc, wxChar **argv);
+
// Called before OnRun(), this is a good place to do initialization -- if
// anything fails, return false from here to prevent the program from
// continuing. The command line is normally parsed here, call the base
// class OnInit() to do it.
virtual bool OnInit();
+ // this is here only temproary hopefully (FIXME)
+ virtual bool OnInitGui() { return true; }
+
// This is the replacement for the normal main(): all program work should
// be done here. When OnRun() returns, the programs starts shutting down.
virtual int OnRun() = 0;
// any cleanup matching the initializations done there.
virtual int OnExit();
+ // This is the very last function called on wxApp object before it is
+ // destroyed. If you override it (instead of overriding OnExit() as usual)
+ // do not forget to call the base class version!
+ virtual void CleanUp();
+
// Called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core dump
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
+ // very first initialization function
+ //
+ // Override: very rarely
+ virtual bool Initialize(int argc, wxChar **argv);
+
// a platform-dependent version of OnInit(): the code here is likely to
// depend on the toolkit. default version does nothing.
//
// Override: rarely in GUI applications, always in console ones.
virtual int OnRun();
- // exit the main loop thus terminating the application
- virtual void Exit();
+ // very last clean up function
+ //
+ // Override: very rarely
+ virtual void CleanUp();
// the worker functions - usually not used directly by the user code
// execute the main GUI loop, the function returns when the loop ends
virtual int MainLoop() = 0;
+ // exit the main loop thus terminating the application
+ virtual void Exit();
+
// exit the main GUI loop during the next iteration (i.e. it does not
// stop the program immediately!)
virtual void ExitMainLoop() = 0;
protected:
+ // delete all objects in wxPendingDelete list
+ void DeletePendingObjects();
+
// override base class method to use GUI traits
virtual wxAppTraits *CreateTraits();
// Yield to other apps/messages
extern void WXDLLEXPORT wxWakeUpIdle();
-
-// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros
-// and call these functions instead at the program startup and termination
-// -------------------------------------------------------------------------
-
-#if !wxUSE_GUI
-
-// initialize the library (may be called as many times as needed, but each
-// call to wxInitialize() must be matched by wxUninitialize())
-extern bool WXDLLEXPORT wxInitialize();
-
-// clean up - the library can't be used any more after the last call to
-// wxUninitialize()
-extern void WXDLLEXPORT wxUninitialize();
-
-// create an object of this class on stack to initialize/cleanup thel ibrary
-// automatically
-class WXDLLEXPORT wxInitializer
-{
-public:
- // initialize the library
- wxInitializer() { m_ok = wxInitialize(); }
-
- // has the initialization been successful? (explicit test)
- bool IsOk() const { return m_ok; }
-
- // has the initialization been successful? (implicit test)
- operator bool() const { return m_ok; }
-
- // dtor only does clean up if we initialized the library properly
- ~wxInitializer() { if ( m_ok ) wxUninitialize(); }
-
-private:
- bool m_ok;
-};
-
-#endif // !wxUSE_GUI
-
// ----------------------------------------------------------------------------
// macros for dynamic creation of the application object
// ----------------------------------------------------------------------------
extern int wxEntry( int argc, char **argv, bool enterLoop = TRUE ); \
int main(int argc, char **argv) { return wxEntry(argc, argv); }
#elif defined(__WXMSW__) && defined(WXUSINGDLL)
- // NT defines APIENTRY, 3.x not
- #if !defined(WXAPIENTRY)
- #define WXAPIENTRY WXFAR wxSTDCALL
- #endif
-
- #include <windows.h>
- #include "wx/msw/winundef.h"
-
#define IMPLEMENT_WXWIN_MAIN \
- extern "C" int WXAPIENTRY WinMain(HINSTANCE hInstance,\
- HINSTANCE hPrevInstance,\
- LPSTR m_lpCmdLine, int nCmdShow)\
- {\
- return wxEntry((WXHINSTANCE) hInstance,\
- (WXHINSTANCE) hPrevInstance,\
- m_lpCmdLine, nCmdShow);\
+ extern int wxEntry(WXHINSTANCE hInstance, \
+ WXHINSTANCE hPrevInstance, \
+ char *pCmdLine, \
+ int nCmdShow); \
+ extern "C" int wxSTDCALL WinMain(WXHINSTANCE hInstance, \
+ WXHINSTANCE hPrevInstance, \
+ char *lpCmdLine, \
+ int nCmdShow) \
+ { \
+ return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); \
}
#else
#define IMPLEMENT_WXWIN_MAIN
// Use this macro if you want to define your own main() or WinMain() function
// and call wxEntry() from there.
-#define IMPLEMENT_APP_NO_MAIN(appname) \
- wxApp *wxCreateApp() \
- { \
- wxApp::CheckBuildOptions(wxBuildOptions()); \
- return new appname; \
- } \
- wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
+#define IMPLEMENT_APP_NO_MAIN(appname) \
+ wxApp *wxCreateApp() \
+ { \
+ wxApp::CheckBuildOptions(wxBuildOptions()); \
+ return new appname; \
+ } \
+ wxAppInitializer \
+ wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
appname& wxGetApp() { return *(appname *)wxTheApp; }
// Same as IMPLEMENT_APP() normally but doesn't include themes support in
// function
#define DECLARE_APP(appname) extern appname& wxGetApp();
-#endif
- // _WX_APP_H_BASE_
+#endif // _WX_APP_H_BASE_
+
// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
// ----------------------------------------------------------------------------
-class wxConsoleAppTraitsBase : public wxAppTraits
+class WXDLLEXPORT wxConsoleAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
#if wxUSE_GUI
-class wxGUIAppTraitsBase : public wxAppTraits
+class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindowCocoa* win);
- static bool Initialize();
- static void CleanUp();
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
virtual bool OnInit();
virtual bool OnInitGui();
- void DeletePendingObjects();
};
#endif // _WX_COCOA_APP_H_
bool SendIdleEvents();
bool SendIdleEvents( wxWindow* win );
- static bool Initialize();
- static bool InitialzeVisual();
- static void CleanUp();
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
- void DeletePendingObjects();
+ static bool InitialzeVisual();
#ifdef __WXDEBUG__
virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg);
bool SendIdleEvents();
bool SendIdleEvents( wxWindow* win );
- static bool Initialize();
- static bool InitialzeVisual();
- static void CleanUp();
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
- void DeletePendingObjects();
+ static bool InitialzeVisual();
#ifdef __WXDEBUG__
virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg);
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/init.h
+// Purpose: wxWindows initialization and finalization functions
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 29.06.2003
+// RCS-ID: $Id$
+// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_INIT_H_
+#define _WX_INIT_H_
+
+#include "wx/wxchar.h"
+
+// ----------------------------------------------------------------------------
+// wxEntry helper functions which allow to have more fine grained control
+// ----------------------------------------------------------------------------
+
+// do common initialization, return true if ok (in this case wxEntryCleanup
+// must be called later), otherwise the program can't use wxWindows at all
+//
+// this function also creates wxTheApp as a side effect, if IMPLEMENT_APP
+// hadn't been used a dummy default application object is created
+//
+// note that the parameters may be modified
+extern bool WXDLLEXPORT wxEntryStart(int argc, wxChar **argv);
+
+// free the resources allocated by the library in wxEntryStart() and shut it
+// down (wxEntryStart() may be called again afterwards if necessary)
+extern void WXDLLEXPORT wxEntryCleanup();
+
+
+// ----------------------------------------------------------------------------
+// wxEntry: this function initializes the library, runs the main event loop
+// and cleans it up
+// ----------------------------------------------------------------------------
+
+// note that other, platform-specific, overloads of wxEntry may exist as well
+// but this one always exists under all platforms
+//
+// returns the program exit code
+extern int WXDLLEXPORT wxEntry(int argc, wxChar **argv);
+
+
+// ----------------------------------------------------------------------------
+// Using the library without (explicit) application object: you may avoid using
+// DECLARE_APP and IMPLEMENT_APP macros and call the functions below instead at
+// the program startup and termination
+// ----------------------------------------------------------------------------
+
+// initialize the library (may be called as many times as needed, but each
+// call to wxInitialize() must be matched by wxUninitialize())
+extern bool WXDLLEXPORT wxInitialize(int argc = 0, wxChar **argv = NULL);
+
+// clean up -- the library can't be used any more after the last call to
+// wxUninitialize()
+extern void WXDLLEXPORT wxUninitialize();
+
+// create an object of this class on stack to initialize/cleanup the library
+// automatically
+class WXDLLEXPORT wxInitializer
+{
+public:
+ // initialize the library
+ wxInitializer() { m_ok = wxInitialize(); }
+
+ // has the initialization been successful? (explicit test)
+ bool IsOk() const { return m_ok; }
+
+ // has the initialization been successful? (implicit test)
+ operator bool() const { return m_ok; }
+
+ // dtor only does clean up if we initialized the library properly
+ ~wxInitializer() { if ( m_ok ) wxUninitialize(); }
+
+private:
+ bool m_ok;
+};
+
+#endif // _WX_INIT_H_
+
public:
// Implementation
- static bool Initialize();
- static void CleanUp();
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
- void DeletePendingObjects();
bool IsExiting() { return !m_keepGoing ; }
#if TARGET_CARBON
WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
bool SendIdleEvents();
bool SendIdleEvents(wxWindow* win);
- static bool Initialize();
- static void CleanUp();
-
- void DeletePendingObjects();
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
virtual bool Yield(bool onlyIfNeeded = FALSE);
public:
// Implementation
- static bool Initialize();
- static void CleanUp();
-
- void DeletePendingObjects();
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
// Motif-specific
WXAppContext GetAppContext() const { return m_appContext; }
virtual ~wxApp();
// override base class (pure) virtuals
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp();
+
virtual int MainLoop();
virtual void ExitMainLoop();
virtual bool Initialized();
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindow* win);
- void SetAuto3D(bool flag) { m_auto3D = flag; }
- bool GetAuto3D() const { return m_auto3D; }
-
protected:
- bool m_showOnInit;
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
- bool m_auto3D ; // Always use 3D controls, except where overriden
/* Windows-specific wxApp definitions */
public:
// Implementation
- static bool Initialize();
- static void CleanUp();
-
static bool RegisterWindowClasses();
static bool UnregisterWindowClasses();
- // Convert Windows to argc, argv style
- void ConvertToStandardCommandArgs(const char* p);
-
// message processing
// ------------------
// idle processing
// ---------------
- void DeletePendingObjects();
-
#if wxUSE_RICHEDIT
// initialize the richedit DLL of (at least) given version, return TRUE if
// ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3)
static int GetComCtl32Version();
public:
- int m_nCmdShow;
+ // the SW_XXX value to be used for the frames opened by the application
+ // (currently seems unused which is a bug -- TODO)
+ static int m_nCmdShow;
protected:
- bool m_keepGoing;
+ // we exit the main event loop when this flag becomes false
+ bool m_keepGoing;
DECLARE_EVENT_TABLE()
};
-#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance,
- char *lpszCmdLine, int nCmdShow, bool enterLoop = TRUE);
-#else
-int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
-#endif
+ char *lpszCmdLine, int nCmdShow);
-#endif
- // _WX_APP_H_
+#endif // _WX_APP_H_
public:
// Implementation
- static bool Initialize(HAB vHab);
- static void CleanUp(void);
+ virtual bool Initialize(int argc, wxChar **argv);
+ virtual void CleanUp(void);
static bool RegisterWindowClasses(HAB vHab);
virtual void DoMessage(WXMSG *pMsg);
virtual bool DoMessage(void);
virtual bool ProcessMessage(WXMSG* pMsg);
- void DeletePendingObjects(void);
public:
int m_nCmdShow;
public:
// Implementation
- static bool Initialize();
- static void CleanUp();
+ virtual bool Initialize();
+ virtual void CleanUp();
void DeletePendingObjects();
// ----------------------------------------------------------------------------
// wxApp static functions
// ----------------------------------------------------------------------------
-/*static*/ bool wxApp::Initialize()
+
+bool wxApp::Initialize(int argc, wxChar **argv)
{
+ // VZ: apparently this needs to be done a.s.a.p., right? it is done after
+ // wxClassInfo::InitializeClasses() now but usd to be done before, I
+ // hope it's not a problem -- if it is, please let me know, David (if
+ // it isn't, just remove this comment :-)
wxPoseAsInitializer::InitializePosers();
- wxClassInfo::InitializeClasses();
-
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
-#if wxUSE_WX_RESOURCES
- wxInitializeResourceSystem();
-#endif
-
- wxBitmap::InitStandardHandlers();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) {
- return FALSE;
- }
- return TRUE;
+ return wxAppBase::Initialize(argc, argv);
}
-/*static*/ void wxApp::CleanUp()
+void wxApp::CleanUp()
{
- wxModule::CleanUpModules();
-
-#if wxUSE_WX_RESOURCES
- wxCleanUpResourceSystem();
-#endif
-
- wxDeleteStockObjects() ;
-
- // Destroy all GDI lists, etc.
- wxDeleteStockLists();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxBitmap::CleanUpHandlers();
-
- delete wxPendingEvents;
-
-#if wxUSE_THREADS
- delete wxPendingEventsLocker;
- // If we don't do the following, we get an apparent memory leak.
- ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
-#endif
-
- wxClassInfo::CleanUpClasses();
-
- delete wxTheApp;
- wxTheApp = NULL;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks."));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
- // wxDebugContext::SetStream(NULL, NULL);
-#endif
-
wxDC::CocoaShutdownTextSystem();
-#if wxUSE_LOG
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
+
+ wxAppBase::CleanUp();
}
// ----------------------------------------------------------------------------
return true;
}
-void wxApp::DeletePendingObjects()
-{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Find(obj))
- delete node;
-
- node = wxPendingDelete.GetFirst();
- }
-}
-
-// platform specifics
-
#include "wx/apptrait.h"
#include "wx/cmdline.h"
#include "wx/confbase.h"
+#if wxUSE_FILENAME
+ #include "wx/filename.h"
+#endif // wxUSE_FILENAME
#if wxUSE_FONTMAP
#include "wx/fontmap.h"
#endif // wxUSE_FONTMAP
delete m_traits;
}
+// ----------------------------------------------------------------------------
+// initilization/cleanup
+// ----------------------------------------------------------------------------
+
+bool wxAppConsole::Initialize(int argc, wxChar **argv)
+{
+ // remember the command line arguments
+ this->argc = argc;
+ this->argv = argv;
+
+ if ( m_appName.empty() )
+ {
+ // the application name is, by default, the name of its executable file
+#if wxUSE_FILENAME
+ wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL);
+#else // !wxUSE_FILENAME
+ m_appName = argv[0];
+#endif // wxUSE_FILENAME/!wxUSE_FILENAME
+ }
+
+ return true;
+}
+
+void wxAppConsole::CleanUp()
+{
+}
+
// ----------------------------------------------------------------------------
// OnXXX() callbacks
// ----------------------------------------------------------------------------
// ============================================================================
// ----------------------------------------------------------------------------
-// initialization and termination
+// initialization
// ----------------------------------------------------------------------------
wxAppBase::wxAppBase()
m_exitOnFrameDelete = Later;
}
+bool wxAppBase::Initialize(int argc, wxChar **argv)
+{
+ if ( !wxAppConsole::Initialize(argc, argv) )
+ return false;
+
+ // for compatibility call the old initialization function too
+ if ( !OnInitGui() )
+ {
+ wxAppConsole::CleanUp();
+
+ return false;
+ }
+
+#if wxUSE_THREADS
+ wxPendingEventsLocker = new wxCriticalSection;
+#endif
+
+ wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
+ wxTheColourDatabase->Initialize();
+
+ wxInitializeStockLists();
+ wxInitializeStockObjects();
+
+ wxBitmap::InitStandardHandlers();
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+// cleanup
+// ----------------------------------------------------------------------------
+
wxAppBase::~wxAppBase()
{
// this destructor is required for Darwin
}
+void wxAppBase::CleanUp()
+{
+ // one last chance for pending objects to be cleaned up
+ DeletePendingObjects();
+
+ wxBitmap::CleanUpHandlers();
+
+ wxDeleteStockObjects();
+
+ wxDeleteStockLists();
+
+ delete wxTheColourDatabase;
+ wxTheColourDatabase = NULL;
+
+#if wxUSE_THREADS
+ delete wxPendingEvents;
+ wxPendingEvents = NULL;
+
+ delete wxPendingEventsLocker;
+ wxPendingEventsLocker = NULL;
+
+#if wxUSE_VALIDATORS
+ // If we don't do the following, we get an apparent memory leak.
+ ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
+#endif // wxUSE_VALIDATORS
+#endif // wxUSE_THREADS
+}
+
+// ----------------------------------------------------------------------------
+// OnXXX() hooks
+// ----------------------------------------------------------------------------
+
bool wxAppBase::OnInitGui()
{
#ifdef __WXUNIVERSAL__
(void)ProcessEvent(event);
}
+void wxAppBase::DeletePendingObjects()
+{
+ wxNode *node = wxPendingDelete.GetFirst();
+ while (node)
+ {
+ wxObject *obj = node->GetData();
+
+ delete obj;
+
+ if (wxPendingDelete.Member(obj))
+ delete node;
+
+ // Deleting one object may have deleted other pending
+ // objects, so start from beginning of list again.
+ node = wxPendingDelete.GetFirst();
+ }
+}
+
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase
// ----------------------------------------------------------------------------
#if wxUSE_FILESYSTEM && wxUSE_STREAMS
-#include "wx/image.h"
-#include "wx/bitmap.h"
#include "wx/fs_mem.h"
+#if wxUSE_GUI
+ #include "wx/image.h"
+ #include "wx/bitmap.h"
+#endif // wxUSE_GUI
#ifndef WXPRECOMP
#include "wx/intl.h"
#include "wx/debug.h"
#include "wx/filefn.h"
#include "wx/log.h"
+ #include "wx/thread.h"
#endif
+#include "wx/ptr_scpd.h"
#include "wx/module.h"
+#if defined(__WXMSW__) && defined(__WXDEBUG__)
+ #include "wx/msw/msvcrt.h"
+
+ static struct EnableMemLeakChecking
+ {
+ EnableMemLeakChecking()
+ {
+ // do check for memory leaks on program exit (another useful flag
+ // is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free deallocated
+ // memory which may be used to simulate low-memory condition)
+ wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
+ }
+ } gs_enableLeakChecks;
+#endif // __WXMSW__ && __WXDEBUG__
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// we need a dummy app object if the user doesn't want to create a real one
-class wxDummyConsoleApp : public wxApp
+class wxDummyConsoleApp : public wxAppConsole
{
public:
virtual int OnRun() { wxFAIL_MSG( _T("unreachable code") ); return 0; }
};
-// ----------------------------------------------------------------------------
-// private functions
-// ----------------------------------------------------------------------------
+// we need a special kind of auto pointer to wxApp which not only deletes the
+// pointer it holds in its dtor but also resets wxTheApp
+wxDECLARE_SCOPED_PTR(wxApp, wxAppPtrBase);
+wxDEFINE_SCOPED_PTR(wxApp, wxAppPtrBase);
-static bool DoInit();
-static void DoCleanUp();
+class wxAppPtr : public wxAppPtrBase
+{
+public:
+ wxEXPLICIT wxAppPtr(wxApp *ptr = NULL) : wxAppPtrBase(ptr) { }
+ ~wxAppPtr()
+ {
+ if ( get() )
+ {
+ // the pointer is going to be deleted in the base class dtor, don't
+ // leave the dangling pointer!
+ wxTheApp = NULL;
+ }
+ }
+
+ void Set(wxApp *ptr)
+ {
+ reset(ptr);
+
+ wxTheApp = ptr;
+ }
+};
+
+// another tiny class which simply exists to ensure that wxEntryCleanup is
+// always called
+class wxCleanupOnExit
+{
+public:
+ ~wxCleanupOnExit() { wxEntryCleanup(); }
+};
// ----------------------------------------------------------------------------
-// private vars
+// initialization data
// ----------------------------------------------------------------------------
-static size_t gs_nInitCount = 0;
+static struct InitData
+{
+ InitData()
+ {
+ nInitCount = 0;
+
+#if wxUSE_UNICODE
+ argc = 0;
+ // argv = NULL; -- not even really needed
+#endif // wxUSE_UNICODE
+ }
+
+ // critical section protecting this struct
+ wxCRIT_SECT_DECLARE_MEMBER(csInit);
+
+ // number of times wxInitialize() was called minus the number of times
+ // wxUninitialize() was
+ size_t nInitCount;
+
+#if wxUSE_UNICODE
+ int argc;
+
+ // if we receive the command line arguments as ASCII and have to convert
+ // them to Unicode ourselves (this is the case under Unix but not Windows,
+ // for example), we remember the converted argv here because we'll have to
+ // free it when doing cleanup to avoid memory leaks
+ wchar_t *argv;
+#endif // wxUSE_UNICODE
+} gs_initData;
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
-// wxBase-specific functions
+// command line arguments ANSI -> Unicode conversion
// ----------------------------------------------------------------------------
-bool WXDLLEXPORT wxInitialize()
+#if wxUSE_UNICODE
+
+static void ConvertArgsToUnicode(int argc, char **argv)
{
- if ( gs_nInitCount )
+ gs_initData.argv = new wchar_t *[argc + 1];
+ for ( int i = 0; i < argc; i++ )
{
- // already initialized
- return TRUE;
+ gs_initData.argv[i] = wxStrdup(wxConvLocal.cMB2WX(argv[i]));
}
- wxASSERT_MSG( !wxTheApp,
- wxT("either call wxInitialize or create app, not both!") );
+ gs_initData.argv[argc] = NULL;
+}
- if ( !DoInit() )
+static void FreeConvertedArgs()
+{
+ for ( int mb_argc = 0; mb_argc < wxTheApp->argc; mb_argc++ )
{
- return FALSE;
+ free(wxTheApp->argv[mb_argc]);
}
+}
- wxTheApp = new wxDummyConsoleApp;
+#endif // wxUSE_UNICODE
- if ( !wxTheApp )
- {
- return FALSE;
- }
+// ----------------------------------------------------------------------------
+// start up
+// ----------------------------------------------------------------------------
- gs_nInitCount++;
+// initialization which is always done (not customizable) before wxApp creation
+static bool DoCommonPreInit()
+{
+ wxClassInfo::InitializeClasses();
- return TRUE;
+ return true;
}
-void WXDLLEXPORT wxUninitialize()
+// non customizable initialization done after wxApp creation and initialization
+static bool DoCommonPostInit()
{
- if ( !--gs_nInitCount )
- {
- DoCleanUp();
- }
+ wxModule::RegisterModules();
+
+ return wxModule::InitializeModules();
}
-int wxEntry(int argc, char **argv)
+bool wxEntryStart(int argc, wxChar **argv)
{
- // library initialization
- if ( !DoInit() )
+ // do minimal, always necessary, initialization
+ // --------------------------------------------
+
+ // initialize wxRTTI
+ if ( !DoCommonPreInit() )
{
- return -1;
+ return false;
}
- // create the app
- if ( !wxTheApp )
- {
- wxCHECK_MSG( wxApp::GetInitializerFunction(), -1,
- wxT("No application object: use IMPLEMENT_APP macro.") );
+ // first of all, we need an application object
+ // -------------------------------------------
+
+ // the user might have already created it himself somehow
+ wxAppPtr app(wxTheApp);
+ if ( !app.get() )
+ {
+ // if not, he might have used IMPLEMENT_APP() to give us a function to
+ // create it
wxAppInitializerFunction fnCreate = wxApp::GetInitializerFunction();
- wxTheApp = (wxApp *)fnCreate();
+ if ( fnCreate )
+ {
+ // he did, try to create the custom wxApp object
+ app.Set((*fnCreate)());
+ }
+ }
+
+ if ( !app.get() )
+ {
+ // either IMPLEMENT_APP() was not used at all or it failed -- in any
+ // case we still need something
+ //
+ // NB: cast is needed because for the backwards-compatibility reasons
+ // wxTheApp is really a wxApp and not just wxAppConsole...
+ app.Set((wxApp *)new wxDummyConsoleApp);
}
- wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
- // app preinitialization
- wxTheApp->argc = argc;
+ // wxApp initialization: this can be customized
+ // --------------------------------------------
-#if wxUSE_UNICODE
- wxTheApp->argv = new wxChar*[argc+1];
- for ( int mb_argc = 0; mb_argc < argc; mb_argc++ )
+ if ( !wxTheApp->Initialize(argc, argv) )
{
- wxTheApp->argv[mb_argc] = wxStrdup(wxConvLocal.cMB2WX(argv[mb_argc]));
+ return false;
}
- wxTheApp->argv[mb_argc] = (wxChar *)NULL;
-#else
- wxTheApp->argv = argv;
-#endif
- wxString name = wxFileNameFromPath(wxTheApp->argv[0]);
- wxStripExtension(name);
- wxTheApp->SetAppName(name);
- int retValue = 0;
-
- // app initialization
- if ( !wxTheApp->OnInit() )
- retValue = -1;
+ // common initialization after wxTheApp creation
+ // ---------------------------------------------
- // app execution
- if ( retValue == 0 )
+ if ( !DoCommonPostInit() )
{
- retValue = wxTheApp->OnRun();
-
- // app clean up
- wxTheApp->OnExit();
+ return false;
}
- // library clean up
- DoCleanUp();
- return retValue;
+ // prevent the smart pointer from destroying its contents
+ app.release();
+
+ return true;
}
-// ----------------------------------------------------------------------------
-// private functions
-// ----------------------------------------------------------------------------
+#if wxUSE_UNICODE
-static bool DoInit()
+// we provide a wxEntryStart() wrapper taking "char *" pointer too
+bool wxEntryStart(int argc, char **argv)
{
- wxClassInfo::InitializeClasses();
+ ConvertArgsToUnicode(argc, argv);
- wxModule::RegisterModules();
- if ( !wxModule::InitializeModules() )
+ if ( !wxEntryStart(argc, gs_initData.argv) )
{
- return FALSE;
+ FreeConvertedArgs();
+
+ return false;
}
- return TRUE;
+ return true;
}
-static void DoCleanUp()
+#endif // wxUSE_UNICODE
+
+// ----------------------------------------------------------------------------
+// clean up
+// ----------------------------------------------------------------------------
+
+// cleanup done before destroying wxTheApp
+static void DoCommonPreCleanup()
{
#if wxUSE_LOG
- // flush the logged messages if any
- wxLog *log = wxLog::GetActiveTarget();
- if (log != NULL && log->HasPendingMessages())
- log->Flush();
-
- // continuing to use user defined log target is unsafe from now on because
- // some resources may be already unavailable, so replace it by something
- // more safe
+ // flush the logged messages if any and install a 'safer' log target: the
+ // default one (wxLogGui) can't be used after the resources are freed just
+ // below and the user supplied one might be even more unsafe (using any
+ // wxWindows GUI function is unsafe starting from now)
wxLog::DontCreateOnDemand();
+
+ // this will flush the old messages if any
delete wxLog::SetActiveTarget(new wxLogStderr);
#endif // wxUSE_LOG
wxModule::CleanUpModules();
+}
+// cleanup done after destroying wxTheApp
+static void DoCommonPostCleanup()
+{
wxClassInfo::CleanUpClasses();
- // TODO: this should really be done in ~wxApp
+ // we can't do this in wxApp itself because it doesn't know if argv had
+ // been allocated
#if wxUSE_UNICODE
- for ( int mb_argc = 0; mb_argc < wxTheApp->argc; mb_argc++ )
- {
- free(wxTheApp->argv[mb_argc]);
- }
+ FreeConvertedArgs();
#endif // wxUSE_UNICODE
- // delete the application object
- delete wxTheApp;
- wxTheApp = (wxApp *)NULL;
-
#if wxUSE_LOG
// and now delete the last logger as well
delete wxLog::SetActiveTarget(NULL);
#endif // wxUSE_LOG
}
+void wxEntryCleanup()
+{
+ DoCommonPreCleanup();
+
+
+ // delete the application object
+ if ( wxTheApp )
+ {
+ wxTheApp->CleanUp();
+
+ delete wxTheApp;
+ wxTheApp = NULL;
+ }
+
+
+ DoCommonPostCleanup();
+
+ // check for memory leaks
+#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
+ if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
+ {
+ wxLogDebug(wxT("There were memory leaks.\n"));
+ wxDebugContext::Dump();
+ wxDebugContext::PrintStatistics();
+ }
+#endif // Debug
+
+}
+
+// ----------------------------------------------------------------------------
+// wxEntry
+// ----------------------------------------------------------------------------
+
+#if !defined(__WXMSW__) || !wxUSE_ON_FATAL_EXCEPTION
+ #define wxEntryReal wxEntry
+#endif // !(__WXMSW__ && wxUSE_ON_FATAL_EXCEPTION)
+
+int wxEntryReal(int argc, wxChar **argv)
+{
+ // library initialization
+ if ( !wxEntryStart(argc, argv) )
+ {
+ return -1;
+ }
+
+ // if wxEntryStart succeeded, we must call wxEntryCleanup even if the code
+ // below returns or throws
+ wxCleanupOnExit cleanupOnExit;
+
+ // app initialization
+ if ( !wxTheApp->OnInit() )
+ {
+ // don't call OnExit() if OnInit() failed
+ return -1;
+ }
+
+ // app execution
+ int retValue = wxTheApp->OnRun();
+
+ // why should we do this? it doesn't close all window, just one of them and
+ // this shouldn't be necessary anyhow...
+#if 0
+ // close any remaining windows
+ wxWindow *topWindow = wxTheApp->GetTopWindow();
+ if ( topWindow )
+ {
+ // forcibly delete the window.
+ topWindow->Destroy();
+
+ // collect the dead objects
+ wxTheApp->DeletePendingObjects();
+ }
+#endif // 0
+
+ // app clean up
+ wxTheApp->OnExit();
+
+ return retValue;
+}
+
+// wrap real wxEntry in a try-except block to be able to call
+// OnFatalException() if necessary
+#if defined(__WXMSW__) && wxUSE_ON_FATAL_EXCEPTION
+
+extern unsigned long wxGlobalSEHandler();
+
+int wxEntry(int argc, wxChar **argv)
+{
+ __try
+ {
+ return wxEntryReal(argc, argv);
+ }
+ __except ( wxGlobalSEHandler() )
+ {
+ ::ExitProcess(3); // the same exit code as abort()
+
+ // this code is unreachable but put it here to suppress warnings
+ return -1;
+ }
+}
+
+#endif // __WXMSW__ && wxUSE_ON_FATAL_EXCEPTION
+
+#if wxUSE_UNICODE
+
+// as with wxEntryStart, we provide an ANSI wrapper
+int wxEntry(int argc, char **argv)
+{
+ ConvertArgsToUnicode(argc, argv);
+
+ return wxEntry(argc, gs_initData.argv);
+}
+
+#endif // wxUSE_UNICODE
+
+// ----------------------------------------------------------------------------
+// wxInitialize/wxUninitialize
+// ----------------------------------------------------------------------------
+
+bool wxInitialize(int argc, wxChar **argv)
+{
+ wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit);
+
+ if ( gs_initData.nInitCount++ )
+ {
+ // already initialized
+ return true;
+ }
+
+ return wxEntryStart(argc, argv);
+}
+
+void wxUninitialize()
+{
+ wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit);
+
+ if ( !--gs_initData.nInitCount )
+ {
+ wxEntryCleanup();
+ }
+}
+
gtk_main_iteration();
}
-void wxApp::DeletePendingObjects()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Find(obj))
- delete node;
-
- node = wxPendingDelete.GetFirst();
- }
-}
-
-bool wxApp::Initialize()
-{
- wxClassInfo::InitializeClasses();
-
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- wxPendingEvents = new wxList();
- wxPendingEventsLocker = new wxCriticalSection();
-#endif
-
- wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules())
- return FALSE;
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
- return TRUE;
+ return true;
}
void wxApp::CleanUp()
{
- wxModule::CleanUpModules();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = (wxColourDatabase*) NULL;
-
- wxDeleteStockObjects();
-
- wxDeleteStockLists();
-
- delete wxTheApp;
- wxTheApp = (wxApp*) NULL;
-
- wxClassInfo::CleanUpClasses();
-
-#if wxUSE_THREADS
- delete wxPendingEvents;
- wxPendingEvents = NULL;
- delete wxPendingEventsLocker;
- wxPendingEventsLocker = NULL;
-#endif
-
- // check for memory leaks
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks.\n"));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif // Debug
-
-#if wxUSE_LOG
- // do this as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
-
- wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
- if (oldLog)
- delete oldLog;
-#endif // wxUSE_LOG
+ wxAppBase::CleanUp();
}
//-----------------------------------------------------------------------------
gtk_main_iteration();
}
-void wxApp::DeletePendingObjects()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Find(obj))
- delete node;
-
- node = wxPendingDelete.GetFirst();
- }
-}
-
-bool wxApp::Initialize()
-{
- wxClassInfo::InitializeClasses();
-
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- wxPendingEvents = new wxList();
- wxPendingEventsLocker = new wxCriticalSection();
-#endif
-
- wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules())
- return FALSE;
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
- return TRUE;
+ return true;
}
void wxApp::CleanUp()
{
- wxModule::CleanUpModules();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = (wxColourDatabase*) NULL;
-
- wxDeleteStockObjects();
-
- wxDeleteStockLists();
-
- delete wxTheApp;
- wxTheApp = (wxApp*) NULL;
-
- wxClassInfo::CleanUpClasses();
-
-#if wxUSE_THREADS
- delete wxPendingEvents;
- wxPendingEvents = NULL;
- delete wxPendingEventsLocker;
- wxPendingEventsLocker = NULL;
-#endif
-
- // check for memory leaks
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks.\n"));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif // Debug
-
-#if wxUSE_LOG
- // do this as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
-
- wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
- if (oldLog)
- delete oldLog;
-#endif // wxUSE_LOG
+ wxAppBase::CleanUp();
}
//-----------------------------------------------------------------------------
WXIMPORT char std::__throws_bad_alloc ;
#endif
-bool wxApp::Initialize()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
int error = 0 ;
s_macCursorRgn = ::NewRgn() ;
- wxClassInfo::InitializeClasses();
-
-#if wxUSE_RESOURCES
-// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
-#endif
-
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
wxWinMacWindowList = new wxList(wxKEY_INTEGER);
wxWinMacControlList = new wxList(wxKEY_INTEGER);
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxBitmap::InitStandardHandlers();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) {
- return FALSE;
- }
-
wxMacCreateNotifierTable() ;
UMAShowArrowCursor() ;
- return TRUE;
+ return true;
}
bool wxApp::OnInitGui()
void wxApp::CleanUp()
{
wxToolTip::RemoveToolTips() ;
-#if wxUSE_LOG
- // flush the logged messages if any and install a 'safer' log target: the
- // default one (wxLogGui) can't be used after the resources are freed just
- // below and the user suppliedo ne might be even more unsafe (using any
- // wxWindows GUI function is unsafe starting from now)
- wxLog::DontCreateOnDemand();
-
- // this will flush the old messages if any
- delete wxLog::SetActiveTarget(new wxLogStderr);
-#endif // wxUSE_LOG
// One last chance for pending objects to be cleaned up
wxTheApp->DeletePendingObjects();
- wxModule::CleanUpModules();
-
- wxDeleteStockObjects() ;
-
- // Destroy all GDI lists, etc.
- wxDeleteStockLists();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxBitmap::CleanUpHandlers();
-
wxMacDestroyNotifierTable() ;
- if (wxWinMacWindowList) {
- delete wxWinMacWindowList ;
- }
- if (wxWinMacControlList) {
- delete wxWinMacControlList ;
- }
- delete wxPendingEvents;
- wxPendingEvents = NULL;
-#if wxUSE_THREADS
- delete wxPendingEventsLocker;
- // There is still more cleanup code that will try to use this if not NULL.
- wxPendingEventsLocker = NULL;
- // If we don't do the following, we get an apparent memory leak.
- ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
-#endif
+ delete wxWinMacWindowList ;
+ wxWinMacWindowList = NULL;
- wxClassInfo::CleanUpClasses();
+ delete wxWinMacControlList ;
+ wxWinMacControlList = NULL;
#ifndef __DARWIN__
# if __option(profile)
# endif
#endif
- delete wxTheApp;
- wxTheApp = NULL;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks."));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
- // wxDebugContext::SetStream(NULL, NULL);
-#endif
-
-#if wxUSE_LOG
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
-
#if defined(WXMAKINGDLL) && defined(__DARWIN__)
// close shared library resources from here since we don't have
// __wxterminate in Mach-O shared libraries
#if 0
TerminateAE() ;
#endif
+
+ wxAppBase::CleanUp();
}
//----------------------------------------------------------------------
return needMore ;
}
-void wxApp::DeletePendingObjects()
-{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Member(obj))
- delete node;
-
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- node = wxPendingDelete.GetFirst();
- }
-}
-
void wxApp::Exit()
{
wxApp::CleanUp();
WXIMPORT char std::__throws_bad_alloc ;
#endif
-bool wxApp::Initialize()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
int error = 0 ;
s_macCursorRgn = ::NewRgn() ;
- wxClassInfo::InitializeClasses();
-
-#if wxUSE_RESOURCES
-// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
-#endif
-
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
wxWinMacWindowList = new wxList(wxKEY_INTEGER);
wxWinMacControlList = new wxList(wxKEY_INTEGER);
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxBitmap::InitStandardHandlers();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) {
- return FALSE;
- }
-
wxMacCreateNotifierTable() ;
UMAShowArrowCursor() ;
- return TRUE;
+ return true;
}
bool wxApp::OnInitGui()
void wxApp::CleanUp()
{
wxToolTip::RemoveToolTips() ;
-#if wxUSE_LOG
- // flush the logged messages if any and install a 'safer' log target: the
- // default one (wxLogGui) can't be used after the resources are freed just
- // below and the user suppliedo ne might be even more unsafe (using any
- // wxWindows GUI function is unsafe starting from now)
- wxLog::DontCreateOnDemand();
-
- // this will flush the old messages if any
- delete wxLog::SetActiveTarget(new wxLogStderr);
-#endif // wxUSE_LOG
// One last chance for pending objects to be cleaned up
wxTheApp->DeletePendingObjects();
- wxModule::CleanUpModules();
-
- wxDeleteStockObjects() ;
-
- // Destroy all GDI lists, etc.
- wxDeleteStockLists();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxBitmap::CleanUpHandlers();
-
wxMacDestroyNotifierTable() ;
- if (wxWinMacWindowList) {
- delete wxWinMacWindowList ;
- }
- if (wxWinMacControlList) {
- delete wxWinMacControlList ;
- }
- delete wxPendingEvents;
- wxPendingEvents = NULL;
-#if wxUSE_THREADS
- delete wxPendingEventsLocker;
- // There is still more cleanup code that will try to use this if not NULL.
- wxPendingEventsLocker = NULL;
- // If we don't do the following, we get an apparent memory leak.
- ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
-#endif
+ delete wxWinMacWindowList ;
+ wxWinMacWindowList = NULL;
- wxClassInfo::CleanUpClasses();
+ delete wxWinMacControlList ;
+ wxWinMacControlList = NULL;
#ifndef __DARWIN__
# if __option(profile)
# endif
#endif
- delete wxTheApp;
- wxTheApp = NULL;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks."));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
- // wxDebugContext::SetStream(NULL, NULL);
-#endif
-
-#if wxUSE_LOG
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
-
#if defined(WXMAKINGDLL) && defined(__DARWIN__)
// close shared library resources from here since we don't have
// __wxterminate in Mach-O shared libraries
#if 0
TerminateAE() ;
#endif
+
+ wxAppBase::CleanUp();
}
//----------------------------------------------------------------------
return needMore ;
}
-void wxApp::DeletePendingObjects()
-{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Member(obj))
- delete node;
-
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- node = wxPendingDelete.GetFirst();
- }
-}
-
void wxApp::Exit()
{
wxApp::CleanUp();
wxEventLoop::GetActive()->Dispatch();
}
-void wxApp::DeletePendingObjects()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
- wxNode *node = wxPendingDelete.First();
- while (node)
- {
- wxObject *obj = (wxObject *)node->Data();
-
- delete obj;
+ // must do it before calling wxAppBase::Initialize(), because fonts are
+ // needed by stock lists which are created there
+ wxTheFontsManager = new wxFontsManager;
- if ( wxPendingDelete.Find(obj) )
- delete node;
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
- node = wxPendingDelete.First();
- }
-}
-
-bool wxApp::Initialize()
-{
if ( MGL_init(".", NULL) == 0 )
{
wxLogError(_("Cannot initialize SciTech MGL!"));
- return FALSE;
- }
- wxClassInfo::InitializeClasses();
+ wxAppBase::CleanUp();
+
+ return false;
+ }
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- wxPendingEvents = new wxList;
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
-
- // Can't do this in wxModule, because fonts are needed by stock lists
- wxTheFontsManager = new wxFontsManager;
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
-
- return TRUE;
+ return true;
}
void wxApp::CleanUp()
{
-#if wxUSE_LOG
- // continuing to use user defined log target is unsafe from now on because
- // some resources may be already unavailable, so replace it by something
- // more safe
- wxLog *oldlog = wxLog::SetActiveTarget(new wxLogStderr);
- if ( oldlog )
- delete oldlog;
-#endif // wxUSE_LOG
-
delete gs_rootWindow;
- wxModule::CleanUpModules();
-
- if (wxTheColourDatabase)
- delete wxTheColourDatabase;
-
- wxTheColourDatabase = (wxColourDatabase*) NULL;
-
- wxDeleteStockObjects();
- wxDeleteStockLists();
-
- delete wxTheApp;
- wxTheApp = (wxApp*) NULL;
-
-
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- delete wxPendingEvents;
- delete wxPendingEventsLocker;
-#endif
-
- wxClassInfo::CleanUpClasses();
+ wxAppBase::CleanUp();
- // Can't do this in wxModule, because fonts are needed by stock lists
- // (do it after deleting wxTheApp and cleaning modules up, since somebody
- // may be deleting fonts that lately)
+ // must do this after calling base class CleanUp()
delete wxTheFontsManager;
wxTheFontsManager = (wxFontsManager*) NULL;
- // check for memory leaks
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks.\n"));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif // Debug
-
-#if wxUSE_LOG
- // do this as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
-
- wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
- if (oldLog)
- delete oldLog;
-#endif // wxUSE_LOG
-
wxDestroyMGL_WM();
MGL_exit();
}
}
#endif // __WXDEBUG__
-bool wxApp::Initialize()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
- wxClassInfo::InitializeClasses();
-
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection();
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
-
- return TRUE;
+ return true;
}
void wxApp::CleanUp()
{
- wxModule::CleanUpModules();
-
- wxDeleteStockObjects() ;
-
- // Destroy all GDI lists, etc.
-
- wxDeleteStockLists();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxClassInfo::CleanUpClasses();
-
- delete wxTheApp;
- wxTheApp = NULL;
-
delete wxWidgetHashTable;
wxWidgetHashTable = NULL;
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- delete wxPendingEvents;
- wxPendingEvents = NULL;
- delete wxPendingEventsLocker;
- wxPendingEventsLocker = NULL;
-#endif
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug("There were memory leaks.\n");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif
-
- // do it as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
+ wxAppBase::CleanUp();
}
void wxApp::Exit()
return needMore ;
}
-void wxApp::DeletePendingObjects()
-{
- wxList::Node *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Member(obj))
- delete node;
-
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- node = wxPendingDelete.GetFirst();
- }
-}
-
static char *fallbackResources[] = {
"*menuBar.marginHeight: 0",
"*menuBar.shadowThickness: 1",
#endif
#include "wx/apptrait.h"
-#include "wx/cmdline.h"
#include "wx/filename.h"
#include "wx/module.h"
#include <commctrl.h>
#endif
-#ifndef __WXMICROWIN__
-#include "wx/msw/msvcrt.h"
-#endif
-
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass");
const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR");
-HICON wxSTD_FRAME_ICON = (HICON) NULL;
-HICON wxSTD_MDICHILDFRAME_ICON = (HICON) NULL;
-HICON wxSTD_MDIPARENTFRAME_ICON = (HICON) NULL;
-
-HICON wxDEFAULT_FRAME_ICON = (HICON) NULL;
-HICON wxDEFAULT_MDICHILDFRAME_ICON = (HICON) NULL;
-HICON wxDEFAULT_MDIPARENTFRAME_ICON = (HICON) NULL;
-
HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
-LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
-// FIXME wxUSE_ON_FATAL_EXCEPTION is only supported for VC++ now because it
-// needs compiler support for Win32 SEH. Others (especially Borland)
-// probably have it too, but I'm not sure about how it works
-// JACS: get 'Cannot use __try in functions that require unwinding
-// in Unicode mode, so disabling.
-#if !defined(__VISUALC__) || defined(__WIN16__) || defined(UNICODE)
- #undef wxUSE_ON_FATAL_EXCEPTION
- #define wxUSE_ON_FATAL_EXCEPTION 0
-#endif // VC++
-
-#if wxUSE_ON_FATAL_EXCEPTION
- static bool gs_handleExceptions = FALSE;
-#endif
+LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
// ===========================================================================
// wxGUIAppTraits implementation
// wxApp implementation
// ===========================================================================
+int wxApp::m_nCmdShow = SW_SHOWNORMAL;
+
// ---------------------------------------------------------------------------
// wxWin macros
// ---------------------------------------------------------------------------
EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
END_EVENT_TABLE()
+// class to ensure that wxAppBase::CleanUp() is called if our Initialize()
+// fails
+class wxCallBaseCleanup
+{
+public:
+ wxCallBaseCleanup(wxApp *app) : m_app(app) { }
+ ~wxCallBaseCleanup() { if ( m_app ) m_app->wxAppBase::CleanUp(); }
+
+ void Dismiss() { m_app = NULL; }
+
+private:
+ wxApp *m_app;
+};
+
//// Initialize
-bool wxApp::Initialize()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
+
+ // ensure that base cleanup is done if we return too early
+ wxCallBaseCleanup callBaseCleanup(this);
+
// the first thing to do is to check if we're trying to run an Unicode
// program under Win9x w/o MSLU emulation layer - if so, abort right now
// as it has no chance to work
wxBuffer = new wxChar[1500]; // FIXME
- wxClassInfo::InitializeClasses();
-
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxBitmap::InitStandardHandlers();
-
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
InitCommonControls();
#endif // __WIN95__
Ctl3dAutoSubclass(wxhInstance);
#endif // wxUSE_CTL3D
- // VZ: these icons are not in wx.rc anyhow (but should they?)!
-#if 0
- wxSTD_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_FRAME"));
- wxSTD_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDIPARENTFRAME"));
- wxSTD_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDICHILDFRAME"));
-
- wxDEFAULT_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_FRAME"));
- wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDIPARENTFRAME"));
- wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDICHILDFRAME"));
-#endif // 0
-
RegisterWindowClasses();
#ifndef __WXMICROWIN__
wxSetKeyboardHook(TRUE);
#endif
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules())
- return FALSE;
- return TRUE;
+ callBaseCleanup.Dismiss();
+
+ return true;
}
// ---------------------------------------------------------------------------
return retval;
}
-// ---------------------------------------------------------------------------
-// Convert Windows to argc, argv style
-// ---------------------------------------------------------------------------
-
-void wxApp::ConvertToStandardCommandArgs(const char* lpCmdLine)
-{
- // break the command line in words
- wxArrayString args =
- wxCmdLineParser::ConvertStringToArgs(wxConvertMB2WX(lpCmdLine));
-
- // +1 here for the program name
- argc = args.GetCount() + 1;
-
- // and +1 here for the terminating NULL
- argv = new wxChar *[argc + 1];
-
- argv[0] = new wxChar[260]; // 260 is MAX_PATH value from windef.h
- ::GetModuleFileName(wxhInstance, argv[0], 260);
-
- // also set the app name from argv[0]
- wxString name;
- wxFileName::SplitPath(argv[0], NULL, &name, NULL);
-
- // but don't override the name already set by the user code, if any
- if ( GetAppName().empty() )
- SetAppName(name);
-
- // copy all the other arguments to wxApp::argv[]
- for ( int i = 1; i < argc; i++ )
- {
- argv[i] = copystring(args[i - 1]);
- }
-
- // argv[] must be NULL-terminated
- argv[argc] = NULL;
-}
-
-//// Cleans up any wxWindows internal structures left lying around
-
void wxApp::CleanUp()
{
- //// COMMON CLEANUP
-
-#if wxUSE_LOG
- // flush the logged messages if any and install a 'safer' log target: the
- // default one (wxLogGui) can't be used after the resources are freed just
- // below and the user suppliedo ne might be even more unsafe (using any
- // wxWindows GUI function is unsafe starting from now)
- wxLog::DontCreateOnDemand();
-
- // this will flush the old messages if any
- delete wxLog::SetActiveTarget(new wxLogStderr);
-#endif // wxUSE_LOG
-
- // One last chance for pending objects to be cleaned up
- wxTheApp->DeletePendingObjects();
-
- wxModule::CleanUpModules();
-
- wxDeleteStockObjects();
-
- // Destroy all GDI lists, etc.
- wxDeleteStockLists();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxBitmap::CleanUpHandlers();
-
delete[] wxBuffer;
wxBuffer = NULL;
- //// WINDOWS-SPECIFIC CLEANUP
-
#ifndef __WXMICROWIN__
wxSetKeyboardHook(FALSE);
#endif
wxCleanUpPenWin();
#endif
- if (wxSTD_FRAME_ICON)
- DestroyIcon(wxSTD_FRAME_ICON);
- if (wxSTD_MDICHILDFRAME_ICON)
- DestroyIcon(wxSTD_MDICHILDFRAME_ICON);
- if (wxSTD_MDIPARENTFRAME_ICON)
- DestroyIcon(wxSTD_MDIPARENTFRAME_ICON);
-
- if (wxDEFAULT_FRAME_ICON)
- DestroyIcon(wxDEFAULT_FRAME_ICON);
- if (wxDEFAULT_MDICHILDFRAME_ICON)
- DestroyIcon(wxDEFAULT_MDICHILDFRAME_ICON);
- if (wxDEFAULT_MDIPARENTFRAME_ICON)
- DestroyIcon(wxDEFAULT_MDIPARENTFRAME_ICON);
-
if ( wxDisableButtonBrush )
::DeleteObject( wxDisableButtonBrush );
::OleUninitialize();
#endif
-#ifdef WXMAKINGDLL
// for an EXE the classes are unregistered when it terminates but DLL may
// be loaded several times (load/unload/load) into the same process in
// which case the registration will fail after the first time if we don't
// unregister the classes now
UnregisterWindowClasses();
-#endif // WXMAKINGDLL
#if wxUSE_CTL3D
Ctl3dUnregister(wxhInstance);
#endif
delete wxWinHandleHash;
- wxWinHandleHash = NULL; // Set to null in case anything later tries to ref it.
-
- delete wxPendingEvents;
- wxPendingEvents = NULL; // Set to null because wxAppBase::wxEvtHandler is destroyed later.
-
-#if wxUSE_THREADS
- delete wxPendingEventsLocker;
- wxPendingEventsLocker = NULL; // Set to null because wxAppBase::wxEvtHandler is destroyed later.
- // If we don't do the following, we get an apparent memory leak
-#if wxUSE_VALIDATORS
- ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
-#endif // wxUSE_VALIDATORS
-#endif // wxUSE_THREADS
-
- wxClassInfo::CleanUpClasses();
-
- delete wxTheApp;
- wxTheApp = NULL;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogMessage(wxT("There were memory leaks."));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
- // wxDebugContext::SetStream(NULL, NULL);
-#endif
-
-#if wxUSE_LOG
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
-}
-
-//----------------------------------------------------------------------
-// Entry point helpers, used by wxPython
-//----------------------------------------------------------------------
-
-int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char** WXUNUSED(argv) )
-{
- return wxApp::Initialize();
-}
-
-int WXDLLEXPORT wxEntryInitGui()
-{
- return wxTheApp->OnInitGui();
-}
-
-void WXDLLEXPORT wxEntryCleanup()
-{
- wxApp::CleanUp();
-}
-
-
-#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
-
-// temporarily disable this warning which would be generated in release builds
-// because of __try
-#ifdef __VISUALC__
- #pragma warning(disable: 4715) // not all control paths return a value
-#endif // Visual C++
+ wxWinHandleHash = NULL;
-//----------------------------------------------------------------------
-// Main wxWindows entry point
-//----------------------------------------------------------------------
-int wxEntry(WXHINSTANCE hInstance,
- WXHINSTANCE WXUNUSED(hPrevInstance),
- char *lpCmdLine,
- int nCmdShow,
- bool enterLoop)
-{
- // do check for memory leaks on program exit
- // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
- // deallocated memory which may be used to simulate low-memory condition)
-#ifndef __WXMICROWIN__
- wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
-#endif
-
-#ifdef __MWERKS__
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // This seems to be necessary since there are 'rogue'
- // objects present at this point (perhaps global objects?)
- // Setting a checkpoint will ignore them as far as the
- // memory checking facility is concerned.
- // Of course you may argue that memory allocated in globals should be
- // checked, but this is a reasonable compromise.
- wxDebugContext::SetCheckpoint();
-#endif
-#endif
-
- // take everything into a try-except block to be able to call
- // OnFatalException() if necessary
-#if wxUSE_ON_FATAL_EXCEPTION
- __try {
-#endif
- wxhInstance = (HINSTANCE) hInstance;
-
- if (!wxEntryStart(0,0))
- return 0;
-
- // create the application object or ensure that one already exists
- if (!wxTheApp)
- {
- // The app may have declared a global application object, but we recommend
- // the IMPLEMENT_APP macro is used instead, which sets an initializer
- // function for delayed, dynamic app object construction.
- wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
- wxT("No initializer - use IMPLEMENT_APP macro.") );
-
- wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
- }
-
- wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
-
- // save the WinMain() parameters
- if (lpCmdLine) // MicroWindows passes NULL
- wxTheApp->ConvertToStandardCommandArgs(lpCmdLine);
- wxTheApp->m_nCmdShow = nCmdShow;
-
- // We really don't want timestamps by default, because it means
- // we can't simply double-click on the error message and get to that
- // line in the source. So VC++ at least, let's have a sensible default.
-#ifdef __VISUALC__
-#if wxUSE_LOG
- wxLog::SetTimestamp(NULL);
-#endif // wxUSE_LOG
-#endif // __VISUALC__
-
- // init the app
- int retValue = wxEntryInitGui() && wxTheApp->OnInit() ? 0 : -1;
-
- if ( retValue == 0 )
- {
- if ( enterLoop )
- {
- // run the main loop
- wxTheApp->OnRun();
- }
- else
- {
- // we want to initialize, but not run or exit immediately.
- return 1;
- }
- }
- //else: app initialization failed, so we skipped OnRun()
-
- wxWindow *topWindow = wxTheApp->GetTopWindow();
- if ( topWindow )
- {
- // Forcibly delete the window.
- if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
- topWindow->IsKindOf(CLASSINFO(wxDialog)) )
- {
- topWindow->Close(TRUE);
- wxTheApp->DeletePendingObjects();
- }
- else
- {
- delete topWindow;
- wxTheApp->SetTopWindow(NULL);
- }
- }
-
- retValue = wxTheApp->OnExit();
-
- wxEntryCleanup();
-
- return retValue;
-
-#if wxUSE_ON_FATAL_EXCEPTION
- }
- __except ( gs_handleExceptions ? EXCEPTION_EXECUTE_HANDLER
- : EXCEPTION_CONTINUE_SEARCH ) {
- if ( wxTheApp )
- {
- // give the user a chance to do something special about this
- wxTheApp->OnFatalException();
- }
-
- ::ExitProcess(3); // the same exit code as abort()
-
- // NOTREACHED
- }
-#endif // wxUSE_ON_FATAL_EXCEPTION
+ wxAppBase::CleanUp();
}
-// restore warning state
-#ifdef __VISUALC__
- #pragma warning(default: 4715) // not all control paths return a value
-#endif // Visual C++
-
-#else /* _WINDLL */
-
-//----------------------------------------------------------------------
-// Entry point for wxWindows + the App in a DLL
-//----------------------------------------------------------------------
-
-int wxEntry(WXHINSTANCE hInstance)
-{
- wxhInstance = (HINSTANCE) hInstance;
- wxEntryStart(0, 0);
-
- // The app may have declared a global application object, but we recommend
- // the IMPLEMENT_APP macro is used instead, which sets an initializer function
- // for delayed, dynamic app object construction.
- if (!wxTheApp)
- {
- wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
- "No initializer - use IMPLEMENT_APP macro." );
-
- wxTheApp = (* wxApp::GetInitializerFunction()) ();
- }
-
- wxCHECK_MSG( wxTheApp, 0, "You have to define an instance of wxApp!" );
-
- wxTheApp->argc = 0;
- wxTheApp->argv = NULL;
-
- wxEntryInitGui();
-
- wxTheApp->OnInit();
-
- wxWindow *topWindow = wxTheApp->GetTopWindow();
- if ( topWindow && topWindow->GetHWND())
- {
- topWindow->Show(TRUE);
- }
-
- return 1;
-}
-#endif // _WINDLL
-
-//// Static member initialization
+// ----------------------------------------------------------------------------
+// wxApp ctor/dtor
+// ----------------------------------------------------------------------------
wxApp::wxApp()
{
- argc = 0;
- argv = NULL;
m_printMode = wxPRINT_WINDOWS;
- m_auto3D = TRUE;
}
wxApp::~wxApp()
{
- // Delete command-line args
- int i;
- for (i = 0; i < argc; i++)
+ // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
+ // don't come from main(), so we have to free them
+
+ while ( argc )
{
- delete[] argv[i];
+ // m_argv elements were allocated by wxStrdup()
+ free(argv[--argc]);
}
- delete[] argv;
+
+ // but m_argv itself -- using new[]
+ delete [] argv;
}
bool wxApp::Initialized()
}
}
-void wxApp::DeletePendingObjects()
-{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Member(obj))
- delete node;
-
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- node = wxPendingDelete.GetFirst();
- }
-}
-
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
if (GetTopWindow())
return TRUE;
}
-bool wxHandleFatalExceptions(bool doit)
-{
-#if wxUSE_ON_FATAL_EXCEPTION
- // assume this can only be called from the main thread
- gs_handleExceptions = doit;
-
- return TRUE;
-#else
- wxFAIL_MSG(_T("set wxUSE_ON_FATAL_EXCEPTION to 1 to use this function"));
-
- (void)doit;
- return FALSE;
-#endif
-}
-
-//-----------------------------------------------------------------------------
-
-// For some reason, with MSVC++ 1.5, WinMain isn't linked in properly
-// if in a separate file. So include it here to ensure it's linked.
-#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__WINE__) && !defined(WXMAKINGDLL))
-#include "main.cpp"
-#endif
WXHICON wxFrame::GetDefaultIcon() const
{
- return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON
- : wxDEFAULT_FRAME_ICON);
+ // we don't have any standard icons (any more)
+ return (WXHICON)0;
}
// ===========================================================================
#include "wx/event.h"
#include "wx/app.h"
+#include "wx/cmdline.h"
#include "wx/msw/private.h"
#define HINSTANCE HANDLE
#endif
+#if wxUSE_GUI
+
// ----------------------------------------------------------------------------
// function prototypes
// ----------------------------------------------------------------------------
// from src/msw/app.cpp
extern void WXDLLEXPORT wxEntryCleanup();
+static wxChar **ConvertToStandardCommandArgs(const wxChar *p, int& argc);
+
// ============================================================================
// implementation: various entry points
// ============================================================================
+// ----------------------------------------------------------------------------
+// Windows-specific wxEntry
+// ----------------------------------------------------------------------------
+
+int wxEntry(WXHINSTANCE hInstance,
+ WXHINSTANCE WXUNUSED(hPrevInstance),
+ char *pCmdLine,
+ int nCmdShow)
+{
+ // remember the parameters Windows gave us
+ wxSetInstance((HINSTANCE)hInstance);
+ wxApp::m_nCmdShow = nCmdShow;
+
+ // parse the command line
+ int argc;
+ wxChar **argv = ConvertToStandardCommandArgs(wxConvertMB2WX(pCmdLine), argc);
+
+ return wxEntry(argc, argv);
+}
+
// May wish not to have a DllMain or WinMain, e.g. if we're programming
// a Netscape plugin or if we're writing a console application
-#if wxUSE_GUI && !defined(NOMAIN)
+#if !defined(NOMAIN)
extern "C"
{
return wxEntry((WXHINSTANCE) hModule);
case DLL_PROCESS_DETACH:
- if ( wxTheApp )
- wxTheApp->OnExit();
- wxEntryCleanup();
- break;
+ wxEntryCleanup();
+ break;
}
#else
(void)hModule;
#endif // !NOMAIN
+// ---------------------------------------------------------------------------
+// Convert Windows to argc, argv style
+// ---------------------------------------------------------------------------
+
+wxChar **ConvertToStandardCommandArgs(const wxChar *p, int& argc)
+{
+ // break the command line in words
+ wxArrayString args;
+ if ( p )
+ {
+ args = wxCmdLineParser::ConvertStringToArgs(p);
+ }
+
+ // +1 here for the program name
+ argc = args.GetCount() + 1;
+
+ // and +1 here for the terminating NULL
+ wxChar **argv = new wxChar *[argc + 1];
+
+ argv[0] = new wxChar[MAX_PATH];
+ ::GetModuleFileName(wxhInstance, argv[0], MAX_PATH);
+
+ // copy all the other arguments to wxApp::argv[]
+ for ( int i = 1; i < argc; i++ )
+ {
+ argv[i] = wxStrdup(args[i - 1]);
+ }
+
+ // argv[] must be NULL-terminated
+ argv[argc] = NULL;
+
+ return argv;
+}
+
+#endif // wxUSE_GUI
+
// ----------------------------------------------------------------------------
// global HINSTANCE
// ----------------------------------------------------------------------------
WXHICON wxMDIParentFrame::GetDefaultIcon() const
{
- return (WXHICON)(wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON
- : wxDEFAULT_MDIPARENTFRAME_ICON);
+ // we don't have any standard icons (any more)
+ return (WXHICON)0;
}
// ---------------------------------------------------------------------------
WXHICON wxMDIChildFrame::GetDefaultIcon() const
{
- return (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON
- : wxDEFAULT_MDICHILDFRAME_ICON);
+ // we don't have any standard icons (any more)
+ return (WXHICON)0;
}
// ---------------------------------------------------------------------------
#endif
#endif
+// ----------------------------------------------------------------------------
+// module globals
+// ----------------------------------------------------------------------------
+
+#if wxUSE_ON_FATAL_EXCEPTION
+ static bool gs_handleExceptions = FALSE;
+#endif
+
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
+// ----------------------------------------------------------------------------
+// wxApp::OnFatalException() support
+// ----------------------------------------------------------------------------
+
+bool wxHandleFatalExceptions(bool doit)
+{
+#if wxUSE_ON_FATAL_EXCEPTION
+ // assume this can only be called from the main thread
+ gs_handleExceptions = doit;
+
+ return TRUE;
+#else
+ wxFAIL_MSG(_T("set wxUSE_ON_FATAL_EXCEPTION to 1 to use this function"));
+
+ (void)doit;
+ return FALSE;
+#endif
+}
+
+#if wxUSE_ON_FATAL_EXCEPTION
+
+extern unsigned long wxGlobalSEHandler()
+{
+ if ( gs_handleExceptions && wxTheApp )
+ {
+ // give the user a chance to do something special about this
+ wxTheApp->OnFatalException();
+
+ // this will execute our handler and terminate the process
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+
+#endif // wxUSE_ON_FATAL_EXCEPTION
+
// is a more neutral term, we don't necessarily get a sunken effect in
// Windows XP. Instead we get the appropriate style for the theme.
- if (border == wxBORDER_DEFAULT && wxTheApp->GetAuto3D() &&
+ if (border == wxBORDER_DEFAULT &&
IsKindOf(CLASSINFO(wxControl)) &&
GetParent() &&
((GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS))
//
// Initialize
//
-bool wxApp::Initialize(
- HAB vHab
-)
+bool wxApp::Initialize(int argc, wxChar **argv)
{
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
+
#if defined(wxUSE_CONSOLEDEBUG)
#if wxUSE_CONSOLEDEBUG
/***********************************************/
#endif //wxUSE_CONSOLEDEBUG
#endif
- wxBuffer = new wxChar[1500]; // FIXME; why?
-
- wxClassInfo::InitializeClasses();
-
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection;
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxBitmap::InitStandardHandlers();
-
//
// OS2 has to have an anchorblock
//
- vHab = WinInitialize(0);
+ vHabmain = WinInitialize(0);
+
+ if (!vHabmain)
+ {
+ // TODO: at least give some error message here...
+ wxAppBase::CleanUp();
- if (!vHab)
return FALSE;
- else
- vHabmain = vHab;
+ }
+
+ wxBuffer = new wxChar[1500]; // FIXME; why?
// Some people may wish to use this, but
// probably it shouldn't be here by default.
// wxSetKeyboardHook(TRUE);
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules())
- return FALSE;
RegisterWindowClasses(vHab);
+
return TRUE;
} // end of wxApp::Initialize
//
void wxApp::CleanUp()
{
- //
- // COMMON CLEANUP
- //
-
-#if wxUSE_LOG
-
- //
- // Flush the logged messages if any and install a 'safer' log target: the
- // default one (wxLogGui) can't be used after the resources are freed just
- // below and the user suppliedo ne might be even more unsafe (using any
- // wxWindows GUI function is unsafe starting from now)
- //
- wxLog::DontCreateOnDemand();
-
- //
- // This will flush the old messages if any
- //
- delete wxLog::SetActiveTarget(new wxLogStderr);
-#endif // wxUSE_LOG
-
- //
- // One last chance for pending objects to be cleaned up
- //
- wxTheApp->DeletePendingObjects();
-
- wxModule::CleanUpModules();
-
- wxDeleteStockObjects();
-
- //
- // Destroy all GDI lists, etc.
- //
- wxDeleteStockLists();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxBitmap::CleanUpHandlers();
-
delete[] wxBuffer;
wxBuffer = NULL;
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
#endif
- wxClassInfo::CleanUpClasses();
-
// Delete Message queue
if (wxTheApp->m_hMq)
::WinDestroyMsgQueue(wxTheApp->m_hMq);
- delete wxTheApp;
- wxTheApp = NULL;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks."));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
- // wxDebugContext::SetStream(NULL, NULL);
-#endif
-
-#if wxUSE_LOG
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
+ wxAppBase::CleanUp();
} // end of wxApp::CleanUp
//----------------------------------------------------------------------
return bNeedMore;
} // end of wxApp::SendIdleEvents
-void wxApp::DeletePendingObjects()
-{
- wxNode* pNode = wxPendingDelete.First();
-
- while (pNode)
- {
- wxObject* pObj = (wxObject *)pNode->Data();
-
- delete pObj;
-
- if (wxPendingDelete.Member(pObj))
- delete pNode;
-
- //
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- //
- pNode = wxPendingDelete.First();
- }
-} // end of wxApp::DeletePendingObjects
-
void wxApp::OnEndSession(
wxCloseEvent& WXUNUSED(rEvent))
{
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=wxBase - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
!IF "$(CFG)" == "wxBase - Win32 Release Unicode DLL"
# PROP Intermediate_Dir "../BaseReleaseUnicodeDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedllu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedllu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../lib/wxbase250u.dll"
-# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlib.lib ../lib/regex.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250u.dll"
+# ADD LINK32 ../lib/zlib.lib ../lib/regex.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250u.dll"
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug Unicode DLL"
# PROP Intermediate_Dir "../BaseDebugUnicodeDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedllud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedllud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxbase250ud.dll"
-# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlibd.lib ../lib/regexd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250ud.dll"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../lib/wxbase250ud.dll" /pdbtype:sept
+# ADD LINK32 ../lib/zlibd.lib ../lib/regexd.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250ud.dll"
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Release Unicode"
# PROP BASE Use_MFC 0
# PROP Output_Dir "..\lib"
# PROP Intermediate_Dir "..\BaseReleaseUnicode"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/baseu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/baseu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# PROP Output_Dir "..\lib"
# PROP Intermediate_Dir "..\BaseDebugUnicode"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/baseud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D "__WXDEBUG__" /D WINVER=0x400 /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/baseud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "__WXDEBUG__" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo /o"../lib/wxbase.bsc"
+# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib\wxbaseud.lib"
# PROP Intermediate_Dir "../BaseReleaseDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedll" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedll" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D "WXMAKINGDLL" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../lib/wxbase250.dll"
-# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlib.lib ../lib/regex.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250.dll"
+# ADD LINK32 ../lib/zlib.lib ../lib/regex.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250.dll"
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug DLL"
# PROP Intermediate_Dir "../BaseDebugDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedlld" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedlld" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "WXMAKINGDLL" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxbase250d.dll"
-# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlibd.lib ../lib/regexd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250d.dll"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../lib/wxbase250d.dll" /pdbtype:sept
+# ADD LINK32 ../lib/zlibd.lib ../lib/regexd.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250d.dll"
!ELSEIF "$(CFG)" == "wxBase - Win32 Release"
# PROP Output_Dir "..\lib"
# PROP Intermediate_Dir "..\BaseRelease"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/base" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/base" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\lib\wxbase.lib"
+# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug"
# PROP Output_Dir "..\lib"
# PROP Intermediate_Dir "..\BaseDebug"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/based" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D "__WXDEBUG__" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/based" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "__WXDEBUG__" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo /o"../lib/wxbase.bsc"
+# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib\wxbased.lib"
# Name "wxBase - Win32 Debug DLL"
# Name "wxBase - Win32 Release"
# Name "wxBase - Win32 Debug"
-
# Begin Group "Common Files"
# PROP Default_Filter ""
# End Source File
# Begin Source File
+SOURCE=.\common\extended.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=.\common\ffile.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\common\init.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\common\intl.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\common\unzip.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=.\common\url.cpp
# End Source File
# Begin Source File
SOURCE=.\common\zstream.cpp
# End Source File
+# End Group
+# Begin Group "MSW Files"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=.\common\init.cpp
+SOURCE=.\msw\basemsw.cpp
# End Source File
-
# Begin Source File
-SOURCE=.\common\extended.c
-# SUBTRACT CPP /YX /Yc /Yu
+SOURCE=.\msw\dde.cpp
# End Source File
# Begin Source File
-SOURCE=.\common\unzip.c
-# SUBTRACT CPP /YX /Yc /Yu
+SOURCE=.\msw\dir.cpp
# End Source File
-
-# End Group
-# Begin Group "MSW Files"
-
-# PROP Default_Filter ""
# Begin Source File
SOURCE=.\msw\dummy.cpp
# End Source File
# Begin Source File
-SOURCE=.\msw\basemsw.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\dde.cpp
+SOURCE=.\msw\gsocket.c
+# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
-SOURCE=.\msw\dir.cpp
+SOURCE=.\msw\gsockmsw.c
+# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=.\msw\volume.cpp
# End Source File
-
-# Begin Source File
-
-SOURCE=.\msw\gsocket.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\gsockmsw.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-
# End Group
# Begin Group "Headers"
# Begin Source File
SOURCE=..\include\wx\msw\setup.h
+
!IF "$(CFG)" == "wxBase - Win32 Release Unicode DLL"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\basedllu\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug Unicode DLL"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
"../lib/basedllud/wx/setup.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy "$(InputPath)" ..\lib\basedllud\wx\setup.h
+
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Release Unicode"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\baseu\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug Unicode"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\baseud\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Release DLL"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\basedll\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug DLL"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
"../lib/basedlld/wx/setup.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy "$(InputPath)" ..\lib\basedlld\wx\setup.h
+
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Release"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\base\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxBase - Win32 Debug"
+
# Begin Custom Build - Copying $(InputPath) to $(TargetDir)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\based\wx\setup.h
# End Custom Build
+
!ENDIF
# End Source File
SOURCE=..\include\wx\zstream.h
# End Source File
-
# End Group
# Begin Group "MSW"
SOURCE=..\include\wx\msw\winundef.h
# End Source File
-
# End Group
# End Group
# End Target
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
-!MESSAGE NMAKE /f "wxWindows.mak".
+!MESSAGE NMAKE /f "wxMSW.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
-!MESSAGE NMAKE /f "wxWindows.mak" CFG="wxWindows - Win32 Debug"
+!MESSAGE NMAKE /f "wxMSW.mak" CFG="wxWindows - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250d.dll" /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib ../lib/wxbase250d.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll"
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\lib\wxmsw.lib"
+# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug"
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=wxWindows - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
!IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL"
# PROP Intermediate_Dir "../ReleaseUnicodeDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "NDEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
BSC32=bscmake.exe
# PROP Intermediate_Dir "../DebugUnicodeDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "_DEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxmsw250ud.dll"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250ud.dll" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250ud.dll"
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode"
# PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../ReleaseUnicode"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../DebugUnicode"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_DEBUG" /D "__WXDEBUG__" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# PROP Intermediate_Dir "../ReleaseDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "NDEBUG" /D "WXMAKINGDLL" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "../include" /d "NDEBUG"
BSC32=bscmake.exe
# PROP Intermediate_Dir "../DebugDll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "_DEBUG" /D "WXMAKINGDLL" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "../include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxmsw250d.dll"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250d.dll" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll"
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
# PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../Release"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "NDEBUG" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# PROP Output_Dir "../lib"
# PROP Intermediate_Dir "../Debug"
# PROP Target_Dir ""
+CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c
+# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_DEBUG" /D "__WXDEBUG__" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c
+RSC=rc.exe
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# End Source File
# Begin Source File
+SOURCE=.\common\extended.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=.\common\fddlgcmn.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\common\init.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\common\intl.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\common\unzip.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=.\common\url.cpp
# End Source File
# Begin Source File
SOURCE=.\common\zstream.cpp
# End Source File
-
-# Begin Source File
-
-SOURCE=.\common\extended.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=.\common\unzip.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-
# End Group
# Begin Group "Generic Files"
SOURCE=.\generic\wizard.cpp
# End Source File
-
# End Group
# Begin Group "wxHTML Files"
SOURCE=.\html\winpars.cpp
# End Source File
-
# End Group
# Begin Group "MSW Files"
+# PROP Default_Filter ""
+# Begin Group "OLE Files"
+
# PROP Default_Filter ""
# Begin Source File
-SOURCE=.\msw\dummy.cpp
-# ADD CPP /Yc"wx/wxprec.h"
+SOURCE=.\msw\ole\access.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\ole\automtn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\ole\dataobj.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\ole\dropsrc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\ole\droptgt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\ole\oleutils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\ole\uuid.cpp
# End Source File
+# End Group
# Begin Source File
SOURCE=.\msw\accel.cpp
# End Source File
# Begin Source File
+SOURCE=.\msw\dummy.cpp
+# ADD CPP /Yc"wx/wxprec.h"
+# End Source File
+# Begin Source File
+
SOURCE=.\msw\enhmeta.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\msw\gsocket.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=.\msw\gsockmsw.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=.\msw\helpbest.cpp
# End Source File
# Begin Source File
SOURCE=.\msw\window.cpp
# End Source File
-
-# Begin Source File
-
-SOURCE=.\msw\gsocket.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\gsockmsw.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-
-# Begin Group "OLE Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\msw\ole\access.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\ole\automtn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\ole\dataobj.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\ole\dropsrc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\ole\droptgt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\ole\oleutils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msw\ole\uuid.cpp
-# End Source File
-
-# End Group
# End Group
# Begin Group "Headers"
# Begin Source File
SOURCE=..\include\wx\msw\setup.h
+
!IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL"
+
# Begin Custom Build - Creating ..\lib\mswdllu\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdllu\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode DLL"
+
# Begin Custom Build - Creating ..\lib\mswdllud\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdllud\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode"
+
# Begin Custom Build - Creating ..\lib\mswu\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswu\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode"
+
# Begin Custom Build - Creating ..\lib\mswud\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswud\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release DLL"
+
# Begin Custom Build - Creating ..\lib\mswdll\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdll\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug DLL"
+
# Begin Custom Build - Creating ..\lib\mswdlld\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswdlld\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Release"
+
# Begin Custom Build - Creating ..\lib\msw\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\msw\wx\setup.h
# End Custom Build
+
!ELSEIF "$(CFG)" == "wxWindows - Win32 Debug"
+
# Begin Custom Build - Creating ..\lib\mswd\wx\setup.h from $(InputPath)
InputPath=..\include\wx\msw\setup.h
copy "$(InputPath)" ..\lib\mswd\wx\setup.h
# End Custom Build
+
!ENDIF
+
# End Source File
# End Group
# Begin Group "Common"
SOURCE=..\include\wx\zstream.h
# End Source File
-
# End Group
# Begin Group "MSW"
SOURCE=..\include\wx\msw\winundef.h
# End Source File
-
# End Group
# Begin Group "Generic"
SOURCE=..\include\wx\generic\wizard.h
# End Source File
-
# End Group
# Begin Group "HTML"
SOURCE=..\include\wx\html\winpars.h
# End Source File
-
# End Group
# End Group
# End Target
EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE()
-bool wxApp::Initialize()
+bool wxApp::Initialize(int argc, wxChar **argv)
{
- wxClassInfo::InitializeClasses();
+ if ( !wxAppBase::Initialize(argc, argv) )
+ return false;
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- wxPendingEventsLocker = new wxCriticalSection();
-#endif
-
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
wxClientWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
-
- return TRUE;
+ return true;
}
void wxApp::CleanUp()
delete wxClientWidgetHashTable;
wxClientWidgetHashTable = NULL;
- wxModule::CleanUpModules();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = NULL;
-
- wxDeleteStockObjects();
-
- wxDeleteStockLists();
-
- delete wxTheApp;
- wxTheApp = NULL;
-
- wxClassInfo::CleanUpClasses();
-
-#if wxUSE_THREADS
- delete wxPendingEvents;
- delete wxPendingEventsLocker;
-#endif
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug("There were memory leaks.");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif
-
- // do it as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
+ wxAppBase::CleanUp();
}
// NB: argc and argv may be changed here, pass by reference!
return needMore;
}
-void wxApp::DeletePendingObjects()
-{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Member(obj))
- delete node;
-
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- node = wxPendingDelete.GetFirst();
- }
-}
-
// Create display, and other initialization
bool wxApp::OnInitGui()
{