]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/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 | virtual ~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 | virtual ~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 | virtual ~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 | virtual ~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 | #if WXWIN_COMPATIBILITY_2_6 | |
428 | // deprecated, use GetHistoryFilesCount() instead | |
429 | wxDEPRECATED( size_t GetNoHistoryFiles() const ); | |
430 | #endif // WXWIN_COMPATIBILITY_2_6 | |
431 | ||
432 | protected: | |
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; | |
440 | wxString m_lastDirectory; | |
441 | static wxDocManager* sm_docManager; | |
442 | ||
443 | DECLARE_EVENT_TABLE() | |
444 | DECLARE_DYNAMIC_CLASS(wxDocManager) | |
445 | DECLARE_NO_COPY_CLASS(wxDocManager) | |
446 | }; | |
447 | ||
448 | #if WXWIN_COMPATIBILITY_2_6 | |
449 | inline size_t wxDocManager::GetNoHistoryFiles() const | |
450 | { | |
451 | return GetHistoryFilesCount(); | |
452 | } | |
453 | #endif // WXWIN_COMPATIBILITY_2_6 | |
454 | ||
455 | // ---------------------------------------------------------------------------- | |
456 | // A default child frame | |
457 | // ---------------------------------------------------------------------------- | |
458 | ||
459 | class WXDLLEXPORT wxDocChildFrame : public wxFrame | |
460 | { | |
461 | public: | |
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, | |
470 | const wxString& name = wxT("frame")); | |
471 | virtual ~wxDocChildFrame(){} | |
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; } | |
483 | bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); } | |
484 | ||
485 | protected: | |
486 | wxDocument* m_childDocument; | |
487 | wxView* m_childView; | |
488 | ||
489 | private: | |
490 | DECLARE_CLASS(wxDocChildFrame) | |
491 | DECLARE_EVENT_TABLE() | |
492 | DECLARE_NO_COPY_CLASS(wxDocChildFrame) | |
493 | }; | |
494 | ||
495 | // ---------------------------------------------------------------------------- | |
496 | // A default parent frame | |
497 | // ---------------------------------------------------------------------------- | |
498 | ||
499 | class WXDLLEXPORT wxDocParentFrame : public wxFrame | |
500 | { | |
501 | public: | |
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, | |
509 | const wxString& name = wxT("frame")); | |
510 | ||
511 | // Extend event processing to search the document manager's event table | |
512 | virtual bool ProcessEvent(wxEvent& event); | |
513 | ||
514 | wxDocManager *GetDocumentManager() const { return m_docManager; } | |
515 | ||
516 | void OnExit(wxCommandEvent& event); | |
517 | void OnMRUFile(wxCommandEvent& event); | |
518 | void OnCloseWindow(wxCloseEvent& event); | |
519 | ||
520 | protected: | |
521 | wxDocManager *m_docManager; | |
522 | ||
523 | private: | |
524 | DECLARE_CLASS(wxDocParentFrame) | |
525 | DECLARE_EVENT_TABLE() | |
526 | DECLARE_NO_COPY_CLASS(wxDocParentFrame) | |
527 | }; | |
528 | ||
529 | // ---------------------------------------------------------------------------- | |
530 | // Provide simple default printing facilities | |
531 | // ---------------------------------------------------------------------------- | |
532 | ||
533 | #if wxUSE_PRINTING_ARCHITECTURE | |
534 | class WXDLLEXPORT wxDocPrintout : public wxPrintout | |
535 | { | |
536 | public: | |
537 | wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout")); | |
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); | |
542 | ||
543 | virtual wxView *GetView() { return m_printoutView; } | |
544 | ||
545 | protected: | |
546 | wxView* m_printoutView; | |
547 | ||
548 | private: | |
549 | DECLARE_DYNAMIC_CLASS(wxDocPrintout) | |
550 | DECLARE_NO_COPY_CLASS(wxDocPrintout) | |
551 | }; | |
552 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
553 | ||
554 | // ---------------------------------------------------------------------------- | |
555 | // File history management | |
556 | // ---------------------------------------------------------------------------- | |
557 | ||
558 | class WXDLLEXPORT wxFileHistory : public wxObject | |
559 | { | |
560 | public: | |
561 | wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1); | |
562 | virtual ~wxFileHistory(); | |
563 | ||
564 | // Operations | |
565 | virtual void AddFileToHistory(const wxString& file); | |
566 | virtual void RemoveFileFromHistory(size_t i); | |
567 | virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; } | |
568 | virtual void UseMenu(wxMenu *menu); | |
569 | ||
570 | // Remove menu from the list (MDI child may be closing) | |
571 | virtual void RemoveMenu(wxMenu *menu); | |
572 | ||
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 | |
582 | virtual wxString GetHistoryFile(size_t i) const; | |
583 | virtual size_t GetCount() const { return m_fileHistoryN; } | |
584 | ||
585 | const wxList& GetMenus() const { return m_fileMenus; } | |
586 | ||
587 | #if WXWIN_COMPATIBILITY_2_6 | |
588 | // deprecated, use GetCount() instead | |
589 | wxDEPRECATED( size_t GetNoHistoryFiles() const ); | |
590 | #endif // WXWIN_COMPATIBILITY_2_6 | |
591 | ||
592 | protected: | |
593 | // Last n files | |
594 | wxChar** m_fileHistory; | |
595 | // Number of files saved | |
596 | size_t m_fileHistoryN; | |
597 | // Menus to maintain (may need several for an MDI app) | |
598 | wxList m_fileMenus; | |
599 | // Max files to maintain | |
600 | size_t m_fileMaxFiles; | |
601 | ||
602 | private: | |
603 | // The ID of the first history menu item (Doesn't have to be wxID_FILE1) | |
604 | wxWindowID m_idBase; | |
605 | ||
606 | DECLARE_DYNAMIC_CLASS(wxFileHistory) | |
607 | DECLARE_NO_COPY_CLASS(wxFileHistory) | |
608 | }; | |
609 | ||
610 | #if WXWIN_COMPATIBILITY_2_6 | |
611 | inline size_t wxFileHistory::GetNoHistoryFiles() const | |
612 | { | |
613 | return m_fileHistoryN; | |
614 | } | |
615 | #endif // WXWIN_COMPATIBILITY_2_6 | |
616 | ||
617 | #if wxUSE_STD_IOSTREAM | |
618 | // For compatibility with existing file formats: | |
619 | // converts from/to a stream to/from a temporary file. | |
620 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); | |
621 | bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); | |
622 | #else | |
623 | // For compatibility with existing file formats: | |
624 | // converts from/to a stream to/from a temporary file. | |
625 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); | |
626 | bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); | |
627 | #endif // wxUSE_STD_IOSTREAM | |
628 | ||
629 | #endif // wxUSE_DOC_VIEW_ARCHITECTURE | |
630 | ||
631 | #endif // _WX_DOCH__ |