+public:
+ wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true);
+ ~wxDocManager();
+
+ virtual bool Initialize();
+
+ // Handlers for common user commands
+ void OnFileClose(wxCommandEvent& event);
+ void OnFileCloseAll(wxCommandEvent& event);
+ void OnFileNew(wxCommandEvent& event);
+ void OnFileOpen(wxCommandEvent& event);
+ void OnFileRevert(wxCommandEvent& event);
+ void OnFileSave(wxCommandEvent& event);
+ void OnFileSaveAs(wxCommandEvent& event);
+ void OnPrint(wxCommandEvent& event);
+ void OnPreview(wxCommandEvent& event);
+ void OnUndo(wxCommandEvent& event);
+ void OnRedo(wxCommandEvent& event);
+
+ // Handlers for UI update commands
+ void OnUpdateFileOpen(wxUpdateUIEvent& event);
+ void OnUpdateFileClose(wxUpdateUIEvent& event);
+ void OnUpdateFileRevert(wxUpdateUIEvent& event);
+ void OnUpdateFileNew(wxUpdateUIEvent& event);
+ void OnUpdateFileSave(wxUpdateUIEvent& event);
+ void OnUpdateFileSaveAs(wxUpdateUIEvent& event);
+ void OnUpdateUndo(wxUpdateUIEvent& event);
+ void OnUpdateRedo(wxUpdateUIEvent& event);
+
+ void OnUpdatePrint(wxUpdateUIEvent& event);
+ void OnUpdatePreview(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);
+ virtual wxView *CreateView(wxDocument *doc, long flags = 0);
+ virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
+ virtual bool FlushDoc(wxDocument *doc);
+ virtual wxDocTemplate *MatchTemplate(const wxString& path);
+ virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates,
+ int noTemplates, wxString& path, long flags, bool save = false);
+ virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates,
+ int noTemplates, bool sort = false);
+ virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
+ int noTemplates, bool sort = false);
+ virtual wxDocTemplate *FindTemplateForPath(const wxString& path);
+
+ void AssociateTemplate(wxDocTemplate *temp);
+ void DisassociateTemplate(wxDocTemplate *temp);
+
+ wxDocument *GetCurrentDocument() const;
+
+ void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
+ int GetMaxDocsOpen() const { return m_maxDocsOpen; }
+
+ // Add and remove a document from the manager's list
+ void AddDocument(wxDocument *doc);
+ void RemoveDocument(wxDocument *doc);
+
+ // closes all currently open documents
+ bool CloseDocuments(bool force = true);
+
+ // closes the specified document
+ bool CloseDocument(wxDocument* doc, bool force = false);
+
+ // Clear remaining documents and templates
+ bool Clear(bool force = true);
+
+ // Views or windows should inform the document manager
+ // when a view is going in or out of focus
+ virtual void ActivateView(wxView *view, bool activate = true);
+ virtual wxView *GetCurrentView() const;
+
+ wxList& GetDocuments() { return m_docs; }
+ wxList& GetTemplates() { return m_templates; }
+
+ // Make a default document name
+ virtual bool MakeDefaultName(wxString& buf);
+
+ // Make a frame title (override this to do something different)
+ virtual wxString MakeFrameTitle(wxDocument* doc);
+
+ virtual wxFileHistory *OnCreateFileHistory();
+ virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
+
+ // File history management
+ virtual void AddFileToHistory(const wxString& file);
+ virtual void RemoveFileFromHistory(size_t i);
+ virtual size_t GetHistoryFilesCount() const;
+ virtual wxString GetHistoryFile(size_t i) const;
+ virtual void FileHistoryUseMenu(wxMenu *menu);
+ virtual void FileHistoryRemoveMenu(wxMenu *menu);
+#if wxUSE_CONFIG
+ virtual void FileHistoryLoad(wxConfigBase& config);
+ virtual void FileHistorySave(wxConfigBase& config);
+#endif // wxUSE_CONFIG
+
+ virtual void FileHistoryAddFilesToMenu();
+ virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
+
+ wxString GetLastDirectory() const { return m_lastDirectory; }
+ void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
+
+ // Get the current document manager
+ static wxDocManager* GetDocumentManager() { return sm_docManager; }
+
+ // deprecated, use GetHistoryFilesCount() instead
+ wxDEPRECATED( size_t GetNoHistoryFiles() const );
+
+protected:
+ long m_flags;
+ int m_defaultDocumentNameCounter;
+ int m_maxDocsOpen;
+ wxList m_docs;
+ wxList m_templates;
+ wxView* m_currentView;
+ wxFileHistory* m_fileHistory;
+ wxString m_lastDirectory;
+ static wxDocManager* sm_docManager;
+
+ DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS(wxDocManager)
+ DECLARE_NO_COPY_CLASS(wxDocManager)