]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
return int, not wxUniChar, from wxTo{upp,low}er_l() for consistency with the standard...
[wxWidgets.git] / src / common / docview.cpp
index 37f1f642644f4acaec9b2a5006c863035293a202..d678ca6b54c3d473fd3ed2d1244baa09ecefe661 100644 (file)
@@ -298,8 +298,12 @@ bool wxDocument::SaveAs()
 #else
     wxString filter = docTemplate->GetFileFilter() ;
 #endif
-    wxString tmp = wxFileSelector(_("Save as"),
-            docTemplate->GetDirectory(),
+    wxString defaultDir = docTemplate->GetDirectory();
+    if (defaultDir.IsEmpty())
+        defaultDir = wxPathOnly(GetFilename());
+
+    wxString tmp = wxFileSelector(_("Save As"),
+            defaultDir,
             wxFileNameFromPath(GetFilename()),
             docTemplate->GetDefaultExtension(),
             filter,
@@ -468,8 +472,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 +581,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 +1454,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;
@@ -1617,7 +1621,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
 
     wxWindow* parent = wxFindSuitableParent();
 
-    wxString pathTmp = wxFileSelectorEx(_("Select a file"),
+    wxString pathTmp = wxFileSelectorEx(_("Open File"),
                                         m_lastDirectory,
                                         wxEmptyString,
                                         &FilterIndex,
@@ -1631,8 +1635,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"));
 
@@ -2216,7 +2220,7 @@ void wxFileHistory::RemoveFileFromHistory(size_t i)
     wxCHECK_RET( i < m_fileHistory.GetCount(),
                  wxT("invalid index in wxFileHistory::RemoveFileFromHistory") );
 
-    // delete the element from the array 
+    // delete the element from the array
     m_fileHistory.RemoveAt(i);
 
     wxList::compatibility_iterator node = m_fileMenus.GetFirst();
@@ -2279,7 +2283,7 @@ void wxFileHistory::Load(wxConfigBase& config)
     buf.Printf(wxT("file%d"), 1);
 
     wxString historyFile;
-    while ((m_fileHistory.GetCount() < m_fileMaxFiles) && 
+    while ((m_fileHistory.GetCount() < m_fileMaxFiles) &&
            config.Read(buf, &historyFile) && !historyFile.empty())
     {
         m_fileHistory.Add(historyFile);
@@ -2435,15 +2439,22 @@ bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename)
         return false;
 
     char buf[4096];
-    do
+    for ( ;; )
     {
         stream.Read(buf, WXSIZEOF(buf));
 
         const size_t nRead = stream.LastRead();
-        if ( !nRead || !file.Write(buf, nRead) )
+        if ( !nRead )
+        {
+            if ( stream.Eof() )
+                break;
+
+            return false;
+        }
+
+        if ( !file.Write(buf, nRead) )
             return false;
     }
-    while ( !stream.Eof() );
 
     return true;
 }