]>
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 | DECLARE_ABSTRACT_CLASS(wxDocument) |
68 | ||
69 | public: | |
70 | wxDocument(wxDocument *parent = (wxDocument *) NULL); | |
71 | ~wxDocument(); | |
72 | ||
73 | // accessors | |
74 | void SetFilename(const wxString& filename, bool notifyViews = FALSE); | |
75 | wxString GetFilename() const { return m_documentFile; } | |
76 | ||
77 | void SetTitle(const wxString& title) { m_documentTitle = title; }; | |
78 | wxString GetTitle() const { return m_documentTitle; } | |
79 | ||
80 | void SetDocumentName(const wxString& name) { m_documentTypeName = name; }; | |
81 | wxString GetDocumentName() const { return m_documentTypeName; } | |
82 | ||
83 | bool GetDocumentSaved() const { return m_savedYet; } | |
84 | void SetDocumentSaved(bool saved = TRUE) { m_savedYet = saved; } | |
85 | ||
86 | virtual bool Close(); | |
87 | virtual bool Save(); | |
88 | virtual bool SaveAs(); | |
89 | virtual bool Revert(); | |
90 | ||
a533f5c1 | 91 | #if wxUSE_STD_IOSTREAM |
dd107c50 VZ |
92 | virtual wxSTD ostream& SaveObject(wxSTD ostream& stream); |
93 | virtual wxSTD istream& LoadObject(wxSTD istream& stream); | |
a533f5c1 | 94 | #else |
23a54e14 RR |
95 | virtual wxOutputStream& SaveObject(wxOutputStream& stream); |
96 | virtual wxInputStream& LoadObject(wxInputStream& stream); | |
a533f5c1 | 97 | #endif |
caf0debf VZ |
98 | |
99 | // Called by wxWindows | |
100 | virtual bool OnSaveDocument(const wxString& filename); | |
101 | virtual bool OnOpenDocument(const wxString& filename); | |
102 | virtual bool OnNewDocument(); | |
103 | virtual bool OnCloseDocument(); | |
104 | ||
105 | // Prompts for saving if about to close a modified document. Returns TRUE | |
106 | // if ok to close the document (may have saved in the meantime, or set | |
107 | // modified to FALSE) | |
108 | virtual bool OnSaveModified(); | |
109 | ||
110 | // Called by framework if created automatically by the default document | |
111 | // manager: gives document a chance to initialise and (usually) create a | |
112 | // view | |
113 | virtual bool OnCreate(const wxString& path, long flags); | |
114 | ||
115 | // By default, creates a base wxCommandProcessor. | |
116 | virtual wxCommandProcessor *OnCreateCommandProcessor(); | |
117 | virtual wxCommandProcessor *GetCommandProcessor() const { return m_commandProcessor; } | |
118 | virtual void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; } | |
119 | ||
120 | // Called after a view is added or removed. The default implementation | |
121 | // deletes the document if this is there are no more views. | |
122 | virtual void OnChangedViewList(); | |
123 | ||
124 | virtual bool DeleteContents(); | |
125 | ||
126 | virtual bool Draw(wxDC&); | |
127 | virtual bool IsModified() const { return m_documentModified; } | |
128 | virtual void Modify(bool mod) { m_documentModified = mod; } | |
129 | ||
130 | virtual bool AddView(wxView *view); | |
131 | virtual bool RemoveView(wxView *view); | |
132 | wxList& GetViews() const { return (wxList&) m_documentViews; } | |
133 | wxView *GetFirstView() const; | |
134 | ||
135 | virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL); | |
b23e843b | 136 | virtual void NotifyClosing(); |
caf0debf VZ |
137 | |
138 | // Remove all views (because we're closing the document) | |
139 | virtual bool DeleteAllViews(); | |
140 | ||
141 | // Other stuff | |
142 | virtual wxDocManager *GetDocumentManager() const; | |
143 | virtual wxDocTemplate *GetDocumentTemplate() const { return m_documentTemplate; } | |
144 | virtual void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; } | |
145 | ||
146 | // Get title, or filename if no title, else [unnamed] | |
147 | virtual bool GetPrintableName(wxString& buf) const; | |
148 | ||
149 | // Returns a window that can be used as a parent for document-related | |
150 | // dialogs. Override if necessary. | |
151 | virtual wxWindow *GetDocumentWindow() const; | |
152 | ||
153 | protected: | |
154 | wxList m_documentViews; | |
155 | wxString m_documentFile; | |
156 | wxString m_documentTitle; | |
157 | wxString m_documentTypeName; | |
158 | wxDocTemplate* m_documentTemplate; | |
159 | bool m_documentModified; | |
160 | wxDocument* m_documentParent; | |
161 | wxCommandProcessor* m_commandProcessor; | |
162 | bool m_savedYet; | |
c801d85f KB |
163 | }; |
164 | ||
165 | class WXDLLEXPORT wxView: public wxEvtHandler | |
166 | { | |
caf0debf | 167 | DECLARE_ABSTRACT_CLASS(wxView) |
c801d85f | 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; |
c801d85f KB |
225 | }; |
226 | ||
227 | // Represents user interface (and other) properties of documents and views | |
228 | class WXDLLEXPORT wxDocTemplate: public wxObject | |
229 | { | |
caf0debf VZ |
230 | DECLARE_CLASS(wxDocTemplate) |
231 | ||
232 | friend class WXDLLEXPORT wxDocManager; | |
233 | ||
234 | public: | |
235 | // Associate document and view types. They're for identifying what view is | |
236 | // associated with what template/document type | |
237 | wxDocTemplate(wxDocManager *manager, | |
238 | const wxString& descr, | |
239 | const wxString& filter, | |
240 | const wxString& dir, | |
241 | const wxString& ext, | |
242 | const wxString& docTypeName, | |
243 | const wxString& viewTypeName, | |
244 | wxClassInfo *docClassInfo = (wxClassInfo *) NULL, | |
245 | wxClassInfo *viewClassInfo = (wxClassInfo *)NULL, | |
246 | long flags = wxDEFAULT_TEMPLATE_FLAGS); | |
247 | ||
248 | ~wxDocTemplate(); | |
249 | ||
250 | // By default, these two member functions dynamically creates document and | |
251 | // view using dynamic instance construction. Override these if you need a | |
252 | // different method of construction. | |
253 | virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); | |
254 | virtual wxView *CreateView(wxDocument *doc, long flags = 0); | |
255 | ||
256 | wxString GetDefaultExtension() const { return m_defaultExt; }; | |
257 | wxString GetDescription() const { return m_description; } | |
258 | wxString GetDirectory() const { return m_directory; }; | |
259 | wxDocManager *GetDocumentManager() const { return m_documentManager; } | |
260 | void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; } | |
261 | wxString GetFileFilter() const { return m_fileFilter; }; | |
262 | long GetFlags() const { return m_flags; }; | |
263 | virtual wxString GetViewName() const { return m_viewTypeName; } | |
264 | virtual wxString GetDocumentName() const { return m_docTypeName; } | |
265 | ||
266 | void SetFileFilter(const wxString& filter) { m_fileFilter = filter; }; | |
267 | void SetDirectory(const wxString& dir) { m_directory = dir; }; | |
268 | void SetDescription(const wxString& descr) { m_description = descr; }; | |
269 | void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; }; | |
270 | void SetFlags(long flags) { m_flags = flags; }; | |
271 | ||
272 | bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); } | |
273 | ||
274 | virtual bool FileMatchesTemplate(const wxString& path); | |
275 | ||
276 | protected: | |
277 | long m_flags; | |
278 | wxString m_fileFilter; | |
279 | wxString m_directory; | |
280 | wxString m_description; | |
281 | wxString m_defaultExt; | |
282 | wxString m_docTypeName; | |
283 | wxString m_viewTypeName; | |
284 | wxDocManager* m_documentManager; | |
285 | ||
286 | // For dynamic creation of appropriate instances. | |
287 | wxClassInfo* m_docClassInfo; | |
288 | wxClassInfo* m_viewClassInfo; | |
c801d85f KB |
289 | }; |
290 | ||
caf0debf VZ |
291 | // One object of this class may be created in an application, to manage all |
292 | // the templates and documents. | |
c801d85f KB |
293 | class WXDLLEXPORT wxDocManager: public wxEvtHandler |
294 | { | |
caf0debf VZ |
295 | DECLARE_DYNAMIC_CLASS(wxDocManager) |
296 | ||
297 | public: | |
298 | wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = TRUE); | |
299 | ~wxDocManager(); | |
300 | ||
301 | virtual bool Initialize(); | |
302 | ||
303 | // Handlers for common user commands | |
304 | void OnFileClose(wxCommandEvent& event); | |
33a20136 | 305 | void OnFileCloseAll(wxCommandEvent& event); |
caf0debf VZ |
306 | void OnFileNew(wxCommandEvent& event); |
307 | void OnFileOpen(wxCommandEvent& event); | |
308 | void OnFileRevert(wxCommandEvent& event); | |
309 | void OnFileSave(wxCommandEvent& event); | |
310 | void OnFileSaveAs(wxCommandEvent& event); | |
311 | void OnPrint(wxCommandEvent& event); | |
312 | void OnPrintSetup(wxCommandEvent& event); | |
313 | void OnPreview(wxCommandEvent& event); | |
314 | void OnUndo(wxCommandEvent& event); | |
315 | void OnRedo(wxCommandEvent& event); | |
316 | ||
f2506310 JS |
317 | // Handlers for UI update commands |
318 | void OnUpdateFileOpen(wxUpdateUIEvent& event); | |
319 | void OnUpdateFileClose(wxUpdateUIEvent& event); | |
320 | void OnUpdateFileRevert(wxUpdateUIEvent& event); | |
321 | void OnUpdateFileNew(wxUpdateUIEvent& event); | |
322 | void OnUpdateFileSave(wxUpdateUIEvent& event); | |
323 | void OnUpdateFileSaveAs(wxUpdateUIEvent& event); | |
324 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
325 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
326 | ||
327 | void OnUpdatePrint(wxUpdateUIEvent& event); | |
328 | void OnUpdatePrintSetup(wxUpdateUIEvent& event); | |
329 | void OnUpdatePreview(wxUpdateUIEvent& event); | |
330 | ||
caf0debf VZ |
331 | // Extend event processing to search the view's event table |
332 | virtual bool ProcessEvent(wxEvent& event); | |
333 | ||
5f170f33 VZ |
334 | // called when file format detection didn't work, can be overridden to do |
335 | // something in this case | |
0a0352f2 JS |
336 | // This is of course completely stupid, because if the file dialog is |
337 | // cancelled you get an assert. Brilliant. -- JACS | |
338 | // virtual void OnOpenFileFailure() { wxFAIL_MSG(_T("file format mismatch")); } | |
339 | virtual void OnOpenFileFailure() { } | |
5f170f33 | 340 | |
caf0debf VZ |
341 | virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); |
342 | virtual wxView *CreateView(wxDocument *doc, long flags = 0); | |
343 | virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0); | |
344 | virtual bool FlushDoc(wxDocument *doc); | |
345 | virtual wxDocTemplate *MatchTemplate(const wxString& path); | |
346 | virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates, | |
347 | int noTemplates, wxString& path, long flags, bool save = FALSE); | |
348 | virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates, | |
52b9ca21 | 349 | int noTemplates, bool sort = FALSE); |
caf0debf | 350 | virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates, |
52b9ca21 | 351 | int noTemplates, bool sort = FALSE); |
caf0debf VZ |
352 | virtual wxDocTemplate *FindTemplateForPath(const wxString& path); |
353 | ||
354 | void AssociateTemplate(wxDocTemplate *temp); | |
355 | void DisassociateTemplate(wxDocTemplate *temp); | |
356 | ||
357 | wxDocument *GetCurrentDocument() const; | |
358 | ||
359 | void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; } | |
360 | int GetMaxDocsOpen() const { return m_maxDocsOpen; } | |
361 | ||
362 | // Add and remove a document from the manager's list | |
363 | void AddDocument(wxDocument *doc); | |
364 | void RemoveDocument(wxDocument *doc); | |
365 | ||
33a20136 VZ |
366 | // closes all currently open documents |
367 | bool CloseDocuments(bool force = TRUE); | |
368 | ||
caf0debf VZ |
369 | // Clear remaining documents and templates |
370 | bool Clear(bool force = TRUE); | |
371 | ||
372 | // Views or windows should inform the document manager | |
373 | // when a view is going in or out of focus | |
374 | virtual void ActivateView(wxView *view, bool activate = TRUE, bool deleting = FALSE); | |
375 | virtual wxView *GetCurrentView() const; | |
376 | ||
0b237b67 JS |
377 | wxList& GetDocuments() { return m_docs; } |
378 | wxList& GetTemplates() { return m_templates; } | |
caf0debf VZ |
379 | |
380 | // Make a default document name | |
381 | virtual bool MakeDefaultName(wxString& buf); | |
382 | ||
f2506310 JS |
383 | // Make a frame title (override this to do something different) |
384 | virtual wxString MakeFrameTitle(wxDocument* doc); | |
385 | ||
caf0debf VZ |
386 | virtual wxFileHistory *OnCreateFileHistory(); |
387 | virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; } | |
388 | ||
389 | // File history management | |
390 | virtual void AddFileToHistory(const wxString& file); | |
0c5d3e1c | 391 | virtual void RemoveFileFromHistory(int i); |
caf0debf VZ |
392 | virtual int GetNoHistoryFiles() const; |
393 | virtual wxString GetHistoryFile(int i) const; | |
394 | virtual void FileHistoryUseMenu(wxMenu *menu); | |
395 | virtual void FileHistoryRemoveMenu(wxMenu *menu); | |
702ca7c0 | 396 | #if wxUSE_CONFIG |
caf0debf VZ |
397 | virtual void FileHistoryLoad(wxConfigBase& config); |
398 | virtual void FileHistorySave(wxConfigBase& config); | |
399 | #endif // wxUSE_CONFIG | |
400 | ||
401 | virtual void FileHistoryAddFilesToMenu(); | |
402 | virtual void FileHistoryAddFilesToMenu(wxMenu* menu); | |
403 | ||
ac0ac824 JS |
404 | inline wxString GetLastDirectory() const { return m_lastDirectory; } |
405 | inline void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; } | |
406 | ||
f2506310 JS |
407 | // Get the current document manager |
408 | static wxDocManager* GetDocumentManager() { return sm_docManager; } | |
409 | ||
caf0debf VZ |
410 | protected: |
411 | long m_flags; | |
412 | int m_defaultDocumentNameCounter; | |
413 | int m_maxDocsOpen; | |
414 | wxList m_docs; | |
415 | wxList m_templates; | |
416 | wxView* m_currentView; | |
417 | wxFileHistory* m_fileHistory; | |
ac0ac824 | 418 | wxString m_lastDirectory; |
f2506310 | 419 | static wxDocManager* sm_docManager; |
caf0debf VZ |
420 | |
421 | DECLARE_EVENT_TABLE() | |
c801d85f KB |
422 | }; |
423 | ||
caf0debf VZ |
424 | // ---------------------------------------------------------------------------- |
425 | // A default child frame | |
426 | // ---------------------------------------------------------------------------- | |
c801d85f | 427 | |
caf0debf | 428 | class WXDLLEXPORT wxDocChildFrame : public wxFrame |
c801d85f | 429 | { |
caf0debf VZ |
430 | DECLARE_CLASS(wxDocChildFrame) |
431 | ||
432 | public: | |
433 | wxDocChildFrame(wxDocument *doc, | |
434 | wxView *view, | |
435 | wxFrame *frame, | |
436 | wxWindowID id, | |
437 | const wxString& title, | |
438 | const wxPoint& pos = wxDefaultPosition, | |
439 | const wxSize& size = wxDefaultSize, | |
440 | long type = wxDEFAULT_FRAME_STYLE, | |
441 | const wxString& name = "frame"); | |
442 | ~wxDocChildFrame(); | |
443 | ||
444 | // Extend event processing to search the view's event table | |
445 | virtual bool ProcessEvent(wxEvent& event); | |
446 | ||
447 | void OnActivate(wxActivateEvent& event); | |
448 | void OnCloseWindow(wxCloseEvent& event); | |
449 | ||
450 | wxDocument *GetDocument() const { return m_childDocument; } | |
451 | wxView *GetView() const { return m_childView; } | |
452 | void SetDocument(wxDocument *doc) { m_childDocument = doc; } | |
453 | void SetView(wxView *view) { m_childView = view; } | |
0d8737fd | 454 | bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); } |
caf0debf VZ |
455 | |
456 | protected: | |
457 | wxDocument* m_childDocument; | |
458 | wxView* m_childView; | |
459 | ||
460 | DECLARE_EVENT_TABLE() | |
461 | }; | |
c801d85f | 462 | |
caf0debf VZ |
463 | // ---------------------------------------------------------------------------- |
464 | // A default parent frame | |
465 | // ---------------------------------------------------------------------------- | |
c801d85f | 466 | |
caf0debf VZ |
467 | class WXDLLEXPORT wxDocParentFrame : public wxFrame |
468 | { | |
469 | DECLARE_CLASS(wxDocParentFrame) | |
c801d85f | 470 | |
caf0debf VZ |
471 | public: |
472 | wxDocParentFrame(wxDocManager *manager, | |
473 | wxFrame *frame, | |
474 | wxWindowID id, | |
475 | const wxString& title, | |
476 | const wxPoint& pos = wxDefaultPosition, | |
477 | const wxSize& size = wxDefaultSize, | |
478 | long type = wxDEFAULT_FRAME_STYLE, | |
479 | const wxString& name = "frame"); | |
c801d85f | 480 | |
caf0debf VZ |
481 | // Extend event processing to search the document manager's event table |
482 | virtual bool ProcessEvent(wxEvent& event); | |
c801d85f | 483 | |
caf0debf | 484 | wxDocManager *GetDocumentManager() const { return m_docManager; } |
c801d85f | 485 | |
caf0debf VZ |
486 | void OnExit(wxCommandEvent& event); |
487 | void OnMRUFile(wxCommandEvent& event); | |
488 | void OnCloseWindow(wxCloseEvent& event); | |
c801d85f | 489 | |
caf0debf VZ |
490 | protected: |
491 | wxDocManager *m_docManager; | |
492 | ||
493 | DECLARE_EVENT_TABLE() | |
494 | }; | |
c801d85f | 495 | |
caf0debf VZ |
496 | // ---------------------------------------------------------------------------- |
497 | // Provide simple default printing facilities | |
498 | // ---------------------------------------------------------------------------- | |
c801d85f | 499 | |
caf0debf VZ |
500 | #if wxUSE_PRINTING_ARCHITECTURE |
501 | class WXDLLEXPORT wxDocPrintout : public wxPrintout | |
502 | { | |
503 | DECLARE_DYNAMIC_CLASS(wxDocPrintout) | |
c801d85f | 504 | |
caf0debf VZ |
505 | public: |
506 | wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = "Printout"); | |
507 | bool OnPrintPage(int page); | |
508 | bool HasPage(int page); | |
509 | bool OnBeginDocument(int startPage, int endPage); | |
510 | void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); | |
c801d85f | 511 | |
caf0debf | 512 | virtual wxView *GetView() { return m_printoutView; } |
c801d85f | 513 | |
caf0debf VZ |
514 | protected: |
515 | wxView* m_printoutView; | |
c801d85f | 516 | }; |
caf0debf | 517 | #endif // wxUSE_PRINTING_ARCHITECTURE |
c801d85f | 518 | |
caf0debf | 519 | // ---------------------------------------------------------------------------- |
7f555861 | 520 | // File history management |
caf0debf | 521 | // ---------------------------------------------------------------------------- |
7f555861 | 522 | |
caf0debf | 523 | class WXDLLEXPORT wxFileHistory : public wxObject |
c801d85f | 524 | { |
caf0debf | 525 | DECLARE_DYNAMIC_CLASS(wxFileHistory) |
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; | |
c801d85f KB |
566 | }; |
567 | ||
a533f5c1 | 568 | #if wxUSE_STD_IOSTREAM |
c801d85f KB |
569 | // For compatibility with existing file formats: |
570 | // converts from/to a stream to/from a temporary file. | |
dd107c50 VZ |
571 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); |
572 | bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); | |
dc1efb1d JS |
573 | #else |
574 | // For compatibility with existing file formats: | |
575 | // converts from/to a stream to/from a temporary file. | |
576 | bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); | |
577 | bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); | |
a533f5c1 | 578 | #endif |
c801d85f | 579 | |
caf0debf | 580 | #endif // _WX_DOCH__ |