moved wxUniv-specific GUI stuff from wxBase to wxCore; this fixes wxUniv DLL build
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -170,11 +170,13 @@ public:
|
|||||||
|
|
||||||
#if wxUSE_CMDLINE_PARSER
|
#if wxUSE_CMDLINE_PARSER
|
||||||
// this one is called from OnInit() to add all supported options
|
// this one is called from OnInit() to add all supported options
|
||||||
// to the given parser
|
// to the given parser (don't forget to call the base class version if you
|
||||||
|
// override it!)
|
||||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||||
|
|
||||||
// called after successfully parsing the command line, return TRUE
|
// called after successfully parsing the command line, return TRUE
|
||||||
// to continue and FALSE to exit
|
// to continue and FALSE to exit (don't forget to call the base class
|
||||||
|
// version if you override it!)
|
||||||
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||||
|
|
||||||
// called if "--help" option was specified, return TRUE to continue
|
// called if "--help" option was specified, return TRUE to continue
|
||||||
@@ -346,6 +348,9 @@ public:
|
|||||||
// Override: rarely in GUI applications, always in console ones.
|
// Override: rarely in GUI applications, always in console ones.
|
||||||
virtual int OnRun();
|
virtual int OnRun();
|
||||||
|
|
||||||
|
// a matching function for OnInit()
|
||||||
|
virtual int OnExit();
|
||||||
|
|
||||||
// very last clean up function
|
// very last clean up function
|
||||||
//
|
//
|
||||||
// Override: very rarely
|
// Override: very rarely
|
||||||
@@ -457,6 +462,13 @@ public:
|
|||||||
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
|
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
|
||||||
|
|
||||||
|
|
||||||
|
// command line parsing (GUI-specific)
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||||
|
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||||
|
|
||||||
|
|
||||||
// miscellaneous other stuff
|
// miscellaneous other stuff
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -182,10 +182,6 @@ int wxAppConsole::OnExit()
|
|||||||
delete wxConfigBase::Set((wxConfigBase *) NULL);
|
delete wxConfigBase::Set((wxConfigBase *) NULL);
|
||||||
#endif // wxUSE_CONFIG
|
#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
|
// use Set(NULL) and not Get() to avoid creating a message output object on
|
||||||
// demand when we just want to delete it
|
// demand when we just want to delete it
|
||||||
delete wxMessageOutput::Set(NULL);
|
delete wxMessageOutput::Set(NULL);
|
||||||
@@ -288,8 +284,6 @@ int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event))
|
|||||||
#if wxUSE_CMDLINE_PARSER
|
#if wxUSE_CMDLINE_PARSER
|
||||||
|
|
||||||
#define OPTION_VERBOSE _T("verbose")
|
#define OPTION_VERBOSE _T("verbose")
|
||||||
#define OPTION_THEME _T("theme")
|
|
||||||
#define OPTION_MODE _T("mode")
|
|
||||||
|
|
||||||
void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
|
void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
|
||||||
{
|
{
|
||||||
@@ -316,31 +310,6 @@ void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
|
|||||||
},
|
},
|
||||||
#endif // wxUSE_LOG
|
#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
|
// terminator
|
||||||
{
|
{
|
||||||
wxCMD_LINE_NONE,
|
wxCMD_LINE_NONE,
|
||||||
@@ -364,39 +333,6 @@ bool wxAppConsole::OnCmdLineParsed(wxCmdLineParser& parser)
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_LOG
|
#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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/apptrait.h"
|
#include "wx/apptrait.h"
|
||||||
|
#include "wx/cmdline.h"
|
||||||
#include "wx/msgout.h"
|
#include "wx/msgout.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
@@ -128,13 +129,106 @@ void wxAppBase::CleanUp()
|
|||||||
delete wxPendingEventsLocker;
|
delete wxPendingEventsLocker;
|
||||||
wxPendingEventsLocker = NULL;
|
wxPendingEventsLocker = NULL;
|
||||||
|
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
// If we don't do the following, we get an apparent memory leak.
|
// If we don't do the following, we get an apparent memory leak.
|
||||||
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
|
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
|
||||||
#endif // wxUSE_VALIDATORS
|
#endif // wxUSE_VALIDATORS
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_CMDLINE_PARSER
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// GUI-specific command line options handling
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define OPTION_THEME _T("theme")
|
||||||
|
#define OPTION_MODE _T("mode")
|
||||||
|
|
||||||
|
void wxAppBase::OnInitCmdLine(wxCmdLineParser& parser)
|
||||||
|
{
|
||||||
|
// the standard command line options
|
||||||
|
static const wxCmdLineEntryDesc cmdLineGUIDesc[] =
|
||||||
|
{
|
||||||
|
#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,
|
||||||
|
_T(""),
|
||||||
|
_T(""),
|
||||||
|
_T(""),
|
||||||
|
wxCMD_LINE_VAL_NONE,
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.SetDesc(cmdLineGUIDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||||
|
{
|
||||||
|
#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 wxAppConsole::OnCmdLineParsed(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_CMDLINE_PARSER
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// OnXXX() hooks
|
// OnXXX() hooks
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -162,6 +256,15 @@ int wxAppBase::OnRun()
|
|||||||
return MainLoop();
|
return MainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wxAppBase::OnExit()
|
||||||
|
{
|
||||||
|
#ifdef __WXUNIVERSAL__
|
||||||
|
delete wxTheme::Set(NULL);
|
||||||
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
|
return wxAppConsole::OnExit();
|
||||||
|
}
|
||||||
|
|
||||||
void wxAppBase::Exit()
|
void wxAppBase::Exit()
|
||||||
{
|
{
|
||||||
ExitMainLoop();
|
ExitMainLoop();
|
||||||
|
Reference in New Issue
Block a user