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