]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
ca3e85cf | 2 | // Name: wx/docview.h |
c801d85f KB |
3 | // Purpose: Doc/View classes |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
99d80019 | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_DOCH__ |
13 | #define _WX_DOCH__ | |
c801d85f | 14 | |
c801d85f | 15 | #include "wx/defs.h" |
e30285ab VZ |
16 | |
17 | #if wxUSE_DOC_VIEW_ARCHITECTURE | |
18 | ||
c801d85f | 19 | #include "wx/list.h" |
4db97e24 | 20 | #include "wx/dlist.h" |
c801d85f | 21 | #include "wx/string.h" |
2f7adba0 | 22 | #include "wx/frame.h" |
a0219e45 | 23 | #include "wx/filehistory.h" |
288de46c | 24 | #include "wx/vector.h" |
c801d85f | 25 | |
47d67540 | 26 | #if wxUSE_PRINTING_ARCHITECTURE |
caf0debf | 27 | #include "wx/print.h" |
c801d85f KB |
28 | #endif |
29 | ||
b5dbe15d VS |
30 | class WXDLLIMPEXP_FWD_CORE wxWindow; |
31 | class WXDLLIMPEXP_FWD_CORE wxDocument; | |
32 | class WXDLLIMPEXP_FWD_CORE wxView; | |
33 | class WXDLLIMPEXP_FWD_CORE wxDocTemplate; | |
34 | class WXDLLIMPEXP_FWD_CORE wxDocManager; | |
35 | class WXDLLIMPEXP_FWD_CORE wxPrintInfo; | |
36 | class WXDLLIMPEXP_FWD_CORE wxCommandProcessor; | |
4f7d425f | 37 | class WXDLLIMPEXP_FWD_BASE wxConfigBase; |
c801d85f | 38 | |
a9e2e6e5 VZ |
39 | class wxDocChildFrameAnyBase; |
40 | ||
a533f5c1 | 41 | #if wxUSE_STD_IOSTREAM |
65f19af1 | 42 | #include "wx/iosfwrap.h" |
a533f5c1 RR |
43 | #else |
44 | #include "wx/stream.h" | |
45 | #endif | |
c801d85f | 46 | |
c77049a0 | 47 | // Flags for wxDocManager (can be combined). |
caf0debf VZ |
48 | enum |
49 | { | |
c77049a0 VZ |
50 | wxDOC_NEW = 1, |
51 | wxDOC_SILENT = 2 | |
caf0debf | 52 | }; |
c801d85f KB |
53 | |
54 | // Document template flags | |
caf0debf VZ |
55 | enum |
56 | { | |
57 | wxTEMPLATE_VISIBLE = 1, | |
89d94e04 | 58 | wxTEMPLATE_INVISIBLE = 2, |
caf0debf VZ |
59 | wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE |
60 | }; | |
c801d85f | 61 | |
caf0debf | 62 | #define wxMAX_FILE_HISTORY 9 |
c801d85f | 63 | |
93d0805b VZ |
64 | typedef wxVector<wxDocument*> wxDocVector; |
65 | typedef wxVector<wxView*> wxViewVector; | |
66 | typedef wxVector<wxDocTemplate*> wxDocTemplateVector; | |
93d0805b | 67 | |
53a2db12 | 68 | class WXDLLIMPEXP_CORE wxDocument : public wxEvtHandler |
c801d85f | 69 | { |
caf0debf | 70 | public: |
c77049a0 | 71 | wxDocument(wxDocument *parent = NULL); |
d3c7fc99 | 72 | virtual ~wxDocument(); |
caf0debf VZ |
73 | |
74 | // accessors | |
68379eaf | 75 | void SetFilename(const wxString& filename, bool notifyViews = false); |
caf0debf VZ |
76 | wxString GetFilename() const { return m_documentFile; } |
77 | ||
47b378bd | 78 | void SetTitle(const wxString& title) { m_documentTitle = title; } |
caf0debf VZ |
79 | wxString GetTitle() const { return m_documentTitle; } |
80 | ||
47b378bd | 81 | void SetDocumentName(const wxString& name) { m_documentTypeName = name; } |
caf0debf VZ |
82 | wxString GetDocumentName() const { return m_documentTypeName; } |
83 | ||
d7b3a73d VZ |
84 | // access the flag indicating whether this document had been already saved, |
85 | // SetDocumentSaved() is only used internally, don't call it | |
caf0debf | 86 | bool GetDocumentSaved() const { return m_savedYet; } |
68379eaf | 87 | void SetDocumentSaved(bool saved = true) { m_savedYet = saved; } |
caf0debf | 88 | |
beba4fa6 VZ |
89 | // activate the first view of the document if any |
90 | void Activate(); | |
91 | ||
de56f240 VZ |
92 | // return true if the document hasn't been modified since the last time it |
93 | // was saved (implying that it returns false if it was never saved, even if | |
94 | // the document is not modified) | |
95 | bool AlreadySaved() const { return !IsModified() && GetDocumentSaved(); } | |
96 | ||
caf0debf VZ |
97 | virtual bool Close(); |
98 | virtual bool Save(); | |
99 | virtual bool SaveAs(); | |
100 | virtual bool Revert(); | |
101 | ||
a533f5c1 | 102 | #if wxUSE_STD_IOSTREAM |
dd107c50 VZ |
103 | virtual wxSTD ostream& SaveObject(wxSTD ostream& stream); |
104 | virtual wxSTD istream& LoadObject(wxSTD istream& stream); | |
a533f5c1 | 105 | #else |
23a54e14 RR |
106 | virtual wxOutputStream& SaveObject(wxOutputStream& stream); |
107 | virtual wxInputStream& LoadObject(wxInputStream& stream); | |
a533f5c1 | 108 | #endif |
caf0debf | 109 | |
77ffb593 | 110 | // Called by wxWidgets |
caf0debf VZ |
111 | virtual bool OnSaveDocument(const wxString& filename); |
112 | virtual bool OnOpenDocument(const wxString& filename); | |
113 | virtual bool OnNewDocument(); | |
114 | virtual bool OnCloseDocument(); | |
115 | ||
68379eaf | 116 | // Prompts for saving if about to close a modified document. Returns true |
caf0debf | 117 | // if ok to close the document (may have saved in the meantime, or set |
68379eaf | 118 | // modified to false) |
caf0debf VZ |
119 | virtual bool OnSaveModified(); |
120 | ||
8cc208e3 | 121 | // if you override, remember to call the default |
00e3ea1c FM |
122 | // implementation (wxDocument::OnChangeFilename) |
123 | virtual void OnChangeFilename(bool notifyViews); | |
124 | ||
caf0debf VZ |
125 | // Called by framework if created automatically by the default document |
126 | // manager: gives document a chance to initialise and (usually) create a | |
127 | // view | |
128 | virtual bool OnCreate(const wxString& path, long flags); | |
129 | ||
130 | // By default, creates a base wxCommandProcessor. | |
131 | virtual wxCommandProcessor *OnCreateCommandProcessor(); | |
89d94e04 VZ |
132 | virtual wxCommandProcessor *GetCommandProcessor() const |
133 | { return m_commandProcessor; } | |
134 | virtual void SetCommandProcessor(wxCommandProcessor *proc) | |
135 | { m_commandProcessor = proc; } | |
caf0debf VZ |
136 | |
137 | // Called after a view is added or removed. The default implementation | |
138 | // deletes the document if this is there are no more views. | |
139 | virtual void OnChangedViewList(); | |
140 | ||
29548835 VZ |
141 | // Called from OnCloseDocument(), does nothing by default but may be |
142 | // overridden. Return value is ignored. | |
caf0debf VZ |
143 | virtual bool DeleteContents(); |
144 | ||
145 | virtual bool Draw(wxDC&); | |
146 | virtual bool IsModified() const { return m_documentModified; } | |
250ab35a | 147 | virtual void Modify(bool mod); |
caf0debf VZ |
148 | |
149 | virtual bool AddView(wxView *view); | |
150 | virtual bool RemoveView(wxView *view); | |
93d0805b VZ |
151 | |
152 | #ifndef __VISUALC6__ | |
8f2a8df4 | 153 | wxViewVector GetViewsVector() const; |
288de46c VZ |
154 | #endif // !__VISUALC6__ |
155 | ||
b80388aa VZ |
156 | wxList& GetViews() { return m_documentViews; } |
157 | const wxList& GetViews() const { return m_documentViews; } | |
93d0805b | 158 | |
caf0debf VZ |
159 | wxView *GetFirstView() const; |
160 | ||
c77049a0 | 161 | virtual void UpdateAllViews(wxView *sender = NULL, wxObject *hint = NULL); |
b23e843b | 162 | virtual void NotifyClosing(); |
caf0debf VZ |
163 | |
164 | // Remove all views (because we're closing the document) | |
165 | virtual bool DeleteAllViews(); | |
166 | ||
167 | // Other stuff | |
168 | virtual wxDocManager *GetDocumentManager() const; | |
89d94e04 VZ |
169 | virtual wxDocTemplate *GetDocumentTemplate() const |
170 | { return m_documentTemplate; } | |
171 | virtual void SetDocumentTemplate(wxDocTemplate *temp) | |
172 | { m_documentTemplate = temp; } | |
caf0debf | 173 | |
724b119a VZ |
174 | // Get the document name to be shown to the user: the title if there is |
175 | // any, otherwise the filename if the document was saved and, finally, | |
176 | // "unnamed" otherwise | |
177 | virtual wxString GetUserReadableName() const; | |
178 | ||
179 | #if WXWIN_COMPATIBILITY_2_8 | |
180 | // use GetUserReadableName() instead | |
181 | wxDEPRECATED_BUT_USED_INTERNALLY( | |
182 | virtual bool GetPrintableName(wxString& buf) const | |
183 | ); | |
184 | #endif // WXWIN_COMPATIBILITY_2_8 | |
caf0debf VZ |
185 | |
186 | // Returns a window that can be used as a parent for document-related | |
187 | // dialogs. Override if necessary. | |
188 | virtual wxWindow *GetDocumentWindow() const; | |
189 | ||
4db97e24 VZ |
190 | // Returns true if this document is a child document corresponding to a |
191 | // part of the parent document and not a disk file as usual. | |
192 | bool IsChildDocument() const { return m_documentParent != NULL; } | |
193 | ||
caf0debf VZ |
194 | protected: |
195 | wxList m_documentViews; | |
196 | wxString m_documentFile; | |
197 | wxString m_documentTitle; | |
198 | wxString m_documentTypeName; | |
199 | wxDocTemplate* m_documentTemplate; | |
200 | bool m_documentModified; | |
4db97e24 VZ |
201 | |
202 | // if the document parent is non-NULL, it's a pseudo-document corresponding | |
203 | // to a part of the parent document which can't be saved or loaded | |
204 | // independently of its parent and is always closed when its parent is | |
caf0debf | 205 | wxDocument* m_documentParent; |
4db97e24 | 206 | |
caf0debf VZ |
207 | wxCommandProcessor* m_commandProcessor; |
208 | bool m_savedYet; | |
b5f159ac | 209 | |
69936aea | 210 | // Called by OnSaveDocument and OnOpenDocument to implement standard |
4c51a665 DS |
211 | // Save/Load behaviour. Re-implement in derived class for custom |
212 | // behaviour. | |
69936aea VZ |
213 | virtual bool DoSaveDocument(const wxString& file); |
214 | virtual bool DoOpenDocument(const wxString& file); | |
215 | ||
724b119a VZ |
216 | // the default implementation of GetUserReadableName() |
217 | wxString DoGetUserReadableName() const; | |
218 | ||
2b5f62a0 | 219 | private: |
4db97e24 VZ |
220 | // list of all documents whose m_documentParent is this one |
221 | typedef wxDList<wxDocument> DocsList; | |
222 | DocsList m_childDocuments; | |
223 | ||
2b5f62a0 | 224 | DECLARE_ABSTRACT_CLASS(wxDocument) |
c0c133e1 | 225 | wxDECLARE_NO_COPY_CLASS(wxDocument); |
c801d85f KB |
226 | }; |
227 | ||
53a2db12 | 228 | class WXDLLIMPEXP_CORE wxView: public wxEvtHandler |
c801d85f | 229 | { |
caf0debf | 230 | public: |
caf0debf | 231 | wxView(); |
d3c7fc99 | 232 | virtual ~wxView(); |
c801d85f | 233 | |
caf0debf | 234 | wxDocument *GetDocument() const { return m_viewDocument; } |
bb28b477 | 235 | virtual void SetDocument(wxDocument *doc); |
c801d85f | 236 | |
caf0debf | 237 | wxString GetViewName() const { return m_viewTypeName; } |
47b378bd | 238 | void SetViewName(const wxString& name) { m_viewTypeName = name; } |
c801d85f | 239 | |
b9f933ab JS |
240 | wxWindow *GetFrame() const { return m_viewFrame ; } |
241 | void SetFrame(wxWindow *frame) { m_viewFrame = frame; } | |
c801d85f | 242 | |
89d94e04 VZ |
243 | virtual void OnActivateView(bool activate, |
244 | wxView *activeView, | |
245 | wxView *deactiveView); | |
caf0debf VZ |
246 | virtual void OnDraw(wxDC *dc) = 0; |
247 | virtual void OnPrint(wxDC *dc, wxObject *info); | |
c77049a0 | 248 | virtual void OnUpdate(wxView *sender, wxObject *hint = NULL); |
6fb99eb3 | 249 | virtual void OnClosingDocument() {} |
caf0debf | 250 | virtual void OnChangeFilename(); |
c801d85f | 251 | |
caf0debf VZ |
252 | // Called by framework if created automatically by the default document |
253 | // manager class: gives view a chance to initialise | |
c77049a0 VZ |
254 | virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) |
255 | { return true; } | |
c801d85f | 256 | |
caf0debf VZ |
257 | // Checks if the view is the last one for the document; if so, asks user |
258 | // to confirm save data (if modified). If ok, deletes itself and returns | |
68379eaf WS |
259 | // true. |
260 | virtual bool Close(bool deleteWindow = true); | |
caf0debf VZ |
261 | |
262 | // Override to do cleanup/veto close | |
263 | virtual bool OnClose(bool deleteWindow); | |
2b854a32 | 264 | |
caf0debf VZ |
265 | // A view's window can call this to notify the view it is (in)active. |
266 | // The function then notifies the document manager. | |
267 | virtual void Activate(bool activate); | |
c801d85f | 268 | |
caf0debf VZ |
269 | wxDocManager *GetDocumentManager() const |
270 | { return m_viewDocument->GetDocumentManager(); } | |
c801d85f | 271 | |
47d67540 | 272 | #if wxUSE_PRINTING_ARCHITECTURE |
caf0debf | 273 | virtual wxPrintout *OnCreatePrintout(); |
c801d85f KB |
274 | #endif |
275 | ||
a9e2e6e5 VZ |
276 | // implementation only |
277 | // ------------------- | |
278 | ||
279 | // set the associated frame, it is used to reset its view when we're | |
280 | // destroyed | |
ada1ff0d | 281 | void SetDocChildFrame(wxDocChildFrameAnyBase *docChildFrame); |
a9e2e6e5 | 282 | |
caf0debf | 283 | protected: |
bba5e72a | 284 | // hook the document into event handlers chain here |
8cc208e3 | 285 | virtual bool TryBefore(wxEvent& event); |
bba5e72a | 286 | |
caf0debf VZ |
287 | wxDocument* m_viewDocument; |
288 | wxString m_viewTypeName; | |
b9f933ab | 289 | wxWindow* m_viewFrame; |
22f3361e | 290 | |
a9e2e6e5 VZ |
291 | wxDocChildFrameAnyBase *m_docChildFrame; |
292 | ||
2b5f62a0 VZ |
293 | private: |
294 | DECLARE_ABSTRACT_CLASS(wxView) | |
c0c133e1 | 295 | wxDECLARE_NO_COPY_CLASS(wxView); |
c801d85f KB |
296 | }; |
297 | ||
298 | // Represents user interface (and other) properties of documents and views | |
53a2db12 | 299 | class WXDLLIMPEXP_CORE wxDocTemplate: public wxObject |
c801d85f | 300 | { |
caf0debf | 301 | |
b5dbe15d | 302 | friend class WXDLLIMPEXP_FWD_CORE wxDocManager; |
caf0debf VZ |
303 | |
304 | public: | |
305 | // Associate document and view types. They're for identifying what view is | |
306 | // associated with what template/document type | |
307 | wxDocTemplate(wxDocManager *manager, | |
308 | const wxString& descr, | |
309 | const wxString& filter, | |
310 | const wxString& dir, | |
311 | const wxString& ext, | |
312 | const wxString& docTypeName, | |
313 | const wxString& viewTypeName, | |
c77049a0 VZ |
314 | wxClassInfo *docClassInfo = NULL, |
315 | wxClassInfo *viewClassInfo = NULL, | |
caf0debf VZ |
316 | long flags = wxDEFAULT_TEMPLATE_FLAGS); |
317 | ||
d3c7fc99 | 318 | virtual ~wxDocTemplate(); |
caf0debf VZ |
319 | |
320 | // By default, these two member functions dynamically creates document and | |
321 | // view using dynamic instance construction. Override these if you need a | |
322 | // different method of construction. | |
323 | virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); | |
324 | virtual wxView *CreateView(wxDocument *doc, long flags = 0); | |
325 | ||
217b7140 JS |
326 | // Helper method for CreateDocument; also allows you to do your own document |
327 | // creation | |
89d94e04 VZ |
328 | virtual bool InitDocument(wxDocument* doc, |
329 | const wxString& path, | |
330 | long flags = 0); | |
217b7140 | 331 | |
47b378bd | 332 | wxString GetDefaultExtension() const { return m_defaultExt; } |
caf0debf | 333 | wxString GetDescription() const { return m_description; } |
47b378bd | 334 | wxString GetDirectory() const { return m_directory; } |
caf0debf | 335 | wxDocManager *GetDocumentManager() const { return m_documentManager; } |
89d94e04 VZ |
336 | void SetDocumentManager(wxDocManager *manager) |
337 | { m_documentManager = manager; } | |
47b378bd VS |
338 | wxString GetFileFilter() const { return m_fileFilter; } |
339 | long GetFlags() const { return m_flags; } | |
caf0debf VZ |
340 | virtual wxString GetViewName() const { return m_viewTypeName; } |
341 | virtual wxString GetDocumentName() const { return m_docTypeName; } | |
342 | ||
47b378bd VS |
343 | void SetFileFilter(const wxString& filter) { m_fileFilter = filter; } |
344 | void SetDirectory(const wxString& dir) { m_directory = dir; } | |
345 | void SetDescription(const wxString& descr) { m_description = descr; } | |
346 | void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; } | |
347 | void SetFlags(long flags) { m_flags = flags; } | |
caf0debf | 348 | |
89d94e04 | 349 | bool IsVisible() const { return (m_flags & wxTEMPLATE_VISIBLE) != 0; } |
caf0debf | 350 | |
04129514 JS |
351 | wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; } |
352 | wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; } | |
353 | ||
caf0debf VZ |
354 | virtual bool FileMatchesTemplate(const wxString& path); |
355 | ||
356 | protected: | |
357 | long m_flags; | |
358 | wxString m_fileFilter; | |
359 | wxString m_directory; | |
360 | wxString m_description; | |
361 | wxString m_defaultExt; | |
362 | wxString m_docTypeName; | |
363 | wxString m_viewTypeName; | |
364 | wxDocManager* m_documentManager; | |
365 | ||
366 | // For dynamic creation of appropriate instances. | |
367 | wxClassInfo* m_docClassInfo; | |
368 | wxClassInfo* m_viewClassInfo; | |
b5f159ac | 369 | |
89d94e04 VZ |
370 | // Called by CreateDocument and CreateView to create the actual |
371 | // document/view object. | |
372 | // | |
373 | // By default uses the ClassInfo provided to the constructor. Override | |
374 | // these functions to provide a different method of creation. | |
69936aea VZ |
375 | virtual wxDocument *DoCreateDocument(); |
376 | virtual wxView *DoCreateView(); | |
377 | ||
2b5f62a0 VZ |
378 | private: |
379 | DECLARE_CLASS(wxDocTemplate) | |
c0c133e1 | 380 | wxDECLARE_NO_COPY_CLASS(wxDocTemplate); |
c801d85f KB |
381 | }; |
382 | ||
caf0debf VZ |
383 | // One object of this class may be created in an application, to manage all |
384 | // the templates and documents. | |
53a2db12 | 385 | class WXDLLIMPEXP_CORE wxDocManager: public wxEvtHandler |
c801d85f | 386 | { |
caf0debf | 387 | public: |
c77049a0 VZ |
388 | // NB: flags are unused, don't pass wxDOC_XXX to this ctor |
389 | wxDocManager(long flags = 0, bool initialize = true); | |
d3c7fc99 | 390 | virtual ~wxDocManager(); |
caf0debf VZ |
391 | |
392 | virtual bool Initialize(); | |
393 | ||
394 | // Handlers for common user commands | |
395 | void OnFileClose(wxCommandEvent& event); | |
33a20136 | 396 | void OnFileCloseAll(wxCommandEvent& event); |
caf0debf VZ |
397 | void OnFileNew(wxCommandEvent& event); |
398 | void OnFileOpen(wxCommandEvent& event); | |
399 | void OnFileRevert(wxCommandEvent& event); | |
400 | void OnFileSave(wxCommandEvent& event); | |
401 | void OnFileSaveAs(wxCommandEvent& event); | |
c70da1a2 | 402 | void OnMRUFile(wxCommandEvent& event); |
b99017ce | 403 | #if wxUSE_PRINTING_ARCHITECTURE |
caf0debf | 404 | void OnPrint(wxCommandEvent& event); |
caf0debf | 405 | void OnPreview(wxCommandEvent& event); |
b99017ce VZ |
406 | void OnPageSetup(wxCommandEvent& event); |
407 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
caf0debf VZ |
408 | void OnUndo(wxCommandEvent& event); |
409 | void OnRedo(wxCommandEvent& event); | |
410 | ||
f2506310 JS |
411 | // Handlers for UI update commands |
412 | void OnUpdateFileOpen(wxUpdateUIEvent& event); | |
c77049a0 | 413 | void OnUpdateDisableIfNoDoc(wxUpdateUIEvent& event); |
4311588b | 414 | void OnUpdateFileRevert(wxUpdateUIEvent& event); |
f2506310 JS |
415 | void OnUpdateFileNew(wxUpdateUIEvent& event); |
416 | void OnUpdateFileSave(wxUpdateUIEvent& event); | |
4db97e24 | 417 | void OnUpdateFileSaveAs(wxUpdateUIEvent& event); |
f2506310 JS |
418 | void OnUpdateUndo(wxUpdateUIEvent& event); |
419 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
420 | ||
5f170f33 VZ |
421 | // called when file format detection didn't work, can be overridden to do |
422 | // something in this case | |
0a0352f2 | 423 | virtual void OnOpenFileFailure() { } |
5f170f33 | 424 | |
caf0debf | 425 | virtual wxDocument *CreateDocument(const wxString& path, long flags = 0); |
b5412983 VZ |
426 | |
427 | // wrapper around CreateDocument() with a more clear name | |
428 | wxDocument *CreateNewDocument() | |
429 | { return CreateDocument(wxString(), wxDOC_NEW); } | |
430 | ||
caf0debf VZ |
431 | virtual wxView *CreateView(wxDocument *doc, long flags = 0); |
432 | virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0); | |
433 | virtual bool FlushDoc(wxDocument *doc); | |
434 | virtual wxDocTemplate *MatchTemplate(const wxString& path); | |
435 | virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates, | |
68379eaf | 436 | int noTemplates, wxString& path, long flags, bool save = false); |
caf0debf | 437 | virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates, |
68379eaf | 438 | int noTemplates, bool sort = false); |
caf0debf | 439 | virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates, |
68379eaf | 440 | int noTemplates, bool sort = false); |
caf0debf VZ |
441 | virtual wxDocTemplate *FindTemplateForPath(const wxString& path); |
442 | ||
443 | void AssociateTemplate(wxDocTemplate *temp); | |
444 | void DisassociateTemplate(wxDocTemplate *temp); | |
445 | ||
a70d268a VZ |
446 | // Find template from document class info, may return NULL. |
447 | wxDocTemplate* FindTemplate(const wxClassInfo* documentClassInfo); | |
448 | ||
1127eb3a VZ |
449 | // Find document from file name, may return NULL. |
450 | wxDocument* FindDocumentByPath(const wxString& path) const; | |
451 | ||
caf0debf VZ |
452 | wxDocument *GetCurrentDocument() const; |
453 | ||
454 | void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; } | |
455 | int GetMaxDocsOpen() const { return m_maxDocsOpen; } | |
456 | ||
457 | // Add and remove a document from the manager's list | |
458 | void AddDocument(wxDocument *doc); | |
459 | void RemoveDocument(wxDocument *doc); | |
460 | ||
33a20136 | 461 | // closes all currently open documents |
68379eaf | 462 | bool CloseDocuments(bool force = true); |
33a20136 | 463 | |
b72b1920 | 464 | // closes the specified document |
68379eaf | 465 | bool CloseDocument(wxDocument* doc, bool force = false); |
b72b1920 | 466 | |
caf0debf | 467 | // Clear remaining documents and templates |
68379eaf | 468 | bool Clear(bool force = true); |
caf0debf VZ |
469 | |
470 | // Views or windows should inform the document manager | |
471 | // when a view is going in or out of focus | |
68379eaf | 472 | virtual void ActivateView(wxView *view, bool activate = true); |
575e4cd6 | 473 | virtual wxView *GetCurrentView() const { return m_currentView; } |
caf0debf | 474 | |
de280423 VZ |
475 | // This method tries to find an active view harder than GetCurrentView(): |
476 | // if the latter is NULL, it also checks if we don't have just a single | |
477 | // view and returns it then. | |
478 | wxView *GetAnyUsableView() const; | |
479 | ||
480 | ||
93d0805b | 481 | #ifndef __VISUALC6__ |
8f2a8df4 VZ |
482 | wxDocVector GetDocumentsVector() const; |
483 | wxDocTemplateVector GetTemplatesVector() const; | |
288de46c VZ |
484 | #endif // !__VISUALC6__ |
485 | ||
0b237b67 JS |
486 | wxList& GetDocuments() { return m_docs; } |
487 | wxList& GetTemplates() { return m_templates; } | |
caf0debf | 488 | |
724b119a VZ |
489 | // Return the default name for a new document (by default returns strings |
490 | // in the form "unnamed <counter>" but can be overridden) | |
491 | virtual wxString MakeNewDocumentName(); | |
caf0debf | 492 | |
f2506310 JS |
493 | // Make a frame title (override this to do something different) |
494 | virtual wxString MakeFrameTitle(wxDocument* doc); | |
495 | ||
caf0debf VZ |
496 | virtual wxFileHistory *OnCreateFileHistory(); |
497 | virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; } | |
498 | ||
499 | // File history management | |
500 | virtual void AddFileToHistory(const wxString& file); | |
e49c85af | 501 | virtual void RemoveFileFromHistory(size_t i); |
7af6b69e | 502 | virtual size_t GetHistoryFilesCount() const; |
e49c85af | 503 | virtual wxString GetHistoryFile(size_t i) const; |
caf0debf VZ |
504 | virtual void FileHistoryUseMenu(wxMenu *menu); |
505 | virtual void FileHistoryRemoveMenu(wxMenu *menu); | |
702ca7c0 | 506 | #if wxUSE_CONFIG |
9c8116f8 | 507 | virtual void FileHistoryLoad(const wxConfigBase& config); |
caf0debf VZ |
508 | virtual void FileHistorySave(wxConfigBase& config); |
509 | #endif // wxUSE_CONFIG | |
510 | ||
511 | virtual void FileHistoryAddFilesToMenu(); | |
512 | virtual void FileHistoryAddFilesToMenu(wxMenu* menu); | |
513 | ||
d8efd219 | 514 | wxString GetLastDirectory() const; |
7af6b69e | 515 | void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; } |
ac0ac824 | 516 | |
f2506310 JS |
517 | // Get the current document manager |
518 | static wxDocManager* GetDocumentManager() { return sm_docManager; } | |
519 | ||
61490d3b VZ |
520 | #if wxUSE_PRINTING_ARCHITECTURE |
521 | wxPageSetupDialogData& GetPageSetupDialogData() | |
522 | { return m_pageSetupDialogData; } | |
523 | const wxPageSetupDialogData& GetPageSetupDialogData() const | |
524 | { return m_pageSetupDialogData; } | |
525 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
526 | ||
724b119a VZ |
527 | #if WXWIN_COMPATIBILITY_2_8 |
528 | // deprecated, override GetDefaultName() instead | |
529 | wxDEPRECATED_BUT_USED_INTERNALLY( | |
530 | virtual bool MakeDefaultName(wxString& buf) | |
531 | ); | |
532 | #endif | |
533 | ||
ca3e85cf | 534 | #if WXWIN_COMPATIBILITY_2_6 |
b5f159ac VZ |
535 | // deprecated, use GetHistoryFilesCount() instead |
536 | wxDEPRECATED( size_t GetNoHistoryFiles() const ); | |
ca3e85cf | 537 | #endif // WXWIN_COMPATIBILITY_2_6 |
7af6b69e | 538 | |
b99017ce | 539 | |
caf0debf | 540 | protected: |
d38eb01c VZ |
541 | // Called when a file selected from the MRU list doesn't exist any more. |
542 | // The default behaviour is to remove the file from the MRU and notify the | |
543 | // user about it but this method can be overridden to customize it. | |
544 | virtual void OnMRUFileNotExist(unsigned n, const wxString& filename); | |
545 | ||
c70da1a2 VZ |
546 | // Open the MRU file with the given index in our associated file history. |
547 | void DoOpenMRUFile(unsigned n); | |
94dc70d1 VZ |
548 | #if wxUSE_PRINTING_ARCHITECTURE |
549 | virtual wxPreviewFrame* CreatePreviewFrame(wxPrintPreviewBase* preview, | |
550 | wxWindow *parent, | |
551 | const wxString& title); | |
552 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
553 | ||
bba5e72a | 554 | // hook the currently active view into event handlers chain here |
8cc208e3 | 555 | virtual bool TryBefore(wxEvent& event); |
bba5e72a | 556 | |
89d94e04 VZ |
557 | // return the command processor for the current document, if any |
558 | wxCommandProcessor *GetCurrentCommandProcessor() const; | |
559 | ||
caf0debf VZ |
560 | int m_defaultDocumentNameCounter; |
561 | int m_maxDocsOpen; | |
562 | wxList m_docs; | |
563 | wxList m_templates; | |
564 | wxView* m_currentView; | |
565 | wxFileHistory* m_fileHistory; | |
ac0ac824 | 566 | wxString m_lastDirectory; |
f2506310 | 567 | static wxDocManager* sm_docManager; |
caf0debf | 568 | |
b99017ce VZ |
569 | #if wxUSE_PRINTING_ARCHITECTURE |
570 | wxPageSetupDialogData m_pageSetupDialogData; | |
571 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
572 | ||
caf0debf | 573 | DECLARE_EVENT_TABLE() |
b5f159ac | 574 | DECLARE_DYNAMIC_CLASS(wxDocManager) |
c0c133e1 | 575 | wxDECLARE_NO_COPY_CLASS(wxDocManager); |
c801d85f KB |
576 | }; |
577 | ||
ca3e85cf | 578 | #if WXWIN_COMPATIBILITY_2_6 |
b5f159ac VZ |
579 | inline size_t wxDocManager::GetNoHistoryFiles() const |
580 | { | |
581 | return GetHistoryFilesCount(); | |
582 | } | |
ca3e85cf | 583 | #endif // WXWIN_COMPATIBILITY_2_6 |
b5f159ac | 584 | |
caf0debf | 585 | // ---------------------------------------------------------------------------- |
a9e2e6e5 VZ |
586 | // Base class for child frames -- this is what wxView renders itself into |
587 | // | |
588 | // Notice that this is a mix-in class so it doesn't derive from wxWindow, only | |
589 | // wxDocChildFrameAny does | |
caf0debf | 590 | // ---------------------------------------------------------------------------- |
c801d85f | 591 | |
73bde1ef | 592 | class WXDLLIMPEXP_CORE wxDocChildFrameAnyBase |
c801d85f | 593 | { |
caf0debf | 594 | public: |
c65c67be | 595 | // default ctor, use Create() after it |
e5033ed2 VZ |
596 | wxDocChildFrameAnyBase() |
597 | { | |
598 | m_childDocument = NULL; | |
599 | m_childView = NULL; | |
600 | m_win = NULL; | |
601 | } | |
c65c67be VZ |
602 | |
603 | // full ctor equivalent to using the default one and Create(0 | |
ada1ff0d | 604 | wxDocChildFrameAnyBase(wxDocument *doc, wxView *view, wxWindow *win) |
c65c67be VZ |
605 | { |
606 | Create(doc, view, win); | |
607 | } | |
608 | ||
609 | // method which must be called for an object created using the default ctor | |
610 | // | |
611 | // note that it returns bool just for consistency with Create() methods in | |
612 | // other classes, we never return false from here | |
613 | bool Create(wxDocument *doc, wxView *view, wxWindow *win) | |
a9e2e6e5 VZ |
614 | { |
615 | m_childDocument = doc; | |
616 | m_childView = view; | |
c65c67be | 617 | m_win = win; |
caf0debf | 618 | |
a9e2e6e5 VZ |
619 | if ( view ) |
620 | view->SetDocChildFrame(this); | |
c65c67be VZ |
621 | |
622 | return true; | |
a9e2e6e5 | 623 | } |
caf0debf | 624 | |
c65c67be VZ |
625 | // dtor doesn't need to be virtual, an object should never be destroyed via |
626 | // a pointer to this class | |
b7341fe0 VZ |
627 | ~wxDocChildFrameAnyBase() |
628 | { | |
629 | // prevent the view from deleting us if we're being deleted directly | |
630 | // (and not via Close() + Destroy()) | |
631 | if ( m_childView ) | |
632 | m_childView->SetDocChildFrame(NULL); | |
633 | } | |
634 | ||
caf0debf VZ |
635 | wxDocument *GetDocument() const { return m_childDocument; } |
636 | wxView *GetView() const { return m_childView; } | |
637 | void SetDocument(wxDocument *doc) { m_childDocument = doc; } | |
638 | void SetView(wxView *view) { m_childView = view; } | |
639 | ||
ada1ff0d VZ |
640 | wxWindow *GetWindow() const { return m_win; } |
641 | ||
caf0debf | 642 | protected: |
a9e2e6e5 VZ |
643 | // we're not a wxEvtHandler but we provide this wxEvtHandler-like function |
644 | // which is called from TryBefore() of the derived classes to give our view | |
645 | // a chance to process the message before the frame event handlers are used | |
a7c0de8a | 646 | bool TryProcessEvent(wxEvent& event); |
a9e2e6e5 VZ |
647 | |
648 | // called from EVT_CLOSE handler in the frame: check if we can close and do | |
649 | // cleanup if so; veto the event otherwise | |
650 | bool CloseView(wxCloseEvent& event); | |
651 | ||
bba5e72a | 652 | |
caf0debf VZ |
653 | wxDocument* m_childDocument; |
654 | wxView* m_childView; | |
655 | ||
ada1ff0d VZ |
656 | // the associated window: having it here is not terribly elegant but it |
657 | // allows us to avoid having any virtual functions in this class | |
c65c67be | 658 | wxWindow* m_win; |
ada1ff0d VZ |
659 | |
660 | ||
a9e2e6e5 VZ |
661 | wxDECLARE_NO_COPY_CLASS(wxDocChildFrameAnyBase); |
662 | }; | |
663 | ||
664 | // ---------------------------------------------------------------------------- | |
665 | // Template implementing child frame concept using the given wxFrame-like class | |
666 | // | |
667 | // This is used to define wxDocChildFrame and wxDocMDIChildFrame: ChildFrame is | |
668 | // a wxFrame or wxMDIChildFrame (although in theory it could be any wxWindow- | |
669 | // derived class as long as it provided a ctor with the same signature as | |
670 | // wxFrame and OnActivate() method) and ParentFrame is either wxFrame or | |
671 | // wxMDIParentFrame. | |
672 | // ---------------------------------------------------------------------------- | |
673 | ||
674 | template <class ChildFrame, class ParentFrame> | |
675 | class WXDLLIMPEXP_CORE wxDocChildFrameAny : public ChildFrame, | |
676 | public wxDocChildFrameAnyBase | |
677 | { | |
678 | public: | |
679 | typedef ChildFrame BaseClass; | |
680 | ||
c65c67be VZ |
681 | // default ctor, use Create after it |
682 | wxDocChildFrameAny() { } | |
683 | ||
a9e2e6e5 VZ |
684 | // ctor for a frame showing the given view of the specified document |
685 | wxDocChildFrameAny(wxDocument *doc, | |
686 | wxView *view, | |
687 | ParentFrame *parent, | |
688 | wxWindowID id, | |
689 | const wxString& title, | |
690 | const wxPoint& pos = wxDefaultPosition, | |
691 | const wxSize& size = wxDefaultSize, | |
692 | long style = wxDEFAULT_FRAME_STYLE, | |
693 | const wxString& name = wxFrameNameStr) | |
a9e2e6e5 | 694 | { |
c65c67be VZ |
695 | Create(doc, view, parent, id, title, pos, size, style, name); |
696 | } | |
697 | ||
698 | bool Create(wxDocument *doc, | |
699 | wxView *view, | |
700 | ParentFrame *parent, | |
701 | wxWindowID id, | |
702 | const wxString& title, | |
703 | const wxPoint& pos = wxDefaultPosition, | |
704 | const wxSize& size = wxDefaultSize, | |
705 | long style = wxDEFAULT_FRAME_STYLE, | |
706 | const wxString& name = wxFrameNameStr) | |
707 | { | |
e5033ed2 | 708 | if ( !wxDocChildFrameAnyBase::Create(doc, view, this) ) |
c65c67be VZ |
709 | return false; |
710 | ||
e5033ed2 | 711 | if ( !BaseClass::Create(parent, id, title, pos, size, style, name) ) |
c65c67be VZ |
712 | return false; |
713 | ||
a9e2e6e5 VZ |
714 | this->Connect(wxEVT_ACTIVATE, |
715 | wxActivateEventHandler(wxDocChildFrameAny::OnActivate)); | |
716 | this->Connect(wxEVT_CLOSE_WINDOW, | |
717 | wxCloseEventHandler(wxDocChildFrameAny::OnCloseWindow)); | |
c65c67be VZ |
718 | |
719 | return true; | |
a9e2e6e5 VZ |
720 | } |
721 | ||
722 | virtual bool Destroy() | |
723 | { | |
724 | // FIXME: why exactly do we do this? to avoid activation events during | |
725 | // destructions maybe? | |
726 | m_childView = NULL; | |
727 | return BaseClass::Destroy(); | |
728 | } | |
729 | ||
730 | protected: | |
731 | // hook the child view into event handlers chain here | |
732 | virtual bool TryBefore(wxEvent& event) | |
733 | { | |
734 | return TryProcessEvent(event) || BaseClass::TryBefore(event); | |
735 | } | |
736 | ||
737 | private: | |
738 | void OnActivate(wxActivateEvent& event) | |
739 | { | |
740 | BaseClass::OnActivate(event); | |
741 | ||
742 | if ( m_childView ) | |
743 | m_childView->Activate(event.GetActive()); | |
744 | } | |
745 | ||
746 | void OnCloseWindow(wxCloseEvent& event) | |
747 | { | |
748 | if ( CloseView(event) ) | |
749 | Destroy(); | |
750 | //else: vetoed | |
751 | } | |
752 | ||
753 | wxDECLARE_NO_COPY_TEMPLATE_CLASS_2(wxDocChildFrameAny, | |
754 | ChildFrame, ParentFrame); | |
755 | }; | |
756 | ||
757 | // ---------------------------------------------------------------------------- | |
758 | // A default child frame: we need to define it as a class just for wxRTTI, | |
759 | // otherwise we could simply typedef it | |
760 | // ---------------------------------------------------------------------------- | |
761 | ||
27d77a59 VZ |
762 | #ifdef __VISUALC6__ |
763 | // "non dll-interface class 'wxDocChildFrameAny<>' used as base interface | |
764 | // for dll-interface class 'wxDocChildFrame'" -- this is bogus as the | |
765 | // template will be DLL-exported but only once it is used as base class | |
766 | // here! | |
fb330c2e | 767 | #pragma warning (push) |
27d77a59 VZ |
768 | #pragma warning (disable:4275) |
769 | #endif | |
770 | ||
a9e2e6e5 VZ |
771 | typedef wxDocChildFrameAny<wxFrame, wxFrame> wxDocChildFrameBase; |
772 | ||
773 | class WXDLLIMPEXP_CORE wxDocChildFrame : public wxDocChildFrameBase | |
774 | { | |
775 | public: | |
c65c67be VZ |
776 | wxDocChildFrame() |
777 | { | |
778 | } | |
779 | ||
a9e2e6e5 VZ |
780 | wxDocChildFrame(wxDocument *doc, |
781 | wxView *view, | |
782 | wxFrame *parent, | |
783 | wxWindowID id, | |
784 | const wxString& title, | |
785 | const wxPoint& pos = wxDefaultPosition, | |
786 | const wxSize& size = wxDefaultSize, | |
787 | long style = wxDEFAULT_FRAME_STYLE, | |
788 | const wxString& name = wxFrameNameStr) | |
789 | : wxDocChildFrameBase(doc, view, | |
790 | parent, id, title, pos, size, style, name) | |
791 | { | |
792 | } | |
793 | ||
c65c67be VZ |
794 | bool Create(wxDocument *doc, |
795 | wxView *view, | |
796 | wxFrame *parent, | |
797 | wxWindowID id, | |
798 | const wxString& title, | |
799 | const wxPoint& pos = wxDefaultPosition, | |
800 | const wxSize& size = wxDefaultSize, | |
801 | long style = wxDEFAULT_FRAME_STYLE, | |
802 | const wxString& name = wxFrameNameStr) | |
803 | { | |
804 | return wxDocChildFrameBase::Create | |
805 | ( | |
806 | doc, view, | |
807 | parent, id, title, pos, size, style, name | |
808 | ); | |
809 | } | |
810 | ||
2b5f62a0 VZ |
811 | private: |
812 | DECLARE_CLASS(wxDocChildFrame) | |
c0c133e1 | 813 | wxDECLARE_NO_COPY_CLASS(wxDocChildFrame); |
caf0debf | 814 | }; |
c801d85f | 815 | |
caf0debf | 816 | // ---------------------------------------------------------------------------- |
c48bdb0c VZ |
817 | // wxDocParentFrame and related classes. |
818 | // | |
819 | // As with wxDocChildFrame we define a template base class used by both normal | |
820 | // and MDI versions | |
caf0debf | 821 | // ---------------------------------------------------------------------------- |
c801d85f | 822 | |
c48bdb0c VZ |
823 | // Base class containing type-independent code of wxDocParentFrameAny |
824 | // | |
825 | // Similarly to wxDocChildFrameAnyBase, this class is a mix-in and doesn't | |
826 | // derive from wxWindow. | |
827 | class WXDLLIMPEXP_CORE wxDocParentFrameAnyBase | |
caf0debf | 828 | { |
caf0debf | 829 | public: |
a7c0de8a VZ |
830 | wxDocParentFrameAnyBase(wxWindow* frame) |
831 | : m_frame(frame) | |
832 | { | |
833 | m_docManager = NULL; | |
834 | } | |
c48bdb0c VZ |
835 | |
836 | wxDocManager *GetDocumentManager() const { return m_docManager; } | |
837 | ||
838 | protected: | |
a7c0de8a VZ |
839 | // This is similar to wxDocChildFrameAnyBase method with the same name: |
840 | // while we're not an event handler ourselves and so can't override | |
841 | // TryBefore(), we provide a helper that the derived template class can use | |
842 | // from its TryBefore() implementation. | |
843 | bool TryProcessEvent(wxEvent& event); | |
844 | ||
845 | wxWindow* const m_frame; | |
c48bdb0c VZ |
846 | wxDocManager *m_docManager; |
847 | ||
848 | wxDECLARE_NO_COPY_CLASS(wxDocParentFrameAnyBase); | |
849 | }; | |
850 | ||
851 | // This is similar to wxDocChildFrameAny and is used to provide common | |
852 | // implementation for both wxDocParentFrame and wxDocMDIParentFrame | |
853 | template <class BaseFrame> | |
854 | class WXDLLIMPEXP_CORE wxDocParentFrameAny : public BaseFrame, | |
855 | public wxDocParentFrameAnyBase | |
856 | { | |
857 | public: | |
a7c0de8a | 858 | wxDocParentFrameAny() : wxDocParentFrameAnyBase(this) { } |
c48bdb0c VZ |
859 | wxDocParentFrameAny(wxDocManager *manager, |
860 | wxFrame *frame, | |
861 | wxWindowID id, | |
862 | const wxString& title, | |
863 | const wxPoint& pos = wxDefaultPosition, | |
864 | const wxSize& size = wxDefaultSize, | |
865 | long style = wxDEFAULT_FRAME_STYLE, | |
866 | const wxString& name = wxFrameNameStr) | |
a7c0de8a | 867 | : wxDocParentFrameAnyBase(this) |
c48bdb0c VZ |
868 | { |
869 | Create(manager, frame, id, title, pos, size, style, name); | |
870 | } | |
0c246b3c PC |
871 | |
872 | bool Create(wxDocManager *manager, | |
873 | wxFrame *frame, | |
874 | wxWindowID id, | |
875 | const wxString& title, | |
876 | const wxPoint& pos = wxDefaultPosition, | |
877 | const wxSize& size = wxDefaultSize, | |
878 | long style = wxDEFAULT_FRAME_STYLE, | |
c48bdb0c VZ |
879 | const wxString& name = wxFrameNameStr) |
880 | { | |
881 | m_docManager = manager; | |
c801d85f | 882 | |
c48bdb0c VZ |
883 | if ( !BaseFrame::Create(frame, id, title, pos, size, style, name) ) |
884 | return false; | |
885 | ||
ce7fe42e | 886 | this->Connect(wxID_EXIT, wxEVT_MENU, |
c48bdb0c | 887 | wxCommandEventHandler(wxDocParentFrameAny::OnExit)); |
c48bdb0c VZ |
888 | this->Connect(wxEVT_CLOSE_WINDOW, |
889 | wxCloseEventHandler(wxDocParentFrameAny::OnCloseWindow)); | |
c801d85f | 890 | |
c48bdb0c VZ |
891 | return true; |
892 | } | |
c801d85f | 893 | |
caf0debf | 894 | protected: |
bba5e72a | 895 | // hook the document manager into event handling chain here |
c48bdb0c VZ |
896 | virtual bool TryBefore(wxEvent& event) |
897 | { | |
a7c0de8a | 898 | return TryProcessEvent(event) || BaseFrame::TryBefore(event); |
c48bdb0c VZ |
899 | } |
900 | ||
901 | private: | |
902 | void OnExit(wxCommandEvent& WXUNUSED(event)) | |
903 | { | |
904 | this->Close(); | |
905 | } | |
906 | ||
c48bdb0c VZ |
907 | void OnCloseWindow(wxCloseEvent& event) |
908 | { | |
909 | if ( m_docManager && !m_docManager->Clear(!event.CanVeto()) ) | |
910 | { | |
911 | // The user decided not to close finally, abort. | |
912 | event.Veto(); | |
913 | } | |
914 | else | |
915 | { | |
916 | // Just skip the event, base class handler will destroy the window. | |
917 | event.Skip(); | |
918 | } | |
919 | } | |
920 | ||
921 | ||
922 | wxDECLARE_NO_COPY_CLASS(wxDocParentFrameAny); | |
923 | }; | |
924 | ||
925 | typedef wxDocParentFrameAny<wxFrame> wxDocParentFrameBase; | |
926 | ||
927 | class WXDLLIMPEXP_CORE wxDocParentFrame : public wxDocParentFrameBase | |
928 | { | |
929 | public: | |
930 | wxDocParentFrame() : wxDocParentFrameBase() { } | |
931 | ||
932 | wxDocParentFrame(wxDocManager *manager, | |
933 | wxFrame *parent, | |
934 | wxWindowID id, | |
935 | const wxString& title, | |
936 | const wxPoint& pos = wxDefaultPosition, | |
937 | const wxSize& size = wxDefaultSize, | |
938 | long style = wxDEFAULT_FRAME_STYLE, | |
939 | const wxString& name = wxFrameNameStr) | |
940 | : wxDocParentFrameBase(manager, | |
941 | parent, id, title, pos, size, style, name) | |
942 | { | |
943 | } | |
944 | ||
945 | bool Create(wxDocManager *manager, | |
946 | wxFrame *parent, | |
947 | wxWindowID id, | |
948 | const wxString& title, | |
949 | const wxPoint& pos = wxDefaultPosition, | |
950 | const wxSize& size = wxDefaultSize, | |
951 | long style = wxDEFAULT_FRAME_STYLE, | |
952 | const wxString& name = wxFrameNameStr) | |
953 | { | |
954 | return wxDocParentFrameBase::Create(manager, | |
955 | parent, id, title, | |
956 | pos, size, style, name); | |
957 | } | |
caf0debf | 958 | |
2b5f62a0 VZ |
959 | private: |
960 | DECLARE_CLASS(wxDocParentFrame) | |
c0c133e1 | 961 | wxDECLARE_NO_COPY_CLASS(wxDocParentFrame); |
caf0debf | 962 | }; |
c801d85f | 963 | |
c48bdb0c VZ |
964 | #ifdef __VISUALC6__ |
965 | // reenable warning 4275 | |
966 | #pragma warning (pop) | |
967 | #endif | |
968 | ||
caf0debf VZ |
969 | // ---------------------------------------------------------------------------- |
970 | // Provide simple default printing facilities | |
971 | // ---------------------------------------------------------------------------- | |
c801d85f | 972 | |
caf0debf | 973 | #if wxUSE_PRINTING_ARCHITECTURE |
53a2db12 | 974 | class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout |
caf0debf | 975 | { |
caf0debf | 976 | public: |
302674fe | 977 | wxDocPrintout(wxView *view = NULL, const wxString& title = wxString()); |
89d94e04 VZ |
978 | |
979 | // implement wxPrintout methods | |
980 | virtual bool OnPrintPage(int page); | |
981 | virtual bool HasPage(int page); | |
982 | virtual bool OnBeginDocument(int startPage, int endPage); | |
983 | virtual void GetPageInfo(int *minPage, int *maxPage, | |
984 | int *selPageFrom, int *selPageTo); | |
c801d85f | 985 | |
caf0debf | 986 | virtual wxView *GetView() { return m_printoutView; } |
c801d85f | 987 | |
caf0debf VZ |
988 | protected: |
989 | wxView* m_printoutView; | |
2b5f62a0 VZ |
990 | |
991 | private: | |
992 | DECLARE_DYNAMIC_CLASS(wxDocPrintout) | |
c0c133e1 | 993 | wxDECLARE_NO_COPY_CLASS(wxDocPrintout); |
c801d85f | 994 | }; |
caf0debf | 995 | #endif // wxUSE_PRINTING_ARCHITECTURE |
c801d85f | 996 | |
c801d85f KB |
997 | // For compatibility with existing file formats: |
998 | // converts from/to a stream to/from a temporary file. | |
89d94e04 VZ |
999 | #if wxUSE_STD_IOSTREAM |
1000 | bool WXDLLIMPEXP_CORE | |
1001 | wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream); | |
1002 | bool WXDLLIMPEXP_CORE | |
1003 | wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename); | |
dc1efb1d | 1004 | #else |
89d94e04 VZ |
1005 | bool WXDLLIMPEXP_CORE |
1006 | wxTransferFileToStream(const wxString& filename, wxOutputStream& stream); | |
1007 | bool WXDLLIMPEXP_CORE | |
1008 | wxTransferStreamToFile(wxInputStream& stream, const wxString& filename); | |
e30285ab VZ |
1009 | #endif // wxUSE_STD_IOSTREAM |
1010 | ||
c77049a0 VZ |
1011 | |
1012 | // these flags are not used anywhere by wxWidgets and kept only for an unlikely | |
1013 | // case of existing user code using them for its own purposes | |
7bc57fd9 | 1014 | #if WXWIN_COMPATIBILITY_2_8 |
c77049a0 VZ |
1015 | enum |
1016 | { | |
1017 | wxDOC_SDI = 1, | |
1018 | wxDOC_MDI, | |
1019 | wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI | |
1020 | }; | |
1021 | #endif // WXWIN_COMPATIBILITY_2_8 | |
1022 | ||
8f2a8df4 VZ |
1023 | #ifndef __VISUALC6__ |
1024 | inline wxViewVector wxDocument::GetViewsVector() const | |
1025 | { | |
1026 | return m_documentViews.AsVector<wxView*>(); | |
1027 | } | |
1028 | ||
1029 | inline wxDocVector wxDocManager::GetDocumentsVector() const | |
1030 | { | |
1031 | return m_docs.AsVector<wxDocument*>(); | |
1032 | } | |
1033 | ||
1034 | inline wxDocTemplateVector wxDocManager::GetTemplatesVector() const | |
1035 | { | |
1036 | return m_templates.AsVector<wxDocTemplate*>(); | |
1037 | } | |
1038 | #endif // !__VISUALC6__ | |
1039 | ||
e30285ab | 1040 | #endif // wxUSE_DOC_VIEW_ARCHITECTURE |
c801d85f | 1041 | |
caf0debf | 1042 | #endif // _WX_DOCH__ |