Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy > Class Template Reference

class DocumentManagerImpl implementation of the DocumentManager for which also the DocInterfacePolicy is specified. More...

#include <vcf/ApplicationKit/DocumentManager.h>

Inheritance diagram for VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >:

VCF::DocumentManager DocInterfacePolicy List of all members.

Public Member Functions

 DocumentManagerImpl ()
virtual void init ()
 inizialization function for document based applications.
virtual DocumentgetCurrentDocument ()
 gets a pointer to the active document.
virtual void setCurrentDocument (Document *newCurrentDocument)
 sets the given document as the active one.
virtual bool saveFile (Document *document)
 save a document into a file.
virtual bool saveFileAs (Document *document, const String &newFileName=String(L""))
 save a document into a file.
virtual void openFile ()
 opens a file.
virtual void closeCurrentDocument ()
 closes the current document, and all its children if they exist according to the policy.
virtual void reloadDocument (Document *document, const bool &keepPosition=true)
 reloads a file for an existing document.
virtual DocumentcreateDocumentFromType (const DocumentInfo &info)
 just creates the object from its type using the VCF RTTI The info.classID is used first if available, otherwise the info.className.
virtual WindowgetWindowForNewDocument (Document *document, const DocumentInfo &info)
 gets a window to be associated to the document just created.
virtual DocumentnewDefaultDocument (const String &fileName, const String &mimetype=L"")
 default procedures when creating a new document
virtual void attachUIToDocument (const String &mimeType, Document *document)
 attaches a document specific User Interface to a document using the appropriate DocumentInfo extracted from the mimeType.
virtual void createMenus ()
 creates the standard menu for a document based application and adds them as target to the appropriate action instances.
virtual void initializeWindowMenus (Window *window, Document *document, const DocumentInfo &info)
 initializes the menu for the window associated to a document.

Protected Member Functions

void attachUI (const DocumentInfo &info, Document *document)
 attaches a UI to the specified document param const DocumentInfo& info, the infos about this document's class.
void initActions ()
 initializes the actions for the application.
virtual void onSave (Event *e)
 saves the current document, if it has been modified.
virtual void onUpdateSave (ActionEvent *e)
 called when this target gets notified for update events
virtual void onSaveAs (Event *e)
 saves the current document, but let the user to specify an alternative filename and type through a dialog box.
virtual void onUpdateSaveAs (ActionEvent *e)
 called when this target gets notified for update events
virtual void onOpen (Event *e)
 opens a document.
virtual void onClose (Event *e)
 closes a document.
virtual void onUpdateClose (ActionEvent *e)
 called when this target gets notified for update events
virtual void onNew (Event *e)
 creates a new document.
virtual void onPreferences (Event *e)
 let the user to change preferences.
virtual void onUpdatePreferences (ActionEvent *e)
 handles notification that the user preferences has been changed
void onDocWindowClosing (FrameEvent *e)
 closes the document's window
void onDocWindowActive (WindowEvent *e)
 activates a window and its document
void onDocWindowCreated (Event *e)
 Happens the first time after the window is created.
void onDocModified (ModelEvent *e)
 handles notification that a document ( specified by the event ) has been changed.
virtual void onCut (Event *e)
 starts cut operation
virtual void onUpdateCut (ActionEvent *e)
 called when this target gets notified for update events
virtual void onCopy (Event *e)
 starts copy operation
virtual void onUpdateCopy (ActionEvent *e)
 called when this target gets notified for update events
virtual void onPaste (Event *e)
 starts paste operation
virtual void onUpdatePaste (ActionEvent *e)
 called when this target gets notified for update events
virtual void onUndo (Event *e)
 starts undo operation
virtual void onUpdateUndo (ActionEvent *e)
 called when this target gets notified for update events
virtual void onRedo (Event *e)
 starts redo operation
virtual void onUpdateRedo (ActionEvent *e)
 called when this target gets notified for update events

Protected Attributes

AppClass * app_
 pointer to the application
bool closingDocument_
bool documentClosedOK_

Detailed Description

template<typename AppClass, typename DocInterfacePolicy>
class VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >

class DocumentManagerImpl implementation of the DocumentManager for which also the DocInterfacePolicy is specified.

The DocInterfacePolicy is the template argument class that specifies how the DocumentManager is supposed to manage the collection (of one or more) documents. We can say than DocumentManagerImpl is the part of the DocumentManager whose member functions are depending on the DocInterfacePolicy chosen by the user.


Constructor & Destructor Documentation

template<typename AppClass, typename DocInterfacePolicy>
VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::DocumentManagerImpl  )  [inline]
 


Member Function Documentation

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::attachUI const DocumentInfo info,
Document document
[protected]
 

attaches a UI to the specified document param const DocumentInfo& info, the infos about this document's class.

param Document* document, the document to attach the UI to.
fire event:: DocumentManager::DocumentInitialized
event class: DocManagerEvent
event type: DocumentManager::dmDocumentInitialized this event is fired after the UI has been attached to the given document; it is useful for custom document initializations ( preferences ).

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::attachUIToDocument const String mimeType,
Document document
[virtual]
 

attaches a document specific User Interface to a document using the appropriate DocumentInfo extracted from the mimeType.

In this standard implementation: first it saves the current document if the policy requests this then it does the work of attaching the UI ( by calling attachUI ), finally it notifies the document has been changed. The implementation is very similar to newDefaultDocument() with the difference that a document instance is already given.
fire event:: DocumentInitialized, indirectly if attachUI() is called.
fire event:: Document::ModelChanged
event class: ModelEvent
event type: Document::deOpened

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::closeCurrentDocument  )  [virtual]
 

closes the current document, and all its children if they exist according to the policy.

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
Document * VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::createDocumentFromType const DocumentInfo info  )  [virtual]
 

just creates the object from its type using the VCF RTTI The info.classID is used first if available, otherwise the info.className.

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::createMenus  )  [virtual]
 

creates the standard menu for a document based application and adds them as target to the appropriate action instances.

The menu follows a standard for all the OS.

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
virtual Document* VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::getCurrentDocument  )  [inline, virtual]
 

gets a pointer to the active document.

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
Window * VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::getWindowForNewDocument Document document,
const DocumentInfo info
[virtual]
 

gets a window to be associated to the document just created.

This implementation just creates the associated window from its type using the VCF RTTI. In a SDI policy the new window for the document is the main window. In a MDI policy the new window for the document is simply a new window. In an AdvancedMDIPolicy this implementation needs to be overriden.

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::init  )  [virtual]
 

inizialization function for document based applications.

This is called just after Application::initRunningApplication().

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::initActions  )  [protected]
 

initializes the actions for the application.

These are tipical for any document based application.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::initializeWindowMenus Window window,
Document document,
const DocumentInfo info
[virtual]
 

initializes the menu for the window associated to a document.

The DocumentInfo is also specified. Initializes the appropriate menu for the document's window, by merging it with the application menu.

Parameters:
DocumentInfo& info, the DocumentInfo.
Window* window, the window.
Document* document, the document.
See also:
DocInterfacePolicy::mergeWindowMenus

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
Document * VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::newDefaultDocument const String fileName,
const String mimetype = L""
[virtual]
 

default procedures when creating a new document

  • under SDI it saves the previous document if it was modified.
  • it creates a document instance according to the mimetype.
  • it calls the user implementation of Document::initNew()
  • it attaches a UI to the document if this getShouldCreateUI() is true.

this is normally called before actually opening the file for the document.

In a SDI policy saveBeforeNewDocument() returns true so, if we create a new document while the current document has been modified the user is asked what to do, and the operation is aborted if the he decides to.
fire event:: DocumentInitialized, indirectly if attachUI() is called.

See also:
DocInterfacePolicy::saveBeforeNewDocument()

DocumentManagerImpl:: attachUI()

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onClose Event e  )  [inline, protected, virtual]
 

closes a document.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onCopy Event e  )  [inline, protected, virtual]
 

starts copy operation

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onCut Event e  )  [inline, protected, virtual]
 

starts cut operation

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onDocModified ModelEvent e  )  [inline, protected]
 

handles notification that a document ( specified by the event ) has been changed.

The UI will set the caption to the caption of modified document's window.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onDocWindowActive WindowEvent e  )  [inline, protected]
 

activates a window and its document

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onDocWindowClosing FrameEvent e  )  [inline, protected]
 

closes the document's window

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onDocWindowCreated Event e  )  [inline, protected]
 

Happens the first time after the window is created.

This will activate the window and its document

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onNew Event e  )  [inline, protected, virtual]
 

creates a new document.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onOpen Event e  )  [inline, protected, virtual]
 

opens a document.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onPaste Event e  )  [inline, protected, virtual]
 

starts paste operation

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onPreferences Event e  )  [inline, protected, virtual]
 

let the user to change preferences.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onRedo Event e  )  [inline, protected, virtual]
 

starts redo operation

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onSave Event e  )  [inline, protected, virtual]
 

saves the current document, if it has been modified.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onSaveAs Event e  )  [inline, protected, virtual]
 

saves the current document, but let the user to specify an alternative filename and type through a dialog box.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUndo Event e  )  [inline, protected, virtual]
 

starts undo operation

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateClose ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateCopy ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateCut ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdatePaste ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdatePreferences ActionEvent e  )  [inline, protected, virtual]
 

handles notification that the user preferences has been changed

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateRedo ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateSave ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateSaveAs ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::onUpdateUndo ActionEvent e  )  [inline, protected, virtual]
 

called when this target gets notified for update events

See also:
Action::update

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::openFile  )  [virtual]
 

opens a file.

the standard behaviour is to show a dialog asking the user which file to open. If we don't want this base behaviour, an event handler must be implemented and added to the SaveFile delegate.
fire event:: DocumentManager::OpenFile
event class: DocManagerEvent
event type: DocumentManager::dmOpenDocument

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::reloadDocument Document document,
const bool &  keepPosition = true
[virtual]
 

reloads a file for an existing document.

If the file is modified, the user is prompted to save it or not. It the operation fails, the user is warned with a message, but the document is not closed.

Parameters:
Document* doc, the document whose file needs to be reloaded.
const bool& keepPosition, true to reopen the file in the same position as before. The default is true.

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
bool VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::saveFile Document document  )  [virtual]
 

save a document into a file.

the standard behaviour is simply save the file if it has been modified, and to create a backup copy first if the document specifies to keep one. If there is a problem with the destination directory, the user is prompted with a dialog in order to specify an alternative location. If we don't want this base behaviour, an event handler must be implemented and added to the SaveFile delegate.

Parameters:
Document* doc, the document.
Returns:
bool, true if the operation completed successfully.
fire event:: DocumentManager::SaveFile
event class: DocManagerEvent
event type: DocumentManager::dmSaveDocument

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
bool VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::saveFileAs Document document,
const String newFileName = String(L"")
[virtual]
 

save a document into a file.

the standard behaviour is to show a dialog asking the user which file to open. The user is prompted with a dialog if the destination filename is not specified or if its directory does not exists. If the document is saved, then a ModelChanged event with type Document::deSaved is fired. If we don't want this base behaviour, an event handler must be implemented and added to the SaveFile delegate.

Parameters:
Document* doc, the document.
const String& newFileName, the new destination filename. By default it is empty so the user is prompted with a dialog.
Returns:
bool, true if the operation completed successfully.
fire event:: DocumentManager::SaveFile
event class: DocManagerEvent
event type: DocumentManager::dmSaveDocument
fire event:: Model::ModelChanged
event class: ModelEvent
event type: Document::deSaved

Reimplemented from VCF::DocumentManager.

template<typename AppClass, typename DocInterfacePolicy>
virtual void VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::setCurrentDocument Document newCurrentDocument  )  [inline, virtual]
 

sets the given document as the active one.

Applies the policy's implemenation and send a change notification.

Reimplemented from VCF::DocumentManager.


Member Data Documentation

template<typename AppClass, typename DocInterfacePolicy>
AppClass* VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::app_ [protected]
 

pointer to the application

template<typename AppClass, typename DocInterfacePolicy>
bool VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::closingDocument_ [protected]
 

template<typename AppClass, typename DocInterfacePolicy>
bool VCF::DocumentManagerImpl< AppClass, DocInterfacePolicy >::documentClosedOK_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information