From 9cf3d218700ccb80a6a2a2715413816c0b2a3ad2 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 9 Sep 2007 23:26:18 +0000
Subject: [PATCH] added wxApp::Set/GetAppDisplayName() (patch 1780414)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/changes.txt          |  1 +
 include/wx/aboutdlg.h     |  4 ++--
 include/wx/app.h          | 20 ++++++++++++++++----
 samples/docview/view.cpp  |  2 +-
 samples/docvwmdi/view.cpp |  2 +-
 src/common/debugrpt.cpp   |  2 +-
 src/common/docview.cpp    | 14 +++++++-------
 src/common/fontmap.cpp    |  4 ++--
 src/common/msgout.cpp     |  2 +-
 src/generic/logg.cpp      |  4 +---
 src/motif/clipbrd.cpp     |  2 +-
 src/msw/main.cpp          |  2 +-
 src/msw/wince/crt.cpp     |  2 +-
 13 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/docs/changes.txt b/docs/changes.txt
index 99a0264245..e74ee4b673 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -182,6 +182,7 @@ All (GUI):
 - Added XRC handler for wxSearchCtrl (Sander Berents)
 - Read image resolution from TIFF, JPEG and BMP images (Maycon Aparecido Gasoto)
 - Added wxSYS_DCLICK_TIME system metric constant
+- Added wxApp::Get/SetAppDisplayName() (Brian A. Vanderburg II)
 
 wxGTK:
 
diff --git a/include/wx/aboutdlg.h b/include/wx/aboutdlg.h
index cc93b7f091..9c8946d193 100644
--- a/include/wx/aboutdlg.h
+++ b/include/wx/aboutdlg.h
@@ -31,10 +31,10 @@ public:
     // 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; }
     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)
     void SetVersion(const wxString& version) { m_version = version; }
diff --git a/include/wx/app.h b/include/wx/app.h
index 03bbad845a..5de475c2a8 100644
--- a/include/wx/app.h
+++ b/include/wx/app.h
@@ -123,6 +123,17 @@ public:
     }
     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
     wxString GetClassName() const { return m_className; }
     void SetClassName(const wxString& name) { m_className = name; }
@@ -325,9 +336,10 @@ protected:
     wxEventLoopBase *CreateMainLoop();
 
     // application info (must be set from the user code)
-    wxString m_vendorName,      // vendor name (ACME Inc)
-             m_appName,         // app name
-             m_className;       // class name
+    wxString m_vendorName,        // vendor name (e.g. "ACME Inc")
+             m_appName,           // app name ("myapp")
+             m_appDisplayName,    // app display name ("My Application")
+             m_className;         // class name
 
     // the class defining the application behaviour, NULL initially and created
     // by GetTraits() when first needed
@@ -458,7 +470,7 @@ public:
     virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; }
 
         // set use of best visual flag (see below)
-    void SetUseBestVisual( bool flag, bool forceTrueColour = false ) 
+    void SetUseBestVisual( bool flag, bool forceTrueColour = false )
         { m_useBestVisual = flag; m_forceTrueColour = forceTrueColour; }
     bool GetUseBestVisual() const { return m_useBestVisual; }
 
diff --git a/samples/docview/view.cpp b/samples/docview/view.cpp
index 957aff4018..e48c269d8f 100644
--- a/samples/docview/view.cpp
+++ b/samples/docview/view.cpp
@@ -127,7 +127,7 @@ bool DrawingView::OnClose(bool deleteWindow)
     canvas->view = (wxView *) NULL;
     canvas = (MyCanvas *) NULL;
     
-    wxString s(wxTheApp->GetAppName());
+    wxString s(wxTheApp->GetAppDisplayName());
     if (frame)
         frame->SetTitle(s);
     
diff --git a/samples/docvwmdi/view.cpp b/samples/docvwmdi/view.cpp
index 6bb0129450..0707d264aa 100644
--- a/samples/docvwmdi/view.cpp
+++ b/samples/docvwmdi/view.cpp
@@ -106,7 +106,7 @@ bool DrawingView::OnClose(bool deleteWindow)
   canvas->view = (wxView *) NULL;
   canvas = (MyCanvas *) NULL;
 
-  wxString s(wxTheApp->GetAppName());
+  wxString s(wxTheApp->GetAppDisplayName());
   if (frame)
     frame->SetTitle(s);
 
diff --git a/src/common/debugrpt.cpp b/src/common/debugrpt.cpp
index 542715a0f0..2b56ed7159 100644
--- a/src/common/debugrpt.cpp
+++ b/src/common/debugrpt.cpp
@@ -253,7 +253,7 @@ wxDebugReport::~wxDebugReport()
 wxString wxDebugReport::GetReportName() const
 {
     if(wxTheApp)
-        return wxTheApp->GetAppName();
+        return wxTheApp->GetAppDisplayName();
 
     return _T("wx");
 }
diff --git a/src/common/docview.cpp b/src/common/docview.cpp
index 37f1f64264..5c52d6059a 100644
--- a/src/common/docview.cpp
+++ b/src/common/docview.cpp
@@ -468,8 +468,8 @@ bool wxDocument::OnSaveModified()
         wxString title = GetUserReadableName();
 
         wxString msgTitle;
-        if (!wxTheApp->GetAppName().empty())
-            msgTitle = wxTheApp->GetAppName();
+        if (!wxTheApp->GetAppDisplayName().empty())
+            msgTitle = wxTheApp->GetAppDisplayName();
         else
             msgTitle = wxString(_("Warning"));
 
@@ -577,8 +577,8 @@ void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
 bool wxDocument::DoSaveDocument(const wxString& file)
 {
     wxString msgTitle;
-    if (!wxTheApp->GetAppName().empty())
-        msgTitle = wxTheApp->GetAppName();
+    if (!wxTheApp->GetAppDisplayName().empty())
+        msgTitle = wxTheApp->GetAppDisplayName();
     else
         msgTitle = wxString(_("File error"));
 
@@ -1450,7 +1450,7 @@ wxString wxDocManager::MakeNewDocumentName()
 // If docName is empty, a document is not currently active.
 wxString wxDocManager::MakeFrameTitle(wxDocument* doc)
 {
-    wxString appName = wxTheApp->GetAppName();
+    wxString appName = wxTheApp->GetAppDisplayName();
     wxString title;
     if (!doc)
         title = appName;
@@ -1631,8 +1631,8 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
         if (!wxFileExists(pathTmp))
         {
             wxString msgTitle;
-            if (!wxTheApp->GetAppName().empty())
-                msgTitle = wxTheApp->GetAppName();
+            if (!wxTheApp->GetAppDisplayName().empty())
+                msgTitle = wxTheApp->GetAppDisplayName();
             else
                 msgTitle = wxString(_("File error"));
 
diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp
index bae3716370..88f9add423 100644
--- a/src/common/fontmap.cpp
+++ b/src/common/fontmap.cpp
@@ -194,7 +194,7 @@ wxFontMapper::CharsetToEncoding(const wxString& charset, bool interactive)
         // the dialog title
         wxString title(m_titleDialog);
         if ( !title )
-            title << wxTheApp->GetAppName() << _(": unknown charset");
+            title << wxTheApp->GetAppDisplayName() << _(": unknown charset");
 
         // the message
         wxString msg;
@@ -408,7 +408,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
     {
         wxString title(m_titleDialog);
         if ( !title )
-            title << wxTheApp->GetAppName() << _(": unknown encoding");
+            title << wxTheApp->GetAppDisplayName() << _(": unknown encoding");
 
         // built the message
         wxString encDesc = GetEncodingDescription(encoding),
diff --git a/src/common/msgout.cpp b/src/common/msgout.cpp
index ec85ee9c13..897414c21d 100644
--- a/src/common/msgout.cpp
+++ b/src/common/msgout.cpp
@@ -222,7 +222,7 @@ void wxMessageOutputMessageBox::Output(const wxString& str)
 
     wxString title;
     if ( wxTheApp )
-        title.Printf(_("%s message"), wxTheApp->GetAppName().c_str());
+        title.Printf(_("%s message"), wxTheApp->GetAppDisplayName().c_str());
 
     ::wxMessageBox(out, title);
 }
diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp
index abc1c6ae6f..4582c3b07e 100644
--- a/src/generic/logg.cpp
+++ b/src/generic/logg.cpp
@@ -281,9 +281,7 @@ void wxLogGui::Flush()
         repeatCount = wxLog::DoLogNumberOfRepeats();
     }
 
-    wxString appName = wxTheApp->GetAppName();
-    if ( !appName.empty() )
-        appName[0u] = (wxChar)wxToupper(appName[0u]);
+    wxString appName = wxTheApp->GetAppDisplayName();
 
     long style;
     wxString titleFormat;
diff --git a/src/motif/clipbrd.cpp b/src/motif/clipbrd.cpp
index df66c9c417..79b013563b 100644
--- a/src/motif/clipbrd.cpp
+++ b/src/motif/clipbrd.cpp
@@ -287,7 +287,7 @@ bool wxClipboard::AddData( wxDataObject *data )
     Display* xdisplay = wxGlobalDisplay();
     Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget();
     Window xwindow = XtWindow( xwidget );
-    wxXmString label( wxTheApp->GetAppName() );
+    wxXmString label( wxTheApp->GetAppDisplayName() );
     Time timestamp = XtLastTimestampProcessed( xdisplay );
     long itemId;
 
diff --git a/src/msw/main.cpp b/src/msw/main.cpp
index 583460c7b1..2142d05ace 100644
--- a/src/msw/main.cpp
+++ b/src/msw/main.cpp
@@ -186,7 +186,7 @@ bool wxHandleFatalExceptions(bool doit)
         wxString name = wxString::Format
                         (
                             _T("%s_%s_%lu.dmp"),
-                            wxTheApp ? (const wxChar*)wxTheApp->GetAppName().c_str()
+                            wxTheApp ? (const wxChar*)wxTheApp->GetAppDisplayName().c_str()
                                      : _T("wxwindows"),
                             wxDateTime::Now().Format(_T("%Y%m%dT%H%M%S")).c_str(),
                             ::GetCurrentProcessId()
diff --git a/src/msw/wince/crt.cpp b/src/msw/wince/crt.cpp
index 29e1cb7019..740205e8e5 100644
--- a/src/msw/wince/crt.cpp
+++ b/src/msw/wince/crt.cpp
@@ -51,7 +51,7 @@ void abort()
 {
     wxString name;
     if ( wxTheApp )
-        name = wxTheApp->GetAppName();
+        name = wxTheApp->GetAppDisplayName();
     if ( name.empty() )
         name = L"wxWidgets Application";
 
-- 
2.47.2