]> git.saurik.com Git - wxWidgets.git/blame - include/wx/docview.h
Added CmdDown() to grid events
[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
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
ca3e85cf 427#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
428 // deprecated, use GetHistoryFilesCount() instead
429 wxDEPRECATED( size_t GetNoHistoryFiles() const );
ca3e85cf 430#endif // WXWIN_COMPATIBILITY_2_6
7af6b69e 431
caf0debf
VZ
432protected:
433 long m_flags;
434 int m_defaultDocumentNameCounter;
435 int m_maxDocsOpen;
436 wxList m_docs;
437 wxList m_templates;
438 wxView* m_currentView;
439 wxFileHistory* m_fileHistory;
ac0ac824 440 wxString m_lastDirectory;
f2506310 441 static wxDocManager* sm_docManager;
caf0debf
VZ
442
443 DECLARE_EVENT_TABLE()
b5f159ac 444 DECLARE_DYNAMIC_CLASS(wxDocManager)
22f3361e 445 DECLARE_NO_COPY_CLASS(wxDocManager)
c801d85f
KB
446};
447
ca3e85cf 448#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
449inline size_t wxDocManager::GetNoHistoryFiles() const
450{
451 return GetHistoryFilesCount();
452}
ca3e85cf 453#endif // WXWIN_COMPATIBILITY_2_6
b5f159ac 454
caf0debf
VZ
455// ----------------------------------------------------------------------------
456// A default child frame
457// ----------------------------------------------------------------------------
c801d85f 458
caf0debf 459class WXDLLEXPORT wxDocChildFrame : public wxFrame
c801d85f 460{
caf0debf
VZ
461public:
462 wxDocChildFrame(wxDocument *doc,
463 wxView *view,
464 wxFrame *frame,
465 wxWindowID id,
466 const wxString& title,
467 const wxPoint& pos = wxDefaultPosition,
468 const wxSize& size = wxDefaultSize,
469 long type = wxDEFAULT_FRAME_STYLE,
2b5f62a0 470 const wxString& name = wxT("frame"));
1b941f2d 471 ~wxDocChildFrame(){}
caf0debf
VZ
472
473 // Extend event processing to search the view's event table
474 virtual bool ProcessEvent(wxEvent& event);
475
476 void OnActivate(wxActivateEvent& event);
477 void OnCloseWindow(wxCloseEvent& event);
478
479 wxDocument *GetDocument() const { return m_childDocument; }
480 wxView *GetView() const { return m_childView; }
481 void SetDocument(wxDocument *doc) { m_childDocument = doc; }
482 void SetView(wxView *view) { m_childView = view; }
0d8737fd 483 bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); }
caf0debf
VZ
484
485protected:
486 wxDocument* m_childDocument;
487 wxView* m_childView;
488
2b5f62a0
VZ
489private:
490 DECLARE_CLASS(wxDocChildFrame)
caf0debf 491 DECLARE_EVENT_TABLE()
22f3361e 492 DECLARE_NO_COPY_CLASS(wxDocChildFrame)
caf0debf 493};
c801d85f 494
caf0debf
VZ
495// ----------------------------------------------------------------------------
496// A default parent frame
497// ----------------------------------------------------------------------------
c801d85f 498
caf0debf
VZ
499class WXDLLEXPORT wxDocParentFrame : public wxFrame
500{
caf0debf
VZ
501public:
502 wxDocParentFrame(wxDocManager *manager,
503 wxFrame *frame,
504 wxWindowID id,
505 const wxString& title,
506 const wxPoint& pos = wxDefaultPosition,
507 const wxSize& size = wxDefaultSize,
508 long type = wxDEFAULT_FRAME_STYLE,
2b5f62a0 509 const wxString& name = wxT("frame"));
c801d85f 510
caf0debf
VZ
511 // Extend event processing to search the document manager's event table
512 virtual bool ProcessEvent(wxEvent& event);
c801d85f 513
caf0debf 514 wxDocManager *GetDocumentManager() const { return m_docManager; }
c801d85f 515
caf0debf
VZ
516 void OnExit(wxCommandEvent& event);
517 void OnMRUFile(wxCommandEvent& event);
518 void OnCloseWindow(wxCloseEvent& event);
c801d85f 519
caf0debf
VZ
520protected:
521 wxDocManager *m_docManager;
522
2b5f62a0
VZ
523private:
524 DECLARE_CLASS(wxDocParentFrame)
caf0debf 525 DECLARE_EVENT_TABLE()
22f3361e 526 DECLARE_NO_COPY_CLASS(wxDocParentFrame)
caf0debf 527};
c801d85f 528
caf0debf
VZ
529// ----------------------------------------------------------------------------
530// Provide simple default printing facilities
531// ----------------------------------------------------------------------------
c801d85f 532
caf0debf
VZ
533#if wxUSE_PRINTING_ARCHITECTURE
534class WXDLLEXPORT wxDocPrintout : public wxPrintout
535{
caf0debf 536public:
2b5f62a0 537 wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout"));
caf0debf
VZ
538 bool OnPrintPage(int page);
539 bool HasPage(int page);
540 bool OnBeginDocument(int startPage, int endPage);
541 void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
c801d85f 542
caf0debf 543 virtual wxView *GetView() { return m_printoutView; }
c801d85f 544
caf0debf
VZ
545protected:
546 wxView* m_printoutView;
2b5f62a0
VZ
547
548private:
549 DECLARE_DYNAMIC_CLASS(wxDocPrintout)
22f3361e 550 DECLARE_NO_COPY_CLASS(wxDocPrintout)
c801d85f 551};
caf0debf 552#endif // wxUSE_PRINTING_ARCHITECTURE
c801d85f 553
caf0debf 554// ----------------------------------------------------------------------------
7f555861 555// File history management
caf0debf 556// ----------------------------------------------------------------------------
7f555861 557
caf0debf 558class WXDLLEXPORT wxFileHistory : public wxObject
c801d85f 559{
caf0debf 560public:
e49c85af 561 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
caf0debf 562 ~wxFileHistory();
7f555861 563
caf0debf
VZ
564 // Operations
565 virtual void AddFileToHistory(const wxString& file);
e49c85af 566 virtual void RemoveFileFromHistory(size_t i);
37c2aa46 567 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; }
caf0debf 568 virtual void UseMenu(wxMenu *menu);
7f555861 569
caf0debf
VZ
570 // Remove menu from the list (MDI child may be closing)
571 virtual void RemoveMenu(wxMenu *menu);
7f555861 572
caf0debf
VZ
573#if wxUSE_CONFIG
574 virtual void Load(wxConfigBase& config);
575 virtual void Save(wxConfigBase& config);
576#endif // wxUSE_CONFIG
577
578 virtual void AddFilesToMenu();
579 virtual void AddFilesToMenu(wxMenu* menu); // Single menu
580
581 // Accessors
e49c85af 582 virtual wxString GetHistoryFile(size_t i) const;
e49c85af 583 virtual size_t GetCount() const { return m_fileHistoryN; }
caf0debf 584
ae500232 585 const wxList& GetMenus() const { return m_fileMenus; }
caf0debf 586
ca3e85cf 587#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
588 // deprecated, use GetCount() instead
589 wxDEPRECATED( size_t GetNoHistoryFiles() const );
ca3e85cf 590#endif // WXWIN_COMPATIBILITY_2_6
7af6b69e 591
caf0debf
VZ
592protected:
593 // Last n files
594 wxChar** m_fileHistory;
595 // Number of files saved
e49c85af 596 size_t m_fileHistoryN;
caf0debf
VZ
597 // Menus to maintain (may need several for an MDI app)
598 wxList m_fileMenus;
599 // Max files to maintain
e49c85af 600 size_t m_fileMaxFiles;
b5f159ac 601
2b5f62a0 602private:
e49c85af
VZ
603 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
604 wxWindowID m_idBase;
605
2b5f62a0 606 DECLARE_DYNAMIC_CLASS(wxFileHistory)
22f3361e 607 DECLARE_NO_COPY_CLASS(wxFileHistory)
c801d85f
KB
608};
609
ca3e85cf 610#if WXWIN_COMPATIBILITY_2_6
b5f159ac
VZ
611inline size_t wxFileHistory::GetNoHistoryFiles() const
612{
613 return m_fileHistoryN;
614}
ca3e85cf 615#endif // WXWIN_COMPATIBILITY_2_6
b5f159ac 616
a533f5c1 617#if wxUSE_STD_IOSTREAM
c801d85f
KB
618// For compatibility with existing file formats:
619// converts from/to a stream to/from a temporary file.
dd107c50
VZ
620bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
621bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
dc1efb1d
JS
622#else
623// For compatibility with existing file formats:
624// converts from/to a stream to/from a temporary file.
625bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
626bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
e30285ab
VZ
627#endif // wxUSE_STD_IOSTREAM
628
629#endif // wxUSE_DOC_VIEW_ARCHITECTURE
c801d85f 630
caf0debf 631#endif // _WX_DOCH__