X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ac57418f39e9671c18b99942180563146625d3ae..1363811bb6338fb0dad6c16cfa47f46fb1eb3b99:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 0495f862db..01f8ebe21a 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -51,15 +51,12 @@ #include #include +#include "wx/ioswrap.h" + #if wxUSE_IOSTREAMH -#include -#include + #include #else -#include -#include -# ifdef _MSC_VER - using namespace std; -# endif + #include #endif #if !USE_SHARED_LIBRARY @@ -194,18 +191,21 @@ bool wxDocument::Save(void) bool wxDocument::SaveAs(void) { - wxDocTemplate *docTemplate = GetDocumentTemplate(); - if (!docTemplate) - return FALSE; - - char *tmp = wxFileSelector(_("Save as"), docTemplate->GetDirectory(), GetFilename(), - docTemplate->GetDefaultExtension(), docTemplate->GetFileFilter(), - wxSAVE|wxOVERWRITE_PROMPT, GetDocumentWindow()); + wxDocTemplate *docTemplate = GetDocumentTemplate(); + if (!docTemplate) + return FALSE; - if (!tmp) - return FALSE; - else - { + wxString tmp = wxFileSelector(_("Save as"), + docTemplate->GetDirectory(), + GetFilename(), + docTemplate->GetDefaultExtension(), + docTemplate->GetFileFilter(), + wxSAVE | wxOVERWRITE_PROMPT, + GetDocumentWindow()); + + if (tmp.IsEmpty()) + return FALSE; + wxString fileName(tmp); wxString path(""); wxString name(""); @@ -231,8 +231,8 @@ bool wxDocument::SaveAs(void) view->OnChangeFilename(); node = node->Next(); } - } - return OnSaveDocument(m_documentFile); + + return OnSaveDocument(m_documentFile); } bool wxDocument::OnSaveDocument(const wxString& file) @@ -462,9 +462,10 @@ void wxDocument::SetFilename(const wxString& filename, bool notifyViews) * Document view */ -wxView::wxView(wxDocument *doc) +wxView::wxView() { - SetDocument(doc); +// SetDocument(doc); + m_viewDocument = (wxDocument*) NULL; m_viewTypeName = ""; m_viewFrame = (wxFrame *) NULL; @@ -1044,7 +1045,7 @@ void wxDocManager::FileHistoryRemoveMenu(wxMenu *menu) m_fileHistory->RemoveMenu(menu); } -#ifdef wxUSE_CONFIG +#if wxUSE_CONFIG void wxDocManager::FileHistoryLoad(wxConfigBase& config) { if (m_fileHistory) @@ -1144,33 +1145,30 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **WXUNUSED(templat { // We can only have multiple filters in Windows #ifdef __WXMSW__ - char *descrBuf = new char[1000]; // FIXME static buffer - descrBuf[0] = 0; - int i; - for (i = 0; i < noTemplates; i++) - { - if (templates[i]->IsVisible()) + wxString descrBuf; + + int i; + for (i = 0; i < noTemplates; i++) { - strcat(descrBuf, templates[i]->GetDescription()); - strcat(descrBuf, " ("); - strcat(descrBuf, templates[i]->GetFileFilter()); - strcat(descrBuf, ") "); - strcat(descrBuf, "|"); - strcat(descrBuf, templates[i]->GetFileFilter()); - strcat(descrBuf, "|"); + if (templates[i]->IsVisible()) + { + // add a '|' to separate this filter from the previous one + if ( !descrBuf.IsEmpty() ) + descrBuf << '|'; + + descrBuf << templates[i]->GetDescription() + << " (" << templates[i]->GetFileFilter() << ") |" + << templates[i]->GetFileFilter(); + } } - } - int len = strlen(descrBuf); - if (len > 0) - // Omit final "|" - descrBuf[len-1] = 0; #else - char* descrBuf = copystring("*.*"); + wxString descrBuf = "*.*"; #endif - char *pathTmp = wxFileSelector(_("Select a file"), "", "", "", descrBuf, 0, wxTheApp->GetTopWindow()); - delete[] descrBuf; - if (pathTmp) + wxString pathTmp = wxFileSelector(_("Select a file"), "", "", "", + descrBuf, 0, wxTheApp->GetTopWindow()); + + if (!pathTmp.IsEmpty()) { path = pathTmp; char *theExt = FindExtension((char *)(const char *)path); @@ -1258,7 +1256,7 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, int n = 0; for (i = 0; i < noTemplates; i++) { - if (templates[i]->IsVisible() && templates[i]->GetViewName()) + if (templates[i]->IsVisible() && (templates[i]->GetViewName() != "")) { strings[n] = WXSTRINGCAST templates[i]->m_viewTypeName; data[n] = (char *)templates[i]; @@ -1706,7 +1704,7 @@ void wxCommandProcessor::SetMenuStrings(void) // we've undone to the start of the list, but can redo the first. wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data(); wxString redoCommandName(redoCommand->GetName()); - if (!redoCommandName) redoCommandName = _("Unnamed command"); + if (redoCommandName == "") redoCommandName = _("Unnamed command"); buf = wxString(_("&Redo ")) + redoCommandName; m_commandEditMenu->SetLabel(wxID_REDO, buf); m_commandEditMenu->Enable(wxID_REDO, TRUE); @@ -1822,7 +1820,7 @@ void wxFileHistory::RemoveMenu(wxMenu *menu) m_fileMenus.DeleteObject(menu); } -#ifdef wxUSE_CONFIG +#if wxUSE_CONFIG void wxFileHistory::Load(wxConfigBase& config) { m_fileHistoryN = 0;