void wxDocManager::OnFileClose(wxCommandEvent& WXUNUSED(event))
{
wxDocument *doc = GetCurrentDocument();
- if (!doc)
- return;
- if (doc->Close())
- {
- doc->DeleteAllViews();
- if (m_docs.Member(doc))
- delete doc;
- }
+ if (doc)
+ CloseDocument(doc);
}
void wxDocManager::OnFileCloseAll(wxCommandEvent& WXUNUSED(event))
// Check if the id is in the range assigned to MRU list entries.
const int id = event.GetId();
if ( id >= wxID_FILE1 &&
- id < wxID_FILE1 + m_fileHistory->GetBaseId() )
+ id < wxID_FILE1 + static_cast<int>(m_fileHistory->GetCount()) )
{
DoOpenMRUFile(id - wxID_FILE1);
}
{
// file already open, just activate it and return
ActivateDocument(doc);
+ return doc;
}
}
}
m_templates.DeleteObject(temp);
}
+wxDocTemplate* wxDocManager::FindTemplate(const wxClassInfo* classinfo)
+{
+ for ( wxList::compatibility_iterator node = m_templates.GetFirst();
+ node;
+ node = node->GetNext() )
+ {
+ wxDocTemplate* t = wxStaticCast(node->GetData(), wxDocTemplate);
+ if ( t->GetDocClassInfo() == classinfo )
+ return t;
+ }
+
+ return NULL;
+}
+
// Add and remove a document from the manager's list
void wxDocManager::AddDocument(wxDocument *doc)
{
#if wxUSE_PRINTING_ARCHITECTURE
+namespace
+{
+
+wxString GetAppropriateTitle(const wxView *view, const wxString& titleGiven)
+{
+ wxString title(titleGiven);
+ if ( title.empty() )
+ {
+ if ( view && view->GetDocument() )
+ title = view->GetDocument()->GetUserReadableName();
+ else
+ title = _("Printout");
+ }
+
+ return title;
+}
+
+} // anonymous namespace
+
wxDocPrintout::wxDocPrintout(wxView *view, const wxString& title)
- : wxPrintout(title)
+ : wxPrintout(GetAppropriateTitle(view, title))
{
m_printoutView = view;
}