+// One object of this class may be created in an application, to manage all
+// the templates and documents.
+class WXDLLIMPEXP_CORE wxDocManager: public wxEvtHandler
+{
+public:
+ wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true);
+ virtual ~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; }
+
+ // Return the default name for a new document (by default returns strings
+ // in the form "unnamed <counter>" but can be overridden)
+ virtual wxString MakeNewDocumentName();
+
+ // 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