X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64c12a6d559c20e495d1ad79b7a6fb547d9cc7b1..665b537f51f768e19cff57fa9b351a530d6b2015:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index ce47e57dd5..86736878ff 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "docview.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -571,7 +567,7 @@ bool wxDocument::DoSaveDocument(const wxString& file) msgTitle = wxString(_("File error")); #if wxUSE_STD_IOSTREAM - wxSTD ofstream store(file.mb_str()); + wxSTD ofstream store(file.mb_str(), wxSTD ios::binary); if (store.fail() || store.bad()) #else wxFileOutputStream store(file); @@ -597,7 +593,7 @@ bool wxDocument::DoSaveDocument(const wxString& file) bool wxDocument::DoOpenDocument(const wxString& file) { #if wxUSE_STD_IOSTREAM - wxSTD ifstream store(file.mb_str()); + wxSTD ifstream store(file.mb_str(), wxSTD ios::binary); if (!store.fail() && !store.bad()) #else wxFileInputStream store(file); @@ -660,14 +656,18 @@ void wxView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)) void wxView::OnChangeFilename() { - if (GetFrame() && GetDocument()) - { - wxString title; + // GetFrame can return wxWindow rather than wxTopLevelWindow due to + // generic MDI implementation so use SetLabel rather than SetTitle. + // It should cause SetTitle() for top level windows. + wxWindow *win = GetFrame(); + if (!win) return; - GetDocument()->GetPrintableName(title); + wxDocument *doc = GetDocument(); + if (!doc) return; - GetFrame()->SetTitle(title); - } + wxString name; + doc->GetPrintableName(name); + win->SetLabel(name); } void wxView::SetDocument(wxDocument *doc) @@ -2165,6 +2165,8 @@ void wxFileHistory::AddFileToHistory(const wxString& file) pathInMenu = m_fileHistory[i]; } + // we need to quote '&' characters which are used for mnemonics + pathInMenu.Replace(_T("&"), _T("&&")); wxString buf; buf.Printf(s_MRUEntryFormat, i + 1, pathInMenu.c_str()); wxList::compatibility_iterator node = m_fileMenus.GetFirst(); @@ -2195,20 +2197,20 @@ void wxFileHistory::RemoveFileFromHistory(size_t i) wxList::compatibility_iterator node = m_fileMenus.GetFirst(); while ( node ) { - wxMenu* menu = (wxMenu*) node->GetData(); + wxMenu* menu = (wxMenu*) node->GetData(); - // shuffle filenames up - wxString buf; - for ( j = i; j < m_fileHistoryN - 1; j++ ) - { - buf.Printf(s_MRUEntryFormat, j + 1, m_fileHistory[j]); - menu->SetLabel(m_idBase + j, buf); - } + // shuffle filenames up + wxString buf; + for ( j = i; j < m_fileHistoryN - 1; j++ ) + { + buf.Printf(s_MRUEntryFormat, j + 1, m_fileHistory[j]); + menu->SetLabel(m_idBase + j, buf); + } - node = node->GetNext(); + node = node->GetNext(); // delete the last menu item which is unused now - wxWindowID lastItemId = m_idBase + m_fileHistoryN - 1; + wxWindowID lastItemId = m_idBase + wx_truncate_cast(wxWindowID, m_fileHistoryN) - 1; if (menu->FindItem(lastItemId)) { menu->Delete(lastItemId); @@ -2217,10 +2219,10 @@ void wxFileHistory::RemoveFileFromHistory(size_t i) // delete the last separator too if no more files are left if ( m_fileHistoryN == 1 ) { - wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetLast(); - if ( node ) + wxMenuItemList::compatibility_iterator nodeLast = menu->GetMenuItems().GetLast(); + if ( nodeLast ) { - wxMenuItem *menuItem = node->GetData(); + wxMenuItem *menuItem = nodeLast->GetData(); if ( menuItem->IsSeparator() ) { menu->Delete(menuItem); @@ -2443,4 +2445,3 @@ bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename) #endif // wxUSE_STD_IOSTREAM/!wxUSE_STD_IOSTREAM #endif // wxUSE_DOC_VIEW_ARCHITECTURE -