]>
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) | |
22f3361e | 164 | DECLARE_NO_COPY_CLASS(wxDocument) |
c801d85f KB |
165 | }; |
166 | ||
167 | class WXDLLEXPORT wxView: public wxEvtHandler | |
168 | { | |
caf0debf VZ |
169 | public: |
170 | // wxView(wxDocument *doc = (wxDocument *) NULL); | |
171 | wxView(); | |
172 | ~wxView(); | |
c801d85f | 173 | |
caf0debf | 174 | wxDocument *GetDocument() const { return m_viewDocument; } |
bb28b477 | 175 | virtual void SetDocument(wxDocument *doc); |
c801d85f | 176 | |
caf0debf VZ |
177 | wxString GetViewName() const { return m_viewTypeName; } |
178 | void SetViewName(const wxString& name) { m_viewTypeName = name; }; | |
c801d85f | 179 | |
b9f933ab JS |
180 | wxWindow *GetFrame() const { return m_viewFrame ; } |
181 | void SetFrame(wxWindow *frame) { m_viewFrame = frame; } | |
c801d85f | 182 | |
caf0debf VZ |
183 | virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView); |
184 | virtual void OnDraw(wxDC *dc) = 0; | |
185 | virtual void OnPrint(wxDC *dc, wxObject *info); | |
186 | virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL); | |
b23e843b | 187 | virtual void OnClosingDocument() {}; |
caf0debf | 188 | virtual void OnChangeFilename(); |
c801d85f | 189 | |
caf0debf VZ |
190 | // Called by framework if created automatically by the default document |
191 | // manager class: gives view a chance to initialise | |
192 | virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return TRUE; }; | |
c801d85f | 193 | |
caf0debf VZ |
194 | // Checks if the view is the last one for the document; if so, asks user |
195 | // to confirm save data (if modified). If ok, deletes itself and returns | |
196 | // TRUE. | |
197 | virtual bool Close(bool deleteWindow = TRUE); | |
198 | ||
199 | // Override to do cleanup/veto close | |
200 | virtual bool OnClose(bool deleteWindow); | |
2b854a32 | 201 | |
e3065973 | 202 | #if WXWIN_COMPATIBILITY |
caf0debf VZ |
203 | // Defeat compiler warning |
204 | bool OnClose() { return wxEvtHandler::OnClose(); } | |
2b854a32 | 205 | #endif |
c801d85f | 206 | |
caf0debf VZ |
207 | // Extend event processing to search the document's event table |
208 | virtual bool ProcessEvent(wxEvent& event); | |
c801d85f | 209 | |
caf0debf VZ |
210 | // A view's window can call this to notify the view it is (in)active. |
211 | // The function then notifies the document manager. | |
212 | virtual void Activate(bool activate); | |
c801d85f | 213 | |
caf0debf VZ |
214 | wxDocManager *GetDocumentManager() const |
215 | { return m_viewDocument->GetDocumentManager(); } | |
c801d85f | 216 | |
47d67540 | 217 | #if wxUSE_PRINTING_ARCHITECTURE |
caf0debf | 218 | virtual wxPrintout *OnCreatePrintout(); |
c801d85f KB |
219 | #endif |
220 | ||
caf0debf VZ |
221 | protected: |
222 | wxDocument* m_viewDocument; | |
223 | wxString m_viewTypeName; | |
b9f933ab | 224 | wxWindow* m_viewFrame; |
22f3361e | 225 | |
2b5f62a0 VZ |
226 | private: |
227 | DECLARE_ABSTRACT_CLASS(wxView) | |
22f3361e | 228 | DECLARE_NO_COPY_CLASS(wxView) |
c801d85f KB |
229 | }; |
230 | ||
231 | // Represents user interface (and other) properties of documents and views | |
232 | class WXDLLEXPORT wxDocTemplate: public wxObject | |
233 | { | |
caf0debf VZ |
234 | |
235 | friend class WXDLLEXPORT wxDocManager; | |
236 | ||
237 | public: | |
238 | // Associate document and view types. They're for identifying what view is | |
239 | // associated with what template/document type | |
240 | wxDocTemplate(wxDocManager *manager, | |
241 | const wxString& descr, | |
242 | const wxString& filter, | |
243 | const wxString& dir, | |
244 | const wxString& ext, | |
245 | const wxString& docTypeName, | |
246 | const wxString& viewTypeName, | |
247 | wxClassInfo *docClassInfo = (wxClassInfo *) NULL, | |
248 | wxClassInfo *viewClassInfo = (wxClassInfo *)NULL, | |
249 | long flags = wxDEFAULT_TEMPLATE_FLAGS); | |
250 | ||
251 | ~wxDocTemplate(); | |
252 | ||
253 | // By default, these two member functions dynamically creates document and | |
254 | // view using dynamic instance construction. Override these if you need a | |
255 | // different method of construction. | |
256 | virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); | |
257 | virtual wxView *CreateView(wxDocument *doc, long flags = 0); | |
258 | ||
259 | wxString GetDefaultExtension() const { return m_defaultExt; }; | |
260 | wxString GetDescription() const { return m_description; } | |
261 | wxString GetDirectory() const { return m_directory; }; | |
262 | wxDocManager *GetDocumentManager() const { return m_documentManager; } | |
263 | void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; } | |
264 | wxString GetFileFilter() const { return m_fileFilter; }; | |
265 | long GetFlags() const { return m_flags; }; | |
266 | virtual wxString GetViewName() const { return m_viewTypeName; } | |
267 | virtual wxString GetDocumentName() const { return m_docTypeName; } | |
268 | ||
269 | void SetFileFilter(const wxString& filter) { m_fileFilter = filter; }; | |
270 | void SetDirectory(const wxString& dir) { m_directory = dir; }; | |
271 | void SetDescription(const wxString& descr) { m_description = descr; }; | |
272 | void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; }; | |
273 | void SetFlags(long flags) { m_flags = flags; }; | |
274 | ||
275 | bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); } | |
276 | ||
277 | virtual bool FileMatchesTemplate(const wxString& path); | |
278 | ||
279 | protected: | |
280 | long m_flags; | |
281 | wxString m_fileFilter; | |
282 | wxString m_directory; | |
283 | wxString m_description; | |
284 | wxString m_defaultExt; | |
285 | wxString m_docTypeName; | |
286 | wxString m_viewTypeName; | |
287 | wxDocManager* m_documentManager; | |
288 | ||
289 | // For dynamic creation of appropriate instances. | |
290 | wxClassInfo* m_docClassInfo; | |
291 | wxClassInfo* m_viewClassInfo; | |
2b5f62a0 VZ |
292 | |
293 | private: | |
294 | DECLARE_CLASS(wxDocTemplate) | |
22f3361e | 295 | DECLARE_NO_COPY_CLASS(wxDocTemplate) |
c801d85f KB |
296 | }; |
297 | ||
caf0debf VZ |
298 | // One object of this class may be created in an application, to manage all |
299 | // the templates and documents. | |
c801d85f KB |
300 | class WXDLLEXPORT wxDocManager: public wxEvtHandler |
301 | { | |
caf0debf VZ |
302 | DECLARE_DYNAMIC_CLASS(wxDocManager) |
303 | ||
304 | public: | |
305 | wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = TRUE); | |
306 | ~wxDocManager(); | |
307 | ||
308 | virtual bool Initialize(); | |
309 | ||
310 | // Handlers for common user commands | |
311 | void OnFileClose(wxCommandEvent& event); | |
33a20136 | 312 | void OnFileCloseAll(wxCommandEvent& event); |
caf0debf VZ |
313 | void OnFileNew(wxCommandEvent& event); |
314 | void OnFileOpen(wxCommandEvent& event); | |
315 | void OnFileRevert(wxCommandEvent& event); | |
316 | void OnFileSave(wxCommandEvent& event); | |
317 | void OnFileSaveAs(wxCommandEvent& event); | |
318 | void OnPrint(wxCommandEvent& event); | |
319 | void OnPrintSetup(wxCommandEvent& event); | |
320 | void OnPreview(wxCommandEvent& event); | |
321 | void OnUndo(wxCommandEvent& event); | |
322 | void OnRedo(wxCommandEvent& event); | |
323 | ||
f2506310 JS |
324 | // Handlers for UI update commands |
325 | void OnUpdateFileOpen(wxUpdateUIEvent& event); | |
326 | void OnUpdateFileClose(wxUpdateUIEvent& event); | |
327 | void OnUpdateFileRevert(wxUpdateUIEvent& event); | |
328 | void OnUpdateFileNew(wxUpdateUIEvent& event); | |
329 | void OnUpdateFileSave(wxUpdateUIEvent& event); | |
330 | void OnUpdateFileSaveAs(wxUpdateUIEvent& event); | |
331 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
332 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
333 | ||
334 | void OnUpdatePrint(wxUpdateUIEvent& event); | |
335 | void OnUpdatePrintSetup(wxUpdateUIEvent& event); | |
336 | void OnUpdatePreview(wxUpdateUIEvent& event); | |
337 | ||
caf0debf VZ |
338 | // Extend event processing to search the view's event table |
339 | virtual bool ProcessEvent(wxEvent& event); | |
340 | ||
5f170f33 VZ |
341 | // called when file format detection didn't work, can be overridden to do |
342 | // something in this case | |
0a0352f2 | 343 | virtual void OnOpenFileFailure() { } |
5f170f33 | 344 | |
caf0debf VZ |
345 | virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); |
346 | virtual wxView *CreateView(wxDocument *doc, long flags = 0); | |
347 | virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0); | |
348 | virtual bool FlushDoc(wxDocument *doc); | |
349 | virtual wxDocTemplate *MatchTemplate(const wxString& path); | |
350 | virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates, | |
351 | int noTemplates, wxString& path, long flags, bool save = FALSE); | |
352 | virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates, | |
52b9ca21 | 353 | int noTemplates, bool sort = FALSE); |
caf0debf | 354 | virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates, |
52b9ca21 | 355 | int noTemplates, bool sort = FALSE); |
caf0debf VZ |
356 | virtual wxDocTemplate *FindTemplateForPath(const wxString& path); |
357 | ||
358 | void AssociateTemplate(wxDocTemplate *temp); | |
359 | void DisassociateTemplate(wxDocTemplate *temp); | |
360 | ||
361 | wxDocument *GetCurrentDocument() const; | |
362 | ||
363 | void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; } | |
364 | int GetMaxDocsOpen() const { return m_maxDocsOpen; } | |
365 | ||
366 | // Add and remove a document from the manager's list | |
367 | void AddDocument(wxDocument *doc); | |
368 | void RemoveDocument(wxDocument *doc); | |
369 | ||
33a20136 VZ |
370 | // closes all currently open documents |
371 | bool CloseDocuments(bool force = TRUE); | |
372 | ||
caf0debf VZ |
373 | // Clear remaining documents and templates |
374 | bool Clear(bool force = TRUE); | |
375 | ||
376 | // Views or windows should inform the document manager | |
377 | // when a view is going in or out of focus | |
378 | virtual void ActivateView(wxView *view, bool activate = TRUE, bool deleting = FALSE); | |
379 | virtual wxView *GetCurrentView() const; | |
380 | ||
0b237b67 JS |
381 | wxList& GetDocuments() { return m_docs; } |
382 | wxList& GetTemplates() { return m_templates; } | |
caf0debf VZ |
383 | |
384 | // Make a default document name | |
385 | virtual bool MakeDefaultName(wxString& buf); | |
386 | ||
f2506310 JS |
387 | // Make a frame title (override this to do something different) |
388 | virtual wxString MakeFrameTitle(wxDocument* doc); | |
389 | ||
caf0debf VZ |
390 | virtual wxFileHistory *OnCreateFileHistory(); |
391 | virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; } | |
392 | ||
393 | // File history management | |
394 | virtual void AddFileToHistory(const wxString& file); | |
0c5d3e1c | 395 | virtual void RemoveFileFromHistory(int i); |
caf0debf VZ |
396 | virtual int GetNoHistoryFiles() const; |
397 | virtual wxString GetHistoryFile(int i) const; | |
398 | virtual void FileHistoryUseMenu(wxMenu *menu); | |
399 | virtual void FileHistoryRemoveMenu(wxMenu *menu); | |
702ca7c0 | 400 | #if wxUSE_CONFIG |
caf0debf VZ |
401 | virtual void FileHistoryLoad(wxConfigBase& config); |
402 | virtual void FileHistorySave(wxConfigBase& config); | |
403 | #endif // wxUSE_CONFIG | |
404 | ||
405 | virtual void FileHistoryAddFilesToMenu(); | |
406 | virtual void FileHistoryAddFilesToMenu(wxMenu* menu); | |
407 | ||
ac0ac824 JS |
408 | inline wxString GetLastDirectory() const { return m_lastDirectory; } |
409 | inline void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; } | |
410 | ||
f2506310 JS |
411 | // Get the current document manager |
412 | static wxDocManager* GetDocumentManager() { return sm_docManager; } | |
413 | ||
caf0debf VZ |
414 | protected: |
415 | long m_flags; | |
416 | int m_defaultDocumentNameCounter; | |
417 | int m_maxDocsOpen; | |
418 | wxList m_docs; | |
419 | wxList m_templates; | |
420 | wxView* m_currentView; | |
421 | wxFileHistory* m_fileHistory; | |
ac0ac824 | 422 | wxString m_lastDirectory; |
f2506310 | 423 | static wxDocManager* sm_docManager; |
caf0debf VZ |
424 | |
425 | DECLARE_EVENT_TABLE() | |
22f3361e | 426 | DECLARE_NO_COPY_CLASS(wxDocManager) |
c801d85f KB |
427 | }; |
428 | ||
caf0debf VZ |
429 | // ---------------------------------------------------------------------------- |
430 | // A default child frame | |
431 | // ---------------------------------------------------------------------------- | |
c801d85f | 432 | |
caf0debf | 433 | class WXDLLEXPORT wxDocChildFrame : public wxFrame |
c801d85f | 434 | { |
caf0debf VZ |
435 | public: |
436 | wxDocChildFrame(wxDocument *doc, | |
437 | wxView *view, | |
438 | wxFrame *frame, | |
439 | wxWindowID id, | |
440 | const wxString& title, | |
441 | const wxPoint& pos = wxDefaultPosition, | |
442 | const wxSize& size = wxDefaultSize, | |
443 | long type = wxDEFAULT_FRAME_STYLE, | |
2b5f62a0 | 444 | const wxString& name = wxT("frame")); |
caf0debf VZ |
445 | ~wxDocChildFrame(); |
446 | ||
447 | // Extend event processing to search the view's event table | |
448 | virtual bool ProcessEvent(wxEvent& event); | |
449 | ||
450 | void OnActivate(wxActivateEvent& event); | |
451 | void OnCloseWindow(wxCloseEvent& event); | |
452 | ||
453 | wxDocument *GetDocument() const { return m_childDocument; } | |
454 | wxView *GetView() const { return m_childView; } | |
455 | void SetDocument(wxDocument *doc) { m_childDocument = doc; } | |
456 | void SetView(wxView *view) { m_childView = view; } | |
0d8737fd | 457 | bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); } |
caf0debf VZ |
458 | |
459 | protected: | |
460 | wxDocument* m_childDocument; | |
461 | wxView* m_childView; | |
462 | ||
2b5f62a0 VZ |
463 | private: |
464 | DECLARE_CLASS(wxDocChildFrame) | |
caf0debf | 465 | DECLARE_EVENT_TABLE() |
22f3361e | 466 | DECLARE_NO_COPY_CLASS(wxDocChildFrame) |
caf0debf | 467 | }; |
c801d85f | 468 | |
caf0debf VZ |
469 | // ---------------------------------------------------------------------------- |
470 | // A default parent frame | |
471 | // ---------------------------------------------------------------------------- | |
c801d85f | 472 | |
caf0debf VZ |
473 | class WXDLLEXPORT wxDocParentFrame : public wxFrame |
474 | { | |
caf0debf VZ |
475 | public: |
476 | wxDocParentFrame(wxDocManager *manager, | |
477 | wxFrame *frame, | |
478 | wxWindowID id, | |
479 | const wxString& title, | |
480 | const wxPoint& pos = wxDefaultPosition, | |
481 | const wxSize& size = wxDefaultSize, | |
482 | long type = wxDEFAULT_FRAME_STYLE, | |
2b5f62a0 | 483 | const wxString& name = wxT("frame")); |
c801d85f | 484 | |
caf0debf VZ |
485 | // Extend event processing to search the document manager's event table |
486 | virtual bool ProcessEvent(wxEvent& event); | |
c801d85f | 487 | |
caf0debf | 488 | wxDocManager *GetDocumentManager() const { return m_docManager; } |
c801d85f | 489 | |
caf0debf VZ |
490 | void OnExit(wxCommandEvent& event); |
491 | void OnMRUFile(wxCommandEvent& event); | |
492 | void OnCloseWindow(wxCloseEvent& event); | |
c801d85f | 493 | |
caf0debf VZ |
494 | protected: |
495 | wxDocManager *m_docManager; | |
496 | ||
2b5f62a0 VZ |
497 | private: |
498 | DECLARE_CLASS(wxDocParentFrame) | |
caf0debf | 499 | DECLARE_EVENT_TABLE() |
22f3361e | 500 | DECLARE_NO_COPY_CLASS(wxDocParentFrame) |
caf0debf | 501 | }; |
c801d85f | 502 | |
caf0debf VZ |
503 | // ---------------------------------------------------------------------------- |
504 | // Provide simple default printing facilities | |
505 | // ---------------------------------------------------------------------------- | |
c801d85f | 506 | |
caf0debf VZ |
507 | #if wxUSE_PRINTING_ARCHITECTURE |
508 | class WXDLLEXPORT wxDocPrintout : public wxPrintout | |
509 | { | |
caf0debf | 510 | public: |
2b5f62a0 | 511 | wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout")); |
caf0debf VZ |
512 | bool OnPrintPage(int page); |
513 | bool HasPage(int page); | |
514 | bool OnBeginDocument(int startPage, int endPage); | |
515 | void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); | |
c801d85f | 516 | |
caf0debf | 517 | virtual wxView *GetView() { return m_printoutView; } |
c801d85f | 518 | |
caf0debf VZ |
519 | protected: |
520 | wxView* m_printoutView; | |
2b5f62a0 VZ |
521 | |
522 | private: | |
523 | DECLARE_DYNAMIC_CLASS(wxDocPrintout) | |
22f3361e | 524 | DECLARE_NO_COPY_CLASS(wxDocPrintout) |
c801d85f | 525 | }; |
caf0debf | 526 | #endif // wxUSE_PRINTING_ARCHITECTURE |
c801d85f | 527 | |
caf0debf | 528 | // ---------------------------------------------------------------------------- |
7f555861 | 529 | // File history management |
caf0debf | 530 | // ---------------------------------------------------------------------------- |
7f555861 | 531 | |
caf0debf | 532 | class WXDLLEXPORT wxFileHistory : public wxObject |
c801d85f | 533 | { |
caf0debf VZ |
534 | public: |
535 | wxFileHistory(int maxFiles = 9); | |
536 | ~wxFileHistory(); | |
7f555861 | 537 | |
caf0debf VZ |
538 | // Operations |
539 | virtual void AddFileToHistory(const wxString& file); | |
0c5d3e1c | 540 | virtual void RemoveFileFromHistory(int i); |
caf0debf VZ |
541 | virtual int GetMaxFiles() const { return m_fileMaxFiles; } |
542 | virtual void UseMenu(wxMenu *menu); | |
7f555861 | 543 | |
caf0debf VZ |
544 | // Remove menu from the list (MDI child may be closing) |
545 | virtual void RemoveMenu(wxMenu *menu); | |
7f555861 | 546 | |
caf0debf VZ |
547 | #if wxUSE_CONFIG |
548 | virtual void Load(wxConfigBase& config); | |
549 | virtual void Save(wxConfigBase& config); | |
550 | #endif // wxUSE_CONFIG | |
551 | ||
552 | virtual void AddFilesToMenu(); | |
553 | virtual void AddFilesToMenu(wxMenu* menu); // Single menu | |
554 | ||
555 | // Accessors | |
556 | virtual wxString GetHistoryFile(int i) const; | |
557 | ||
558 | // A synonym for GetNoHistoryFiles | |
559 | virtual int GetCount() const { return m_fileHistoryN; } | |
560 | int GetNoHistoryFiles() const { return m_fileHistoryN; } | |
561 | ||
562 | wxList& GetMenus() const { return (wxList&) m_fileMenus; } | |
563 | ||
564 | protected: | |
565 | // Last n files | |
566 | wxChar** m_fileHistory; | |
567 | // Number of files saved | |
568 | int m_fileHistoryN; | |
569 | // Menus to maintain (may need several for an MDI app) | |
570 | wxList m_fileMenus; | |
571 | // Max files to maintain | |
572 | int m_fileMaxFiles; | |
2b5f62a0 VZ |
573 | |
574 | private: | |
575 | DECLARE_DYNAMIC_CLASS(wxFileHistory) | |
22f3361e | 576 | DECLARE_NO_COPY_CLASS(wxFileHistory) |
c801d85f KB |
577 | }; |
578 | ||
a533f5c1 | 579 | #if wxUSE_STD_IOSTREAM |
c801d85f KB |
580 | // For compatibility with existing file formats: |
581 | // converts from/to a stream to/from a temporary file. | |
dd107c50 VZ |
582 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); |
583 | bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); | |
dc1efb1d JS |
584 | #else |
585 | // For compatibility with existing file formats: | |
586 | // converts from/to a stream to/from a temporary file. | |
587 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); | |
588 | bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); | |
a533f5c1 | 589 | #endif |
c801d85f | 590 | |
caf0debf | 591 | #endif // _WX_DOCH__ |