OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TDocTemplateT< D, V > Class Template Reference

To register the associated document and view classes, a parameterized subclass, TDocTemplateT<D,V>, is used to construct a particular document and view, where D represents the document class and V represents the view class. More...

#include <owl/doctpl.h>

Inheritance diagram for owl::TDocTemplateT< D, V >:
owl::TDocTemplate owl::TRegLink owl::TStreamableBase

Public Member Functions

 TDocTemplateT (TRegList &regList, TModule *&module=owl::Module, TDocTemplate *&phead=DocTemplateStaticHead)
 Constructs a TDocTemplateT using the registration table to determine the file filter pattern, search path for viewing the directory, default file extension, and flag values.
 
 TDocTemplateT (LPCTSTR desc, LPCTSTR filt, LPCTSTR dir, LPCTSTR ext, long flags=0, TModule *&module=owl::Module, TDocTemplate *&phead=DocTemplateStaticHead)
 Constructs a TDocTemplateT with the specified file description (desc), file filter pattern (filt), search path for viewing the directory (dir), default file extension (ext), and flags representing the view and creation options (flags).
 
TDocTemplateTClone (TModule *module, TDocTemplate *&phead=::DocTemplateStaticHead)
 Makes a copy of the TDocTemplateT object.
 
DConstructDoc (TDocument *parent=nullptr)
 'Factory' method to create a new document of type 'D' using the specified parameter as the parent document.
 
VConstructView (TDocument &doc)
 'Factory' method to create a new view of type 'V' from the specified document parameter.
 
DIsMyKindOfDoc (TDocument &doc)
 Returns 0 if template can't support.
 
VIsMyKindOfView (TView &view)
 Returns 0 if template incompatible.
 
virtual LPCTSTR GetViewName ()
 Gets the name of the view associated with the template.
 
- Public Member Functions inherited from owl::TDocTemplate
bool IsVisible ()
 displayable in file select dialogs
 
TDocManagerGetDocManager () const
 Points to the document manager.
 
void SetDocManager (TDocManager *dm)
 Sets the current document manager to the argument dm.
 
LPCTSTR GetDirectory () const
 Gets the directory path to use when searching for matching files.
 
void SetDirectory (LPCTSTR)
 Sets the directory path to use when searching for matching files.
 
void SetDirectory (LPCTSTR, int len)
 Sets the directory path to use when searching for matching files.
 
TDocTemplateGetNextTemplate () const
 Gets the next template in the list of templates.
 
bool IsFlagSet (long flag) const
 Returns nonzero if the document template flag is set.
 
long GetFlags () const
 Gets the document template constants, which indicate how the document is created and opened.
 
void SetFlag (long flag)
 Sets the document template constants, which indicate how the document is created and opened.
 
void ClearFlag (long flag)
 Clears a document template constant.
 
bool IsStatic () const
 Returns true if the template is statically constructed.
 
TModule *& GetModule ()
 Returns a module pointer.
 
void SetModule (TModule *module)
 Sets a module pointer.
 
int GetRefCount () const
 Return the number of reference count of the template.
 
LPCTSTR GetFileFilter () const
 Gets any valid document matching pattern to use when searching for files.
 
LPCTSTR GetDescription () const
 Gets the template description to put in the file-selection list box or the File|New menu-selection list box.
 
LPCTSTR GetDefaultExt () const
 Gets the default extension to use if the user has entered the name of a file without any extension.
 
- Public Member Functions inherited from owl::TStreamableBase
virtual ~TStreamableBase ()
 

Additional Inherited Members

- Protected Member Functions inherited from owl::TDocTemplate
 TDocTemplate (TRegList &regList, TModule *&module, TDocTemplate *&phead)
 Uses the information in the registration table (regList) to construct a TDocTemplate with the specified file description, file filter pattern, search path for viewing the directory, default file extension, and flags representing the view and creation options from the registration list.
 
 ~TDocTemplate ()
 Destroys a TDocTemplate object and frees the data members (FileFilter, Description, Directory, and DefaultExt).
 
 TDocTemplate (LPCTSTR desc, LPCTSTR filt, LPCTSTR dir, LPCTSTR ext, long flags, TModule *&module, TDocTemplate *&phead)
 Constructs a Doc/View template from the description, filter, directory, file extension, 'dt' flags, module and template head parameters.
 
 DECLARE_ABSTRACT_STREAMABLE_OWL (TDocTemplate, 1)
 

Detailed Description

template<class D, class V>
class owl::TDocTemplateT< D, V >

To register the associated document and view classes, a parameterized subclass, TDocTemplateT<D,V>, is used to construct a particular document and view, where D represents the document class and V represents the view class.

The parameterized template classes are created using a macro, which also generates the associated streamable support. The document and view classes are provided through the use of a parameterized subclass. The template class name is used as a typedef for the parameterized class. For example,

Derived from TView and TEditSearch, TEditView provides a view wrapper for the ObjectWindows text edit...
Definition editview.h:34
Derived from TDocument, TFileDocument opens and closes views and provides stream support for views.
Definition filedoc.h:34
#define DEFINE_DOC_TEMPLATE_CLASS(docClass, viewClass, cls)
Definition doctpl.h:431

You can instantiate a document template using either a static member or an explicit construction. For example,

MyEditFile et1(_T("Edit text files"),
T("*.txt"),T("D:\\doc"),_T(".TXT"),dtNoAutoView);
new MyEditFile(.....)
#define _T(x)
Definition cygwin.h:51
const uint dtNoAutoView
no automatic create of default view
Definition doctpl.h:220

When a document template is created, the document manager (TDocManager) registers the template. When the document template's delete function is called to delete the template, it is no longer visible to the user. However, it remains in memory as long as any documents still use it.

Definition at line 174 of file doctpl.h.

Constructor & Destructor Documentation

◆ TDocTemplateT() [1/2]

template<class D , class V >
owl::TDocTemplateT< D, V >::TDocTemplateT ( TRegList & regList,
TModule *& module = owl::Module,
TDocTemplate *& phead = DocTemplateStaticHead )
inline

Constructs a TDocTemplateT using the registration table to determine the file filter pattern, search path for viewing the directory, default file extension, and flag values.

See the entry in this manual for registration macros for more information about how the registration tables are created. module, which is instantiated and exported directly from every executable module, can be used to access the current instance.

Definition at line 345 of file doctpl.h.

◆ TDocTemplateT() [2/2]

template<class D , class V >
owl::TDocTemplateT< D, V >::TDocTemplateT ( LPCTSTR desc,
LPCTSTR filt,
LPCTSTR dir,
LPCTSTR ext,
long flags = 0,
TModule *& module = owl::Module,
TDocTemplate *& phead = DocTemplateStaticHead )
inline

Constructs a TDocTemplateT with the specified file description (desc), file filter pattern (filt), search path for viewing the directory (dir), default file extension (ext), and flags representing the view and creation options (flags).

module, which is instantiated and exported directly from every executable module, can be used to access the current instance.

Definition at line 360 of file doctpl.h.

Member Function Documentation

◆ Clone()

template<class D , class V >
TDocTemplateT< D, V > * owl::TDocTemplateT< D, V >::Clone ( TModule * module,
TDocTemplate *& phead = ::DocTemplateStaticHead )
inlinevirtual

Makes a copy of the TDocTemplateT object.

Implements owl::TDocTemplate.

Definition at line 372 of file doctpl.h.

◆ ConstructDoc()

template<class D , class V >
D * owl::TDocTemplateT< D, V >::ConstructDoc ( TDocument * parent = nullptr)
inlinevirtual

'Factory' method to create a new document of type 'D' using the specified parameter as the parent document.

Implements owl::TDocTemplate.

Definition at line 385 of file doctpl.h.

◆ ConstructView()

template<class D , class V >
V * owl::TDocTemplateT< D, V >::ConstructView ( TDocument & doc)
inlinevirtual

'Factory' method to create a new view of type 'V' from the specified document parameter.

Implements owl::TDocTemplate.

Definition at line 395 of file doctpl.h.

◆ GetViewName()

template<class D , class V >
LPCTSTR owl::TDocTemplateT< D, V >::GetViewName ( )
inlinevirtual

Gets the name of the view associated with the template.

Implements owl::TDocTemplate.

Definition at line 404 of file doctpl.h.

◆ IsMyKindOfDoc()

template<class D , class V >
D * owl::TDocTemplateT< D, V >::IsMyKindOfDoc ( TDocument & doc)
virtual

Returns 0 if template can't support.

Tests to see if the document (doc) is either the same class as the template's document class or a derived class.

If the template can't use the document, IsMyKIndOfDoc returns 0.

Implements owl::TDocTemplate.

Definition at line 416 of file doctpl.h.

◆ IsMyKindOfView()

template<class D , class V >
V * owl::TDocTemplateT< D, V >::IsMyKindOfView ( TView & view)
virtual

Returns 0 if template incompatible.

Tests to see if the view (view) is either the same class as the template's view class or a derived class.

If the template can't use the view, IsMyKIndOfView returns 0.

Implements owl::TDocTemplate.

Definition at line 426 of file doctpl.h.


The documentation for this class was generated from the following file: