]> git.saurik.com Git - wxWidgets.git/blob - include/wx/docview.h
build fix
[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 wxDECLARE_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 wxDECLARE_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 wxDECLARE_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 { return m_currentView; }
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 // this method tries to find an active view harder than GetCurrentView():
476 // if the latter is NULL, it also checks if we don't have just a single
477 // view and returns it then
478 wxView *GetActiveView() const;
479
480
481 int m_defaultDocumentNameCounter;
482 int m_maxDocsOpen;
483 wxList m_docs;
484 wxList m_templates;
485 wxView* m_currentView;
486 wxFileHistory* m_fileHistory;
487 wxString m_lastDirectory;
488 static wxDocManager* sm_docManager;
489
490 DECLARE_EVENT_TABLE()
491 DECLARE_DYNAMIC_CLASS(wxDocManager)
492 wxDECLARE_NO_COPY_CLASS(wxDocManager);
493 };
494
495 #if WXWIN_COMPATIBILITY_2_6
496 inline size_t wxDocManager::GetNoHistoryFiles() const
497 {
498 return GetHistoryFilesCount();
499 }
500 #endif // WXWIN_COMPATIBILITY_2_6
501
502 // ----------------------------------------------------------------------------
503 // A default child frame
504 // ----------------------------------------------------------------------------
505
506 class WXDLLIMPEXP_CORE wxDocChildFrame : public wxFrame
507 {
508 public:
509 wxDocChildFrame(wxDocument *doc,
510 wxView *view,
511 wxFrame *frame,
512 wxWindowID id,
513 const wxString& title,
514 const wxPoint& pos = wxDefaultPosition,
515 const wxSize& size = wxDefaultSize,
516 long type = wxDEFAULT_FRAME_STYLE,
517 const wxString& name = wxFrameNameStr);
518 virtual ~wxDocChildFrame(){}
519
520 void OnActivate(wxActivateEvent& event);
521 void OnCloseWindow(wxCloseEvent& event);
522
523 wxDocument *GetDocument() const { return m_childDocument; }
524 wxView *GetView() const { return m_childView; }
525 void SetDocument(wxDocument *doc) { m_childDocument = doc; }
526 void SetView(wxView *view) { m_childView = view; }
527 bool Destroy() { m_childView = NULL; return wxFrame::Destroy(); }
528
529 protected:
530 // hook the child view into event handlers chain here
531 virtual bool TryValidator(wxEvent& event);
532
533 wxDocument* m_childDocument;
534 wxView* m_childView;
535
536 private:
537 DECLARE_CLASS(wxDocChildFrame)
538 DECLARE_EVENT_TABLE()
539 wxDECLARE_NO_COPY_CLASS(wxDocChildFrame);
540 };
541
542 // ----------------------------------------------------------------------------
543 // A default parent frame
544 // ----------------------------------------------------------------------------
545
546 class WXDLLIMPEXP_CORE wxDocParentFrame : public wxFrame
547 {
548 public:
549 wxDocParentFrame();
550 wxDocParentFrame(wxDocManager *manager,
551 wxFrame *frame,
552 wxWindowID id,
553 const wxString& title,
554 const wxPoint& pos = wxDefaultPosition,
555 const wxSize& size = wxDefaultSize,
556 long style = wxDEFAULT_FRAME_STYLE,
557 const wxString& name = wxFrameNameStr);
558
559 bool Create(wxDocManager *manager,
560 wxFrame *frame,
561 wxWindowID id,
562 const wxString& title,
563 const wxPoint& pos = wxDefaultPosition,
564 const wxSize& size = wxDefaultSize,
565 long style = wxDEFAULT_FRAME_STYLE,
566 const wxString& name = wxFrameNameStr);
567
568 wxDocManager *GetDocumentManager() const { return m_docManager; }
569
570 void OnExit(wxCommandEvent& event);
571 void OnMRUFile(wxCommandEvent& event);
572 void OnCloseWindow(wxCloseEvent& event);
573
574 protected:
575 // hook the document manager into event handling chain here
576 virtual bool TryValidator(wxEvent& event);
577
578 wxDocManager *m_docManager;
579
580 private:
581 typedef wxFrame base_type;
582 DECLARE_CLASS(wxDocParentFrame)
583 DECLARE_EVENT_TABLE()
584 wxDECLARE_NO_COPY_CLASS(wxDocParentFrame);
585 };
586
587 // ----------------------------------------------------------------------------
588 // Provide simple default printing facilities
589 // ----------------------------------------------------------------------------
590
591 #if wxUSE_PRINTING_ARCHITECTURE
592 class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout
593 {
594 public:
595 wxDocPrintout(wxView *view = NULL, const wxString& title = wxT("Printout"));
596
597 // implement wxPrintout methods
598 virtual bool OnPrintPage(int page);
599 virtual bool HasPage(int page);
600 virtual bool OnBeginDocument(int startPage, int endPage);
601 virtual void GetPageInfo(int *minPage, int *maxPage,
602 int *selPageFrom, int *selPageTo);
603
604 virtual wxView *GetView() { return m_printoutView; }
605
606 protected:
607 wxView* m_printoutView;
608
609 private:
610 DECLARE_DYNAMIC_CLASS(wxDocPrintout)
611 wxDECLARE_NO_COPY_CLASS(wxDocPrintout);
612 };
613 #endif // wxUSE_PRINTING_ARCHITECTURE
614
615 // ----------------------------------------------------------------------------
616 // File history management
617 // ----------------------------------------------------------------------------
618
619 class WXDLLIMPEXP_CORE wxFileHistory : public wxObject
620 {
621 public:
622 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
623
624 // Operations
625 virtual void AddFileToHistory(const wxString& file);
626 virtual void RemoveFileFromHistory(size_t i);
627 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; }
628 virtual void UseMenu(wxMenu *menu);
629
630 // Remove menu from the list (MDI child may be closing)
631 virtual void RemoveMenu(wxMenu *menu);
632
633 #if wxUSE_CONFIG
634 virtual void Load(const wxConfigBase& config);
635 virtual void Save(wxConfigBase& config);
636 #endif // wxUSE_CONFIG
637
638 virtual void AddFilesToMenu();
639 virtual void AddFilesToMenu(wxMenu* menu); // Single menu
640
641 // Accessors
642 virtual wxString GetHistoryFile(size_t i) const { return m_fileHistory[i]; }
643 virtual size_t GetCount() const { return m_fileHistory.GetCount(); }
644
645 const wxList& GetMenus() const { return m_fileMenus; }
646
647 // Set/get base id
648 void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
649 wxWindowID GetBaseId() const { return m_idBase; }
650
651 #if WXWIN_COMPATIBILITY_2_6
652 // deprecated, use GetCount() instead
653 wxDEPRECATED( size_t GetNoHistoryFiles() const );
654 #endif // WXWIN_COMPATIBILITY_2_6
655
656 protected:
657 // Last n files
658 wxArrayString m_fileHistory;
659
660 // Menus to maintain (may need several for an MDI app)
661 wxList m_fileMenus;
662
663 // Max files to maintain
664 size_t m_fileMaxFiles;
665
666 private:
667 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
668 wxWindowID m_idBase;
669
670 DECLARE_DYNAMIC_CLASS(wxFileHistory)
671 wxDECLARE_NO_COPY_CLASS(wxFileHistory);
672 };
673
674 #if WXWIN_COMPATIBILITY_2_6
675 inline size_t wxFileHistory::GetNoHistoryFiles() const
676 {
677 return m_fileHistory.GetCount();
678 }
679 #endif // WXWIN_COMPATIBILITY_2_6
680
681 // For compatibility with existing file formats:
682 // converts from/to a stream to/from a temporary file.
683 #if wxUSE_STD_IOSTREAM
684 bool WXDLLIMPEXP_CORE
685 wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
686 bool WXDLLIMPEXP_CORE
687 wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
688 #else
689 bool WXDLLIMPEXP_CORE
690 wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
691 bool WXDLLIMPEXP_CORE
692 wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
693 #endif // wxUSE_STD_IOSTREAM
694
695
696 // these flags are not used anywhere by wxWidgets and kept only for an unlikely
697 // case of existing user code using them for its own purposes
698 #ifdef WXWIN_COMPATIBILITY_2_8
699 enum
700 {
701 wxDOC_SDI = 1,
702 wxDOC_MDI,
703 wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI
704 };
705 #endif // WXWIN_COMPATIBILITY_2_8
706
707 #endif // wxUSE_DOC_VIEW_ARCHITECTURE
708
709 #endif // _WX_DOCH__