- DECLARE_ABSTRACT_CLASS(wxDocument)
- public:
- wxDocument(wxDocument *parent = (wxDocument *) NULL);
- ~wxDocument(void);
-
- void SetFilename(const wxString& filename, bool notifyViews = FALSE);
- inline wxString GetFilename(void) const { return m_documentFile; }
- inline void SetTitle(const wxString& title) { m_documentTitle = title; };
- inline wxString GetTitle(void) const { return m_documentTitle; }
- inline void SetDocumentName(const wxString& name) { m_documentTypeName = name; };
- inline wxString GetDocumentName(void) const { return m_documentTypeName; }
- // Has the document been saved yet?
- inline bool GetDocumentSaved(void) { return m_savedYet; }
- inline void SetDocumentSaved(bool saved = TRUE) { m_savedYet = saved; }
-
- virtual bool Close(void);
- virtual bool Save(void);
- virtual bool SaveAs(void);
- virtual bool Revert(void);
-
- virtual ostream& SaveObject(ostream& stream);
- virtual istream& LoadObject(istream& stream);
-
- // Called by wxWindows
- virtual bool OnSaveDocument(const wxString& filename);
- virtual bool OnOpenDocument(const wxString& filename);
- virtual bool OnNewDocument(void);
- virtual bool OnCloseDocument(void);
-
- // Prompts for saving if about to close a modified document.
- // Returns TRUE if ok to close the document (may have saved in the
- // meantime, or set modified to FALSE)
- virtual bool OnSaveModified(void);
-
- // Called by framework if created automatically by the
- // default document manager: gives document a chance to
- // initialise and (usually) create a view
- virtual bool OnCreate(const wxString& path, long flags);
-
- // By default, creates a base wxCommandProcessor.
- virtual wxCommandProcessor *OnCreateCommandProcessor(void);
- virtual inline wxCommandProcessor *GetCommandProcessor(void) const { return m_commandProcessor; }
- virtual inline void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; }
-
- // Called after a view is added or removed.
- // The default implementation deletes the document if this
- // is there are no more views.
- virtual void OnChangedViewList(void);
-
- virtual bool DeleteContents(void);
-
- virtual bool Draw(wxDC&);
- virtual inline bool IsModified(void) const { return m_documentModified; }
- virtual inline void Modify(bool mod) { m_documentModified = mod; }
-
- virtual bool AddView(wxView *view);
- virtual bool RemoveView(wxView *view);
- inline wxList& GetViews(void) const { return (wxList&) m_documentViews; }
- wxView *GetFirstView(void) const;
-
- virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL);
-
- // Remove all views (because we're closing the document)
- virtual bool DeleteAllViews(void);
-
- // Other stuff
- virtual wxDocManager *GetDocumentManager(void) const;
- virtual inline wxDocTemplate *GetDocumentTemplate(void) const { return m_documentTemplate; }
- virtual inline void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; }
-
- // Get title, or filename if no title, else [unnamed]
- virtual bool GetPrintableName(wxString& buf) const;
-
- // Returns a window that can be used as a parent for document-related
- // dialogs. Override if necessary.
- virtual wxWindow *GetDocumentWindow(void) const;
- protected:
- wxList m_documentViews;
- wxString m_documentFile;
- wxString m_documentTitle;
- wxString m_documentTypeName;
- wxDocTemplate* m_documentTemplate;
- bool m_documentModified;
- wxDocument* m_documentParent;
- wxCommandProcessor* m_commandProcessor;
- bool m_savedYet;
+ DECLARE_ABSTRACT_CLASS(wxDocument)
+
+public:
+ wxDocument(wxDocument *parent = (wxDocument *) NULL);
+ ~wxDocument();
+
+ // accessors
+ void SetFilename(const wxString& filename, bool notifyViews = FALSE);
+ wxString GetFilename() const { return m_documentFile; }
+
+ void SetTitle(const wxString& title) { m_documentTitle = title; };
+ wxString GetTitle() const { return m_documentTitle; }
+
+ void SetDocumentName(const wxString& name) { m_documentTypeName = name; };
+ wxString GetDocumentName() const { return m_documentTypeName; }
+
+ bool GetDocumentSaved() const { return m_savedYet; }
+ void SetDocumentSaved(bool saved = TRUE) { m_savedYet = saved; }
+
+ virtual bool Close();
+ virtual bool Save();
+ virtual bool SaveAs();
+ virtual bool Revert();
+
+#if wxUSE_STD_IOSTREAM
+ virtual ostream& SaveObject(ostream& stream);
+ virtual istream& LoadObject(istream& stream);
+#else
+ virtual bool SaveObject(wxOutputStream& stream);
+ virtual bool LoadObject(wxInputStream& stream);
+#endif
+
+ // Called by wxWindows
+ virtual bool OnSaveDocument(const wxString& filename);
+ virtual bool OnOpenDocument(const wxString& filename);
+ virtual bool OnNewDocument();
+ virtual bool OnCloseDocument();
+
+ // Prompts for saving if about to close a modified document. Returns TRUE
+ // if ok to close the document (may have saved in the meantime, or set
+ // modified to FALSE)
+ virtual bool OnSaveModified();
+
+ // Called by framework if created automatically by the default document
+ // manager: gives document a chance to initialise and (usually) create a
+ // view
+ virtual bool OnCreate(const wxString& path, long flags);
+
+ // By default, creates a base wxCommandProcessor.
+ virtual wxCommandProcessor *OnCreateCommandProcessor();
+ virtual wxCommandProcessor *GetCommandProcessor() const { return m_commandProcessor; }
+ virtual void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; }
+
+ // Called after a view is added or removed. The default implementation
+ // deletes the document if this is there are no more views.
+ virtual void OnChangedViewList();
+
+ virtual bool DeleteContents();
+
+ virtual bool Draw(wxDC&);
+ virtual bool IsModified() const { return m_documentModified; }
+ virtual void Modify(bool mod) { m_documentModified = mod; }
+
+ virtual bool AddView(wxView *view);
+ virtual bool RemoveView(wxView *view);
+ wxList& GetViews() const { return (wxList&) m_documentViews; }
+ wxView *GetFirstView() const;
+
+ virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL);
+
+ // Remove all views (because we're closing the document)
+ virtual bool DeleteAllViews();
+
+ // Other stuff
+ virtual wxDocManager *GetDocumentManager() const;
+ virtual wxDocTemplate *GetDocumentTemplate() const { return m_documentTemplate; }
+ virtual void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; }
+
+ // Get title, or filename if no title, else [unnamed]
+ virtual bool GetPrintableName(wxString& buf) const;
+
+ // Returns a window that can be used as a parent for document-related
+ // dialogs. Override if necessary.
+ virtual wxWindow *GetDocumentWindow() const;
+
+protected:
+ wxList m_documentViews;
+ wxString m_documentFile;
+ wxString m_documentTitle;
+ wxString m_documentTypeName;
+ wxDocTemplate* m_documentTemplate;
+ bool m_documentModified;
+ wxDocument* m_documentParent;
+ wxCommandProcessor* m_commandProcessor;
+ bool m_savedYet;