]> git.saurik.com Git - wxWidgets.git/blame - include/wx/docview.h
Get/Set LayoutDirection
[wxWidgets.git] / include / wx / docview.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
ca3e85cf 2// Name: wx/docview.h
c801d85f
KB
3// Purpose: Doc/View classes
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
99d80019 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DOCH__
13#define _WX_DOCH__
c801d85f 14
c801d85f 15#include "wx/defs.h"
e30285ab
VZ
16
17#if wxUSE_DOC_VIEW_ARCHITECTURE
18
c801d85f 19#include "wx/list.h"
c801d85f 20#include "wx/string.h"
2f7adba0 21#include "wx/frame.h"
c801d85f 22
47d67540 23#if wxUSE_PRINTING_ARCHITECTURE
caf0debf 24 #include "wx/print.h"
c801d85f
KB
25#endif
26
27class WXDLLEXPORT wxWindow;
28class WXDLLEXPORT wxDocument;
29class WXDLLEXPORT wxView;
30class WXDLLEXPORT wxDocTemplate;
31class WXDLLEXPORT wxDocManager;
32class WXDLLEXPORT wxPrintInfo;
c801d85f
KB
33class WXDLLEXPORT wxCommandProcessor;
34class WXDLLEXPORT wxFileHistory;
7f555861 35class WXDLLEXPORT wxConfigBase;
c801d85f 36
a533f5c1 37#if wxUSE_STD_IOSTREAM
65f19af1 38 #include "wx/iosfwrap.h"
a533f5c1
RR
39#else
40 #include "wx/stream.h"
41#endif
c801d85f
KB
42
43// Document manager flags
caf0debf
VZ
44enum
45{
46 wxDOC_SDI = 1,
47 wxDOC_MDI,
48 wxDOC_NEW,
49 wxDOC_SILENT,
50 wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI
51};
c801d85f
KB
52
53// Document template flags
caf0debf
VZ
54enum
55{
56 wxTEMPLATE_VISIBLE = 1,
57 wxTEMPLATE_INVISIBLE,
58 wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE
59};
c801d85f 60
caf0debf 61#define wxMAX_FILE_HISTORY 9
c801d85f
KB
62
63class WXDLLEXPORT wxDocument : public wxEvtHandler
64{
caf0debf
VZ
65public:
66 wxDocument(wxDocument *parent = (wxDocument *) NULL);
d3c7fc99 67 virtual ~wxDocument();
caf0debf
VZ
68
69 // accessors
68379eaf 70 void SetFilename(const wxString& filename, bool notifyViews = false);
caf0debf
VZ
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; }
68379eaf 80 void SetDocumentSaved(bool saved = true) { m_savedYet = saved; }
caf0debf
VZ
81
82 virtual bool Close();
83 virtual bool Save();
84 virtual bool SaveAs();
85 virtual bool Revert();
86
a533f5c1 87#if wxUSE_STD_IOSTREAM
dd107c50
VZ
88 virtual wxSTD ostream& SaveObject(wxSTD ostream& stream);
89 virtual wxSTD istream& LoadObject(wxSTD istream& stream);
a533f5c1 90#else
23a54e14
RR
91 virtual wxOutputStream& SaveObject(wxOutputStream& stream);
92 virtual wxInputStream& LoadObject(wxInputStream& stream);
a533f5c1 93#endif
caf0debf 94
77ffb593 95 // Called by wxWidgets
caf0debf
VZ
96 virtual bool OnSaveDocument(const wxString& filename);
97 virtual bool OnOpenDocument(const wxString& filename);
98 virtual bool OnNewDocument();
99 virtual bool OnCloseDocument();
100
68379eaf 101 // Prompts for saving if about to close a modified document. Returns true
caf0debf 102 // if ok to close the document (may have saved in the meantime, or set
68379eaf 103 // modified to false)
caf0debf
VZ
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);
b80388aa
VZ
128 wxList& GetViews() { return m_documentViews; }
129 const wxList& GetViews() const { return m_documentViews; }
caf0debf
VZ
130 wxView *GetFirstView() const;
131
132 virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL);
b23e843b 133 virtual void NotifyClosing();
caf0debf
VZ
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 title, or filename if no title, else [unnamed]
144 virtual bool GetPrintableName(wxString& buf) const;
145
146 // Returns a window that can be used as a parent for document-related
147 // dialogs. Override if necessary.
148 virtual wxWindow *GetDocumentWindow() const;
149
150protected:
151 wxList m_documentViews;
152 wxString m_documentFile;
153 wxString m_documentTitle;
154 wxString m_documentTypeName;
155 wxDocTemplate* m_documentTemplate;
156 bool m_documentModified;
157 wxDocument* m_documentParent;
158 wxCommandProcessor* m_commandProcessor;
159 bool m_savedYet;
b5f159ac 160
69936aea
VZ
161 // Called by OnSaveDocument and OnOpenDocument to implement standard
162 // Save/Load behavior. Re-implement in derived class for custom
163 // behavior.
164 virtual bool DoSaveDocument(const wxString& file);
165 virtual bool DoOpenDocument(const wxString& file);
166
2b5f62a0
VZ
167private:
168 DECLARE_ABSTRACT_CLASS(wxDocument)
22f3361e 169 DECLARE_NO_COPY_CLASS(wxDocument)
c801d85f
KB
170};
171
172class WXDLLEXPORT wxView: public wxEvtHandler
173{
caf0debf
VZ
174public:
175 // wxView(wxDocument *doc = (wxDocument *) NULL);
176 wxView();
d3c7fc99 177 virtual ~wxView();
c801d85f 178
caf0debf 179 wxDocument *GetDocument() const { return m_viewDocument; }
bb28b477 180 virtual void SetDocument(wxDocument *doc);
c801d85f 181
caf0debf
VZ
182 wxString GetViewName() const { return m_viewTypeName; }
183 void SetViewName(const wxString& name) { m_viewTypeName = name; };
c801d85f 184
b9f933ab
JS
185 wxWindow *GetFrame() const { return m_viewFrame ; }
186 void SetFrame(wxWindow *frame) { m_viewFrame = frame; }
c801d85f 187
caf0debf
VZ
188 virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView);
189 virtual void OnDraw(wxDC *dc) = 0;
190 virtual void OnPrint(wxDC *dc, wxObject *info);
191 virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
6fb99eb3 192 virtual void OnClosingDocument() {}
caf0debf 193 virtual void OnChangeFilename();
c801d85f 194
caf0debf
VZ
195 // Called by framework if created automatically by the default document
196 // manager class: gives view a chance to initialise
68379eaf 197 virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return true; };
c801d85f 198
caf0debf
VZ
199 // Checks if the view is the last one for the document; if so, asks user
200 // to confirm save data (if modified). If ok, deletes itself and returns
68379eaf
WS
201 // true.
202 virtual bool Close(bool deleteWindow = true);
caf0debf
VZ
203
204 // Override to do cleanup/veto close
205 virtual bool OnClose(bool deleteWindow);
2b854a32 206
caf0debf
VZ
207 // Extend event processing to search the document's event table
208 virtual bool ProcessEvent(wxEvent& event);
c801d85f 209
caf0debf
VZ
210 // A view's window can call this to notify the view it is (in)active.
211 // The function then notifies the document manager.
212 virtual void Activate(bool activate);
c801d85f 213
caf0debf
VZ
214 wxDocManager *GetDocumentManager() const
215 { return m_viewDocument->GetDocumentManager(); }
c801d85f 216
47d67540 217#if wxUSE_PRINTING_ARCHITECTURE
caf0debf 218 virtual wxPrintout *OnCreatePrintout();
c801d85f
KB
219#endif
220
caf0debf
VZ
221protected:
222 wxDocument* m_viewDocument;
223 wxString m_viewTypeName;
b9f933ab 224 wxWindow* m_viewFrame;
22f3361e 225
2b5f62a0
VZ
226private:
227 DECLARE_ABSTRACT_CLASS(wxView)
22f3361e 228 DECLARE_NO_COPY_CLASS(wxView)
c801d85f
KB
229};
230
231// Represents user interface (and other) properties of documents and views
232class WXDLLEXPORT wxDocTemplate: public wxObject
233{
caf0debf
VZ
234
235friend class WXDLLEXPORT wxDocManager;
236
237public:
238 // Associate document and view types. They're for identifying what view is
239 // associated with what template/document type
240 wxDocTemplate(wxDocManager *manager,
241 const wxString& descr,
242 const wxString& filter,
243 const wxString& dir,
244 const wxString& ext,
245 const wxString& docTypeName,
246 const wxString& viewTypeName,
247 wxClassInfo *docClassInfo = (wxClassInfo *) NULL,
248 wxClassInfo *viewClassInfo = (wxClassInfo *)NULL,
249 long flags = wxDEFAULT_TEMPLATE_FLAGS);
250
d3c7fc99 251 virtual ~wxDocTemplate();
caf0debf
VZ
252
253 // By default, these two member functions dynamically creates document and
254 // view using dynamic instance construction. Override these if you need a
255 // different method of construction.
256 virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
257 virtual wxView *CreateView(wxDocument *doc, long flags = 0);
258
217b7140
JS
259 // Helper method for CreateDocument; also allows you to do your own document
260 // creation
261 virtual bool InitDocument(wxDocument* doc, const wxString& path, long flags = 0);
262
caf0debf
VZ
263 wxString GetDefaultExtension() const { return m_defaultExt; };
264 wxString GetDescription() const { return m_description; }
265 wxString GetDirectory() const { return m_directory; };
266 wxDocManager *GetDocumentManager() const { return m_documentManager; }
267 void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; }
268 wxString GetFileFilter() const { return m_fileFilter; };
269 long GetFlags() const { return m_flags; };
270 virtual wxString GetViewName() const { return m_viewTypeName; }
271 virtual wxString GetDocumentName() const { return m_docTypeName; }
272
273 void SetFileFilter(const wxString& filter) { m_fileFilter = filter; };
274 void SetDirectory(const wxString& dir) { m_directory = dir; };
275 void SetDescription(const wxString& descr) { m_description = descr; };
276 void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; };
277 void SetFlags(long flags) { m_flags = flags; };
278
279 bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
280
04129514
JS
281 wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; }
282 wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; }
283
caf0debf
VZ
284 virtual bool FileMatchesTemplate(const wxString& path);
285
286protected:
287 long m_flags;
288 wxString m_fileFilter;
289 wxString m_directory;
290 wxString m_description;
291 wxString m_defaultExt;
292 wxString m_docTypeName;
293 wxString m_viewTypeName;
294 wxDocManager* m_documentManager;
295
296 // For dynamic creation of appropriate instances.
297 wxClassInfo* m_docClassInfo;
298 wxClassInfo* m_viewClassInfo;
b5f159ac 299
69936aea
VZ
300 // Called by CreateDocument and CreateView to create the actual document/view object.
301 // By default uses the ClassInfo provided to the constructor. Override these functions
302 // to provide a different method of creation.
303 virtual wxDocument *DoCreateDocument();
304 virtual wxView *DoCreateView();
305
2b5f62a0
VZ
306private:
307 DECLARE_CLASS(wxDocTemplate)
22f3361e 308 DECLARE_NO_COPY_CLASS(wxDocTemplate)
c801d85f
KB
309};
310
caf0debf
VZ
311// One object of this class may be created in an application, to manage all
312// the templates and documents.
c801d85f
KB
313class WXDLLEXPORT wxDocManager: public wxEvtHandler
314{
caf0debf 315public:
68379eaf 316 wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true);
d3c7fc99 317 virtual ~wxDocManager();
caf0debf
VZ
318
319 virtual bool Initialize();
320
321 // Handlers for common user commands
322 void OnFileClose(wxCommandEvent& event);
33a20136 323 void OnFileCloseAll(wxCommandEvent& event);
caf0debf
VZ
324 void OnFileNew(wxCommandEvent& event);
325 void OnFileOpen(wxCommandEvent& event);
326 void OnFileRevert(wxCommandEvent& event);
327 void OnFileSave(wxCommandEvent& event);
328 void OnFileSaveAs(wxCommandEvent& event);
329 void OnPrint(wxCommandEvent& event);
caf0debf
VZ
330 void OnPreview(wxCommandEvent& event);
331 void OnUndo(wxCommandEvent& event);
332 void OnRedo(wxCommandEvent& event);
333
f2506310
JS
334 // Handlers for UI update commands
335 void OnUpdateFileOpen(wxUpdateUIEvent& event);
336 void OnUpdateFileClose(wxUpdateUIEvent& event);
337 void OnUpdateFileRevert(wxUpdateUIEvent& event);
338 void OnUpdateFileNew(wxUpdateUIEvent& event);
339 void OnUpdateFileSave(wxUpdateUIEvent& event);
340 void OnUpdateFileSaveAs(wxUpdateUIEvent& event);
341 void OnUpdateUndo(wxUpdateUIEvent& event);
342 void OnUpdateRedo(wxUpdateUIEvent& event);
343
344 void OnUpdatePrint(wxUpdateUIEvent& event);
f2506310
JS
345 void OnUpdatePreview(wxUpdateUIEvent& event);
346
caf0debf
VZ
347 // Extend event processing to search the view's event table
348 virtual bool ProcessEvent(wxEvent& event);
349
5f170f33
VZ
350 // called when file format detection didn't work, can be overridden to do
351 // something in this case
0a0352f2 352 virtual void OnOpenFileFailure() { }
5f170f33 353
caf0debf
VZ
354 virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
355 virtual wxView *CreateView(wxDocument *doc, long flags = 0);
356 virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
357 virtual bool FlushDoc(wxDocument *doc);
358 virtual wxDocTemplate *MatchTemplate(const wxString& path);
359 virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates,
68379eaf 360 int noTemplates, wxString& path, long flags, bool save = false);
caf0debf 361 virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates,
68379eaf 362 int noTemplates, bool sort = false);
caf0debf 363 virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
68379eaf 364 int noTemplates, bool sort = false);
caf0debf
VZ
365 virtual wxDocTemplate *FindTemplateForPath(const wxString& path);
366
367 void AssociateTemplate(wxDocTemplate *temp);
368 void DisassociateTemplate(wxDocTemplate *temp);
369
370 wxDocument *GetCurrentDocument() const;
371
372 void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
373 int GetMaxDocsOpen() const { return m_maxDocsOpen; }
374
375 // Add and remove a document from the manager's list
376 void AddDocument(wxDocument *doc);
377 void RemoveDocument(wxDocument *doc);
378
33a20136 379 // closes all currently open documents
68379eaf 380 bool CloseDocuments(bool force = true);
33a20136 381
b72b1920 382 // closes the specified document
68379eaf 383 bool CloseDocument(wxDocument* doc, bool force = false);
b72b1920 384
caf0debf 385 // Clear remaining documents and templates
68379eaf 386 bool Clear(bool force = true);
caf0debf
VZ
387
388 // Views or windows should inform the document manager
389 // when a view is going in or out of focus
68379eaf 390 virtual void ActivateView(wxView *view, bool activate = true);
caf0debf
VZ
391 virtual wxView *GetCurrentView() const;
392
0b237b67
JS
393 wxList& GetDocuments() { return m_docs; }
394 wxList& GetTemplates() { return m_templates; }
caf0debf
VZ
395
396 // Make a default document name
397 virtual bool MakeDefaultName(wxString& buf);
398
f2506310
JS
399 // Make a frame title (override this to do something different)
400 virtual wxString MakeFrameTitle(wxDocument* doc);
401
caf0debf
VZ
402 virtual wxFileHistory *OnCreateFileHistory();
403 virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
404
405 // File history management
406 virtual void AddFileToHistory(const wxString& file);
e49c85af 407 virtual void RemoveFileFromHistory(size_t i);
7af6b69e 408 virtual size_t GetHistoryFilesCount() const;
e49c85af 409 virtual wxString GetHistoryFile(size_t i) const;
caf0debf
VZ
410 virtual void FileHistoryUseMenu(wxMenu *menu);
411 virtual void FileHistoryRemoveMenu(wxMenu *menu);
702ca7c0 412#if wxUSE_CONFIG
caf0debf
VZ
413 virtual void FileHistoryLoad(wxConfigBase& config);
414 virtual void FileHistorySave(wxConfigBase& config);
415#endif // wxUSE_CONFIG
416
417 virtual void FileHistoryAddFilesToMenu();
418 virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
419
7af6b69e
VZ
420 wxString GetLastDirectory() const { return m_lastDirectory; }
421 void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
ac0ac824 422
f2506310
JS
423 // Get the current document manager
424 static wxDocManager* GetDocumentManager() { return sm_docManager; }
425
ca3e85cf 426#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
427 // deprecated, use GetHistoryFilesCount() instead
428 wxDEPRECATED( size_t GetNoHistoryFiles() const );
ca3e85cf 429#endif // WXWIN_COMPATIBILITY_2_6
7af6b69e 430
caf0debf
VZ
431protected:
432 long m_flags;
433 int m_defaultDocumentNameCounter;
434 int m_maxDocsOpen;
435 wxList m_docs;
436 wxList m_templates;
437 wxView* m_currentView;
438 wxFileHistory* m_fileHistory;
ac0ac824 439 wxString m_lastDirectory;
f2506310 440 static wxDocManager* sm_docManager;
caf0debf
VZ
441
442 DECLARE_EVENT_TABLE()
b5f159ac 443 DECLARE_DYNAMIC_CLASS(wxDocManager)
22f3361e 444 DECLARE_NO_COPY_CLASS(wxDocManager)
c801d85f
KB
445};
446
ca3e85cf 447#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
448inline size_t wxDocManager::GetNoHistoryFiles() const
449{
450 return GetHistoryFilesCount();
451}
ca3e85cf 452#endif // WXWIN_COMPATIBILITY_2_6
b5f159ac 453
caf0debf
VZ
454// ----------------------------------------------------------------------------
455// A default child frame
456// ----------------------------------------------------------------------------
c801d85f 457
caf0debf 458class WXDLLEXPORT wxDocChildFrame : public wxFrame
c801d85f 459{
caf0debf
VZ
460public:
461 wxDocChildFrame(wxDocument *doc,
462 wxView *view,
463 wxFrame *frame,
464 wxWindowID id,
465 const wxString& title,
466 const wxPoint& pos = wxDefaultPosition,
467 const wxSize& size = wxDefaultSize,
468 long type = wxDEFAULT_FRAME_STYLE,
2b5f62a0 469 const wxString& name = wxT("frame"));
d3c7fc99 470 virtual ~wxDocChildFrame(){}
caf0debf
VZ
471
472 // Extend event processing to search the view's event table
473 virtual bool ProcessEvent(wxEvent& event);
474
475 void OnActivate(wxActivateEvent& event);
476 void OnCloseWindow(wxCloseEvent& event);
477
478 wxDocument *GetDocument() const { return m_childDocument; }
479 wxView *GetView() const { return m_childView; }
480 void SetDocument(wxDocument *doc) { m_childDocument = doc; }
481 void SetView(wxView *view) { m_childView = view; }
0d8737fd 482 bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); }
caf0debf
VZ
483
484protected:
485 wxDocument* m_childDocument;
486 wxView* m_childView;
487
2b5f62a0
VZ
488private:
489 DECLARE_CLASS(wxDocChildFrame)
caf0debf 490 DECLARE_EVENT_TABLE()
22f3361e 491 DECLARE_NO_COPY_CLASS(wxDocChildFrame)
caf0debf 492};
c801d85f 493
caf0debf
VZ
494// ----------------------------------------------------------------------------
495// A default parent frame
496// ----------------------------------------------------------------------------
c801d85f 497
caf0debf
VZ
498class WXDLLEXPORT wxDocParentFrame : public wxFrame
499{
caf0debf 500public:
0c246b3c 501 wxDocParentFrame();
caf0debf
VZ
502 wxDocParentFrame(wxDocManager *manager,
503 wxFrame *frame,
504 wxWindowID id,
505 const wxString& title,
506 const wxPoint& pos = wxDefaultPosition,
507 const wxSize& size = wxDefaultSize,
0c246b3c
PC
508 long style = wxDEFAULT_FRAME_STYLE,
509 const wxString& name = wxFrameNameStr);
510
511 bool Create(wxDocManager *manager,
512 wxFrame *frame,
513 wxWindowID id,
514 const wxString& title,
515 const wxPoint& pos = wxDefaultPosition,
516 const wxSize& size = wxDefaultSize,
517 long style = wxDEFAULT_FRAME_STYLE,
518 const wxString& name = wxFrameNameStr);
c801d85f 519
caf0debf
VZ
520 // Extend event processing to search the document manager's event table
521 virtual bool ProcessEvent(wxEvent& event);
c801d85f 522
caf0debf 523 wxDocManager *GetDocumentManager() const { return m_docManager; }
c801d85f 524
caf0debf
VZ
525 void OnExit(wxCommandEvent& event);
526 void OnMRUFile(wxCommandEvent& event);
527 void OnCloseWindow(wxCloseEvent& event);
c801d85f 528
caf0debf
VZ
529protected:
530 wxDocManager *m_docManager;
531
2b5f62a0 532private:
0c246b3c 533 typedef wxFrame base_type;
2b5f62a0 534 DECLARE_CLASS(wxDocParentFrame)
caf0debf 535 DECLARE_EVENT_TABLE()
22f3361e 536 DECLARE_NO_COPY_CLASS(wxDocParentFrame)
caf0debf 537};
c801d85f 538
caf0debf
VZ
539// ----------------------------------------------------------------------------
540// Provide simple default printing facilities
541// ----------------------------------------------------------------------------
c801d85f 542
caf0debf
VZ
543#if wxUSE_PRINTING_ARCHITECTURE
544class WXDLLEXPORT wxDocPrintout : public wxPrintout
545{
caf0debf 546public:
2b5f62a0 547 wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout"));
caf0debf
VZ
548 bool OnPrintPage(int page);
549 bool HasPage(int page);
550 bool OnBeginDocument(int startPage, int endPage);
551 void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
c801d85f 552
caf0debf 553 virtual wxView *GetView() { return m_printoutView; }
c801d85f 554
caf0debf
VZ
555protected:
556 wxView* m_printoutView;
2b5f62a0
VZ
557
558private:
559 DECLARE_DYNAMIC_CLASS(wxDocPrintout)
22f3361e 560 DECLARE_NO_COPY_CLASS(wxDocPrintout)
c801d85f 561};
caf0debf 562#endif // wxUSE_PRINTING_ARCHITECTURE
c801d85f 563
caf0debf 564// ----------------------------------------------------------------------------
7f555861 565// File history management
caf0debf 566// ----------------------------------------------------------------------------
7f555861 567
caf0debf 568class WXDLLEXPORT wxFileHistory : public wxObject
c801d85f 569{
caf0debf 570public:
e49c85af 571 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
d3c7fc99 572 virtual ~wxFileHistory();
7f555861 573
caf0debf
VZ
574 // Operations
575 virtual void AddFileToHistory(const wxString& file);
e49c85af 576 virtual void RemoveFileFromHistory(size_t i);
37c2aa46 577 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; }
caf0debf 578 virtual void UseMenu(wxMenu *menu);
7f555861 579
caf0debf
VZ
580 // Remove menu from the list (MDI child may be closing)
581 virtual void RemoveMenu(wxMenu *menu);
7f555861 582
caf0debf
VZ
583#if wxUSE_CONFIG
584 virtual void Load(wxConfigBase& config);
585 virtual void Save(wxConfigBase& config);
586#endif // wxUSE_CONFIG
587
588 virtual void AddFilesToMenu();
589 virtual void AddFilesToMenu(wxMenu* menu); // Single menu
590
591 // Accessors
e49c85af 592 virtual wxString GetHistoryFile(size_t i) const;
e49c85af 593 virtual size_t GetCount() const { return m_fileHistoryN; }
caf0debf 594
ae500232 595 const wxList& GetMenus() const { return m_fileMenus; }
caf0debf 596
ca3e85cf 597#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
598 // deprecated, use GetCount() instead
599 wxDEPRECATED( size_t GetNoHistoryFiles() const );
ca3e85cf 600#endif // WXWIN_COMPATIBILITY_2_6
7af6b69e 601
caf0debf
VZ
602protected:
603 // Last n files
604 wxChar** m_fileHistory;
605 // Number of files saved
e49c85af 606 size_t m_fileHistoryN;
caf0debf
VZ
607 // Menus to maintain (may need several for an MDI app)
608 wxList m_fileMenus;
609 // Max files to maintain
e49c85af 610 size_t m_fileMaxFiles;
b5f159ac 611
2b5f62a0 612private:
e49c85af
VZ
613 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
614 wxWindowID m_idBase;
615
2b5f62a0 616 DECLARE_DYNAMIC_CLASS(wxFileHistory)
22f3361e 617 DECLARE_NO_COPY_CLASS(wxFileHistory)
c801d85f
KB
618};
619
ca3e85cf 620#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
621inline size_t wxFileHistory::GetNoHistoryFiles() const
622{
623 return m_fileHistoryN;
624}
ca3e85cf 625#endif // WXWIN_COMPATIBILITY_2_6
b5f159ac 626
a533f5c1 627#if wxUSE_STD_IOSTREAM
c801d85f
KB
628// For compatibility with existing file formats:
629// converts from/to a stream to/from a temporary file.
dd107c50
VZ
630bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
631bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
dc1efb1d
JS
632#else
633// For compatibility with existing file formats:
634// converts from/to a stream to/from a temporary file.
635bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
636bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
e30285ab
VZ
637#endif // wxUSE_STD_IOSTREAM
638
639#endif // wxUSE_DOC_VIEW_ARCHITECTURE
c801d85f 640
caf0debf 641#endif // _WX_DOCH__