wxWidgets: wxDocTemplate Class Reference

| Version: 3.0.4

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

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

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Public Attributes | List of all members
wxDocTemplate Class Reference
Class List by Category » 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. More...
virtual | ~wxDocTemplate ()
| Destructor. More...
virtual wxDocument * | CreateDocument (const wxString &path, long flags=0)
| Creates a new instance of the associated document class. More...
virtual wxView * | CreateView (wxDocument *doc, long flags=0)
| Creates a new instance of the associated view class. More...
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. More...
wxString | GetDefaultExtension () const
| Returns the default file extension for the document data, as passed to the document template constructor. More...
wxString | GetDescription () const
| Returns the text description of this template, as passed to the document template constructor. More...
wxString | GetDirectory () const
| Returns the default directory, as passed to the document template constructor. More...
wxClassInfo * | GetDocClassInfo () const
| Returns the run-time class information that allows document instances to be constructed dynamically, as passed to the document template constructor. More...
wxDocManager * | GetDocumentManager () const
| Returns a pointer to the document manager instance for which this template was created. More...
virtual wxString | GetDocumentName () const
| Returns the document type name, as passed to the document template constructor. More...
wxString | GetFileFilter () const
| Returns the file filter, as passed to the document template constructor. More...
long | GetFlags () const
| Returns the flags, as passed to the document template constructor. More...
wxClassInfo * | GetViewClassInfo () const
| Returns the run-time class information that allows view instances to be constructed dynamically, as passed to the document template constructor. More...
virtual wxString | GetViewName () const
| Returns the view type name, as passed to the document template constructor. More...
virtual bool | InitDocument (wxDocument *doc, const wxString &path, long flags=0)
| Initialises the document, calling wxDocument::OnCreate(). More...
bool | IsVisible () const
| Returns true if the document template can be shown in user dialogs, false otherwise. More...
void | SetDefaultExtension (const wxString &ext)
| Sets the default file extension. More...
void | SetDescription (const wxString &descr)
| Sets the template description. More...
void | SetDirectory (const wxString &dir)
| Sets the default directory. More...
void | SetDocumentManager (wxDocManager *manager)
| Sets the pointer to the document manager instance for which this template was created. More...
void | SetFileFilter (const wxString &filter)
| Sets the file filter. More...
void | SetFlags (long flags)
| Sets the internal document template flags (see the constructor description for more details). More...
wxPageSetupDialogData & | GetPageSetupDialogData ()
| Returns a reference to the wxPageSetupDialogData associated with the printing operations of this document manager. More...
const wxPageSetupDialogData & | GetPageSetupDialogData () const
| Returns a reference to the wxPageSetupDialogData associated with the printing operations of this document manager. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
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). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined. More...
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. More...

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

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
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. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## 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.