## wxDocTemplate

The wxDocTemplate class is used to model the relationship between a document class and a view class.

Derived from

wxObject

Include files

<wx/docview.h>

See also

wxDocTemplate overview, wxDocument, wxView

Members

wxDocTemplate::m_defaultExt
wxDocTemplate::m_description
wxDocTemplate::m_directory
wxDocTemplate::m_docClassInfo
wxDocTemplate::m_docTypeName
wxDocTemplate::m_documentManager
wxDocTemplate::m_fileFilter
wxDocTemplate::m_flags
wxDocTemplate::m_viewClassInfo
wxDocTemplate::m_viewTypeName
wxDocTemplate::wxDocTemplate
wxDocTemplate::~wxDocTemplate
wxDocTemplate::CreateDocument
wxDocTemplate::CreateView
wxDocTemplate::GetDefaultExtension
wxDocTemplate::GetDescription
wxDocTemplate::GetDirectory
wxDocTemplate::GetDocumentManager
wxDocTemplate::GetDocumentName
wxDocTemplate::GetFileFilter
wxDocTemplate::GetFlags
wxDocTemplate::GetViewName
wxDocTemplate::InitDocument
wxDocTemplate::IsVisible
wxDocTemplate::SetDefaultExtension
wxDocTemplate::SetDescription
wxDocTemplate::SetDirectory
wxDocTemplate::SetDocumentManager
wxDocTemplate::SetFileFilter
wxDocTemplate::SetFlags

### wxDocTemplate::m_defaultExt

wxString m_defaultExt

The default extension for files of this type.

### wxDocTemplate::m_description

wxString m_description

A short description of this template.

### wxDocTemplate::m_directory

wxString m_directory

The default directory for files of this type.

### wxDocTemplate::m_docClassInfo

wxClassInfo* m_docClassInfo

Run-time class information that allows document instances to be constructed dynamically.

### wxDocTemplate::m_docTypeName

wxString m_docTypeName

The named type of the document associated with this template.

### wxDocTemplate::m_documentManager

wxDocTemplate* m_documentManager

A pointer to the document manager for which this template was created.

### wxDocTemplate::m_fileFilter

wxString m_fileFilter

The file filter (such as `*.txt`) to be used in file selector dialogs.

### wxDocTemplate::m_flags

long m_flags

The flags passed to the constructor.

### wxDocTemplate::m_viewClassInfo

wxClassInfo* m_viewClassInfo

Run-time class information that allows view instances to be constructed dynamically.

### wxDocTemplate::m_viewTypeName

wxString m_viewTypeName

The named type of the view associated with this template.

### wxDocTemplate::wxDocTemplate

wxDocTemplate(wxDocManager* manager, const wxString& descr, const wxString& filter, const wxString& dir, const wxString& ext, const wxString& docTypeName, const wxString& viewTypeName, wxClassInfo* docClassInfo = NULL, wxClassInfo* viewClassInfo = NULL, long flags = wxDEFAULT_TEMPLATE_FLAGS)

Constructor. Create instances dynamically near the start of your application after creating a wxDocManager instance, and before doing any document or view operations.

manager is the document manager object which manages this template.

descr is a short description of what the template is for. This string will be displayed in the file filter list of Windows file selectors.

filter is an appropriate file filter such as `*.txt`.

dir is the default directory to use for file selectors.

ext is the default file extension (such as txt).

docTypeName is a name that should be unique for a given type of document, used for gathering a list of views relevant to a particular document.

viewTypeName is a name that should be unique for a given view.

docClassInfo is a pointer to the run-time document class information as returned by the CLASSINFO macro, e.g. CLASSINFO(MyDocumentClass). If this is not supplied, you will need to derive a new wxDocTemplate class and override the CreateDocument member to return a new document instance on demand.

viewClassInfo is a pointer to the run-time view class information as returned by the CLASSINFO macro, e.g. CLASSINFO(MyViewClass). If this is not supplied, you will need to derive a new wxDocTemplate class and override the CreateView member to return a new view instance on demand.

flags is a bit list of the following:

- wxTEMPLATE_VISIBLE The template may be displayed to the user in dialogs.
- wxTEMPLATE_INVISIBLE The template may not be displayed to the user in dialogs.
- wxDEFAULT_TEMPLATE_FLAGS Defined as wxTEMPLATE_VISIBLE.

wxPerl note: In wxPerl `docClassInfo` and `viewClassInfo` can be either `Wx::ClassInfo` objects or strings which contain the name of the perl packages which are to be used as `Wx::Document` and `Wx::View` classes (they must have a constructor named `new`):

Wx::DocTemplate->new( docmgr, descr, filter, dir, ext, docTypeName, viewTypeName, docClassInfo, viewClassInfo, flags ) | will construct document and view objects from the class information
Wx::DocTemplate->new( docmgr, descr, filter, dir, ext, docTypeName, viewTypeName, docClassName, viewClassName, flags ) | will construct document and view objects from perl packages
Wx::DocTemplate->new( docmgr, descr, filter, dir, ext, docTypeName, viewTypeName ) | `Wx::DocTemplate::CreateDocument()` and `Wx::DocTemplate::CreateView()` must be overridden

### wxDocTemplate::~wxDocTemplate

void ~wxDocTemplate()

Destructor.

### wxDocTemplate::CreateDocument

wxDocument * CreateDocument(const wxString& path, long flags = 0)

Creates a new instance of the associated document class. If you have not supplied 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.

### wxDocTemplate::CreateView

wxView * CreateView(wxDocument *doc, long flags = 0)

Creates a new instance of the associated view class. If you have not supplied a wxClassInfo parameter to the template constructor, you will need to override this function to return an appropriate view instance.

### wxDocTemplate::GetDefaultExtension

wxString GetDefaultExtension()

Returns the default file extension for the document data, as passed to the document template constructor.

### wxDocTemplate::GetDescription

wxString GetDescription()

Returns the text description of this template, as passed to the document template constructor.

### wxDocTemplate::GetDirectory

wxString GetDirectory()

Returns the default directory, as passed to the document template constructor.

### wxDocTemplate::GetDocumentManager

wxDocManager * GetDocumentManager()

Returns a pointer to the document manager instance for which this template was created.

### wxDocTemplate::GetDocumentName

wxString GetDocumentName()

Returns the document type name, as passed to the document template constructor.

### wxDocTemplate::GetFileFilter

wxString GetFileFilter()

Returns the file filter, as passed to the document template constructor.

### wxDocTemplate::GetFlags

long GetFlags()

Returns the flags, as passed to the document template constructor.

### wxDocTemplate::GetViewName

wxString GetViewName()

Returns the view type name, as passed to the document template constructor.

### wxDocTemplate::InitDocument

bool InitDocument(wxDocument* doc, const wxString& path, long flags = 0)

Initialises the document, calling wxDocument::OnCreate. This is called from wxDocTemplate::CreateDocument.

### wxDocTemplate::IsVisible

bool IsVisible()

Returns true if the document template can be shown in user dialogs, false otherwise.

### wxDocTemplate::SetDefaultExtension

void SetDefaultExtension(const wxString& ext)

Sets the default file extension.

### wxDocTemplate::SetDescription

void SetDescription(const wxString& descr)

Sets the template description.

### wxDocTemplate::SetDirectory

void SetDirectory(const wxString& dir)

Sets the default directory.

### wxDocTemplate::SetDocumentManager

void SetDocumentManager(wxDocManager *manager)

Sets the pointer to the document manager instance for which this template was created. Should not be called by the application.

### wxDocTemplate::SetFileFilter

void SetFileFilter(const wxString& filter)

Sets the file filter.

### wxDocTemplate::SetFlags

void SetFlags(long flags)

Sets the internal document template flags (see the constructor description for more details).