tbx
0.7.3
|
Class to manage all the documents. More...
#include <docmanager.h>
Public Member Functions | |
DocManager (DocCreatorBase *doc_creator) | |
Construct the document manager for the application. More... | |
DocCreatorBase * | doc_creator () |
Get the object that creates documents and their main window. | |
unsigned int | modified_count () const |
Return number of documents modified. | |
tbx::Command * | new_document_command () |
Return a command that can be executed to create a new document with its window. | |
tbx::Command * | quit_command () |
Return a command that can be executed to quit the application showing a Quit dialogue if necessary. | |
tbx::Loader * | file_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... | |
![]() | |
virtual | ~Listener () |
Destroy the listener object. | |
Static Public Member Functions | |
static DocManager * | instance () |
Get single instance of the document manager. | |
Friends | |
class | Document |
Additional Inherited Members | |
![]() | |
Listener () | |
Construct the Listener object. | |
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.
tbx::doc::DocManager::DocManager | ( | DocCreatorBase * | doc_creator | ) |
Construct the document manager for the application.
doc_creator | - class to help in creating documents and their windows |
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
file_name | name of file to load |
estimated_size | - estimated size of file if given |
from_filer | true if document was loaded from the filer (safe storage) |
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
num_files | number of files in file_names array. |
file_names | names of files to load |
|
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.