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