X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fadc2df6823d988f7a264b94e69a7e1bbcac1337..57cc93eb59cc89992eb136015979effbaa0dd43e:/interface/wx/docview.h?ds=sidebyside diff --git a/interface/wx/docview.h b/interface/wx/docview.h index 76e84f8341..f27dc3ef4e 100644 --- a/interface/wx/docview.h +++ b/interface/wx/docview.h @@ -85,12 +85,27 @@ public: virtual wxDocument* CreateDocument(const wxString& path, long flags = 0); /** - Creates a new instance of the associated view class. If you have not - supplied a wxClassInfo parameter to the template constructor, you will - need to override this function to return an appropriate view instance. + Creates a new instance of the associated view class. + + If you have not supplied a wxClassInfo parameter to the template + constructor, you will need to override this function to return an + appropriate view instance. + + If the new view initialization fails, it must call + wxDocument::RemoveView() for consistency with the default behaviour of + this function. */ 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. @@ -109,6 +124,13 @@ public: */ 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. @@ -132,6 +154,13 @@ public: */ 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. @@ -139,10 +168,25 @@ public: virtual wxString GetViewName() const; /** - Initialises the document, calling wxDocument::OnCreate(). This is - called from CreateDocument(). + Initialises the document, calling wxDocument::OnCreate(). + + This is called from CreateDocument(). + + If you override this method, notice that you must @em delete the @a doc + if its initialization fails for consistency with the default behaviour. + + @param doc + The document to initialize. + @param path + The associated file path. + @param flags + Flags passed to CreateDocument(). + @return + @true if the initialization was successful or @false if it failed + in which case @a doc should be deleted by this function. */ - virtual bool InitDocument(wxDocument* doc, const wxString& path, + virtual bool InitDocument(wxDocument* doc, + const wxString& path, long flags = 0); /** @@ -717,8 +761,7 @@ public: /** 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(); @@ -851,7 +894,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = "frame"); + const wxString& name = wxFrameNameStr); /** Destructor. @@ -933,7 +976,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = "frame"); + const wxString& name = wxFrameNameStr); /** Destructor. @@ -1008,6 +1051,22 @@ public: */ 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 @@ -1043,6 +1102,13 @@ public: */ 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. */ @@ -1083,12 +1149,15 @@ public: */ 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, @@ -1144,9 +1213,22 @@ public: /** Called just after the document object is created to give it a chance to - initialize itself. The default implementation uses the template - associated with the document to create an initial view. If this - function returns @false, the document is deleted. + initialize itself. + + The default implementation uses the template associated with the + document to create an initial view. + + For compatibility reasons, this method may either delete the document + itself if its initialization fails or not do it in which case it is + deleted by caller. It is recommended to delete the document explicitly + in this function if it can't be initialized. + + @param path + The associated file path. + @param flags + Flags passed to CreateDocument(). + @return + @true if the initialization was successful or @false if it failed. */ virtual bool OnCreate(const wxString& path, long flags); @@ -1247,10 +1329,18 @@ public: /** 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 @@ -1446,27 +1536,6 @@ public: 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; }; @@ -1475,7 +1544,7 @@ public: // Global functions/macros // ============================================================================ -/** @ingroup group_funcmacro_file */ +/** @addtogroup group_funcmacro_file */ //@{ /**