#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/intl.h"
+ #include "wx/list.h"
#if wxUSE_LOG
#include "wx/log.h"
#endif // wxUSE_LOG
#endif //WX_PRECOMP
+#include "wx/utils.h"
#include "wx/apptrait.h"
#include "wx/cmdline.h"
#include "wx/confbase.h"
-#if wxUSE_FONTMAP
- #include "wx/fontmap.h"
-#endif // wxUSE_FONTMAP
+#include "wx/filename.h"
#include "wx/msgout.h"
#include "wx/tokenzr.h"
#include "wx/msw/private.h" // includes windows.h for MessageBox()
#endif
+#if wxUSE_FONTMAP
+ #include "wx/fontmap.h"
+#endif // wxUSE_FONTMAP
+
#if defined(__WXMAC__)
- #include "wx/mac/private.h" // includes mac headers
-#endif
+ // VZ: MacTypes.h is enough under Mac OS X (where I could test it) but
+ // I don't know which headers are needed under earlier systems so
+ // include everything when in doubt
+ #ifdef __DARWIN__
+ #include "MacTypes.h"
+ #else
+ #include "wx/mac/private.h" // includes mac headers
+ #endif
+#endif // __WXMAC__
// ----------------------------------------------------------------------------
// private functions prototypes
// global vars
// ----------------------------------------------------------------------------
-wxApp *wxTheApp = NULL;
+wxAppConsole *wxAppConsole::ms_appInstance = NULL;
wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL;
{
m_traits = NULL;
- wxTheApp = (wxApp *)this;
+ ms_appInstance = this;
#ifdef __WXDEBUG__
SetTraceMasks();
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() && argv )
+ {
+ // the application name is, by default, the name of its executable file
+ wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL);
+ }
+
+ return true;
+}
+
+void wxAppConsole::CleanUp()
+{
+}
+
// ----------------------------------------------------------------------------
// OnXXX() callbacks
// ----------------------------------------------------------------------------
delete wxConfigBase::Set((wxConfigBase *) NULL);
#endif // wxUSE_CONFIG
-#ifdef __WXUNIVERSAL__
- delete wxTheme::Set(NULL);
-#endif // __WXUNIVERSAL__
-
// use Set(NULL) and not Get() to avoid creating a message output object on
// demand when we just want to delete it
delete wxMessageOutput::Set(NULL);
wxAppTraits *wxAppConsole::CreateTraits()
{
- return wxAppTraits::CreateConsole();
+ return new wxConsoleAppTraits;
}
wxAppTraits *wxAppConsole::GetTraits()
}
// iterate until the list becomes empty
- wxNode *node = wxPendingEvents->GetFirst();
+ wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
while (node)
{
wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
- delete node;
+ wxPendingEvents->Erase(node);
// In ProcessPendingEvents(), new handlers might be add
// and we can safely leave the critical section here.
#if wxUSE_CMDLINE_PARSER
#define OPTION_VERBOSE _T("verbose")
-#define OPTION_THEME _T("theme")
-#define OPTION_MODE _T("mode")
void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
{
},
#endif // wxUSE_LOG
-#ifdef __WXUNIVERSAL__
- {
- wxCMD_LINE_OPTION,
- _T(""),
- OPTION_THEME,
- gettext_noop("specify the theme to use"),
- wxCMD_LINE_VAL_STRING,
- 0x0
- },
-#endif // __WXUNIVERSAL__
-
-#if defined(__WXMGL__)
- // VS: this is not specific to wxMGL, all fullscreen (framebuffer) ports
- // should provide this option. That's why it is in common/appcmn.cpp
- // and not mgl/app.cpp
- {
- wxCMD_LINE_OPTION,
- _T(""),
- OPTION_MODE,
- gettext_noop("specify display mode to use (e.g. 640x480-16)"),
- wxCMD_LINE_VAL_STRING,
- 0x0
- },
-#endif // __WXMGL__
-
// terminator
{
wxCMD_LINE_NONE,
}
#endif // wxUSE_LOG
-#ifdef __WXUNIVERSAL__
- wxString themeName;
- if ( parser.Found(OPTION_THEME, &themeName) )
- {
- wxTheme *theme = wxTheme::Create(themeName);
- if ( !theme )
- {
- wxLogError(_("Unsupported theme '%s'."), themeName.c_str());
- return FALSE;
- }
-
- // Delete the defaultly created theme and set the new theme.
- delete wxTheme::Get();
- wxTheme::Set(theme);
- }
-#endif // __WXUNIVERSAL__
-
-#if defined(__WXMGL__)
- wxString modeDesc;
- if ( parser.Found(OPTION_MODE, &modeDesc) )
- {
- unsigned w, h, bpp;
- if ( wxSscanf(modeDesc.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3 )
- {
- wxLogError(_("Invalid display mode specification '%s'."), modeDesc.c_str());
- return FALSE;
- }
-
- if ( !SetDisplayMode(wxDisplayModeInfo(w, h, bpp)) )
- return FALSE;
- }
-#endif // __WXMGL__
-
return TRUE;
}
#endif // wxUSE_FONTMAP
+wxRendererNative *wxConsoleAppTraitsBase::CreateRenderer()
+{
+ // console applications don't use renderers
+ return NULL;
+}
+
#ifdef __WXDEBUG__
bool wxConsoleAppTraitsBase::ShowAssertDialog(const wxString& msg)
{
#endif // __WXDEBUG__
-wxAppTraits *wxAppTraitsBase::CreateConsole()
-{
- return new wxConsoleAppTraits;
-}
-
// ============================================================================
// global functions implementation
// ============================================================================
if ( !s_bNoAsserts )
{
// send it to the normal log destination
- wxLogDebug(_T("%s"), msg);
+ wxLogDebug(_T("%s"), msg.c_str());
if ( traits )
{