}
return newDoc;
}
- else
- return (wxDocument *) NULL;
+
+ return (wxDocument *) NULL;
}
wxView *wxDocManager::CreateView(wxDocument *doc, long flags)
wxString descrBuf = wxT("*.*");
#endif
- int FilterIndex = 0;
+ int FilterIndex = -1;
wxWindow* parent = wxFindSuitableParent();
0,
parent);
+ wxDocTemplate *theTemplate = (wxDocTemplate *)NULL;
if (!pathTmp.IsEmpty())
{
if (!wxFileExists(pathTmp))
path = pathTmp;
- // This is dodgy in that we're selecting the template on the
- // basis of the file extension, which may not be a standard
- // one. We really want to know exactly which template was
- // chosen by using a more advanced file selector.
- wxDocTemplate *theTemplate = FindTemplateForPath(path);
- if ( !theTemplate )
+ // first choose the template using the extension, if this fails (i.e.
+ // wxFileSelectorEx() didn't fill it), then use the path
+ if ( FilterIndex != -1 )
theTemplate = templates[FilterIndex];
-
- return theTemplate;
+ if ( !theTemplate )
+ theTemplate = FindTemplateForPath(path);
}
else
{
path = wxT("");
- return (wxDocTemplate *) NULL;
}
+
+ 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
void wxDocParentFrame::OnMRUFile(wxCommandEvent& event)
{
- int n = event.GetSelection() - wxID_FILE1; // the index in MRU list
+ int n = event.GetId() - wxID_FILE1; // the index in MRU list
wxString filename(m_docManager->GetHistoryFile(n));
if ( !filename.IsEmpty() )
{
FILE *fd1;
int ch;
- if ((fd1 = wxFopen (filename.fn_str(), wxT("rb"))) == NULL)
+ if ((fd1 = wxFopen (filename, wxT("rb"))) == NULL)
return FALSE;
while ((ch = getc (fd1)) != EOF)
FILE *fd1;
char ch;
- if ((fd1 = wxFopen (filename.fn_str(), wxT("wb"))) == NULL)
+ if ((fd1 = wxFopen (filename, wxT("wb"))) == NULL)
{
return FALSE;
}