| Version: 3.0.1

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
wxDocTemplate Class Reference
Document/View Framework

`#include <wx/docview.h>`

Inheritance diagram for wxDocTemplate:
[legend]

## Detailed Description

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

##

Library: wxCore
Category: Document/View Framework

See Also
  wxDocTemplate Overview, wxDocument, wxView

## Public Member Functions

| wxDocTemplate (wxDocManager *manager, const wxString &descr, const wxString &filter, const wxString &dir, const wxString &ext, const wxString &docTypeName, const wxString &viewTypeName, wxClassInfo *docClassInfo=0, wxClassInfo *viewClassInfo=0, long flags=wxTEMPLATE_VISIBLE)
| Constructor.
virtual | ~wxDocTemplate ()
| Destructor.
virtual wxDocument * | CreateDocument (const wxString &path, long flags=0)
| Creates a new instance of the associated document class.
virtual wxView * | CreateView (wxDocument *doc, long flags=0)
| Creates a new instance of the associated view class.
virtual bool | FileMatchesTemplate (const wxString &path)
| This function implements the default (very primitive) format detection which checks if the extension is that of the template.
wxString | GetDefaultExtension () const
| Returns the default file extension for the document data, as passed to the document template constructor.
wxString | GetDescription () const
| Returns the text description of this template, as passed to the document template constructor.
wxString | GetDirectory () const
| Returns the default directory, as passed to the document template constructor.
wxClassInfo * | GetDocClassInfo () const
| Returns the run-time class information that allows document instances to be constructed dynamically, as passed to the document template constructor.
wxDocManager * | GetDocumentManager () const
| Returns a pointer to the document manager instance for which this template was created.
virtual wxString | GetDocumentName () const
| Returns the document type name, as passed to the document template constructor.
wxString | GetFileFilter () const
| Returns the file filter, as passed to the document template constructor.
long | GetFlags () const
| Returns the flags, as passed to the document template constructor.
wxClassInfo * | GetViewClassInfo () const
| Returns the run-time class information that allows view instances to be constructed dynamically, as passed to the document template constructor.
virtual wxString | GetViewName () const
| Returns the view type name, as passed to the document template constructor.
virtual bool | InitDocument (wxDocument *doc, const wxString &path, long flags=0)
| Initialises the document, calling wxDocument::OnCreate().
bool | IsVisible () const
| Returns true if the document template can be shown in user dialogs, false otherwise.
void | SetDefaultExtension (const wxString &ext)
| Sets the default file extension.
void | SetDescription (const wxString &descr)
| Sets the template description.
void | SetDirectory (const wxString &dir)
| Sets the default directory.
void | SetDocumentManager (wxDocManager *manager)
| Sets the pointer to the document manager instance for which this template was created.
void | SetFileFilter (const wxString &filter)
| Sets the file filter.
void | SetFlags (long flags)
| Sets the internal document template flags (see the constructor description for more details).
wxPageSetupDialogData & | GetPageSetupDialogData ()
| Returns a reference to the wxPageSetupDialogData associated with the printing operations of this document manager.
const wxPageSetupDialogData & | GetPageSetupDialogData () const
| Returns a reference to the wxPageSetupDialogData associated with the printing operations of this document manager.
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data.
| wxObject (const wxObject &other)
| Copy ctor.
virtual | ~wxObject ()
| Destructor.
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class.
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj.
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone.
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer.
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data.
void | UnShare ()
| This is the same of AllocExclusive() but this method is public.
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined.
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined.

## Public Attributes

wxString | m_defaultExt
| The default extension for files of this type.
wxString | m_description
| A short description of this template.
wxString | m_directory
| The default directory for files of this type.
wxClassInfo * | m_docClassInfo
| Run-time class information that allows document instances to be constructed dynamically.
wxString | m_docTypeName
| The named type of the document associated with this template.
wxDocTemplate * | m_documentManager
| A pointer to the document manager for which this template was created.
wxString | m_fileFilter
| The file filter (such as "*.txt") to be used in file selector dialogs.
long | m_flags
| The flags passed to the constructor.
wxClassInfo * | m_viewClassInfo
| Run-time class information that allows view instances to be constructed dynamically.
wxString | m_viewTypeName
| The named type of the view associated with this template.

## Additional Inherited Members

Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object.
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data.

## Constructor & Destructor Documentation

wxDocTemplate::wxDocTemplate | ( | wxDocManager * | manager,
|  | const wxString & | descr,
|  | const wxString & | filter,
|  | const wxString & | dir,
|  | const wxString & | ext,
|  | const wxString & | docTypeName,
|  | const wxString & | viewTypeName,
|  | wxClassInfo * | docClassInfo = `0`,
|  | wxClassInfo * | viewClassInfo = `0`,
|  | long | flags = `wxTEMPLATE_VISIBLE`
| ) |  |

Constructor.

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

Parameters

  manager | The document manager object which manages this template.
  descr | A short description of what the template is for. This string will be displayed in the file filter list of Windows file selectors.
  filter | An appropriate file filter such as "*.txt".
  dir | The default directory to use for file selectors.
  ext | The default file extension (such as "txt").
  docTypeName | 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 | A name that should be unique for a given view.
  docClassInfo | A pointer to the run-time document class information as returned by the wxCLASSINFO() macro, e.g. wxCLASSINFO(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 | A pointer to the run-time view class information as returned by the wxCLASSINFO() macro, e.g. wxCLASSINFO(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

  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 containing 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); as an example:

- 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): in this case `Wx::DocTemplate::CreateDocument()` and `Wx::DocTemplate::CreateView()` must be overridden

virtual wxDocTemplate::~wxDocTemplate | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

virtual wxDocument* wxDocTemplate::CreateDocument | ( | const wxString & | path,
|  | long | flags = `0`
| ) |  |

virtual

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 InitDocument() which in turns calls wxDocument::OnCreate().

virtual wxView* wxDocTemplate::CreateView | ( | wxDocument * | doc,
|  | long | flags = `0`
| ) |  |

virtual

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.

If the new view initialization fails, it must call wxDocument::RemoveView() for consistency with the default behaviour of this function.

virtual bool wxDocTemplate::FileMatchesTemplate | ( | const wxString & | path | ) |

virtual

This function implements the default (very primitive) format detection which checks if the extension is that of the template.

Parameters

  path | The path to be checked against the template.

wxString wxDocTemplate::GetDefaultExtension | ( |  | ) | const

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

wxString wxDocTemplate::GetDescription | ( |  | ) | const

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

wxString wxDocTemplate::GetDirectory | ( |  | ) | const

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

wxClassInfo* wxDocTemplate::GetDocClassInfo | ( |  | ) | const

Returns the run-time class information that allows document instances to be constructed dynamically, as passed to the document template constructor.

wxDocManager* wxDocTemplate::GetDocumentManager | ( |  | ) | const

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

virtual wxString wxDocTemplate::GetDocumentName | ( |  | ) | const

virtual

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

wxString wxDocTemplate::GetFileFilter | ( |  | ) | const

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

long wxDocTemplate::GetFlags | ( |  | ) | const

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

wxPageSetupDialogData& wxDocTemplate::GetPageSetupDialogData | ( |  | ) |

Returns a reference to the wxPageSetupDialogData associated with the printing operations of this document manager.

const wxPageSetupDialogData& wxDocTemplate::GetPageSetupDialogData | ( |  | ) | const

Returns a reference to the wxPageSetupDialogData associated with the printing operations of this document manager.

wxClassInfo* wxDocTemplate::GetViewClassInfo | ( |  | ) | const

Returns the run-time class information that allows view instances to be constructed dynamically, as passed to the document template constructor.

virtual wxString wxDocTemplate::GetViewName | ( |  | ) | const

virtual

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

virtual bool wxDocTemplate::InitDocument | ( | wxDocument * | doc,
|  | const wxString & | path,
|  | long | flags = `0`
| ) |  |

virtual

Initialises the document, calling wxDocument::OnCreate().

This is called from CreateDocument().

If you override this method, notice that you must delete the doc if its initialization fails for consistency with the default behaviour.

Parameters

  doc | The document to initialize.
  path | The associated file path.
  flags | Flags passed to CreateDocument().

Returns
  true if the initialization was successful or false if it failed in which case doc should be deleted by this function.

bool wxDocTemplate::IsVisible | ( |  | ) | const

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

void wxDocTemplate::SetDefaultExtension | ( | const wxString & | ext | ) |

Sets the default file extension.

void wxDocTemplate::SetDescription | ( | const wxString & | descr | ) |

Sets the template description.

void wxDocTemplate::SetDirectory | ( | const wxString & | dir | ) |

Sets the default directory.

void wxDocTemplate::SetDocumentManager | ( | wxDocManager * | manager | ) |

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

Should not be called by the application.

void wxDocTemplate::SetFileFilter | ( | const wxString & | filter | ) |

Sets the file filter.

void wxDocTemplate::SetFlags | ( | long | flags | ) |

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

## Member Data Documentation

wxString wxDocTemplate::m_defaultExt

The default extension for files of this type.

wxString wxDocTemplate::m_description

A short description of this template.

wxString wxDocTemplate::m_directory

The default directory for files of this type.

wxClassInfo* wxDocTemplate::m_docClassInfo

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

wxString wxDocTemplate::m_docTypeName

The named type of the document associated with this template.

wxDocTemplate* wxDocTemplate::m_documentManager

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

wxString wxDocTemplate::m_fileFilter

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

long wxDocTemplate::m_flags

The flags passed to the constructor.

wxClassInfo* wxDocTemplate::m_viewClassInfo

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

wxString wxDocTemplate::m_viewTypeName

The named type of the view associated with this template.