1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
|
<HTML>
<head><title>wxDocument</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxdocument"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx78.htm#wxdoctemplate"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx80.htm#wxdropfilesevent"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxDocument</H2>
<P>
The document class can be used to model an application's file-based
data. It is part of the document/view framework supported by wxWindows,
and cooperates with the <A HREF="wx258.htm#wxview">wxView</A>, <A HREF="wx78.htm#wxdoctemplate">wxDocTemplate</A>
and <A HREF="wx74.htm#wxdocmanager">wxDocManager</A> classes.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx85.htm#wxevthandler">wxEvtHandler</A><BR>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/docview.h><P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx298.htm#wxdocumentoverview">wxDocument overview</A>, <A HREF="wx258.htm#wxview">wxView</A>,
<A HREF="wx78.htm#wxdoctemplate">wxDocTemplate</A>, <A HREF="wx74.htm#wxdocmanager">wxDocManager</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic294">wxDocument::m_commandProcessor</A><BR>
<A HREF="#topic295">wxDocument::m_documentFile</A><BR>
<A HREF="#topic296">wxDocument::m_documentModified</A><BR>
<A HREF="#topic297">wxDocument::m_documentTemplate</A><BR>
<A HREF="#topic298">wxDocument::m_documentTitle</A><BR>
<A HREF="#documenttypename">wxDocument::m_documentTypeName</A><BR>
<A HREF="#topic299">wxDocument::m_documentViews</A><BR>
<A HREF="#topic300">wxDocument::wxDocument</A><BR>
<A HREF="#topic301">wxDocument::~wxDocument</A><BR>
<A HREF="#topic302">wxDocument::AddView</A><BR>
<A HREF="#topic303">wxDocument::Close</A><BR>
<A HREF="#topic304">wxDocument::DeleteAllViews</A><BR>
<A HREF="#topic305">wxDocument::GetCommandProcessor</A><BR>
<A HREF="#topic306">wxDocument::GetDocumentTemplate</A><BR>
<A HREF="#topic307">wxDocument::GetDocumentManager</A><BR>
<A HREF="#topic308">wxDocument::GetDocumentName</A><BR>
<A HREF="#topic309">wxDocument::GetDocumentWindow</A><BR>
<A HREF="#topic310">wxDocument::GetFilename</A><BR>
<A HREF="#topic311">wxDocument::GetFirstView</A><BR>
<A HREF="#topic312">wxDocument::GetPrintableName</A><BR>
<A HREF="#topic313">wxDocument::GetTitle</A><BR>
<A HREF="#wxdocumentismodified">wxDocument::IsModified</A><BR>
<A HREF="#topic314">wxDocument::LoadObject</A><BR>
<A HREF="#wxdocumentmodify">wxDocument::Modify</A><BR>
<A HREF="#topic315">wxDocument::OnChangedViewList</A><BR>
<A HREF="#topic316">wxDocument::OnCloseDocument</A><BR>
<A HREF="#topic317">wxDocument::OnCreate</A><BR>
<A HREF="#topic318">wxDocument::OnCreateCommandProcessor</A><BR>
<A HREF="#topic319">wxDocument::OnNewDocument</A><BR>
<A HREF="#topic320">wxDocument::OnOpenDocument</A><BR>
<A HREF="#topic321">wxDocument::OnSaveDocument</A><BR>
<A HREF="#topic322">wxDocument::OnSaveModified</A><BR>
<A HREF="#topic323">wxDocument::RemoveView</A><BR>
<A HREF="#topic324">wxDocument::Save</A><BR>
<A HREF="#topic325">wxDocument::SaveAs</A><BR>
<A HREF="#topic326">wxDocument::SaveObject</A><BR>
<A HREF="#topic327">wxDocument::SetCommandProcessor</A><BR>
<A HREF="#topic328">wxDocument::SetDocumentName</A><BR>
<A HREF="#topic329">wxDocument::SetDocumentTemplate</A><BR>
<A HREF="#topic330">wxDocument::SetFilename</A><BR>
<A HREF="#topic331">wxDocument::SetTitle</A><BR>
<A HREF="#wxdocumentupdateallviews">wxDocument::UpdateAllViews</A><BR>
<P>
<HR>
<A NAME="topic294"></A>
<H3>wxDocument::m_commandProcessor</H3>
<P>
wxCommandProcessor* m_commandProcessor<P>
A pointer to the command processor associated with this document.<P>
<HR>
<A NAME="topic295"></A>
<H3>wxDocument::m_documentFile</H3>
<P>
wxString m_documentFile<P>
Filename associated with this document ("" if none).<P>
<HR>
<A NAME="topic296"></A>
<H3>wxDocument::m_documentModified</H3>
<P>
bool m_documentModified<P>
TRUE if the document has been modified, FALSE otherwise.<P>
<HR>
<A NAME="topic297"></A>
<H3>wxDocument::m_documentTemplate</H3>
<P>
wxDocTemplate * m_documentTemplate<P>
A pointer to the template from which this document was created.<P>
<HR>
<A NAME="topic298"></A>
<H3>wxDocument::m_documentTitle</H3>
<P>
wxString m_documentTitle<P>
Document title. The document title is used for an associated
frame (if any), and is usually constructed by the framework from
the filename.<P>
<HR>
<A NAME="documenttypename"></A>
<H3>wxDocument::m_documentTypeName</H3>
<P>
wxString m_documentTypeName<P>
The document type name given to the wxDocTemplate constructor, copied to this
variable when the document is created. If several document templates are
created that use the same document type, this variable is used in wxDocManager::CreateView
to collate a list of alternative view types that can be used on this kind of
document. Do not change the value of this variable.<P>
<HR>
<A NAME="topic299"></A>
<H3>wxDocument::m_documentViews</H3>
<P>
wxList m_documentViews<P>
List of wxView instances associated with this document.<P>
<HR>
<A NAME="topic300"></A>
<H3>wxDocument::wxDocument</H3>
<P>
<B></B> <B>wxDocument</B>()<P>
Constructor. Define your own default constructor to initialize application-specific
data.<P>
<HR>
<A NAME="topic301"></A>
<H3>wxDocument::~wxDocument</H3>
<P>
<B></B> <B>~wxDocument</B>()<P>
Destructor. Removes itself from the document manager.<P>
<HR>
<A NAME="topic302"></A>
<H3>wxDocument::AddView</H3>
<P>
<B>virtual bool</B> <B>AddView</B>(<B>wxView *</B><I>view</I>)<P>
If the view is not already in the list of views, adds the view and calls OnChangedViewList.<P>
<HR>
<A NAME="topic303"></A>
<H3>wxDocument::Close</H3>
<P>
<B>virtual bool</B> <B>Close</B>()<P>
Closes the document, by calling OnSaveModified and then (if this returned TRUE) OnCloseDocument.
This does not normally delete the document object: use DeleteAllViews to do this implicitly.<P>
<HR>
<A NAME="topic304"></A>
<H3>wxDocument::DeleteAllViews</H3>
<P>
<B>virtual bool</B> <B>DeleteAllViews</B>()<P>
Calls wxView::Close and deletes each view. Deleting the final view will implicitly
delete the document itself, because the wxView destructor calls RemoveView. This
in turns calls wxDocument::OnChangedViewList, whose default implemention is to
save and delete the document if no views exist.<P>
<HR>
<A NAME="topic305"></A>
<H3>wxDocument::GetCommandProcessor</H3>
<P>
<B>wxCommandProcessor*</B> <B>GetCommandProcessor</B>() <B>const</B><P>
Returns a pointer to the command processor associated with this document.<P>
See <A HREF="wx53.htm#wxcommandprocessor">wxCommandProcessor</A>.<P>
<HR>
<A NAME="topic306"></A>
<H3>wxDocument::GetDocumentTemplate</H3>
<P>
<B>wxDocTemplate*</B> <B>GetDocumentTemplate</B>() <B>const</B><P>
Gets a pointer to the template that created the document.<P>
<HR>
<A NAME="topic307"></A>
<H3>wxDocument::GetDocumentManager</H3>
<P>
<B>wxDocManager*</B> <B>GetDocumentManager</B>() <B>const</B><P>
Gets a pointer to the associated document manager.<P>
<HR>
<A NAME="topic308"></A>
<H3>wxDocument::GetDocumentName</H3>
<P>
<B>wxString</B> <B>GetDocumentName</B>() <B>const</B><P>
Gets the document type name for this document. See the comment for <A HREF="wx79.htm#documenttypename">documentTypeName</A>.<P>
<HR>
<A NAME="topic309"></A>
<H3>wxDocument::GetDocumentWindow</H3>
<P>
<B>wxWindow*</B> <B>GetDocumentWindow</B>() <B>const</B><P>
Intended to return a suitable window for using as a parent for document-related
dialog boxes. By default, uses the frame associated with the first view.<P>
<HR>
<A NAME="topic310"></A>
<H3>wxDocument::GetFilename</H3>
<P>
<B>wxString</B> <B>GetFilename</B>() <B>const</B><P>
Gets the filename associated with this document, or "" if none is
associated.<P>
<HR>
<A NAME="topic311"></A>
<H3>wxDocument::GetFirstView</H3>
<P>
<B>wxView*</B> <B>GetFirstView</B>() <B>const</B><P>
A convenience function to get the first view for a document, because
in many cases a document will only have a single view.<P>
<HR>
<A NAME="topic312"></A>
<H3>wxDocument::GetPrintableName</H3>
<P>
<B>virtual void</B> <B>GetPrintableName</B>(<B>wxString& </B><I>name</I>) <B>const</B><P>
Copies a suitable document name into the supplied <I>name</I> buffer. The default
function uses the title, or if there is no title, uses the filename; or if no
filename, the string <B>unnamed</B>. <P>
<HR>
<A NAME="topic313"></A>
<H3>wxDocument::GetTitle</H3>
<P>
<B>wxString</B> <B>GetTitle</B>() <B>const</B><P>
Gets the title for this document. The document title is used for an associated
frame (if any), and is usually constructed by the framework from
the filename.<P>
<HR>
<A NAME="wxdocumentismodified"></A>
<H3>wxDocument::IsModified</H3>
<P>
<B>virtual bool</B> <B>IsModified</B>() <B>const</B><P>
Returns TRUE if the document has been modified since the last save, FALSE otherwise.
You may need to override this if your document view maintains its own
record of being modified (for example if using wxTextWindow to view and edit the document).<P>
See also <A HREF="wx79.htm#wxdocumentmodify">Modify</A>.<P>
<HR>
<A NAME="topic314"></A>
<H3>wxDocument::LoadObject</H3>
<P>
<B>virtual istream&</B> <B>LoadObject</B>(<B>istream& </B><I>stream</I>)<P>
Override this function and call it from your own LoadObject before
streaming your own data. LoadObject is called by the framework
automatically when the document contents need to be loaded.<P>
<HR>
<A NAME="wxdocumentmodify"></A>
<H3>wxDocument::Modify</H3>
<P>
<B>virtual void</B> <B>Modify</B>(<B>bool</B><I> modify</I>)<P>
Call with TRUE to mark the document as modified since the last save, FALSE otherwise.
You may need to override this if your document view maintains its own
record of being modified (for example if using wxTextWindow to view and edit the document).<P>
See also <A HREF="wx79.htm#wxdocumentismodified">IsModified</A>.<P>
<HR>
<A NAME="topic315"></A>
<H3>wxDocument::OnChangedViewList</H3>
<P>
<B>virtual void</B> <B>OnChangedViewList</B>()<P>
Called when a view is added to or deleted from this document. The default
implementation saves and deletes the document if no views exist (the last
one has just been removed).<P>
<HR>
<A NAME="topic316"></A>
<H3>wxDocument::OnCloseDocument</H3>
<P>
<B>virtual bool</B> <B>OnCloseDocument</B>()<P>
The default implementation calls DeleteContents (an empty implementation)
sets the modified flag to FALSE. Override this to
supply additional behaviour when the document is closed with Close.<P>
<HR>
<A NAME="topic317"></A>
<H3>wxDocument::OnCreate</H3>
<P>
<B>virtual bool</B> <B>OnCreate</B>(<B>const wxString& </B><I>path</I>, <B>long</B><I> flags</I>)<P>
Called just after the document object is created to give it a chance
to initialize itself. The default implementation uses the
template associated with the document to create an initial view.
If this function returns FALSE, the document is deleted.<P>
<HR>
<A NAME="topic318"></A>
<H3>wxDocument::OnCreateCommandProcessor</H3>
<P>
<B>virtual wxCommandProcessor*</B> <B>OnCreateCommandProcessor</B>()<P>
Override this function if you want a different (or no) command processor
to be created when the document is created. By default, it returns
an instance of wxCommandProcessor.<P>
See <A HREF="wx53.htm#wxcommandprocessor">wxCommandProcessor</A>.<P>
<HR>
<A NAME="topic319"></A>
<H3>wxDocument::OnNewDocument</H3>
<P>
<B>virtual bool</B> <B>OnNewDocument</B>()<P>
The default implementation calls OnSaveModified and DeleteContents, makes a default title for the
document, and notifies the views that the filename (in fact, the title) has changed.<P>
<HR>
<A NAME="topic320"></A>
<H3>wxDocument::OnOpenDocument</H3>
<P>
<B>virtual bool</B> <B>OnOpenDocument</B>(<B>const wxString& </B><I>filename</I>)<P>
Constructs an input file stream for the given filename (which must not be empty),
and calls LoadObject. If LoadObject returns TRUE, the document is set to
unmodified; otherwise, an error message box is displayed. The document's
views are notified that the filename has changed, to give windows an opportunity
to update their titles. All of the document's views are then updated.<P>
<HR>
<A NAME="topic321"></A>
<H3>wxDocument::OnSaveDocument</H3>
<P>
<B>virtual bool</B> <B>OnSaveDocument</B>(<B>const wxString& </B><I>filename</I>)<P>
Constructs an output file stream for the given filename (which must not be empty),
and calls SaveObject. If SaveObject returns TRUE, the document is set to
unmodified; otherwise, an error message box is displayed.<P>
<HR>
<A NAME="topic322"></A>
<H3>wxDocument::OnSaveModified</H3>
<P>
<B>virtual bool</B> <B>OnSaveModified</B>()<P>
If the document has been modified, prompts the user to ask if the changes should
be changed. If the user replies Yes, the Save function is called. If No, the
document is marked as unmodified and the function succeeds. If Cancel, the
function fails.<P>
<HR>
<A NAME="topic323"></A>
<H3>wxDocument::RemoveView</H3>
<P>
<B>virtual bool</B> <B>RemoveView</B>(<B>wxView* </B><I>view</I>)<P>
Removes the view from the document's list of views, and calls OnChangedViewList.<P>
<HR>
<A NAME="topic324"></A>
<H3>wxDocument::Save</H3>
<P>
<B>virtual bool</B> <B>Save</B>()<P>
Saves the document by calling OnSaveDocument if there is an associated filename,
or SaveAs if there is no filename.<P>
<HR>
<A NAME="topic325"></A>
<H3>wxDocument::SaveAs</H3>
<P>
<B>virtual bool</B> <B>SaveAs</B>()<P>
Prompts the user for a file to save to, and then calls OnSaveDocument.<P>
<HR>
<A NAME="topic326"></A>
<H3>wxDocument::SaveObject</H3>
<P>
<B>virtual ostream&</B> <B>SaveObject</B>(<B>ostream& </B><I>stream</I>)<P>
Override this function and call it from your own SaveObject before
streaming your own data. SaveObject is called by the framework
automatically when the document contents need to be saved.<P>
<HR>
<A NAME="topic327"></A>
<H3>wxDocument::SetCommandProcessor</H3>
<P>
<B>virtual void</B> <B>SetCommandProcessor</B>(<B>wxCommandProcessor *</B><I>processor</I>)<P>
Sets the command processor to be used for this document. The document will then be responsible
for its deletion. Normally you should not call this; override OnCreateCommandProcessor
instead.<P>
See <A HREF="wx53.htm#wxcommandprocessor">wxCommandProcessor</A>.<P>
<HR>
<A NAME="topic328"></A>
<H3>wxDocument::SetDocumentName</H3>
<P>
<B>void</B> <B>SetDocumentName</B>(<B>const wxString& </B><I>name</I>)<P>
Sets the document type name for this document. See the comment for <A HREF="wx79.htm#documenttypename">documentTypeName</A>.<P>
<HR>
<A NAME="topic329"></A>
<H3>wxDocument::SetDocumentTemplate</H3>
<P>
<B>void</B> <B>SetDocumentTemplate</B>(<B>wxDocTemplate* </B><I>templ</I>)<P>
Sets the pointer to the template that created the document. Should only be called by the
framework.<P>
<HR>
<A NAME="topic330"></A>
<H3>wxDocument::SetFilename</H3>
<P>
<B>void</B> <B>SetFilename</B>(<B>const wxString& </B><I>filename</I>)<P>
Sets the filename for this document. Usually called by the framework.<P>
<HR>
<A NAME="topic331"></A>
<H3>wxDocument::SetTitle</H3>
<P>
<B>void</B> <B>SetTitle</B>(<B>const wxString& </B><I>title</I>)<P>
Sets the title for this document. The document title is used for an associated
frame (if any), and is usually constructed by the framework from
the filename.<P>
<HR>
<A NAME="wxdocumentupdateallviews"></A>
<H3>wxDocument::UpdateAllViews</H3>
<P>
<B>void</B> <B>UpdateAllViews</B>(<B>wxView* </B><I>sender = NULL</I>)<P>
Updates all views. If <I>sender</I> is non-NULL, does not update this view.<P>
</BODY></HTML>
|