void SetDocumentName(const wxString& name) { m_documentTypeName = name; }
wxString GetDocumentName() const { return m_documentTypeName; }
+ // access the flag indicating whether this document had been already saved,
+ // SetDocumentSaved() is only used internally, don't call it
bool GetDocumentSaved() const { return m_savedYet; }
void SetDocumentSaved(bool saved = true) { m_savedYet = saved; }
+ // return true if the document hasn't been modified since the last time it
+ // was saved (implying that it returns false if it was never saved, even if
+ // the document is not modified)
+ bool AlreadySaved() const { return !IsModified() && GetDocumentSaved(); }
+
virtual bool Close();
virtual bool Save();
virtual bool SaveAs();
// Override to do cleanup/veto close
virtual bool OnClose(bool deleteWindow);
- // Extend event processing to search the document's event table
- virtual bool ProcessEvent(wxEvent& event);
-
// A view's window can call this to notify the view it is (in)active.
// The function then notifies the document manager.
virtual void Activate(bool activate);
#endif
protected:
+ // hook the document into event handlers chain here
+ virtual bool TryValidator(wxEvent& event);
+
wxDocument* m_viewDocument;
wxString m_viewTypeName;
wxWindow* m_viewFrame;
void OnUpdateUndo(wxUpdateUIEvent& event);
void OnUpdateRedo(wxUpdateUIEvent& event);
- // Extend event processing to search the view's event table
- virtual bool ProcessEvent(wxEvent& event);
-
// called when file format detection didn't work, can be overridden to do
// something in this case
virtual void OnOpenFileFailure() { }
virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
+
+ // wrapper around CreateDocument() with a more clear name
+ wxDocument *CreateNewDocument()
+ { return CreateDocument(wxString(), wxDOC_NEW); }
+
virtual wxView *CreateView(wxDocument *doc, long flags = 0);
virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
virtual bool FlushDoc(wxDocument *doc);
#endif // WXWIN_COMPATIBILITY_2_6
protected:
+ // hook the currently active view into event handlers chain here
+ virtual bool TryValidator(wxEvent& event);
+
int m_defaultDocumentNameCounter;
int m_maxDocsOpen;
wxList m_docs;
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxT("frame"));
+ const wxString& name = wxFrameNameStr);
virtual ~wxDocChildFrame(){}
- // Extend event processing to search the view's event table
- virtual bool ProcessEvent(wxEvent& event);
-
void OnActivate(wxActivateEvent& event);
void OnCloseWindow(wxCloseEvent& event);
bool Destroy() { m_childView = NULL; return wxFrame::Destroy(); }
protected:
+ // hook the child view into event handlers chain here
+ virtual bool TryValidator(wxEvent& event);
+
wxDocument* m_childDocument;
wxView* m_childView;
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
- // Extend event processing to search the document manager's event table
- virtual bool ProcessEvent(wxEvent& event);
-
wxDocManager *GetDocumentManager() const { return m_docManager; }
void OnExit(wxCommandEvent& event);
void OnCloseWindow(wxCloseEvent& event);
protected:
+ // hook the document manager into event handling chain here
+ virtual bool TryValidator(wxEvent& event);
+
wxDocManager *m_docManager;
private: