]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/document.tex
Defined PBS_SMOOTH, PBS_VERTICAL in gauge95.cpp, if required
[wxWidgets.git] / docs / latex / wx / document.tex
CommitLineData
a660d684
KB
1\section{\class{wxDocument}}\label{wxdocument}
2
3The document class can be used to model an application's file-based
4data. It is part of the document/view framework supported by wxWindows,
5and cooperates with the \helpref{wxView}{wxview}, \helpref{wxDocTemplate}{wxdoctemplate}\rtfsp
6and \helpref{wxDocManager}{wxdocmanager} classes.
7
8\wxheading{Derived from}
9
10\helpref{wxEvtHandler}{wxevthandler}\\
11\helpref{wxObject}{wxobject}
12
954b8ae6
JS
13\wxheading{Include files}
14
15<wx/docview.h>
16
a660d684
KB
17\wxheading{See also}
18
19\helpref{wxDocument overview}{wxdocumentoverview}, \helpref{wxView}{wxview},\rtfsp
20\helpref{wxDocTemplate}{wxdoctemplate}, \helpref{wxDocManager}{wxdocmanager}
21
22\latexignore{\rtfignore{\wxheading{Members}}}
23
24\membersection{wxDocument::m\_commandProcessor}
25
26\member{wxCommandProcessor*}{m\_commandProcessor}
27
28A pointer to the command processor associated with this document.
29
30\membersection{wxDocument::m\_documentFile}
31
32\member{wxString}{m\_documentFile}
33
34Filename associated with this document (``" if none).
35
36\membersection{wxDocument::m\_documentModified}
37
38\member{bool}{m\_documentModified}
39
40TRUE if the document has been modified, FALSE otherwise.
41
42\membersection{wxDocument::m\_documentTemplate}
43
44\member{wxDocTemplate *}{m\_documentTemplate}
45
46A pointer to the template from which this document was created.
47
48\membersection{wxDocument::m\_documentTitle}
49
50\member{wxString}{m\_documentTitle}
51
52Document title. The document title is used for an associated
53frame (if any), and is usually constructed by the framework from
54the filename.
55
56\membersection{wxDocument::m\_documentTypeName}\label{documenttypename}
57
58\member{wxString}{m\_documentTypeName}
59
60The document type name given to the wxDocTemplate constructor, copied to this
61variable when the document is created. If several document templates are
62created that use the same document type, this variable is used in wxDocManager::CreateView
63to collate a list of alternative view types that can be used on this kind of
64document. Do not change the value of this variable.
65
66\membersection{wxDocument::m\_documentViews}
67
68\member{wxList}{m\_documentViews}
69
70List of wxView instances associated with this document.
71
72\membersection{wxDocument::wxDocument}
73
74\func{}{wxDocument}{\void}
75
76Constructor. Define your own default constructor to initialize application-specific
77data.
78
79\membersection{wxDocument::\destruct{wxDocument}}
80
81\func{}{\destruct{wxDocument}}{\void}
82
83Destructor. Removes itself from the document manager.
84
85\membersection{wxDocument::AddView}
86
87\func{virtual bool}{AddView}{\param{wxView *}{view}}
88
89If the view is not already in the list of views, adds the view and calls OnChangedViewList.
90
91\membersection{wxDocument::Close}
92
93\func{virtual bool}{Close}{\void}
94
95Closes the document, by calling OnSaveModified and then (if this returned TRUE) OnCloseDocument.
96This does not normally delete the document object: use DeleteAllViews to do this implicitly.
97
98\membersection{wxDocument::DeleteAllViews}
99
100\func{virtual bool}{DeleteAllViews}{\void}
101
102Calls wxView::Close and deletes each view. Deleting the final view will implicitly
103delete the document itself, because the wxView destructor calls RemoveView. This
104in turns calls wxDocument::OnChangedViewList, whose default implemention is to
105save and delete the document if no views exist.
106
107\membersection{wxDocument::GetCommandProcessor}
108
109\constfunc{wxCommandProcessor*}{GetCommandProcessor}{\void}
110
111Returns a pointer to the command processor associated with this document.
112
113See \helpref{wxCommandProcessor}{wxcommandprocessor}.
114
115\membersection{wxDocument::GetDocumentTemplate}
116
117\constfunc{wxDocTemplate*}{GetDocumentTemplate}{\void}
118
119Gets a pointer to the template that created the document.
120
121\membersection{wxDocument::GetDocumentManager}
122
123\constfunc{wxDocManager*}{GetDocumentManager}{\void}
124
125Gets a pointer to the associated document manager.
126
127\membersection{wxDocument::GetDocumentName}
128
129\constfunc{wxString}{GetDocumentName}{\void}
130
131Gets the document type name for this document. See the comment for \helpref{documentTypeName}{documenttypename}.
132
133\membersection{wxDocument::GetDocumentWindow}
134
135\constfunc{wxWindow*}{GetDocumentWindow}{\void}
136
137Intended to return a suitable window for using as a parent for document-related
138dialog boxes. By default, uses the frame associated with the first view.
139
140\membersection{wxDocument::GetFilename}
141
142\constfunc{wxString}{GetFilename}{\void}
143
ad813b00 144Gets the filename associated with this document, or "" if none is
a660d684
KB
145associated.
146
4b21397f 147\membersection{wxDocument::GetFirstView}{wxdocumentgetfirstview}
a660d684 148
4b21397f 149\constfunc{wxView *}{GetFirstView}{\void}
a660d684
KB
150
151A convenience function to get the first view for a document, because
152in many cases a document will only have a single view.
153
4b21397f
VZ
154See also: \helpref{GetViews}{wxdocumentgetviews}
155
a660d684
KB
156\membersection{wxDocument::GetPrintableName}
157
158\constfunc{virtual void}{GetPrintableName}{\param{wxString\& }{name}}
159
160Copies a suitable document name into the supplied {\it name} buffer. The default
161function uses the title, or if there is no title, uses the filename; or if no
162filename, the string {\bf unnamed}.
163
164\membersection{wxDocument::GetTitle}
165
166\constfunc{wxString}{GetTitle}{\void}
167
168Gets the title for this document. The document title is used for an associated
169frame (if any), and is usually constructed by the framework from
170the filename.
171
4b21397f
VZ
172\membersection{wxDocument::GetViews}{wxdocumentgetviews}
173
174\constfunc{wxList \&}{GetViews}{\void}
175
176Returns the list whose elements are the views on the document.
177
178See also: \helpref{GetFirstView}{wxdocumentgetfirstview}
179
180
a660d684
KB
181\membersection{wxDocument::IsModified}\label{wxdocumentismodified}
182
183\constfunc{virtual bool}{IsModified}{\void}
184
185Returns TRUE if the document has been modified since the last save, FALSE otherwise.
186You may need to override this if your document view maintains its own
187record of being modified (for example if using wxTextWindow to view and edit the document).
188
189See also \helpref{Modify}{wxdocumentmodify}.
190
191\membersection{wxDocument::LoadObject}
192
193\func{virtual istream\&}{LoadObject}{\param{istream\& }{stream}}
194
195Override this function and call it from your own LoadObject before
196streaming your own data. LoadObject is called by the framework
197automatically when the document contents need to be loaded.
198
199\membersection{wxDocument::Modify}\label{wxdocumentmodify}
200
201\func{virtual void}{Modify}{\param{bool}{ modify}}
202
203Call with TRUE to mark the document as modified since the last save, FALSE otherwise.
204You may need to override this if your document view maintains its own
205record of being modified (for example if using wxTextWindow to view and edit the document).
206
207See also \helpref{IsModified}{wxdocumentismodified}.
208
209\membersection{wxDocument::OnChangedViewList}
210
211\func{virtual void}{OnChangedViewList}{\void}
212
213Called when a view is added to or deleted from this document. The default
214implementation saves and deletes the document if no views exist (the last
215one has just been removed).
216
217\membersection{wxDocument::OnCloseDocument}
218
219\func{virtual bool}{OnCloseDocument}{\void}
220
221The default implementation calls DeleteContents (an empty implementation)
222sets the modified flag to FALSE. Override this to
223supply additional behaviour when the document is closed with Close.
224
225\membersection{wxDocument::OnCreate}
226
227\func{virtual bool}{OnCreate}{\param{const wxString\& }{path}, \param{long}{ flags}}
228
229Called just after the document object is created to give it a chance
230to initialize itself. The default implementation uses the
231template associated with the document to create an initial view.
232If this function returns FALSE, the document is deleted.
233
234\membersection{wxDocument::OnCreateCommandProcessor}
235
236\func{virtual wxCommandProcessor*}{OnCreateCommandProcessor}{\void}
237
238Override this function if you want a different (or no) command processor
239to be created when the document is created. By default, it returns
240an instance of wxCommandProcessor.
241
242See \helpref{wxCommandProcessor}{wxcommandprocessor}.
243
244\membersection{wxDocument::OnNewDocument}
245
246\func{virtual bool}{OnNewDocument}{\void}
247
248The default implementation calls OnSaveModified and DeleteContents, makes a default title for the
249document, and notifies the views that the filename (in fact, the title) has changed.
250
251\membersection{wxDocument::OnOpenDocument}
252
253\func{virtual bool}{OnOpenDocument}{\param{const wxString\& }{filename}}
254
ad813b00 255Constructs an input file stream for the given filename (which must not be empty),
a660d684
KB
256and calls LoadObject. If LoadObject returns TRUE, the document is set to
257unmodified; otherwise, an error message box is displayed. The document's
258views are notified that the filename has changed, to give windows an opportunity
259to update their titles. All of the document's views are then updated.
260
261\membersection{wxDocument::OnSaveDocument}
262
263\func{virtual bool}{OnSaveDocument}{\param{const wxString\& }{filename}}
264
ad813b00 265Constructs an output file stream for the given filename (which must not be empty),
a660d684
KB
266and calls SaveObject. If SaveObject returns TRUE, the document is set to
267unmodified; otherwise, an error message box is displayed.
268
269\membersection{wxDocument::OnSaveModified}
270
271\func{virtual bool}{OnSaveModified}{\void}
272
273If the document has been modified, prompts the user to ask if the changes should
274be changed. If the user replies Yes, the Save function is called. If No, the
275document is marked as unmodified and the function succeeds. If Cancel, the
276function fails.
277
278\membersection{wxDocument::RemoveView}
279
280\func{virtual bool}{RemoveView}{\param{wxView* }{view}}
281
282Removes the view from the document's list of views, and calls OnChangedViewList.
283
284\membersection{wxDocument::Save}
285
286\func{virtual bool}{Save}{\void}
287
288Saves the document by calling OnSaveDocument if there is an associated filename,
289or SaveAs if there is no filename.
290
291\membersection{wxDocument::SaveAs}
292
293\func{virtual bool}{SaveAs}{\void}
294
295Prompts the user for a file to save to, and then calls OnSaveDocument.
296
297\membersection{wxDocument::SaveObject}
298
299\func{virtual ostream\&}{SaveObject}{\param{ostream\& }{stream}}
300
301Override this function and call it from your own SaveObject before
302streaming your own data. SaveObject is called by the framework
303automatically when the document contents need to be saved.
304
305\membersection{wxDocument::SetCommandProcessor}
306
307\func{virtual void}{SetCommandProcessor}{\param{wxCommandProcessor *}{processor}}
308
309Sets the command processor to be used for this document. The document will then be responsible
310for its deletion. Normally you should not call this; override OnCreateCommandProcessor
311instead.
312
313See \helpref{wxCommandProcessor}{wxcommandprocessor}.
314
315\membersection{wxDocument::SetDocumentName}
316
317\func{void}{SetDocumentName}{\param{const wxString\& }{name}}
318
319Sets the document type name for this document. See the comment for \helpref{documentTypeName}{documenttypename}.
320
321\membersection{wxDocument::SetDocumentTemplate}
322
323\func{void}{SetDocumentTemplate}{\param{wxDocTemplate* }{templ}}
324
325Sets the pointer to the template that created the document. Should only be called by the
326framework.
327
328\membersection{wxDocument::SetFilename}
329
330\func{void}{SetFilename}{\param{const wxString\& }{filename}}
331
332Sets the filename for this document. Usually called by the framework.
333
334\membersection{wxDocument::SetTitle}
335
336\func{void}{SetTitle}{\param{const wxString\& }{title}}
337
338Sets the title for this document. The document title is used for an associated
339frame (if any), and is usually constructed by the framework from
340the filename.
341
7f555861 342\membersection{wxDocument::UpdateAllViews}\label{wxdocumentupdateallviews}
a660d684 343
7f555861
JS
344\func{void}{UpdateAllViews}{\param{wxView* }{sender = NULL}}
345
346Updates all views. If {\it sender} is non-NULL, does not update this view.
62448488 347