]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/docprfrm.tex
Motif and other mods
[wxWidgets.git] / docs / latex / wx / docprfrm.tex
1 \section{\class{wxDocParentFrame}}\label{wxdocparentframe}
2
3 The wxDocParentFrame class provides a default top-level frame for
4 applications using the document/view framework. This class can only be used for SDI (not MDI) parent frames.
5
6 It cooperates with the \helpref{wxView}{wxview}, \helpref{wxDocument}{wxdocument},
7 \rtfsp\helpref{wxDocManager}{wxdocmanager} and \helpref{wxDocTemplates}{wxdoctemplate} classes.
8
9 See the example application in {\tt samples/docview}.
10
11 \wxheading{Derived from}
12
13 \helpref{wxFrame}{wxframe}\\
14 \helpref{wxWindow}{wxwindow}\\
15 \helpref{wxEvtHandler}{wxevthandler}\\
16 \helpref{wxObject}{wxobject}
17
18 \wxheading{See also}
19
20 \helpref{Document/view overview}{docviewoverview}, \helpref{wxFrame}{wxframe}
21
22 \latexignore{\rtfignore{\wxheading{Members}}}
23
24 \membersection{wxDocParentFrame::wxDocParentFrame}
25
26 \func{}{wxDocParentFrame}{\param{wxFrame *}{parent}, \param{wxWindowID}{ id},
27 \param{const wxString\& }{title}, \param{int}{ x}, \param{int}{ y}, \param{int}{ width}, \param{int}{ height},
28 \param{long}{ style}, \param{const wxString\& }{name}}
29
30 Constructor.
31
32 \membersection{wxDocParentFrame::\destruct{wxDocParentFrame}}
33
34 \func{}{\destruct{wxDocParentFrame}}{\void}
35
36 Destructor.
37
38 \membersection{wxDocParentFrame::OnClose}
39
40 \func{bool}{OnClose}{\void}
41
42 Deletes all views and documents. If no user input cancelled the
43 operation, the function returns TRUE and the application will exit.
44
45 Since understanding how document/view clean-up takes place can be difficult,
46 the implementation of this function is shown below.
47
48 \begin{verbatim}
49 bool wxDocParentFrame::OnClose(void)
50 {
51 // Delete all views and documents
52 wxNode *node = docManager->GetDocuments().First();
53 while (node)
54 {
55 wxDocument *doc = (wxDocument *)node->Data();
56 wxNode *next = node->Next();
57
58 if (!doc->Close())
59 return FALSE;
60
61 // Implicitly deletes the document when the last
62 // view is removed (deleted)
63 doc->DeleteAllViews();
64
65 // Check document is deleted
66 if (docManager->GetDocuments().Member(doc))
67 delete doc;
68
69 // This assumes that documents are not connected in
70 // any way, i.e. deleting one document does NOT
71 // delete another.
72 node = next;
73 }
74 return TRUE;
75 }
76 \end{verbatim}
77
78