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