X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d29d303b1c37d64c0e6b5638d793a2e425644419..dd3c394ae4e6f6a0041b69e036d4fdf0a085fe39:/include/wx/docview.h diff --git a/include/wx/docview.h b/include/wx/docview.h index a60bfa4536..c7ea657142 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -6,11 +6,11 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __DOCH__ -#define __DOCH__ +#ifndef _WX_DOCH__ +#define _WX_DOCH__ #ifdef __GNUG__ #pragma interface "docview.h" @@ -21,7 +21,7 @@ #include "wx/cmndata.h" #include "wx/string.h" -#if USE_PRINTING_ARCHITECTURE +#if wxUSE_PRINTING_ARCHITECTURE #include "wx/print.h" #endif @@ -34,9 +34,20 @@ class WXDLLEXPORT wxPrintInfo; class WXDLLEXPORT wxCommand; class WXDLLEXPORT wxCommandProcessor; class WXDLLEXPORT wxFileHistory; +#if wxUSE_CONFIG +class WXDLLEXPORT wxConfigBase; +#endif -class WXDLLIMPORT ostream; -class WXDLLIMPORT istream; +#if wxUSE_IOSTREAMH +// N.B. BC++ doesn't have istream.h, ostream.h +# include +#else +# include +# include +# ifdef __VISUALC__ + using namespace std; +# endif +#endif // Document manager flags #define wxDOC_SDI 1 @@ -56,7 +67,7 @@ class WXDLLEXPORT wxDocument : public wxEvtHandler { DECLARE_ABSTRACT_CLASS(wxDocument) public: - wxDocument(wxDocument *parent = NULL); + wxDocument(wxDocument *parent = (wxDocument *) NULL); ~wxDocument(void); void SetFilename(const wxString& filename, bool notifyViews = FALSE); @@ -114,7 +125,7 @@ class WXDLLEXPORT wxDocument : public wxEvtHandler inline wxList& GetViews(void) const { return (wxList&) m_documentViews; } wxView *GetFirstView(void) const; - virtual void UpdateAllViews(wxView *sender = NULL, wxObject *hint = NULL); + virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL); // Remove all views (because we're closing the document) virtual bool DeleteAllViews(void); @@ -146,7 +157,8 @@ class WXDLLEXPORT wxView: public wxEvtHandler { DECLARE_ABSTRACT_CLASS(wxView) public: - wxView(wxDocument *doc = NULL); +// wxView(wxDocument *doc = (wxDocument *) NULL); + wxView(); ~wxView(void); inline wxDocument *GetDocument(void) const { return m_viewDocument; } @@ -161,7 +173,7 @@ class WXDLLEXPORT wxView: public wxEvtHandler virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView); virtual void OnDraw(wxDC *dc) = 0; virtual void OnPrint(wxDC *dc, wxObject *info); - virtual void OnUpdate(wxView *sender, wxObject *hint = NULL); + virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL); virtual void OnChangeFilename(void); // Called by framework if created automatically by the @@ -176,8 +188,11 @@ class WXDLLEXPORT wxView: public wxEvtHandler // Override to do cleanup/veto close virtual bool OnClose(bool deleteWindow); + +#if WXWIN_COMPATIBILITY // Defeat compiler warning - inline bool OnClose(void) { return wxEvtHandler::OnClose(); } + bool OnClose(void) { return wxEvtHandler::OnClose(); } +#endif // Extend event processing to search the document's event table virtual bool ProcessEvent(wxEvent& event); @@ -186,9 +201,10 @@ class WXDLLEXPORT wxView: public wxEvtHandler // The function then notifies the document manager. virtual void Activate(bool activate); - inline wxDocManager *GetDocumentManager(void) const { return m_viewDocument->GetDocumentManager(); } + wxDocManager *GetDocumentManager(void) const + { return m_viewDocument->GetDocumentManager(); } -#if USE_PRINTING_ARCHITECTURE +#if wxUSE_PRINTING_ARCHITECTURE virtual wxPrintout *OnCreatePrintout(void); #endif @@ -212,7 +228,7 @@ class WXDLLEXPORT wxDocTemplate: public wxObject // template/document type wxDocTemplate(wxDocManager *manager, const wxString& descr, const wxString& filter, const wxString& dir, const wxString& ext, const wxString& docTypeName, const wxString& viewTypeName, - wxClassInfo *docClassInfo = NULL, wxClassInfo *viewClassInfo = NULL, + wxClassInfo *docClassInfo = (wxClassInfo *) NULL, wxClassInfo *viewClassInfo = (wxClassInfo *)NULL, long flags = wxDEFAULT_TEMPLATE_FLAGS); ~wxDocTemplate(void); @@ -283,6 +299,9 @@ class WXDLLEXPORT wxDocManager: public wxEvtHandler 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); @@ -314,7 +333,7 @@ class WXDLLEXPORT wxDocManager: public wxEvtHandler // 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 inline wxView *GetCurrentView(void) const { return m_currentView; } + virtual wxView *GetCurrentView(void) const; virtual inline wxList& GetDocuments(void) const { return (wxList&) m_docs; } @@ -329,8 +348,13 @@ class WXDLLEXPORT wxDocManager: public wxEvtHandler virtual int GetNoHistoryFiles(void) const; virtual wxString GetHistoryFile(int i) const; virtual void FileHistoryUseMenu(wxMenu *menu); - virtual void FileHistoryLoad(const wxString& resourceFile, const wxString& section); - virtual void FileHistorySave(const wxString& resourceFile, const wxString& section); + virtual void FileHistoryRemoveMenu(wxMenu *menu); +#if wxUSE_CONFIG + virtual void FileHistoryLoad(wxConfigBase& config); + virtual void FileHistorySave(wxConfigBase& config); +#endif + virtual void FileHistoryAddFilesToMenu(); + virtual void FileHistoryAddFilesToMenu(wxMenu* menu); protected: long m_flags; int m_defaultDocumentNameCounter; @@ -352,17 +376,16 @@ class WXDLLEXPORT wxDocChildFrame: public wxFrame DECLARE_CLASS(wxDocChildFrame) public: - wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, const wxString& title, + wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); ~wxDocChildFrame(void); - bool OnClose(void); // Extend event processing to search the view's event table virtual bool ProcessEvent(wxEvent& event); -// void OldOnMenuCommand(int id); void OnActivate(wxActivateEvent& event); + void OnCloseWindow(wxCloseEvent& event); inline wxDocument *GetDocument(void) const { return m_childDocument; } inline wxView *GetView(void) const { return m_childView; } @@ -384,19 +407,18 @@ class WXDLLEXPORT wxDocParentFrame: public wxFrame { DECLARE_CLASS(wxDocParentFrame) public: - wxDocParentFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, + wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long type = wxDEFAULT_FRAME, const wxString& name = "frame"); + long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); - bool OnClose(void); // Extend event processing to search the document manager's event table virtual bool ProcessEvent(wxEvent& event); -// void OldOnMenuCommand(int id); wxDocManager *GetDocumentManager(void) const { return m_docManager; } void OnExit(wxCommandEvent& event); void OnMRUFile(wxCommandEvent& event); + void OnCloseWindow(wxCloseEvent& event); protected: wxDocManager *m_docManager; @@ -408,12 +430,12 @@ DECLARE_EVENT_TABLE() * Provide simple default printing facilities */ -#if USE_PRINTING_ARCHITECTURE +#if wxUSE_PRINTING_ARCHITECTURE class WXDLLEXPORT wxDocPrintout: public wxPrintout { DECLARE_DYNAMIC_CLASS(wxDocPrintout) public: - wxDocPrintout(wxView *view = NULL, const wxString& title = "Printout"); + wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = "Printout"); bool OnPrintPage(int page); bool HasPage(int page); bool OnBeginDocument(int startPage, int endPage); @@ -462,7 +484,8 @@ class WXDLLEXPORT wxCommandProcessor: public wxObject virtual bool Submit(wxCommand *command, bool storeIt = TRUE); virtual bool Undo(void); virtual bool Redo(void); - virtual bool CanUndo(void); + virtual bool CanUndo(void) const; + virtual bool CanRedo(void) const; // Call this to manage an edit menu. inline void SetEditMenu(wxMenu *menu) { m_commandEditMenu = menu; } @@ -481,6 +504,8 @@ class WXDLLEXPORT wxCommandProcessor: public wxObject wxMenu* m_commandEditMenu; }; +// File history management + class WXDLLEXPORT wxFileHistory: public wxObject { DECLARE_DYNAMIC_CLASS(wxFileHistory) @@ -488,21 +513,38 @@ class WXDLLEXPORT wxFileHistory: public wxObject wxFileHistory(int maxFiles = 9); ~wxFileHistory(void); - // File history management +// Operations virtual void AddFileToHistory(const wxString& file); - inline virtual int GetNoHistoryFiles(void) const { return m_fileHistoryN; } - virtual wxString GetHistoryFile(int i) const; virtual int GetMaxFiles(void) const { return m_fileMaxFiles; } - virtual void FileHistoryUseMenu(wxMenu *menu); - virtual void FileHistoryLoad(const wxString& resourceFile, const wxString& section); - virtual void FileHistorySave(const wxString& resourceFile, const wxString& section); + virtual void UseMenu(wxMenu *menu); + + // Remove menu from the list (MDI child may be closing) + virtual void RemoveMenu(wxMenu *menu); + +#if wxUSE_CONFIG + virtual void Load(wxConfigBase& config); + virtual void Save(wxConfigBase& config); +#endif + + virtual void AddFilesToMenu(); + virtual void AddFilesToMenu(wxMenu* menu); // Single menu + +// Accessors + virtual wxString GetHistoryFile(int i) const; + + // A synonym for GetNoHistoryFiles + virtual int GetCount() const { return m_fileHistoryN; } + inline int GetNoHistoryFiles(void) const { return m_fileHistoryN; } + + inline wxList& GetMenus() const { return (wxList&) m_fileMenus; } + protected: // Last n files char** m_fileHistory; // Number of files saved int m_fileHistoryN; - // Menu to maintain - wxMenu* m_fileMenu; + // Menus to maintain (may need several for an MDI app) + wxList m_fileMenus; // Max files to maintain int m_fileMaxFiles; };