X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ac0ac8241f5ea7249ea01c04452efc0b72f49b1f..07cf98cb8eb7625eeffc95e407a9fa1ad863b451:/src/common/docview.cpp?ds=sidebyside diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 95b489ee7d..3d582f8807 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -103,7 +103,7 @@ static inline wxString FindExtension(const wxChar *path); // local constants // ---------------------------------------------------------------------------- -static const char *s_MRUEntryFormat = wxT("&%d %s"); +static const wxChar *s_MRUEntryFormat = wxT("&%d %s"); // ============================================================================ // implementation @@ -528,7 +528,7 @@ wxView::wxView() wxView::~wxView() { - GetDocumentManager()->ActivateView(this, FALSE, TRUE); +// GetDocumentManager()->ActivateView(this, FALSE, TRUE); m_viewDocument->RemoveView(this); } @@ -706,7 +706,6 @@ wxDocManager::wxDocManager(long flags, bool initialize) m_currentView = (wxView *) NULL; m_maxDocsOpen = 10000; m_fileHistory = (wxFileHistory *) NULL; - m_lastDirectory = wxT("") ; if (initialize) Initialize(); } @@ -1310,7 +1309,7 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, } wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document template"), _("Templates"), n, - strings, (char **)data); + strings, (void **)data); delete[] strings; delete[] data; return theTemplate; @@ -1333,7 +1332,7 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, } } wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document view"), _("Views"), n, - strings, (char **)data); + strings, (void **)data); delete[] strings; delete[] data; return theTemplate; @@ -1910,12 +1909,6 @@ void wxFileHistory::RemoveFileFromHistory(int i) { wxMenu* menu = (wxMenu*) node->Data(); - // wxMenu::Delete() is missing from wxGTK, so this can't be done :-( -#if 0 - // delete the menu items - menu->Delete(wxID_FILE1 + i); -#endif - // delete the element from the array (could use memmove() too...) delete [] m_fileHistory[i]; @@ -1933,22 +1926,44 @@ void wxFileHistory::RemoveFileFromHistory(int i) menu->SetLabel(wxID_FILE1 + j, buf); } - // to be removed as soon as wxMenu::Delete() is implemented -#if 1 - menu->SetLabel(wxID_FILE1 + m_fileHistoryN - 1, wxT("")); -#endif - node = node->Next(); + + // delete the last menu item which is unused now + menu->Delete(wxID_FILE1 + m_fileHistoryN - 1); + + // delete the last separator too if no more files are left + if ( m_fileHistoryN == 1 ) + { + wxMenuItemList::Node *node = menu->GetMenuItems().GetLast(); + if ( node ) + { + wxMenuItem *menuItem = node->GetData(); + if ( menuItem->IsSeparator() ) + { + menu->Delete(menuItem); + } + //else: should we search backwards for the last separator? + } + //else: menu is empty somehow + } } + m_fileHistoryN--; } wxString wxFileHistory::GetHistoryFile(int i) const { - if (i < m_fileHistoryN) - return wxString(m_fileHistory[i]); + wxString s; + if ( i < m_fileHistoryN ) + { + s = m_fileHistory[i]; + } else - return wxString(""); + { + wxFAIL_MSG( wxT("bad index in wxFileHistory::GetHistoryFile") ); + } + + return s; } void wxFileHistory::UseMenu(wxMenu *menu)