X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ac0ac8241f5ea7249ea01c04452efc0b72f49b1f..8a729bb860cec596f4ce5a59fabeb4404a266e97:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 95b489ee7d..a2863a485c 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(); } @@ -1192,7 +1191,7 @@ wxDocTemplate *wxDocManager::FindTemplateForPath(const wxString& path) // template extension. wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXGTK__) int noTemplates, #else int WXUNUSED(noTemplates), @@ -1201,8 +1200,8 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, long WXUNUSED(flags), bool WXUNUSED(save)) { - // We can only have multiple filters in Windows -#ifdef __WXMSW__ + // We can only have multiple filters in Windows and GTK +#if defined(__WXMSW__) || defined(__WXGTK__) wxString descrBuf; int i; @@ -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)