]> git.saurik.com Git - wxWidgets.git/blame - include/wx/docview.h
Fixed wxWindowOS2::Reparent.
[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
b5dbe15d
VS
27class WXDLLIMPEXP_FWD_CORE wxWindow;
28class WXDLLIMPEXP_FWD_CORE wxDocument;
29class WXDLLIMPEXP_FWD_CORE wxView;
30class WXDLLIMPEXP_FWD_CORE wxDocTemplate;
31class WXDLLIMPEXP_FWD_CORE wxDocManager;
32class WXDLLIMPEXP_FWD_CORE wxPrintInfo;
33class WXDLLIMPEXP_FWD_CORE wxCommandProcessor;
34class WXDLLIMPEXP_FWD_CORE wxFileHistory;
4f7d425f 35class WXDLLIMPEXP_FWD_BASE 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 62
53a2db12 63class WXDLLIMPEXP_CORE wxDocument : public wxEvtHandler
c801d85f 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
47b378bd 73 void SetTitle(const wxString& title) { m_documentTitle = title; }
caf0debf
VZ
74 wxString GetTitle() const { return m_documentTitle; }
75
47b378bd 76 void SetDocumentName(const wxString& name) { m_documentTypeName = name; }
caf0debf
VZ
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
724b119a
VZ
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
caf0debf
VZ
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
159protected:
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;
b5f159ac 169
69936aea
VZ
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
724b119a
VZ
176 // the default implementation of GetUserReadableName()
177 wxString DoGetUserReadableName() const;
178
2b5f62a0
VZ
179private:
180 DECLARE_ABSTRACT_CLASS(wxDocument)
22f3361e 181 DECLARE_NO_COPY_CLASS(wxDocument)
c801d85f
KB
182};
183
53a2db12 184class WXDLLIMPEXP_CORE wxView: public wxEvtHandler
c801d85f 185{
caf0debf
VZ
186public:
187 // wxView(wxDocument *doc = (wxDocument *) NULL);
188 wxView();
d3c7fc99 189 virtual ~wxView();
c801d85f 190
caf0debf 191 wxDocument *GetDocument() const { return m_viewDocument; }
bb28b477 192 virtual void SetDocument(wxDocument *doc);
c801d85f 193
caf0debf 194 wxString GetViewName() const { return m_viewTypeName; }
47b378bd 195 void SetViewName(const wxString& name) { m_viewTypeName = name; }
c801d85f 196
b9f933ab
JS
197 wxWindow *GetFrame() const { return m_viewFrame ; }
198 void SetFrame(wxWindow *frame) { m_viewFrame = frame; }
c801d85f 199
caf0debf
VZ
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);
6fb99eb3 204 virtual void OnClosingDocument() {}
caf0debf 205 virtual void OnChangeFilename();
c801d85f 206
caf0debf
VZ
207 // Called by framework if created automatically by the default document
208 // manager class: gives view a chance to initialise
47b378bd 209 virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return true; }
c801d85f 210
caf0debf
VZ
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
68379eaf
WS
213 // true.
214 virtual bool Close(bool deleteWindow = true);
caf0debf
VZ
215
216 // Override to do cleanup/veto close
217 virtual bool OnClose(bool deleteWindow);
2b854a32 218
caf0debf
VZ
219 // Extend event processing to search the document's event table
220 virtual bool ProcessEvent(wxEvent& event);
c801d85f 221
caf0debf
VZ
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);
c801d85f 225
caf0debf
VZ
226 wxDocManager *GetDocumentManager() const
227 { return m_viewDocument->GetDocumentManager(); }
c801d85f 228
47d67540 229#if wxUSE_PRINTING_ARCHITECTURE
caf0debf 230 virtual wxPrintout *OnCreatePrintout();
c801d85f
KB
231#endif
232
caf0debf
VZ
233protected:
234 wxDocument* m_viewDocument;
235 wxString m_viewTypeName;
b9f933ab 236 wxWindow* m_viewFrame;
22f3361e 237
2b5f62a0
VZ
238private:
239 DECLARE_ABSTRACT_CLASS(wxView)
22f3361e 240 DECLARE_NO_COPY_CLASS(wxView)
c801d85f
KB
241};
242
243// Represents user interface (and other) properties of documents and views
53a2db12 244class WXDLLIMPEXP_CORE wxDocTemplate: public wxObject
c801d85f 245{
caf0debf 246
b5dbe15d 247friend class WXDLLIMPEXP_FWD_CORE wxDocManager;
caf0debf
VZ
248
249public:
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
d3c7fc99 263 virtual ~wxDocTemplate();
caf0debf
VZ
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
217b7140
JS
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
47b378bd 275 wxString GetDefaultExtension() const { return m_defaultExt; }
caf0debf 276 wxString GetDescription() const { return m_description; }
47b378bd 277 wxString GetDirectory() const { return m_directory; }
caf0debf
VZ
278 wxDocManager *GetDocumentManager() const { return m_documentManager; }
279 void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; }
47b378bd
VS
280 wxString GetFileFilter() const { return m_fileFilter; }
281 long GetFlags() const { return m_flags; }
caf0debf
VZ
282 virtual wxString GetViewName() const { return m_viewTypeName; }
283 virtual wxString GetDocumentName() const { return m_docTypeName; }
284
47b378bd
VS
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; }
caf0debf
VZ
290
291 bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
292
04129514
JS
293 wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; }
294 wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; }
295
caf0debf
VZ
296 virtual bool FileMatchesTemplate(const wxString& path);
297
298protected:
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;
b5f159ac 311
69936aea
VZ
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
2b5f62a0
VZ
318private:
319 DECLARE_CLASS(wxDocTemplate)
22f3361e 320 DECLARE_NO_COPY_CLASS(wxDocTemplate)
c801d85f
KB
321};
322
caf0debf
VZ
323// One object of this class may be created in an application, to manage all
324// the templates and documents.
53a2db12 325class WXDLLIMPEXP_CORE wxDocManager: public wxEvtHandler
c801d85f 326{
caf0debf 327public:
68379eaf 328 wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true);
d3c7fc99 329 virtual ~wxDocManager();
caf0debf
VZ
330
331 virtual bool Initialize();
332
333 // Handlers for common user commands
334 void OnFileClose(wxCommandEvent& event);
33a20136 335 void OnFileCloseAll(wxCommandEvent& event);
caf0debf
VZ
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);
caf0debf
VZ
342 void OnPreview(wxCommandEvent& event);
343 void OnUndo(wxCommandEvent& event);
344 void OnRedo(wxCommandEvent& event);
345
f2506310
JS
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);
f2506310
JS
357 void OnUpdatePreview(wxUpdateUIEvent& event);
358
caf0debf
VZ
359 // Extend event processing to search the view's event table
360 virtual bool ProcessEvent(wxEvent& event);
361
5f170f33
VZ
362 // called when file format detection didn't work, can be overridden to do
363 // something in this case
0a0352f2 364 virtual void OnOpenFileFailure() { }
5f170f33 365
caf0debf
VZ
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,
68379eaf 372 int noTemplates, wxString& path, long flags, bool save = false);
caf0debf 373 virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates,
68379eaf 374 int noTemplates, bool sort = false);
caf0debf 375 virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
68379eaf 376 int noTemplates, bool sort = false);
caf0debf
VZ
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
33a20136 391 // closes all currently open documents
68379eaf 392 bool CloseDocuments(bool force = true);
33a20136 393
b72b1920 394 // closes the specified document
68379eaf 395 bool CloseDocument(wxDocument* doc, bool force = false);
b72b1920 396
caf0debf 397 // Clear remaining documents and templates
68379eaf 398 bool Clear(bool force = true);
caf0debf
VZ
399
400 // Views or windows should inform the document manager
401 // when a view is going in or out of focus
68379eaf 402 virtual void ActivateView(wxView *view, bool activate = true);
caf0debf
VZ
403 virtual wxView *GetCurrentView() const;
404
0b237b67
JS
405 wxList& GetDocuments() { return m_docs; }
406 wxList& GetTemplates() { return m_templates; }
caf0debf 407
724b119a
VZ
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();
caf0debf 411
f2506310
JS
412 // Make a frame title (override this to do something different)
413 virtual wxString MakeFrameTitle(wxDocument* doc);
414
caf0debf
VZ
415 virtual wxFileHistory *OnCreateFileHistory();
416 virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
417
418 // File history management
419 virtual void AddFileToHistory(const wxString& file);
e49c85af 420 virtual void RemoveFileFromHistory(size_t i);
7af6b69e 421 virtual size_t GetHistoryFilesCount() const;
e49c85af 422 virtual wxString GetHistoryFile(size_t i) const;
caf0debf
VZ
423 virtual void FileHistoryUseMenu(wxMenu *menu);
424 virtual void FileHistoryRemoveMenu(wxMenu *menu);
702ca7c0 425#if wxUSE_CONFIG
9c8116f8 426 virtual void FileHistoryLoad(const wxConfigBase& config);
caf0debf
VZ
427 virtual void FileHistorySave(wxConfigBase& config);
428#endif // wxUSE_CONFIG
429
430 virtual void FileHistoryAddFilesToMenu();
431 virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
432
7af6b69e
VZ
433 wxString GetLastDirectory() const { return m_lastDirectory; }
434 void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
ac0ac824 435
f2506310
JS
436 // Get the current document manager
437 static wxDocManager* GetDocumentManager() { return sm_docManager; }
438
724b119a
VZ
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
ca3e85cf 446#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
447 // deprecated, use GetHistoryFilesCount() instead
448 wxDEPRECATED( size_t GetNoHistoryFiles() const );
ca3e85cf 449#endif // WXWIN_COMPATIBILITY_2_6
7af6b69e 450
caf0debf
VZ
451protected:
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;
ac0ac824 459 wxString m_lastDirectory;
f2506310 460 static wxDocManager* sm_docManager;
caf0debf
VZ
461
462 DECLARE_EVENT_TABLE()
b5f159ac 463 DECLARE_DYNAMIC_CLASS(wxDocManager)
22f3361e 464 DECLARE_NO_COPY_CLASS(wxDocManager)
c801d85f
KB
465};
466
ca3e85cf 467#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
468inline size_t wxDocManager::GetNoHistoryFiles() const
469{
470 return GetHistoryFilesCount();
471}
ca3e85cf 472#endif // WXWIN_COMPATIBILITY_2_6
b5f159ac 473
caf0debf
VZ
474// ----------------------------------------------------------------------------
475// A default child frame
476// ----------------------------------------------------------------------------
c801d85f 477
53a2db12 478class WXDLLIMPEXP_CORE wxDocChildFrame : public wxFrame
c801d85f 479{
caf0debf
VZ
480public:
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,
2b5f62a0 489 const wxString& name = wxT("frame"));
d3c7fc99 490 virtual ~wxDocChildFrame(){}
caf0debf
VZ
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; }
0d8737fd 502 bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); }
caf0debf
VZ
503
504protected:
505 wxDocument* m_childDocument;
506 wxView* m_childView;
507
2b5f62a0
VZ
508private:
509 DECLARE_CLASS(wxDocChildFrame)
caf0debf 510 DECLARE_EVENT_TABLE()
22f3361e 511 DECLARE_NO_COPY_CLASS(wxDocChildFrame)
caf0debf 512};
c801d85f 513
caf0debf
VZ
514// ----------------------------------------------------------------------------
515// A default parent frame
516// ----------------------------------------------------------------------------
c801d85f 517
53a2db12 518class WXDLLIMPEXP_CORE wxDocParentFrame : public wxFrame
caf0debf 519{
caf0debf 520public:
0c246b3c 521 wxDocParentFrame();
caf0debf
VZ
522 wxDocParentFrame(wxDocManager *manager,
523 wxFrame *frame,
524 wxWindowID id,
525 const wxString& title,
526 const wxPoint& pos = wxDefaultPosition,
527 const wxSize& size = wxDefaultSize,
0c246b3c
PC
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);
c801d85f 539
caf0debf
VZ
540 // Extend event processing to search the document manager's event table
541 virtual bool ProcessEvent(wxEvent& event);
c801d85f 542
caf0debf 543 wxDocManager *GetDocumentManager() const { return m_docManager; }
c801d85f 544
caf0debf
VZ
545 void OnExit(wxCommandEvent& event);
546 void OnMRUFile(wxCommandEvent& event);
547 void OnCloseWindow(wxCloseEvent& event);
c801d85f 548
caf0debf
VZ
549protected:
550 wxDocManager *m_docManager;
551
2b5f62a0 552private:
0c246b3c 553 typedef wxFrame base_type;
2b5f62a0 554 DECLARE_CLASS(wxDocParentFrame)
caf0debf 555 DECLARE_EVENT_TABLE()
22f3361e 556 DECLARE_NO_COPY_CLASS(wxDocParentFrame)
caf0debf 557};
c801d85f 558
caf0debf
VZ
559// ----------------------------------------------------------------------------
560// Provide simple default printing facilities
561// ----------------------------------------------------------------------------
c801d85f 562
caf0debf 563#if wxUSE_PRINTING_ARCHITECTURE
53a2db12 564class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout
caf0debf 565{
caf0debf 566public:
2b5f62a0 567 wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout"));
caf0debf
VZ
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);
c801d85f 572
caf0debf 573 virtual wxView *GetView() { return m_printoutView; }
c801d85f 574
caf0debf
VZ
575protected:
576 wxView* m_printoutView;
2b5f62a0
VZ
577
578private:
579 DECLARE_DYNAMIC_CLASS(wxDocPrintout)
22f3361e 580 DECLARE_NO_COPY_CLASS(wxDocPrintout)
c801d85f 581};
caf0debf 582#endif // wxUSE_PRINTING_ARCHITECTURE
c801d85f 583
caf0debf 584// ----------------------------------------------------------------------------
7f555861 585// File history management
caf0debf 586// ----------------------------------------------------------------------------
7f555861 587
53a2db12 588class WXDLLIMPEXP_CORE wxFileHistory : public wxObject
c801d85f 589{
caf0debf 590public:
e49c85af 591 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
d3c7fc99 592 virtual ~wxFileHistory();
7f555861 593
caf0debf
VZ
594 // Operations
595 virtual void AddFileToHistory(const wxString& file);
e49c85af 596 virtual void RemoveFileFromHistory(size_t i);
37c2aa46 597 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; }
caf0debf 598 virtual void UseMenu(wxMenu *menu);
7f555861 599
caf0debf
VZ
600 // Remove menu from the list (MDI child may be closing)
601 virtual void RemoveMenu(wxMenu *menu);
7f555861 602
caf0debf 603#if wxUSE_CONFIG
9c8116f8 604 virtual void Load(const wxConfigBase& config);
caf0debf
VZ
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
b4a980f4
VZ
612 virtual wxString GetHistoryFile(size_t i) const { return m_fileHistory[i]; }
613 virtual size_t GetCount() const { return m_fileHistory.GetCount(); }
caf0debf 614
ae500232 615 const wxList& GetMenus() const { return m_fileMenus; }
caf0debf 616
fc2b0e31 617 // Set/get base id
5d389b04
JS
618 void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
619 wxWindowID GetBaseId() const { return m_idBase; }
620
ca3e85cf 621#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
622 // deprecated, use GetCount() instead
623 wxDEPRECATED( size_t GetNoHistoryFiles() const );
ca3e85cf 624#endif // WXWIN_COMPATIBILITY_2_6
7af6b69e 625
caf0debf
VZ
626protected:
627 // Last n files
b4a980f4
VZ
628 wxArrayString m_fileHistory;
629
caf0debf
VZ
630 // Menus to maintain (may need several for an MDI app)
631 wxList m_fileMenus;
b4a980f4 632
caf0debf 633 // Max files to maintain
e49c85af 634 size_t m_fileMaxFiles;
b5f159ac 635
2b5f62a0 636private:
e49c85af
VZ
637 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
638 wxWindowID m_idBase;
639
2b5f62a0 640 DECLARE_DYNAMIC_CLASS(wxFileHistory)
22f3361e 641 DECLARE_NO_COPY_CLASS(wxFileHistory)
c801d85f
KB
642};
643
ca3e85cf 644#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
645inline size_t wxFileHistory::GetNoHistoryFiles() const
646{
8e4ac1a0 647 return m_fileHistory.GetCount();
b5f159ac 648}
ca3e85cf 649#endif // WXWIN_COMPATIBILITY_2_6
b5f159ac 650
a533f5c1 651#if wxUSE_STD_IOSTREAM
c801d85f
KB
652// For compatibility with existing file formats:
653// converts from/to a stream to/from a temporary file.
53a2db12
FM
654bool WXDLLIMPEXP_CORE wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
655bool WXDLLIMPEXP_CORE wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
dc1efb1d
JS
656#else
657// For compatibility with existing file formats:
658// converts from/to a stream to/from a temporary file.
53a2db12
FM
659bool WXDLLIMPEXP_CORE wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
660bool WXDLLIMPEXP_CORE wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
e30285ab
VZ
661#endif // wxUSE_STD_IOSTREAM
662
663#endif // wxUSE_DOC_VIEW_ARCHITECTURE
c801d85f 664
caf0debf 665#endif // _WX_DOCH__