wxDocTemplate(wxDocManager* manager, const wxString& descr,
const wxString& filter, const wxString& dir,
const wxString& ext, const wxString& docTypeName,
- const wxString& viewTypeName,
- wxClassInfo* docClassInfo = NULL,
- wxClassInfo* viewClassInfo = NULL,
- long flags = wxDEFAULT_TEMPLATE_FLAGS);
+ const wxString& viewTypeName, wxClassInfo* docClassInfo = 0,
+ wxClassInfo* viewClassInfo = 0,
+ long flags = wxTEMPLATE_VISIBLE);
/**
Destructor.
*/
virtual wxView* CreateView(wxDocument* doc, long flags = 0);
+ /**
+ This function implements the default (very primitive) format detection
+ which checks if the extension is that of the template.
+
+ @param path
+ The path to be checked against the template.
+ */
+ virtual bool FileMatchesTemplate(const wxString& path);
+
/**
Returns the default file extension for the document data, as passed to
the document template constructor.
*/
wxString GetDirectory() const;
+ /**
+ Returns the run-time class information that allows document
+ instances to be constructed dynamically, as passed to the document
+ template constructor.
+ */
+ wxClassInfo* GetDocClassInfo() const;
+
/**
Returns a pointer to the document manager instance for which this
template was created.
*/
long GetFlags() const;
+ /**
+ Returns the run-time class information that allows view instances
+ to be constructed dynamically, as passed to the document template
+ constructor.
+ */
+ wxClassInfo* GetViewClassInfo() const;
+
/**
Returns the view type name, as passed to the document template
constructor.
*/
virtual wxDocument* CreateDocument(const wxString& path, long flags = 0);
+ /**
+ Creates an empty new document.
+
+ This is equivalent to calling CreateDocument() with @c wxDOC_NEW flags
+ and without the file name.
+ */
+ wxDocument *CreateNewDocument();
+
/**
Creates a new view for the given document. If more than one view is
allowed for the document (by virtue of multiple templates mentioning
the same document type), a choice of view is presented to the user.
*/
- wxView* CreateView(wxDocument* doc, long flags);
+ virtual wxView* CreateView(wxDocument* doc, long flags = 0);
/**
Removes the template from the list of templates.
/**
Returns a reference to the list of documents.
*/
- wxList GetDocuments();
+ wxList& GetDocuments();
/**
Returns a pointer to file history.
/**
Returns a reference to the list of associated templates.
*/
- wxList GetTemplates();
+ wxList& GetTemplates();
/**
Initializes data; currently just calls OnCreateFileHistory().
This function is used in CreateDocument().
*/
- wxDocTemplate* SelectDocumentPath(wxDocTemplate** templates,
- int noTemplates, wxString& path,
- long flags, bool save);
+ virtual wxDocTemplate* SelectDocumentPath(wxDocTemplate** templates,
+ int noTemplates, wxString& path,
+ long flags, bool save = false);
/**
Returns a document template by asking the user (if there is more than
will have to choose from is sorted or not when shown the choice box
dialog. Default is @false.
*/
- wxDocTemplate* SelectDocumentType(wxDocTemplate** templates,
- int noTemplates, bool sort = false);
+ virtual wxDocTemplate* SelectDocumentType(wxDocTemplate** templates,
+ int noTemplates,
+ bool sort = false);
/**
Returns a document template by asking the user (if there is more than
will have to choose from is sorted or not when shown the choice box
dialog. Default is @false.
*/
- wxDocTemplate* SelectViewType(wxDocTemplate** templates,
- int noTemplates, bool sort = false);
+ virtual wxDocTemplate* SelectViewType(wxDocTemplate** templates,
+ int noTemplates, bool sort = false);
/**
Sets the directory to be displayed to the user when opening a file.
/**
Called when the filename has changed. The default implementation
- constructs a suitable title and sets the title of the view frame (if
- any).
+ constructs a suitable title and sets the title of the view frame (if any).
*/
virtual void OnChangeFilename();
/**
Override this function to render the view on the given device context.
*/
- virtual void OnDraw(wxDC* dc);
+ virtual void OnDraw(wxDC* dc) = 0;
/**
Called when the view should be updated.
application-specific information for making updating more
efficient.
*/
- virtual void OnUpdate(wxView* sender, wxObject* hint);
+ virtual void OnUpdate(wxView* sender, wxObject* hint = 0);
/**
Associates the given document with the view. Normally called by the
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = "frame");
+ const wxString& name = wxFrameNameStr);
/**
Destructor.
override (but still call) this function in order to set the keyboard
focus for your subwindow.
*/
- void OnActivate(wxActivateEvent event);
+ void OnActivate(wxActivateEvent& event);
/**
Closes and deletes the current view and document.
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = "frame");
+ const wxString& name = wxFrameNameStr);
/**
Destructor.
/**
Used in two-step construction.
*/
- bool Create(wxDocManager* manager, wxFrame* parent,
- wxWindowID id, const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = "frame");
+ bool Create(wxDocManager* manager, wxFrame* parent, wxWindowID id,
+ const wxString& title, const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = 541072960,
+ const wxString& name = wxFrameNameStr);
/**
Returns the associated document manager object.
Constructor. Define your own default constructor to initialize
application-specific data.
*/
- wxDocument();
+ wxDocument(wxDocument* parent = 0);
/**
Destructor. Removes itself from the document manager.
*/
virtual bool AddView(wxView* view);
+ /**
+ Returns true if the document hasn't been modified since the last time
+ it had been saved.
+
+ Notice that this function returns @false if the document had been never
+ saved at all, so it may be also used to test whether it makes sense to
+ save the document: if it returns @true, there is nothing to save but if
+ @false is returned, it can be saved, even if it might be not modified
+ (this can be used to create an empty document file by the user).
+
+ @see IsModified(), GetDocumentSaved()
+
+ @since 2.9.0
+ */
+ bool AlreadySaved() const;
+
/**
Closes the document, by calling OnSaveModified() and then (if this
returned @true) OnCloseDocument(). This does not normally delete the
*/
wxString GetDocumentName() const;
+ /**
+ Return true if this document had been already saved.
+
+ @see IsModified()
+ */
+ bool GetDocumentSaved() const;
+
/**
Gets a pointer to the template that created the document.
*/
*/
virtual wxString GetUserReadableName() const;
+ //@{
/**
Returns the list whose elements are the views on the document.
@see GetFirstView()
*/
- wxList GetViews() const;
+ wxList& GetViews();
+ const wxList& GetViews() const;
+ //@}
/**
Returns @true if the document has been modified since the last save,
/**
Sets the filename for this document. Usually called by the framework.
+ Calls OnChangeFilename() which in turn calls wxView::OnChangeFilename() for
+ all views if @a notifyViews is @true,
+ */
+ void SetFilename(const wxString& filename, bool notifyViews = false);
+
+ /**
If @a notifyViews is @true, wxView::OnChangeFilename() is called for
all views.
+
+ @since 2.9.0
*/
- void SetFilename(const wxString& filename, bool notifyViews = false);
+ virtual void OnChangeFilename(bool notifyViews);
/**
Sets the title for this document. The document title is used for an
called, as this is not done automatically.
*/
virtual void UseMenu(wxMenu* menu);
-
- /**
- A character array of strings corresponding to the most recently opened
- files.
- */
- char** m_fileHistory;
-
- /**
- The number of files stored in the history array.
- */
- size_t m_fileHistoryN;
-
- /**
- The maximum number of files to be stored and displayed on the menu.
- */
- size_t m_fileMaxFiles;
-
- /**
- The file menu used to display the file history list (if enabled).
- */
- wxMenu* m_fileMenu;
};
// Global functions/macros
// ============================================================================
-/** @ingroup group_funcmacro_file */
+/** @addtogroup group_funcmacro_file */
//@{
/**