- int noTemplates, wxString& path, long WXUNUSED(flags), bool WXUNUSED(save))
-{
- // We can only have multiple filters in Windows
-#ifdef __WXMSW__
- char *descrBuf = new char[1000];
- descrBuf[0] = 0;
- int i;
- for (i = 0; i < noTemplates; i++)
- {
- if (templates[i]->IsVisible())
- {
- strcat(descrBuf, templates[i]->GetDescription());
- strcat(descrBuf, " (");
- strcat(descrBuf, templates[i]->GetFileFilter());
- strcat(descrBuf, ") ");
- strcat(descrBuf, "|");
- strcat(descrBuf, templates[i]->GetFileFilter());
- strcat(descrBuf, "|");
- }
- }
- int len = strlen(descrBuf);
- if (len > 0)
- // Omit final "|"
- descrBuf[len-1] = 0;
-
- char *pathTmp = wxFileSelector(_("Select a file"), "", "", "", descrBuf, 0, wxTheApp->GetTopWindow());
- delete[] descrBuf;
- if (pathTmp)
- {
- path = pathTmp;
- char *theExt = FindExtension((char *)(const char *)path);
- if (!theExt)
- return (wxDocTemplate *) NULL;
-
- // 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);
- return theTemplate;
- }
- else
- {
- path = "";
- return (wxDocTemplate *) NULL;
- }