tbx
0.7.3
|
Base class for a document. More...
#include <document.h>
Public Member Functions | |
Document () | |
Default constructor. More... | |
virtual | ~Document () |
Default destructor. More... | |
virtual void | new_document () |
Called after a new document has been created and before it is attached to a window. More... | |
void | add_modified_changed_listener (DocModifiedChangedListener *listener) |
Add a listener to detect when a document goes to and from its modified state. | |
void | remove_modified_changed_listener (DocModifiedChangedListener *listener) |
Remove a listener to detect when a document goes to and from its modified state. | |
bool | modified () const |
Return true if document has been modifed since the last save. | |
const std::string & | file_name () const |
Return the name of the document file. | |
virtual int | file_type () const =0 |
Return the file type for this document. | |
virtual int | document_size () const =0 |
Return the size of the document. More... | |
virtual bool | has_selection () const |
Check if the document has a selection. | |
virtual bool | save (std::string file_name) |
Called to save document to the given file. More... | |
virtual bool | save (std::ostream &os)=0 |
Save document to the given stream. | |
virtual void | save_completed (std::string file_name, bool safe) |
This is called when a save is successfully completed. More... | |
virtual bool | save_selection (std::string file_name) |
Save selection. More... | |
virtual bool | save_selection (std::ostream &os) |
Save selection to the given output stream Default does nothing. | |
virtual void | save_selection_completed (std::string file_name) |
Called when selection save has finished. More... | |
virtual bool | load (std::string file_name, int estimated_size=-1) |
Load document from given file name. More... | |
virtual bool | load (std::istream &is, int estimated_size)=0 |
Load document from the given input stream. More... | |
virtual void | load_completed (std::string file_name, bool from_filer) |
This is called after a document has successfully been loaded. More... | |
Protected Member Functions | |
void | modified (bool changed) |
Set the document modified flag. More... | |
Base class for a document.
Automatically adds and removes documents from the document manager and provides the interfaces required for the Document manager and other doc classes.
tbx::doc::Document::Document | ( | ) |
Default constructor.
Adds document to the document manager
|
virtual |
Default destructor.
Removes document from the document manager
|
pure virtual |
Return the size of the document.
If the size can not be accurately calculated an estimate should be returned.
|
virtual |
Load document from given file name.
This version opens a binary input stream on the file name and passes the loading onto load(std::istream*, int) If estimated_size == -1 it also calculates the length of the file before passing it on.
file_name | name of file to load |
estimated_size | - estimated size of file or -1 if not specified |
|
pure virtual |
Load document from the given input stream.
is | input stream to load from |
estimated_size | estimated size of data or -1 if estimate not given |
|
virtual |
This is called after a document has successfully been loaded.
It is called before the window is shown.
If you override this method you should call this base version to update the file name.
|
protected |
Set the document modified flag.
If it has changed from it's old state the DocModifiedChangedListeners are fired.
|
virtual |
Called after a new document has been created and before it is attached to a window.
The default sets the file_name to "Untitled" with a count
|
virtual |
Called to save document to the given file.
This version opens a binary output stream on the file and calls save(std::ostream&).
|
virtual |
This is called when a save is successfully completed.
The default sets the file type, updates the file name and sends a modified event so listeners can update their titles.
file_name | file name used for the save |
safe | true if save was to a "safe" location (e.g. the filer) |
|
virtual |
Save selection.
file_name | file name to save to |
This version opens a binary output stream and calls save_selection(std::ostream&)
file_name | file_name to save to |
|
inlinevirtual |
Called when selection save has finished.
Base does nothing