wxString tmp = wxFileSelector(_("Save as"),
docTemplate->GetDirectory(),
- GetFilename(),
+ wxFileNameFromPath(GetFilename()),
docTemplate->GetDefaultExtension(),
docTemplate->GetFileFilter(),
wxSAVE | wxOVERWRITE_PROMPT,
}
wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
- int noTemplates)
+ int noTemplates, bool sort)
{
- wxArrayString strings;
+ wxArrayString strings(sort);
wxDocTemplate **data = new wxDocTemplate *[noTemplates];
int i;
int n = 0;
- for (i = 0; i < noTemplates; i++)
- {
- if (templates[i]->IsVisible())
- {
- strings.Add(templates[i]->m_description);
- data[n] = templates[i];
- n ++;
- }
- }
+ for (i = 0; i < noTemplates; i++)
+ {
+ if (templates[i]->IsVisible())
+ {
+ strings.Add(templates[i]->m_description);
+ if (!sort)
+ {
+ data[n] = templates[i];
+ n ++;
+ }
+ }
+ } // for
+
+ if (sort)
+ {
+ // Yes, this will be slow, but template lists
+ // are typically short.
+ int j;
+ n = strings.Count();
+ for (i = 0; i < n; i++)
+ {
+ for (j = 0; j < noTemplates; j++)
+ {
+ if (strings[i] == templates[j]->m_description)
+ data[i] = templates[j];
+ }
+ }
+ }
wxDocTemplate *theTemplate;
}
wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
- int noTemplates)
+ int noTemplates, bool sort)
{
- wxArrayString strings;
+ wxArrayString strings(sort);
wxDocTemplate **data = new wxDocTemplate *[noTemplates];
int i;
int n = 0;
if ( templ->IsVisible() && !templ->GetViewName().empty() )
{
strings.Add(templ->m_viewTypeName);
- data[n] = templ;
- n ++;
+ if (!sort)
+ {
+ data[n] = templ;
+ n ++;
+ }
}
}
+ if (sort)
+ {
+ // Yes, this will be slow, but template lists
+ // are typically short.
+ int j;
+ n = strings.Count();
+ for (i = 0; i < n; i++)
+ {
+ for (j = 0; j < noTemplates; j++)
+ {
+ if (strings[i] == templates[j]->m_viewTypeName)
+ data[i] = templates[j];
+ }
+ }
+ }
+
wxDocTemplate *theTemplate;
// the same logic as above
wxCHECK_RET( i < m_fileHistoryN,
wxT("invalid index in wxFileHistory::RemoveFileFromHistory") );
- wxNode* node = m_fileMenus.First();
- while ( node )
- {
- wxMenu* menu = (wxMenu*) node->Data();
-
// delete the element from the array (could use memmove() too...)
delete [] m_fileHistory[i];
m_fileHistory[j] = m_fileHistory[j + 1];
}
+ wxNode* node = m_fileMenus.First();
+ while ( node )
+ {
+ wxMenu* menu = (wxMenu*) node->Data();
+
+
// shuffle filenames up
wxString buf;
for ( j = i; j < m_fileHistoryN - 1; j++ )
node = node->Next();
// delete the last menu item which is unused now
+ if (menu->FindItem(wxID_FILE1 + m_fileHistoryN - 1))
menu->Delete(wxID_FILE1 + m_fileHistoryN - 1);
// delete the last separator too if no more files are left