- DECLARE_DYNAMIC_CLASS(wxDocManager)
- public:
- wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = TRUE);
- ~wxDocManager(void);
-
- virtual bool Initialize(void);
-
- // Handlers for common user commands
-// virtual void OldOnMenuCommand(int command);
-
- void OnFileClose(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 OnPrintSetup(wxCommandEvent& event);
- void OnPreview(wxCommandEvent& event);
- void OnUndo(wxCommandEvent& event);
- void OnRedo(wxCommandEvent& event);
-
- // Extend event processing to search the view's event table
- virtual bool ProcessEvent(wxEvent& event);
-
- 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);
- virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
- int noTemplates);
- virtual wxDocTemplate *FindTemplateForPath(const wxString& path);
-
- void AssociateTemplate(wxDocTemplate *temp);
- void DisassociateTemplate(wxDocTemplate *temp);
-
- wxDocument *GetCurrentDocument(void) const;
-
- inline void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
- inline int GetMaxDocsOpen(void) const { return m_maxDocsOpen; }
-
- // Add and remove a document from the manager's list
- void AddDocument(wxDocument *doc);
- void RemoveDocument(wxDocument *doc);
-
- // 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, bool deleting = FALSE);
- virtual wxView *GetCurrentView(void) const;
-
- virtual inline wxList& GetDocuments(void) const { return (wxList&) m_docs; }
-
- // Make a default document name
- virtual bool MakeDefaultName(wxString& buf);
-
- virtual wxFileHistory *OnCreateFileHistory(void);
- virtual inline wxFileHistory *GetFileHistory(void) const { return m_fileHistory; }
-
- // File history management
- virtual void AddFileToHistory(const wxString& file);
- virtual int GetNoHistoryFiles(void) const;
- virtual wxString GetHistoryFile(int i) const;
- virtual void FileHistoryUseMenu(wxMenu *menu);
- virtual void FileHistoryRemoveMenu(wxMenu *menu);
- virtual void FileHistoryLoad(wxConfigBase& config);
- virtual void FileHistorySave(wxConfigBase& config);
- virtual void FileHistoryAddFilesToMenu();
- virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
- protected:
- long m_flags;
- int m_defaultDocumentNameCounter;
- int m_maxDocsOpen;
- wxList m_docs;
- wxList m_templates;
- wxView* m_currentView;
- wxFileHistory* m_fileHistory;
-
-DECLARE_EVENT_TABLE()
+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
+
+ 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; }
+
+#if WXWIN_COMPATIBILITY_2_8
+ // deprecated, override GetDefaultName() instead
+ wxDEPRECATED_BUT_USED_INTERNALLY(
+ virtual bool MakeDefaultName(wxString& buf)
+ );
+#endif
+
+#if WXWIN_COMPATIBILITY_2_6
+ // deprecated, use GetHistoryFilesCount() instead
+ wxDEPRECATED( size_t GetNoHistoryFiles() const );
+#endif // WXWIN_COMPATIBILITY_2_6
+
+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)