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