31 #ifndef TBX_DOCUMENT_H_
32 #define TBX_DOCUMENT_H_
34 #include "../safelist.h"
35 #include "../listener.h"
43 class DocModifiedChangedListener;
55 std::string _file_name;
58 static unsigned int _untitled;
77 const std::string &
file_name()
const {
return _file_name;}
102 virtual bool save(std::ostream &os) = 0;
124 virtual bool load(std::string
file_name,
int estimated_size = -1);
131 virtual bool load(std::istream &is,
int estimated_size) = 0;
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
virtual bool save(std::string file_name)
Called to save document to the given file.
Definition: document.cc:120
void add_modified_changed_listener(DocModifiedChangedListener *listener)
Add a listener to detect when a document goes to and from its modified state.
Definition: document.cc:80
virtual bool load(std::string file_name, int estimated_size=-1)
Load document from given file name.
Definition: document.cc:172
Base class for a document.
Definition: document.h:53
virtual bool has_selection() const
Check if the document has a selection.
Definition: document.h:95
virtual int file_type() const =0
Return the file type for this document.
virtual bool save_selection(std::ostream &os)
Save selection to the given output stream Default does nothing.
Definition: document.h:115
virtual void save_selection_completed(std::string file_name)
Called when selection save has finished.
Definition: document.h:122
virtual ~Document()
Default destructor.
Definition: document.cc:60
Simple one way linked list of pointers that provides a single iterator that can be used safely if ite...
Definition: safelist.h:45
virtual int document_size() const =0
Return the size of the document.
bool modified() const
Return true if document has been modifed since the last save.
Definition: document.h:72
virtual bool save_selection(std::string file_name)
Save selection.
Definition: document.cc:208
virtual void save_completed(std::string file_name, bool safe)
This is called when a save is successfully completed.
Definition: document.cc:136
Base class for all toolbox event listeners.
Definition: listener.h:34
const std::string & file_name() const
Return the name of the document file.
Definition: document.h:77
virtual void load_completed(std::string file_name, bool from_filer)
This is called after a document has successfully been loaded.
Definition: document.cc:194
virtual void new_document()
Called after a new document has been created and before it is attached to a window.
Definition: document.cc:71
virtual void document_modified_changed(Document *doc)=0
This routine is called when the documents modified flag changes.
virtual bool save(std::ostream &os)=0
Save document to the given stream.
void remove_modified_changed_listener(DocModifiedChangedListener *listener)
Remove a listener to detect when a document goes to and from its modified state.
Definition: document.cc:89
Document()
Default constructor.
Definition: document.cc:50
Listener for document modified state changed.
Definition: document.h:144
virtual bool load(std::istream &is, int estimated_size)=0
Load document from the given input stream.