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