a wxClassInfo parameter to the template constructor, you will need to override this
function to return an appropriate document instance.
+This function calls wxDocTemplate::InitDocument which in turns
+calls wxDocument::OnCreate.
+
\membersection{wxDocTemplate::CreateView}
\func{wxView *}{CreateView}{\param{wxDocument *}{doc}, \param{long}{ flags = 0}}
Returns the view type name, as passed to the document template constructor.
+\membersection{wxDocTemplate::InitDocument}
+
+\func{bool}{InitDocument}{\param{wxDocument* }{doc}, \param{const wxString\& }{path}, \param{long}{ flags = 0}}
+
+Initialises the document, calling wxDocument::OnCreate. This is called from
+wxDocTemplate::CreateDocument.
+
\membersection{wxDocTemplate::IsVisible}
\func{bool}{IsVisible}{\void}
virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
virtual wxView *CreateView(wxDocument *doc, long flags = 0);
+ // Helper method for CreateDocument; also allows you to do your own document
+ // creation
+ virtual bool InitDocument(wxDocument* doc, const wxString& path, long flags = 0);
+
wxString GetDefaultExtension() const { return m_defaultExt; };
wxString GetDescription() const { return m_description; }
wxString GetDirectory() const { return m_directory; };
if (!m_docClassInfo)
return (wxDocument *) NULL;
wxDocument *doc = (wxDocument *)m_docClassInfo->CreateObject();
+
+ if (InitDocument(doc, path, flags))
+ {
+ return doc;
+ }
+ else
+ {
+ return (wxDocument *) NULL;
+ }
+}
+
+bool wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags)
+{
doc->SetFilename(path);
doc->SetDocumentTemplate(this);
GetDocumentManager()->AddDocument(doc);
doc->SetCommandProcessor(doc->OnCreateCommandProcessor());
if (doc->OnCreate(path, flags))
- return doc;
+ return true;
else
{
if (GetDocumentManager()->GetDocuments().Member(doc))
doc->DeleteAllViews();
- return (wxDocument *) NULL;
+ return false;
}
}