]>
Commit | Line | Data |
---|---|---|
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$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DOCH__ | |
13 | #define _WX_DOCH__ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_DOC_VIEW_ARCHITECTURE | |
18 | ||
19 | #include "wx/list.h" | |
20 | #include "wx/cmndata.h" | |
21 | #include "wx/string.h" | |
22 | #include "wx/frame.h" | |
23 | ||
24 | #if wxUSE_PRINTING_ARCHITECTURE | |
25 | #include "wx/print.h" | |
26 | #endif | |
27 | ||
28 | class WXDLLEXPORT wxWindow; | |
29 | class WXDLLEXPORT wxDocument; | |
30 | class WXDLLEXPORT wxView; | |
31 | class WXDLLEXPORT wxDocTemplate; | |
32 | class WXDLLEXPORT wxDocManager; | |
33 | class WXDLLEXPORT wxPrintInfo; | |
34 | class WXDLLEXPORT wxCommandProcessor; | |
35 | class WXDLLEXPORT wxFileHistory; | |
36 | class WXDLLEXPORT wxConfigBase; | |
37 | ||
38 | #if wxUSE_STD_IOSTREAM | |
39 | #include "wx/iosfwrap.h" | |
40 | #else | |
41 | #include "wx/stream.h" | |
42 | #endif | |
43 | ||
44 | // Document manager flags | |
45 | enum | |
46 | { | |
47 | wxDOC_SDI = 1, | |
48 | wxDOC_MDI, | |
49 | wxDOC_NEW, | |
50 | wxDOC_SILENT, | |
51 | wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI | |
52 | }; | |
53 | ||
54 | // Document template flags | |
55 | enum | |
56 | { | |
57 | wxTEMPLATE_VISIBLE = 1, | |
58 | wxTEMPLATE_INVISIBLE, | |
59 | wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE | |
60 | }; | |
61 | ||
62 | #define wxMAX_FILE_HISTORY 9 | |
63 | ||
64 | class WXDLLEXPORT wxDocument : public wxEvtHandler | |
65 | { | |
66 | public: | |
67 | wxDocument(wxDocument *parent = (wxDocument *) NULL); | |
68 | ~wxDocument(); | |
69 | ||
70 | // accessors | |
71 | void SetFilename(const wxString& filename, bool notifyViews = false); | |
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; } | |
81 | void SetDocumentSaved(bool saved = true) { m_savedYet = saved; } | |
82 | ||
83 | virtual bool Close(); | |
84 | virtual bool Save(); | |
85 | virtual bool SaveAs(); | |
86 | virtual bool Revert(); | |
87 | ||
88 | #if wxUSE_STD_IOSTREAM | |
89 | virtual wxSTD ostream& SaveObject(wxSTD ostream& stream); | |
90 | virtual wxSTD istream& LoadObject(wxSTD istream& stream); | |
91 | #else | |
92 | virtual wxOutputStream& SaveObject(wxOutputStream& stream); | |
93 | virtual wxInputStream& LoadObject(wxInputStream& stream); | |
94 | #endif | |
95 | ||
96 | // Called by wxWidgets | |
97 | virtual bool OnSaveDocument(const wxString& filename); | |
98 | virtual bool OnOpenDocument(const wxString& filename); | |
99 | virtual bool OnNewDocument(); | |
100 | virtual bool OnCloseDocument(); | |
101 | ||
102 | // Prompts for saving if about to close a modified document. Returns true | |
103 | // if ok to close the document (may have saved in the meantime, or set | |
104 | // modified to false) | |
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); | |
129 | wxList& GetViews() { return m_documentViews; } | |
130 | const wxList& GetViews() const { return m_documentViews; } | |
131 | wxView *GetFirstView() const; | |
132 | ||
133 | virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL); | |
134 | virtual void NotifyClosing(); | |
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 | ||
151 | protected: | |
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; | |
161 | ||
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 | ||
168 | private: | |
169 | DECLARE_ABSTRACT_CLASS(wxDocument) | |
170 | DECLARE_NO_COPY_CLASS(wxDocument) | |
171 | }; | |
172 | ||
173 | class WXDLLEXPORT wxView: public wxEvtHandler | |
174 | { | |
175 | public: | |
176 | // wxView(wxDocument *doc = (wxDocument *) NULL); | |
177 | wxView(); | |
178 | ~wxView(); | |
179 | ||
180 | wxDocument *GetDocument() const { return m_viewDocument; } | |
181 | virtual void SetDocument(wxDocument *doc); | |
182 | ||
183 | wxString GetViewName() const { return m_viewTypeName; } | |
184 | void SetViewName(const wxString& name) { m_viewTypeName = name; }; | |
185 | ||
186 | wxWindow *GetFrame() const { return m_viewFrame ; } | |
187 | void SetFrame(wxWindow *frame) { m_viewFrame = frame; } | |
188 | ||
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); | |
193 | virtual void OnClosingDocument() {} | |
194 | virtual void OnChangeFilename(); | |
195 | ||
196 | // Called by framework if created automatically by the default document | |
197 | // manager class: gives view a chance to initialise | |
198 | virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return true; }; | |
199 | ||
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 | |
202 | // true. | |
203 | virtual bool Close(bool deleteWindow = true); | |
204 | ||
205 | // Override to do cleanup/veto close | |
206 | virtual bool OnClose(bool deleteWindow); | |
207 | ||
208 | // Extend event processing to search the document's event table | |
209 | virtual bool ProcessEvent(wxEvent& event); | |
210 | ||
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); | |
214 | ||
215 | wxDocManager *GetDocumentManager() const | |
216 | { return m_viewDocument->GetDocumentManager(); } | |
217 | ||
218 | #if wxUSE_PRINTING_ARCHITECTURE | |
219 | virtual wxPrintout *OnCreatePrintout(); | |
220 | #endif | |
221 | ||
222 | protected: | |
223 | wxDocument* m_viewDocument; | |
224 | wxString m_viewTypeName; | |
225 | wxWindow* m_viewFrame; | |
226 | ||
227 | private: | |
228 | DECLARE_ABSTRACT_CLASS(wxView) | |
229 | DECLARE_NO_COPY_CLASS(wxView) | |
230 | }; | |
231 | ||
232 | // Represents user interface (and other) properties of documents and views | |
233 | class WXDLLEXPORT wxDocTemplate: public wxObject | |
234 | { | |
235 | ||
236 | friend class WXDLLEXPORT wxDocManager; | |
237 | ||
238 | public: | |
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 | ||
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 | ||
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 | ||
282 | wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; } | |
283 | wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; } | |
284 | ||
285 | virtual bool FileMatchesTemplate(const wxString& path); | |
286 | ||
287 | protected: | |
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; | |
300 | ||
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 | ||
307 | private: | |
308 | DECLARE_CLASS(wxDocTemplate) | |
309 | DECLARE_NO_COPY_CLASS(wxDocTemplate) | |
310 | }; | |
311 | ||
312 | // One object of this class may be created in an application, to manage all | |
313 | // the templates and documents. | |
314 | class WXDLLEXPORT wxDocManager: public wxEvtHandler | |
315 | { | |
316 | public: | |
317 | wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true); | |
318 | ~wxDocManager(); | |
319 | ||
320 | virtual bool Initialize(); | |
321 | ||
322 | // Handlers for common user commands | |
323 | void OnFileClose(wxCommandEvent& event); | |
324 | void OnFileCloseAll(wxCommandEvent& event); | |
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); | |
331 | void OnPreview(wxCommandEvent& event); | |
332 | void OnUndo(wxCommandEvent& event); | |
333 | void OnRedo(wxCommandEvent& event); | |
334 | ||
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); | |
346 | void OnUpdatePreview(wxUpdateUIEvent& event); | |
347 | ||
348 | // Extend event processing to search the view's event table | |
349 | virtual bool ProcessEvent(wxEvent& event); | |
350 | ||
351 | // called when file format detection didn't work, can be overridden to do | |
352 | // something in this case | |
353 | virtual void OnOpenFileFailure() { } | |
354 | ||
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, | |
361 | int noTemplates, wxString& path, long flags, bool save = false); | |
362 | virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates, | |
363 | int noTemplates, bool sort = false); | |
364 | virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates, | |
365 | int noTemplates, bool sort = false); | |
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 | ||
380 | // closes all currently open documents | |
381 | bool CloseDocuments(bool force = true); | |
382 | ||
383 | // closes the specified document | |
384 | bool CloseDocument(wxDocument* doc, bool force = false); | |
385 | ||
386 | // Clear remaining documents and templates | |
387 | bool Clear(bool force = true); | |
388 | ||
389 | // Views or windows should inform the document manager | |
390 | // when a view is going in or out of focus | |
391 | virtual void ActivateView(wxView *view, bool activate = true); | |
392 | virtual wxView *GetCurrentView() const; | |
393 | ||
394 | wxList& GetDocuments() { return m_docs; } | |
395 | wxList& GetTemplates() { return m_templates; } | |
396 | ||
397 | // Make a default document name | |
398 | virtual bool MakeDefaultName(wxString& buf); | |
399 | ||
400 | // Make a frame title (override this to do something different) | |
401 | virtual wxString MakeFrameTitle(wxDocument* doc); | |
402 | ||
403 | virtual wxFileHistory *OnCreateFileHistory(); | |
404 | virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; } | |
405 | ||
406 | // File history management | |
407 | virtual void AddFileToHistory(const wxString& file); | |
408 | virtual void RemoveFileFromHistory(size_t i); | |
409 | virtual size_t GetHistoryFilesCount() const; | |
410 | virtual wxString GetHistoryFile(size_t i) const; | |
411 | virtual void FileHistoryUseMenu(wxMenu *menu); | |
412 | virtual void FileHistoryRemoveMenu(wxMenu *menu); | |
413 | #if wxUSE_CONFIG | |
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 | ||
421 | wxString GetLastDirectory() const { return m_lastDirectory; } | |
422 | void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; } | |
423 | ||
424 | // Get the current document manager | |
425 | static wxDocManager* GetDocumentManager() { return sm_docManager; } | |
426 | ||
427 | // deprecated, use GetHistoryFilesCount() instead | |
428 | wxDEPRECATED( size_t GetNoHistoryFiles() const ); | |
429 | ||
430 | protected: | |
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; | |
438 | wxString m_lastDirectory; | |
439 | static wxDocManager* sm_docManager; | |
440 | ||
441 | DECLARE_EVENT_TABLE() | |
442 | DECLARE_DYNAMIC_CLASS(wxDocManager) | |
443 | DECLARE_NO_COPY_CLASS(wxDocManager) | |
444 | }; | |
445 | ||
446 | inline size_t wxDocManager::GetNoHistoryFiles() const | |
447 | { | |
448 | return GetHistoryFilesCount(); | |
449 | } | |
450 | ||
451 | // ---------------------------------------------------------------------------- | |
452 | // A default child frame | |
453 | // ---------------------------------------------------------------------------- | |
454 | ||
455 | class WXDLLEXPORT wxDocChildFrame : public wxFrame | |
456 | { | |
457 | public: | |
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, | |
466 | const wxString& name = wxT("frame")); | |
467 | ~wxDocChildFrame(){} | |
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; } | |
479 | bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); } | |
480 | ||
481 | protected: | |
482 | wxDocument* m_childDocument; | |
483 | wxView* m_childView; | |
484 | ||
485 | private: | |
486 | DECLARE_CLASS(wxDocChildFrame) | |
487 | DECLARE_EVENT_TABLE() | |
488 | DECLARE_NO_COPY_CLASS(wxDocChildFrame) | |
489 | }; | |
490 | ||
491 | // ---------------------------------------------------------------------------- | |
492 | // A default parent frame | |
493 | // ---------------------------------------------------------------------------- | |
494 | ||
495 | class WXDLLEXPORT wxDocParentFrame : public wxFrame | |
496 | { | |
497 | public: | |
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, | |
505 | const wxString& name = wxT("frame")); | |
506 | ||
507 | // Extend event processing to search the document manager's event table | |
508 | virtual bool ProcessEvent(wxEvent& event); | |
509 | ||
510 | wxDocManager *GetDocumentManager() const { return m_docManager; } | |
511 | ||
512 | void OnExit(wxCommandEvent& event); | |
513 | void OnMRUFile(wxCommandEvent& event); | |
514 | void OnCloseWindow(wxCloseEvent& event); | |
515 | ||
516 | protected: | |
517 | wxDocManager *m_docManager; | |
518 | ||
519 | private: | |
520 | DECLARE_CLASS(wxDocParentFrame) | |
521 | DECLARE_EVENT_TABLE() | |
522 | DECLARE_NO_COPY_CLASS(wxDocParentFrame) | |
523 | }; | |
524 | ||
525 | // ---------------------------------------------------------------------------- | |
526 | // Provide simple default printing facilities | |
527 | // ---------------------------------------------------------------------------- | |
528 | ||
529 | #if wxUSE_PRINTING_ARCHITECTURE | |
530 | class WXDLLEXPORT wxDocPrintout : public wxPrintout | |
531 | { | |
532 | public: | |
533 | wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout")); | |
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); | |
538 | ||
539 | virtual wxView *GetView() { return m_printoutView; } | |
540 | ||
541 | protected: | |
542 | wxView* m_printoutView; | |
543 | ||
544 | private: | |
545 | DECLARE_DYNAMIC_CLASS(wxDocPrintout) | |
546 | DECLARE_NO_COPY_CLASS(wxDocPrintout) | |
547 | }; | |
548 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
549 | ||
550 | // ---------------------------------------------------------------------------- | |
551 | // File history management | |
552 | // ---------------------------------------------------------------------------- | |
553 | ||
554 | class WXDLLEXPORT wxFileHistory : public wxObject | |
555 | { | |
556 | public: | |
557 | wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1); | |
558 | ~wxFileHistory(); | |
559 | ||
560 | // Operations | |
561 | virtual void AddFileToHistory(const wxString& file); | |
562 | virtual void RemoveFileFromHistory(size_t i); | |
563 | virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; } | |
564 | virtual void UseMenu(wxMenu *menu); | |
565 | ||
566 | // Remove menu from the list (MDI child may be closing) | |
567 | virtual void RemoveMenu(wxMenu *menu); | |
568 | ||
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 | |
578 | virtual wxString GetHistoryFile(size_t i) const; | |
579 | virtual size_t GetCount() const { return m_fileHistoryN; } | |
580 | ||
581 | const wxList& GetMenus() const { return m_fileMenus; } | |
582 | ||
583 | // deprecated, use GetCount() instead | |
584 | wxDEPRECATED( size_t GetNoHistoryFiles() const ); | |
585 | ||
586 | protected: | |
587 | // Last n files | |
588 | wxChar** m_fileHistory; | |
589 | // Number of files saved | |
590 | size_t m_fileHistoryN; | |
591 | // Menus to maintain (may need several for an MDI app) | |
592 | wxList m_fileMenus; | |
593 | // Max files to maintain | |
594 | size_t m_fileMaxFiles; | |
595 | ||
596 | private: | |
597 | // The ID of the first history menu item (Doesn't have to be wxID_FILE1) | |
598 | wxWindowID m_idBase; | |
599 | ||
600 | DECLARE_DYNAMIC_CLASS(wxFileHistory) | |
601 | DECLARE_NO_COPY_CLASS(wxFileHistory) | |
602 | }; | |
603 | ||
604 | inline size_t wxFileHistory::GetNoHistoryFiles() const | |
605 | { | |
606 | return m_fileHistoryN; | |
607 | } | |
608 | ||
609 | #if wxUSE_STD_IOSTREAM | |
610 | // For compatibility with existing file formats: | |
611 | // converts from/to a stream to/from a temporary file. | |
612 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); | |
613 | bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); | |
614 | #else | |
615 | // For compatibility with existing file formats: | |
616 | // converts from/to a stream to/from a temporary file. | |
617 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); | |
618 | bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); | |
619 | #endif // wxUSE_STD_IOSTREAM | |
620 | ||
621 | #endif // wxUSE_DOC_VIEW_ARCHITECTURE | |
622 | ||
623 | #endif // _WX_DOCH__ |