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