added wxApp::Set/GetAppDisplayName() (patch 1780414)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-09-09 23:26:18 +00:00
parent 5595181f48
commit 9cf3d21870
13 changed files with 36 additions and 25 deletions

View File

@@ -182,6 +182,7 @@ All (GUI):
- Added XRC handler for wxSearchCtrl (Sander Berents) - Added XRC handler for wxSearchCtrl (Sander Berents)
- Read image resolution from TIFF, JPEG and BMP images (Maycon Aparecido Gasoto) - Read image resolution from TIFF, JPEG and BMP images (Maycon Aparecido Gasoto)
- Added wxSYS_DCLICK_TIME system metric constant - Added wxSYS_DCLICK_TIME system metric constant
- Added wxApp::Get/SetAppDisplayName() (Brian A. Vanderburg II)
wxGTK: wxGTK:

View File

@@ -31,10 +31,10 @@ public:
// accessors for various simply fields // accessors for various simply fields
// ----------------------------------- // -----------------------------------
// name of the program, if not used defaults wxApp::GetAppName() // name of the program, if not used defaults to wxApp::GetAppDisplayName()
void SetName(const wxString& name) { m_name = name; } void SetName(const wxString& name) { m_name = name; }
wxString GetName() const wxString GetName() const
{ return m_name.empty() ? wxTheApp->GetAppName() : m_name; } { return m_name.empty() ? wxTheApp->GetAppDisplayName() : m_name; }
// version of the program, in free format (but without "version" word) // version of the program, in free format (but without "version" word)
void SetVersion(const wxString& version) { m_version = version; } void SetVersion(const wxString& version) { m_version = version; }

View File

@@ -123,6 +123,17 @@ public:
} }
void SetAppName(const wxString& name) { m_appName = name; } void SetAppName(const wxString& name) { m_appName = name; }
// set/get the application display name: the display name is the name
// shown to the user in titles, reports, etc while the app name is
// used for paths, config, and other places the user doesn't see
//
// so the app name could be myapp while display name could be "My App"
wxString GetAppDisplayName() const
{
return m_appDisplayName.empty() ? GetAppName() : m_appDisplayName;
}
void SetAppDisplayName(const wxString& name) { m_appDisplayName = name; }
// set/get the app class name // set/get the app class name
wxString GetClassName() const { return m_className; } wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; } void SetClassName(const wxString& name) { m_className = name; }
@@ -325,8 +336,9 @@ protected:
wxEventLoopBase *CreateMainLoop(); wxEventLoopBase *CreateMainLoop();
// application info (must be set from the user code) // application info (must be set from the user code)
wxString m_vendorName, // vendor name (ACME Inc) wxString m_vendorName, // vendor name (e.g. "ACME Inc")
m_appName, // app name m_appName, // app name ("myapp")
m_appDisplayName, // app display name ("My Application")
m_className; // class name m_className; // class name
// the class defining the application behaviour, NULL initially and created // the class defining the application behaviour, NULL initially and created

View File

@@ -127,7 +127,7 @@ bool DrawingView::OnClose(bool deleteWindow)
canvas->view = (wxView *) NULL; canvas->view = (wxView *) NULL;
canvas = (MyCanvas *) NULL; canvas = (MyCanvas *) NULL;
wxString s(wxTheApp->GetAppName()); wxString s(wxTheApp->GetAppDisplayName());
if (frame) if (frame)
frame->SetTitle(s); frame->SetTitle(s);

View File

@@ -106,7 +106,7 @@ bool DrawingView::OnClose(bool deleteWindow)
canvas->view = (wxView *) NULL; canvas->view = (wxView *) NULL;
canvas = (MyCanvas *) NULL; canvas = (MyCanvas *) NULL;
wxString s(wxTheApp->GetAppName()); wxString s(wxTheApp->GetAppDisplayName());
if (frame) if (frame)
frame->SetTitle(s); frame->SetTitle(s);

View File

@@ -253,7 +253,7 @@ wxDebugReport::~wxDebugReport()
wxString wxDebugReport::GetReportName() const wxString wxDebugReport::GetReportName() const
{ {
if(wxTheApp) if(wxTheApp)
return wxTheApp->GetAppName(); return wxTheApp->GetAppDisplayName();
return _T("wx"); return _T("wx");
} }

View File

@@ -468,8 +468,8 @@ bool wxDocument::OnSaveModified()
wxString title = GetUserReadableName(); wxString title = GetUserReadableName();
wxString msgTitle; wxString msgTitle;
if (!wxTheApp->GetAppName().empty()) if (!wxTheApp->GetAppDisplayName().empty())
msgTitle = wxTheApp->GetAppName(); msgTitle = wxTheApp->GetAppDisplayName();
else else
msgTitle = wxString(_("Warning")); msgTitle = wxString(_("Warning"));
@@ -577,8 +577,8 @@ void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
bool wxDocument::DoSaveDocument(const wxString& file) bool wxDocument::DoSaveDocument(const wxString& file)
{ {
wxString msgTitle; wxString msgTitle;
if (!wxTheApp->GetAppName().empty()) if (!wxTheApp->GetAppDisplayName().empty())
msgTitle = wxTheApp->GetAppName(); msgTitle = wxTheApp->GetAppDisplayName();
else else
msgTitle = wxString(_("File error")); msgTitle = wxString(_("File error"));
@@ -1450,7 +1450,7 @@ wxString wxDocManager::MakeNewDocumentName()
// If docName is empty, a document is not currently active. // If docName is empty, a document is not currently active.
wxString wxDocManager::MakeFrameTitle(wxDocument* doc) wxString wxDocManager::MakeFrameTitle(wxDocument* doc)
{ {
wxString appName = wxTheApp->GetAppName(); wxString appName = wxTheApp->GetAppDisplayName();
wxString title; wxString title;
if (!doc) if (!doc)
title = appName; title = appName;
@@ -1631,8 +1631,8 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
if (!wxFileExists(pathTmp)) if (!wxFileExists(pathTmp))
{ {
wxString msgTitle; wxString msgTitle;
if (!wxTheApp->GetAppName().empty()) if (!wxTheApp->GetAppDisplayName().empty())
msgTitle = wxTheApp->GetAppName(); msgTitle = wxTheApp->GetAppDisplayName();
else else
msgTitle = wxString(_("File error")); msgTitle = wxString(_("File error"));

View File

@@ -194,7 +194,7 @@ wxFontMapper::CharsetToEncoding(const wxString& charset, bool interactive)
// the dialog title // the dialog title
wxString title(m_titleDialog); wxString title(m_titleDialog);
if ( !title ) if ( !title )
title << wxTheApp->GetAppName() << _(": unknown charset"); title << wxTheApp->GetAppDisplayName() << _(": unknown charset");
// the message // the message
wxString msg; wxString msg;
@@ -408,7 +408,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
{ {
wxString title(m_titleDialog); wxString title(m_titleDialog);
if ( !title ) if ( !title )
title << wxTheApp->GetAppName() << _(": unknown encoding"); title << wxTheApp->GetAppDisplayName() << _(": unknown encoding");
// built the message // built the message
wxString encDesc = GetEncodingDescription(encoding), wxString encDesc = GetEncodingDescription(encoding),

View File

@@ -222,7 +222,7 @@ void wxMessageOutputMessageBox::Output(const wxString& str)
wxString title; wxString title;
if ( wxTheApp ) if ( wxTheApp )
title.Printf(_("%s message"), wxTheApp->GetAppName().c_str()); title.Printf(_("%s message"), wxTheApp->GetAppDisplayName().c_str());
::wxMessageBox(out, title); ::wxMessageBox(out, title);
} }

View File

@@ -281,9 +281,7 @@ void wxLogGui::Flush()
repeatCount = wxLog::DoLogNumberOfRepeats(); repeatCount = wxLog::DoLogNumberOfRepeats();
} }
wxString appName = wxTheApp->GetAppName(); wxString appName = wxTheApp->GetAppDisplayName();
if ( !appName.empty() )
appName[0u] = (wxChar)wxToupper(appName[0u]);
long style; long style;
wxString titleFormat; wxString titleFormat;

View File

@@ -287,7 +287,7 @@ bool wxClipboard::AddData( wxDataObject *data )
Display* xdisplay = wxGlobalDisplay(); Display* xdisplay = wxGlobalDisplay();
Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget(); Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget();
Window xwindow = XtWindow( xwidget ); Window xwindow = XtWindow( xwidget );
wxXmString label( wxTheApp->GetAppName() ); wxXmString label( wxTheApp->GetAppDisplayName() );
Time timestamp = XtLastTimestampProcessed( xdisplay ); Time timestamp = XtLastTimestampProcessed( xdisplay );
long itemId; long itemId;

View File

@@ -186,7 +186,7 @@ bool wxHandleFatalExceptions(bool doit)
wxString name = wxString::Format wxString name = wxString::Format
( (
_T("%s_%s_%lu.dmp"), _T("%s_%s_%lu.dmp"),
wxTheApp ? (const wxChar*)wxTheApp->GetAppName().c_str() wxTheApp ? (const wxChar*)wxTheApp->GetAppDisplayName().c_str()
: _T("wxwindows"), : _T("wxwindows"),
wxDateTime::Now().Format(_T("%Y%m%dT%H%M%S")).c_str(), wxDateTime::Now().Format(_T("%Y%m%dT%H%M%S")).c_str(),
::GetCurrentProcessId() ::GetCurrentProcessId()

View File

@@ -51,7 +51,7 @@ void abort()
{ {
wxString name; wxString name;
if ( wxTheApp ) if ( wxTheApp )
name = wxTheApp->GetAppName(); name = wxTheApp->GetAppDisplayName();
if ( name.empty() ) if ( name.empty() )
name = L"wxWidgets Application"; name = L"wxWidgets Application";