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