1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/docview.h
3 // Purpose:     Doc/View classes
4 // Author:      Julian Smart
5 // Modified by:
6 // Created:     01/02/97
7 // RCS-ID:      $Id: docview.h 53546 2008-05-10 21:02:36Z VZ $
8 // Copyright:   (c) Julian Smart
9 // Licence:     wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef _WX_DOCH__
13 #define _WX_DOCH__
14 
15 #include "wx/defs.h"
16 
17 #if wxUSE_DOC_VIEW_ARCHITECTURE
18 
19 #include "wx/list.h"
20 #include "wx/string.h"
21 #include "wx/frame.h"
22 
23 #if wxUSE_PRINTING_ARCHITECTURE
24     #include "wx/print.h"
25 #endif
26 
27 class WXDLLIMPEXP_FWD_CORE wxWindow;
28 class WXDLLIMPEXP_FWD_CORE wxDocument;
29 class WXDLLIMPEXP_FWD_CORE wxView;
30 class WXDLLIMPEXP_FWD_CORE wxDocTemplate;
31 class WXDLLIMPEXP_FWD_CORE wxDocManager;
32 class WXDLLIMPEXP_FWD_CORE wxPrintInfo;
33 class WXDLLIMPEXP_FWD_CORE wxCommandProcessor;
34 class WXDLLIMPEXP_FWD_CORE wxFileHistory;
35 class WXDLLIMPEXP_FWD_BASE wxConfigBase;
36 
37 #if wxUSE_STD_IOSTREAM
38   #include "wx/iosfwrap.h"
39 #else
40   #include "wx/stream.h"
41 #endif
42 
43 // Document manager flags
44 enum
45 {
46     wxDOC_SDI = 1,
47     wxDOC_MDI,
48     wxDOC_NEW,
49     wxDOC_SILENT,
50     wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI
51 };
52 
53 // Document template flags
54 enum
55 {
56     wxTEMPLATE_VISIBLE = 1,
57     wxTEMPLATE_INVISIBLE,
58     wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE
59 };
60 
61 #define wxMAX_FILE_HISTORY 9
62 
63 class WXDLLEXPORT wxDocument : public wxEvtHandler
64 {
65 public:
66     wxDocument(wxDocument *parent = (wxDocument *) NULL);
67     virtual ~wxDocument();
68 
69     // accessors
70     void SetFilename(const wxString& filename, bool notifyViews = false);
GetFilename()71     wxString GetFilename() const { return m_documentFile; }
72 
SetTitle(const wxString & title)73     void SetTitle(const wxString& title) { m_documentTitle = title; }
GetTitle()74     wxString GetTitle() const { return m_documentTitle; }
75 
SetDocumentName(const wxString & name)76     void SetDocumentName(const wxString& name) { m_documentTypeName = name; }
GetDocumentName()77     wxString GetDocumentName() const { return m_documentTypeName; }
78 
GetDocumentSaved()79     bool GetDocumentSaved() const { return m_savedYet; }
80     void SetDocumentSaved(bool saved = true) { m_savedYet = saved; }
81 
82     virtual bool Close();
83     virtual bool Save();
84     virtual bool SaveAs();
85     virtual bool Revert();
86 
87 #if wxUSE_STD_IOSTREAM
88     virtual wxSTD ostream& SaveObject(wxSTD ostream& stream);
89     virtual wxSTD istream& LoadObject(wxSTD istream& stream);
90 #else
91     virtual wxOutputStream& SaveObject(wxOutputStream& stream);
92     virtual wxInputStream& LoadObject(wxInputStream& stream);
93 #endif
94 
95     // Called by wxWidgets
96     virtual bool OnSaveDocument(const wxString& filename);
97     virtual bool OnOpenDocument(const wxString& filename);
98     virtual bool OnNewDocument();
99     virtual bool OnCloseDocument();
100 
101     // Prompts for saving if about to close a modified document. Returns true
102     // if ok to close the document (may have saved in the meantime, or set
103     // modified to false)
104     virtual bool OnSaveModified();
105 
106     // Called by framework if created automatically by the default document
107     // manager: gives document a chance to initialise and (usually) create a
108     // view
109     virtual bool OnCreate(const wxString& path, long flags);
110 
111     // By default, creates a base wxCommandProcessor.
112     virtual wxCommandProcessor *OnCreateCommandProcessor();
GetCommandProcessor()113     virtual wxCommandProcessor *GetCommandProcessor() const { return m_commandProcessor; }
SetCommandProcessor(wxCommandProcessor * proc)114     virtual void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; }
115 
116     // Called after a view is added or removed. The default implementation
117     // deletes the document if this is there are no more views.
118     virtual void OnChangedViewList();
119 
120     virtual bool DeleteContents();
121 
122     virtual bool Draw(wxDC&);
IsModified()123     virtual bool IsModified() const { return m_documentModified; }
Modify(bool mod)124     virtual void Modify(bool mod) { m_documentModified = mod; }
125 
126     virtual bool AddView(wxView *view);
127     virtual bool RemoveView(wxView *view);
GetViews()128     wxList& GetViews() { return m_documentViews; }
GetViews()129     const wxList& GetViews() const { return m_documentViews; }
130     wxView *GetFirstView() const;
131 
132     virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL);
133     virtual void NotifyClosing();
134 
135     // Remove all views (because we're closing the document)
136     virtual bool DeleteAllViews();
137 
138     // Other stuff
139     virtual wxDocManager *GetDocumentManager() const;
GetDocumentTemplate()140     virtual wxDocTemplate *GetDocumentTemplate() const { return m_documentTemplate; }
SetDocumentTemplate(wxDocTemplate * temp)141     virtual void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; }
142 
143     // Get title, or filename if no title, else [unnamed]
144     //
145     // NB: this method will be deprecated in wxWidgets 3.0, you still need to
146     //     override it if you need to modify the existing behaviour in this
147     //     version but use GetUserReadableName() below if you just need to call
148     //     it
149     virtual bool GetPrintableName(wxString& buf) const;
150 
151 #if wxABI_VERSION >= 20805
GetUserReadableName()152     wxString GetUserReadableName() const
153     {
154         wxString s;
155         GetPrintableName(s);
156         return s;
157     }
158 #endif // wxABI 2.8.5+
159 
160     // Returns a window that can be used as a parent for document-related
161     // dialogs. Override if necessary.
162     virtual wxWindow *GetDocumentWindow() const;
163 
164 protected:
165     wxList                m_documentViews;
166     wxString              m_documentFile;
167     wxString              m_documentTitle;
168     wxString              m_documentTypeName;
169     wxDocTemplate*        m_documentTemplate;
170     bool                  m_documentModified;
171     wxDocument*           m_documentParent;
172     wxCommandProcessor*   m_commandProcessor;
173     bool                  m_savedYet;
174 
175     // Called by OnSaveDocument and OnOpenDocument to implement standard
176     // Save/Load behavior. Re-implement in derived class for custom
177     // behavior.
178     virtual bool DoSaveDocument(const wxString& file);
179     virtual bool DoOpenDocument(const wxString& file);
180 
181 private:
182     DECLARE_ABSTRACT_CLASS(wxDocument)
183     DECLARE_NO_COPY_CLASS(wxDocument)
184 };
185 
186 class WXDLLEXPORT wxView: public wxEvtHandler
187 {
188 public:
189     //  wxView(wxDocument *doc = (wxDocument *) NULL);
190     wxView();
191     virtual ~wxView();
192 
GetDocument()193     wxDocument *GetDocument() const { return m_viewDocument; }
194     virtual void SetDocument(wxDocument *doc);
195 
GetViewName()196     wxString GetViewName() const { return m_viewTypeName; }
SetViewName(const wxString & name)197     void SetViewName(const wxString& name) { m_viewTypeName = name; }
198 
GetFrame()199     wxWindow *GetFrame() const { return m_viewFrame ; }
SetFrame(wxWindow * frame)200     void SetFrame(wxWindow *frame) { m_viewFrame = frame; }
201 
202     virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView);
203     virtual void OnDraw(wxDC *dc) = 0;
204     virtual void OnPrint(wxDC *dc, wxObject *info);
205     virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
OnClosingDocument()206     virtual void OnClosingDocument() {}
207     virtual void OnChangeFilename();
208 
209     // Called by framework if created automatically by the default document
210     // manager class: gives view a chance to initialise
OnCreate(wxDocument * WXUNUSED (doc),long WXUNUSED (flags))211     virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return true; }
212 
213     // Checks if the view is the last one for the document; if so, asks user
214     // to confirm save data (if modified). If ok, deletes itself and returns
215     // true.
216     virtual bool Close(bool deleteWindow = true);
217 
218     // Override to do cleanup/veto close
219     virtual bool OnClose(bool deleteWindow);
220 
221     // Extend event processing to search the document's event table
222     virtual bool ProcessEvent(wxEvent& event);
223 
224     // A view's window can call this to notify the view it is (in)active.
225     // The function then notifies the document manager.
226     virtual void Activate(bool activate);
227 
GetDocumentManager()228     wxDocManager *GetDocumentManager() const
229         { return m_viewDocument->GetDocumentManager(); }
230 
231 #if wxUSE_PRINTING_ARCHITECTURE
232     virtual wxPrintout *OnCreatePrintout();
233 #endif
234 
235 protected:
236     wxDocument*       m_viewDocument;
237     wxString          m_viewTypeName;
238     wxWindow*         m_viewFrame;
239 
240 private:
241     DECLARE_ABSTRACT_CLASS(wxView)
242     DECLARE_NO_COPY_CLASS(wxView)
243 };
244 
245 // Represents user interface (and other) properties of documents and views
246 class WXDLLEXPORT wxDocTemplate: public wxObject
247 {
248 
249 friend class WXDLLIMPEXP_FWD_CORE wxDocManager;
250 
251 public:
252     // Associate document and view types. They're for identifying what view is
253     // associated with what template/document type
254     wxDocTemplate(wxDocManager *manager,
255                   const wxString& descr,
256                   const wxString& filter,
257                   const wxString& dir,
258                   const wxString& ext,
259                   const wxString& docTypeName,
260                   const wxString& viewTypeName,
261                   wxClassInfo *docClassInfo = (wxClassInfo *) NULL,
262                   wxClassInfo *viewClassInfo = (wxClassInfo *)NULL,
263                   long flags = wxDEFAULT_TEMPLATE_FLAGS);
264 
265     virtual ~wxDocTemplate();
266 
267     // By default, these two member functions dynamically creates document and
268     // view using dynamic instance construction. Override these if you need a
269     // different method of construction.
270     virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
271     virtual wxView *CreateView(wxDocument *doc, long flags = 0);
272 
273     // Helper method for CreateDocument; also allows you to do your own document
274     // creation
275     virtual bool InitDocument(wxDocument* doc, const wxString& path, long flags = 0);
276 
GetDefaultExtension()277     wxString GetDefaultExtension() const { return m_defaultExt; }
GetDescription()278     wxString GetDescription() const { return m_description; }
GetDirectory()279     wxString GetDirectory() const { return m_directory; }
GetDocumentManager()280     wxDocManager *GetDocumentManager() const { return m_documentManager; }
SetDocumentManager(wxDocManager * manager)281     void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; }
GetFileFilter()282     wxString GetFileFilter() const { return m_fileFilter; }
GetFlags()283     long GetFlags() const { return m_flags; }
GetViewName()284     virtual wxString GetViewName() const { return m_viewTypeName; }
GetDocumentName()285     virtual wxString GetDocumentName() const { return m_docTypeName; }
286 
SetFileFilter(const wxString & filter)287     void SetFileFilter(const wxString& filter) { m_fileFilter = filter; }
SetDirectory(const wxString & dir)288     void SetDirectory(const wxString& dir) { m_directory = dir; }
SetDescription(const wxString & descr)289     void SetDescription(const wxString& descr) { m_description = descr; }
SetDefaultExtension(const wxString & ext)290     void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; }
SetFlags(long flags)291     void SetFlags(long flags) { m_flags = flags; }
292 
IsVisible()293     bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
294 
GetDocClassInfo()295     wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; }
GetViewClassInfo()296     wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; }
297 
298     virtual bool FileMatchesTemplate(const wxString& path);
299 
300 protected:
301     long              m_flags;
302     wxString          m_fileFilter;
303     wxString          m_directory;
304     wxString          m_description;
305     wxString          m_defaultExt;
306     wxString          m_docTypeName;
307     wxString          m_viewTypeName;
308     wxDocManager*     m_documentManager;
309 
310     // For dynamic creation of appropriate instances.
311     wxClassInfo*      m_docClassInfo;
312     wxClassInfo*      m_viewClassInfo;
313 
314     // Called by CreateDocument and CreateView to create the actual document/view object.
315     // By default uses the ClassInfo provided to the constructor. Override these functions
316     // to provide a different method of creation.
317     virtual wxDocument *DoCreateDocument();
318     virtual wxView *DoCreateView();
319 
320 private:
321     DECLARE_CLASS(wxDocTemplate)
322     DECLARE_NO_COPY_CLASS(wxDocTemplate)
323 };
324 
325 // One object of this class may be created in an application, to manage all
326 // the templates and documents.
327 class WXDLLEXPORT wxDocManager: public wxEvtHandler
328 {
329 public:
330     wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true);
331     virtual ~wxDocManager();
332 
333     virtual bool Initialize();
334 
335     // Handlers for common user commands
336     void OnFileClose(wxCommandEvent& event);
337     void OnFileCloseAll(wxCommandEvent& event);
338     void OnFileNew(wxCommandEvent& event);
339     void OnFileOpen(wxCommandEvent& event);
340     void OnFileRevert(wxCommandEvent& event);
341     void OnFileSave(wxCommandEvent& event);
342     void OnFileSaveAs(wxCommandEvent& event);
343     void OnPrint(wxCommandEvent& event);
344     void OnPreview(wxCommandEvent& event);
345     void OnUndo(wxCommandEvent& event);
346     void OnRedo(wxCommandEvent& event);
347 
348     // Handlers for UI update commands
349     void OnUpdateFileOpen(wxUpdateUIEvent& event);
350     void OnUpdateFileClose(wxUpdateUIEvent& event);
351     void OnUpdateFileRevert(wxUpdateUIEvent& event);
352     void OnUpdateFileNew(wxUpdateUIEvent& event);
353     void OnUpdateFileSave(wxUpdateUIEvent& event);
354     void OnUpdateFileSaveAs(wxUpdateUIEvent& event);
355     void OnUpdateUndo(wxUpdateUIEvent& event);
356     void OnUpdateRedo(wxUpdateUIEvent& event);
357 
358     void OnUpdatePrint(wxUpdateUIEvent& event);
359     void OnUpdatePreview(wxUpdateUIEvent& event);
360 
361     // Extend event processing to search the view's event table
362     virtual bool ProcessEvent(wxEvent& event);
363 
364     // called when file format detection didn't work, can be overridden to do
365     // something in this case
OnOpenFileFailure()366     virtual void OnOpenFileFailure() { }
367 
368     virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
369     virtual wxView *CreateView(wxDocument *doc, long flags = 0);
370     virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
371     virtual bool FlushDoc(wxDocument *doc);
372     virtual wxDocTemplate *MatchTemplate(const wxString& path);
373     virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates,
374             int noTemplates, wxString& path, long flags, bool save = false);
375     virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates,
376             int noTemplates, bool sort = false);
377     virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
378             int noTemplates, bool sort = false);
379     virtual wxDocTemplate *FindTemplateForPath(const wxString& path);
380 
381     void AssociateTemplate(wxDocTemplate *temp);
382     void DisassociateTemplate(wxDocTemplate *temp);
383 
384     wxDocument *GetCurrentDocument() const;
385 
SetMaxDocsOpen(int n)386     void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
GetMaxDocsOpen()387     int GetMaxDocsOpen() const { return m_maxDocsOpen; }
388 
389     // Add and remove a document from the manager's list
390     void AddDocument(wxDocument *doc);
391     void RemoveDocument(wxDocument *doc);
392 
393     // closes all currently open documents
394     bool CloseDocuments(bool force = true);
395 
396     // closes the specified document
397     bool CloseDocument(wxDocument* doc, bool force = false);
398 
399     // Clear remaining documents and templates
400     bool Clear(bool force = true);
401 
402     // Views or windows should inform the document manager
403     // when a view is going in or out of focus
404     virtual void ActivateView(wxView *view, bool activate = true);
405     virtual wxView *GetCurrentView() const;
406 
GetDocuments()407     wxList& GetDocuments() { return m_docs; }
GetTemplates()408     wxList& GetTemplates() { return m_templates; }
409 
410     // Make a default document name
411     //
412     // NB: this method is renamed to MakeNewDocumentName() in wx 3.0, you still
413     //     need to override it if your code needs to customize the default name
414     //     generation but if you just use it from your code, prefer the version
415     //     below which is forward-compatible with wx 3.0
416     virtual bool MakeDefaultName(wxString& buf);
417 
418 #if wxABI_VERSION >= 20808
MakeNewDocumentName()419     wxString MakeNewDocumentName() const
420     {
421         wxString s;
422         wx_const_cast(wxDocManager *, this)->MakeDefaultName(s);
423         return s;
424     }
425 #endif // wx ABI >= 2.8.8
426 
427     // Make a frame title (override this to do something different)
428     virtual wxString MakeFrameTitle(wxDocument* doc);
429 
430     virtual wxFileHistory *OnCreateFileHistory();
GetFileHistory()431     virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
432 
433     // File history management
434     virtual void AddFileToHistory(const wxString& file);
435     virtual void RemoveFileFromHistory(size_t i);
436     virtual size_t GetHistoryFilesCount() const;
437     virtual wxString GetHistoryFile(size_t i) const;
438     virtual void FileHistoryUseMenu(wxMenu *menu);
439     virtual void FileHistoryRemoveMenu(wxMenu *menu);
440 #if wxUSE_CONFIG
441     virtual void FileHistoryLoad(wxConfigBase& config);
442     virtual void FileHistorySave(wxConfigBase& config);
443 #endif // wxUSE_CONFIG
444 
445     virtual void FileHistoryAddFilesToMenu();
446     virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
447 
GetLastDirectory()448     wxString GetLastDirectory() const { return m_lastDirectory; }
SetLastDirectory(const wxString & dir)449     void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
450 
451     // Get the current document manager
GetDocumentManager()452     static wxDocManager* GetDocumentManager() { return sm_docManager; }
453 
454 #if WXWIN_COMPATIBILITY_2_6
455     // deprecated, use GetHistoryFilesCount() instead
456     wxDEPRECATED( size_t GetNoHistoryFiles() const );
457 #endif // WXWIN_COMPATIBILITY_2_6
458 
459 protected:
460     long              m_flags;
461     int               m_defaultDocumentNameCounter;
462     int               m_maxDocsOpen;
463     wxList            m_docs;
464     wxList            m_templates;
465     wxView*           m_currentView;
466     wxFileHistory*    m_fileHistory;
467     wxString          m_lastDirectory;
468     static wxDocManager* sm_docManager;
469 
470     DECLARE_EVENT_TABLE()
471     DECLARE_DYNAMIC_CLASS(wxDocManager)
472     DECLARE_NO_COPY_CLASS(wxDocManager)
473 };
474 
475 #if WXWIN_COMPATIBILITY_2_6
GetNoHistoryFiles()476 inline size_t wxDocManager::GetNoHistoryFiles() const
477 {
478     return GetHistoryFilesCount();
479 }
480 #endif // WXWIN_COMPATIBILITY_2_6
481 
482 // ----------------------------------------------------------------------------
483 // A default child frame
484 // ----------------------------------------------------------------------------
485 
486 class WXDLLEXPORT wxDocChildFrame : public wxFrame
487 {
488 public:
489     wxDocChildFrame(wxDocument *doc,
490                     wxView *view,
491                     wxFrame *frame,
492                     wxWindowID id,
493                     const wxString& title,
494                     const wxPoint& pos = wxDefaultPosition,
495                     const wxSize& size = wxDefaultSize,
496                     long type = wxDEFAULT_FRAME_STYLE,
497                     const wxString& name = wxT("frame"));
~wxDocChildFrame()498     virtual ~wxDocChildFrame(){}
499 
500     // Extend event processing to search the view's event table
501     virtual bool ProcessEvent(wxEvent& event);
502 
503     void OnActivate(wxActivateEvent& event);
504     void OnCloseWindow(wxCloseEvent& event);
505 
GetDocument()506     wxDocument *GetDocument() const { return m_childDocument; }
GetView()507     wxView *GetView() const { return m_childView; }
SetDocument(wxDocument * doc)508     void SetDocument(wxDocument *doc) { m_childDocument = doc; }
SetView(wxView * view)509     void SetView(wxView *view) { m_childView = view; }
Destroy()510     bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); }
511 
512 protected:
513     wxDocument*       m_childDocument;
514     wxView*           m_childView;
515 
516 private:
517     DECLARE_CLASS(wxDocChildFrame)
518     DECLARE_EVENT_TABLE()
519     DECLARE_NO_COPY_CLASS(wxDocChildFrame)
520 };
521 
522 // ----------------------------------------------------------------------------
523 // A default parent frame
524 // ----------------------------------------------------------------------------
525 
526 class WXDLLEXPORT wxDocParentFrame : public wxFrame
527 {
528 public:
529     wxDocParentFrame();
530     wxDocParentFrame(wxDocManager *manager,
531                      wxFrame *frame,
532                      wxWindowID id,
533                      const wxString& title,
534                      const wxPoint& pos = wxDefaultPosition,
535                      const wxSize& size = wxDefaultSize,
536                      long style = wxDEFAULT_FRAME_STYLE,
537                      const wxString& name = wxFrameNameStr);
538 
539     bool Create(wxDocManager *manager,
540                 wxFrame *frame,
541                 wxWindowID id,
542                 const wxString& title,
543                 const wxPoint& pos = wxDefaultPosition,
544                 const wxSize& size = wxDefaultSize,
545                 long style = wxDEFAULT_FRAME_STYLE,
546                 const wxString& name = wxFrameNameStr);
547 
548     // Extend event processing to search the document manager's event table
549     virtual bool ProcessEvent(wxEvent& event);
550 
GetDocumentManager()551     wxDocManager *GetDocumentManager() const { return m_docManager; }
552 
553     void OnExit(wxCommandEvent& event);
554     void OnMRUFile(wxCommandEvent& event);
555     void OnCloseWindow(wxCloseEvent& event);
556 
557 protected:
558     wxDocManager *m_docManager;
559 
560 private:
561     typedef wxFrame base_type;
562     DECLARE_CLASS(wxDocParentFrame)
563     DECLARE_EVENT_TABLE()
564     DECLARE_NO_COPY_CLASS(wxDocParentFrame)
565 };
566 
567 // ----------------------------------------------------------------------------
568 // Provide simple default printing facilities
569 // ----------------------------------------------------------------------------
570 
571 #if wxUSE_PRINTING_ARCHITECTURE
572 class WXDLLEXPORT wxDocPrintout : public wxPrintout
573 {
574 public:
575     wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout"));
576     bool OnPrintPage(int page);
577     bool HasPage(int page);
578     bool OnBeginDocument(int startPage, int endPage);
579     void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
580 
GetView()581     virtual wxView *GetView() { return m_printoutView; }
582 
583 protected:
584     wxView*       m_printoutView;
585 
586 private:
587     DECLARE_DYNAMIC_CLASS(wxDocPrintout)
588     DECLARE_NO_COPY_CLASS(wxDocPrintout)
589 };
590 #endif // wxUSE_PRINTING_ARCHITECTURE
591 
592 // ----------------------------------------------------------------------------
593 // File history management
594 // ----------------------------------------------------------------------------
595 
596 class WXDLLEXPORT wxFileHistory : public wxObject
597 {
598 public:
599     wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
600     virtual ~wxFileHistory();
601 
602     // Operations
603     virtual void AddFileToHistory(const wxString& file);
604     virtual void RemoveFileFromHistory(size_t i);
GetMaxFiles()605     virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; }
606     virtual void UseMenu(wxMenu *menu);
607 
608     // Remove menu from the list (MDI child may be closing)
609     virtual void RemoveMenu(wxMenu *menu);
610 
611 #if wxUSE_CONFIG
612     virtual void Load(wxConfigBase& config);
613     virtual void Save(wxConfigBase& config);
614 #endif // wxUSE_CONFIG
615 
616     virtual void AddFilesToMenu();
617     virtual void AddFilesToMenu(wxMenu* menu); // Single menu
618 
619     // Accessors
620     virtual wxString GetHistoryFile(size_t i) const;
GetCount()621     virtual size_t GetCount() const { return m_fileHistoryN; }
622 
GetMenus()623     const wxList& GetMenus() const { return m_fileMenus; }
624 
625 #if wxABI_VERSION >= 20802
626     // Set/get base id
SetBaseId(wxWindowID baseId)627     void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
GetBaseId()628     wxWindowID GetBaseId() const { return m_idBase; }
629 #endif // wxABI 2.8.2+
630 
631 #if WXWIN_COMPATIBILITY_2_6
632     // deprecated, use GetCount() instead
633     wxDEPRECATED( size_t GetNoHistoryFiles() const );
634 #endif // WXWIN_COMPATIBILITY_2_6
635 
636 protected:
637     // Last n files
638     wxChar**          m_fileHistory;
639     // Number of files saved
640     size_t            m_fileHistoryN;
641     // Menus to maintain (may need several for an MDI app)
642     wxList            m_fileMenus;
643     // Max files to maintain
644     size_t            m_fileMaxFiles;
645 
646 private:
647     // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
648     wxWindowID m_idBase;
649 
650     DECLARE_DYNAMIC_CLASS(wxFileHistory)
651     DECLARE_NO_COPY_CLASS(wxFileHistory)
652 };
653 
654 #if WXWIN_COMPATIBILITY_2_6
GetNoHistoryFiles()655 inline size_t wxFileHistory::GetNoHistoryFiles() const
656 {
657     return m_fileHistoryN;
658 }
659 #endif // WXWIN_COMPATIBILITY_2_6
660 
661 #if wxUSE_STD_IOSTREAM
662 // For compatibility with existing file formats:
663 // converts from/to a stream to/from a temporary file.
664 bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
665 bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
666 #else
667 // For compatibility with existing file formats:
668 // converts from/to a stream to/from a temporary file.
669 bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
670 bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
671 #endif // wxUSE_STD_IOSTREAM
672 
673 #endif // wxUSE_DOC_VIEW_ARCHITECTURE
674 
675 #endif // _WX_DOCH__
676