tbx  0.7.3
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
tbx::doc::DocManager Class Reference

Class to manage all the documents. More...

#include <docmanager.h>

Inheritance diagram for tbx::doc::DocManager:
tbx::PreQuitListener tbx::Listener

Public Member Functions

 DocManager (DocCreatorBase *doc_creator)
 Construct the document manager for the application. More...
 
DocCreatorBasedoc_creator ()
 Get the object that creates documents and their main window.
 
unsigned int modified_count () const
 Return number of documents modified.
 
tbx::Commandnew_document_command ()
 Return a command that can be executed to create a new document with its window.
 
tbx::Commandquit_command ()
 Return a command that can be executed to quit the application showing a Quit dialogue if necessary.
 
tbx::Loaderfile_loader ()
 Return a loader to load a document into a new window.
 
int file_type () const
 Get the document file type.
 
bool load_files (int num_files, char *file_names[])
 Load multiple files into documents and show windows for them. More...
 
bool load_file (const std::string &file_name, int estimated_size=-1, bool from_filer=true)
 Load a file into a document and show it in a window. More...
 
virtual void pre_quit (tbx::PreQuitEvent &event)
 Called when the prequit message is received by the application. More...
 
- Public Member Functions inherited from tbx::Listener
virtual ~Listener ()
 Destroy the listener object.
 

Static Public Member Functions

static DocManagerinstance ()
 Get single instance of the document manager.
 

Friends

class Document
 

Additional Inherited Members

- Protected Member Functions inherited from tbx::Listener
 Listener ()
 Construct the Listener object.
 

Detailed Description

Class to manage all the documents.

It keeps track of the documents created and process the application pre-quit message to prompt the user if an attempt to quit the application is made when there are unsaved documents.

It also provides commands to implement: Quit from the menu Creating a new document A loader to load a file to a new document, and traps the data open WIMP message to open a document.

The document manager requires a Quit resource called "Quit" that it will use if multiple documents are open when the application is quit.

If the message in the Quit resource contains "%0" this will be replaced by the number of unsaved documents.

It uses the following message tokens if defined in the Messages file; TbxNewDocFailed - new document creation failed TbxLoadDocFailed - Loading of a document failed. In both cases the %0 parameter is replace by the exception message.

Constructor & Destructor Documentation

tbx::doc::DocManager::DocManager ( DocCreatorBase doc_creator)

Construct the document manager for the application.

Parameters
doc_creator- class to help in creating documents and their windows

Member Function Documentation

bool tbx::doc::DocManager::load_file ( const std::string &  file_name,
int  estimated_size = -1,
bool  from_filer = true 
)

Load a file into a document and show it in a window.

Display's an error if the file can not be loaded

Parameters
file_namename of file to load
estimated_size- estimated size of file if given
from_filertrue if document was loaded from the filer (safe storage)
Returns
true if loaded successfully
bool tbx::doc::DocManager::load_files ( int  num_files,
char *  file_names[] 
)

Load multiple files into documents and show windows for them.

Display's an error for the first file it can not load and stops loading following files

Parameters
num_filesnumber of files in file_names array.
file_namesnames of files to load
Returns
true if loaded successfully
void tbx::doc::DocManager::pre_quit ( tbx::PreQuitEvent event)
virtual

Called when the prequit message is received by the application.

Check if we have any modified packages and if so cancel the quit and show the quit dialog box.

Implements tbx::PreQuitListener.


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