deTABified

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-07-10 09:28:34 +00:00
parent 2b6d8c00fc
commit 427716213f

View File

@@ -172,7 +172,7 @@ bool wxDocument::Close()
bool wxDocument::OnCloseDocument() bool wxDocument::OnCloseDocument()
{ {
// Tell all views that we're about to close // Tell all views that we're about to close
NotifyClosing(); NotifyClosing();
DeleteContents(); DeleteContents();
Modify(FALSE); Modify(FALSE);
return TRUE; return TRUE;
@@ -288,7 +288,7 @@ bool wxDocument::SaveAs()
if (!OnSaveDocument(m_documentFile)) if (!OnSaveDocument(m_documentFile))
return FALSE; return FALSE;
// A file that doesn't use the default extension of its document template cannot be opened // A file that doesn't use the default extension of its document template cannot be opened
// via the FileHistory, so we do not add it. // via the FileHistory, so we do not add it.
if (docTemplate->FileMatchesTemplate(fileName)) if (docTemplate->FileMatchesTemplate(fileName))
{ {
@@ -529,7 +529,7 @@ void wxDocument::UpdateAllViews(wxView *sender, wxObject *hint)
while (node) while (node)
{ {
wxView *view = (wxView *)node->GetData(); wxView *view = (wxView *)node->GetData();
if (view != sender) if (view != sender)
view->OnUpdate(sender, hint); view->OnUpdate(sender, hint);
node = node->GetNext(); node = node->GetNext();
} }
@@ -800,7 +800,7 @@ bool wxDocManager::CloseDocument(wxDocument* doc, bool force)
// Check we're really deleted // Check we're really deleted
if (m_docs.Member(doc)) if (m_docs.Member(doc))
delete doc; delete doc;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@@ -813,7 +813,7 @@ bool wxDocManager::CloseDocuments(bool force)
{ {
wxDocument *doc = (wxDocument *)node->GetData(); wxDocument *doc = (wxDocument *)node->GetData();
wxNode *next = node->GetNext(); wxNode *next = node->GetNext();
if (!CloseDocument(doc, force)) if (!CloseDocument(doc, force))
return FALSE; return FALSE;
@@ -1110,7 +1110,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
delete[] templates; delete[] templates;
return (wxDocument *) NULL; return (wxDocument *) NULL;
} }
wxDocument* docToClose = NULL; wxDocument* docToClose = NULL;
// If we've reached the max number of docs, close the // If we've reached the max number of docs, close the
@@ -1134,11 +1134,11 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
return NULL; return NULL;
} }
} }
wxDocTemplate *temp = templates[0]; wxDocTemplate *temp = templates[0];
delete[] templates; delete[] templates;
wxDocument *newDoc = temp->CreateDocument(path, flags); wxDocument *newDoc = temp->CreateDocument(path, flags);
if (newDoc) if (newDoc)
{ {
newDoc->SetDocumentName(temp->GetDocumentName()); newDoc->SetDocumentName(temp->GetDocumentName());
@@ -1159,7 +1159,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
return NULL; return NULL;
} }
} }
wxDocument *newDoc = temp->CreateDocument(path, flags); wxDocument *newDoc = temp->CreateDocument(path, flags);
if (newDoc) if (newDoc)
@@ -1186,10 +1186,10 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
temp = FindTemplateForPath(path2); temp = FindTemplateForPath(path2);
if (!temp) if (!temp)
{ {
// Since we do not add files with non-default extensions to the FileHistory this // Since we do not add files with non-default extensions to the FileHistory this
// can only happen if the application changes the allowed templates in runtime. // can only happen if the application changes the allowed templates in runtime.
(void)wxMessageBox(_("Sorry, the format for this file is unknown."), (void)wxMessageBox(_("Sorry, the format for this file is unknown."),
_("Open File"), _("Open File"),
wxOK | wxICON_EXCLAMATION, wxFindSuitableParent()); wxOK | wxICON_EXCLAMATION, wxFindSuitableParent());
} }
} }
@@ -1207,7 +1207,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
return NULL; return NULL;
} }
} }
wxDocument *newDoc = temp->CreateDocument(path2, flags); wxDocument *newDoc = temp->CreateDocument(path2, flags);
if (newDoc) if (newDoc)
{ {
@@ -1514,10 +1514,10 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
theTemplate = FindTemplateForPath(path); theTemplate = FindTemplateForPath(path);
if ( !theTemplate ) if ( !theTemplate )
{ {
// Since we do not add files with non-default extensions to the FileHistory this // Since we do not add files with non-default extensions to the FileHistory this
// can only happen if the application changes the allowed templates in runtime. // can only happen if the application changes the allowed templates in runtime.
(void)wxMessageBox(_("Sorry, the format for this file is unknown."), (void)wxMessageBox(_("Sorry, the format for this file is unknown."),
_("Open File"), _("Open File"),
wxOK | wxICON_EXCLAMATION, wxFindSuitableParent()); wxOK | wxICON_EXCLAMATION, wxFindSuitableParent());
} }
} }
@@ -1527,28 +1527,6 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
} }
return theTemplate; return theTemplate;
#if 0
// In all other windowing systems, until we have more advanced
// file selectors, we must select the document type (template) first, and
// _then_ pop up the file selector.
wxDocTemplate *temp = SelectDocumentType(templates, noTemplates);
if (!temp)
return (wxDocTemplate *) NULL;
wxChar *pathTmp = wxFileSelector(_("Select a file"), wxT(""), wxT(""),
temp->GetDefaultExtension(),
temp->GetFileFilter(),
0, wxTheApp->GetTopWindow());
if (pathTmp)
{
path = pathTmp;
return temp;
}
else
return (wxDocTemplate *) NULL;
#endif // 0
} }
wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
@@ -1558,47 +1536,47 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
wxDocTemplate **data = new wxDocTemplate *[noTemplates]; wxDocTemplate **data = new wxDocTemplate *[noTemplates];
int i; int i;
int n = 0; int n = 0;
for (i = 0; i < noTemplates; i++) for (i = 0; i < noTemplates; i++)
{ {
if (templates[i]->IsVisible()) if (templates[i]->IsVisible())
{ {
int j; int j;
bool want = TRUE; bool want = TRUE;
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
//filter out NOT unique documents + view combinations //filter out NOT unique documents + view combinations
if ( templates[i]->m_docTypeName == data[j]->m_docTypeName && if ( templates[i]->m_docTypeName == data[j]->m_docTypeName &&
templates[i]->m_viewTypeName == data[j]->m_viewTypeName templates[i]->m_viewTypeName == data[j]->m_viewTypeName
) )
want = FALSE; want = FALSE;
} }
if ( want ) if ( want )
{ {
strings.Add(templates[i]->m_description); strings.Add(templates[i]->m_description);
data[n] = templates[i]; data[n] = templates[i];
n ++; n ++;
} }
} }
} // for } // for
if (sort) if (sort)
{ {
// Yes, this will be slow, but template lists // Yes, this will be slow, but template lists
// are typically short. // are typically short.
int j; int j;
n = strings.Count(); n = strings.Count();
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
for (j = 0; j < noTemplates; j++) for (j = 0; j < noTemplates; j++)
{ {
if (strings[i] == templates[j]->m_description) if (strings[i] == templates[j]->m_description)
data[i] = templates[j]; data[i] = templates[j];
} }
} }
} }
wxDocTemplate *theTemplate; wxDocTemplate *theTemplate;
@@ -1638,45 +1616,45 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
wxDocTemplate **data = new wxDocTemplate *[noTemplates]; wxDocTemplate **data = new wxDocTemplate *[noTemplates];
int i; int i;
int n = 0; int n = 0;
for (i = 0; i < noTemplates; i++) for (i = 0; i < noTemplates; i++)
{ {
wxDocTemplate *templ = templates[i]; wxDocTemplate *templ = templates[i];
if ( templ->IsVisible() && !templ->GetViewName().empty() ) if ( templ->IsVisible() && !templ->GetViewName().empty() )
{ {
int j; int j;
bool want = TRUE; bool want = TRUE;
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
//filter out NOT unique views //filter out NOT unique views
if ( templates[i]->m_viewTypeName == data[j]->m_viewTypeName ) if ( templates[i]->m_viewTypeName == data[j]->m_viewTypeName )
want = FALSE; want = FALSE;
} }
if ( want ) if ( want )
{ {
strings.Add(templ->m_viewTypeName); strings.Add(templ->m_viewTypeName);
data[n] = templ; data[n] = templ;
n ++; n ++;
} }
} }
} }
if (sort) if (sort)
{ {
// Yes, this will be slow, but template lists // Yes, this will be slow, but template lists
// are typically short. // are typically short.
int j; int j;
n = strings.Count(); n = strings.Count();
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
for (j = 0; j < noTemplates; j++) for (j = 0; j < noTemplates; j++)
{ {
if (strings[i] == templates[j]->m_viewTypeName) if (strings[i] == templates[j]->m_viewTypeName)
data[i] = templates[j]; data[i] = templates[j];
} }
} }
} }
wxDocTemplate *theTemplate; wxDocTemplate *theTemplate;
@@ -1878,7 +1856,7 @@ void wxDocParentFrame::OnMRUFile(wxCommandEvent& event)
{ {
// remove the file from the MRU list. The user should already be notified. // remove the file from the MRU list. The user should already be notified.
m_docManager->RemoveFileFromHistory(n); m_docManager->RemoveFileFromHistory(n);
wxLogError(_("The file '%s' couldn't be opened.\nIt has been removed from the most recently used files list."), wxLogError(_("The file '%s' couldn't be opened.\nIt has been removed from the most recently used files list."),
filename.c_str()); filename.c_str());
} }
@@ -2217,7 +2195,7 @@ void wxFileHistory::Save(wxConfigBase& config)
if (i < m_fileHistoryN) if (i < m_fileHistoryN)
config.Write(buf, wxString(m_fileHistory[i])); config.Write(buf, wxString(m_fileHistory[i]));
else else
config.Write(buf, wxEmptyString); config.Write(buf, wxEmptyString);
} }
} }
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG