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