]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxView}}\label{wxview} |
2 | ||
3 | The view class can be used to model the viewing and editing component of | |
fc2171bd | 4 | an application's file-based data. It is part of the document/view framework supported by wxWidgets, |
82540ef2 | 5 | and cooperates with the \helpref{wxDocument}{wxdocument}, \helpref{wxDocTemplate}{wxdoctemplate} |
a660d684 KB |
6 | and \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{wxView overview}{wxviewoverview}, \helpref{wxDocument}{wxdocument}, \helpref{wxDocTemplate}{wxdoctemplate},\rtfsp | |
20 | \helpref{wxDocManager}{wxdocmanager} | |
21 | ||
22 | \latexignore{\rtfignore{\wxheading{Members}}} | |
23 | ||
6d06e061 | 24 | \membersection{wxView::m\_viewDocument}\label{wxviewmviewdocument} |
a660d684 KB |
25 | |
26 | \member{wxDocument*}{m\_viewDocument} | |
27 | ||
28 | The document associated with this view. There may be more than one view per | |
29 | document, but there can never be more than one document for one view. | |
30 | ||
6d06e061 | 31 | \membersection{wxView::m\_viewFrame}\label{wxviewmviewframe} |
a660d684 KB |
32 | |
33 | \member{wxFrame*}{m\_viewFrame} | |
34 | ||
35 | Frame associated with the view, if any. | |
36 | ||
6d06e061 | 37 | \membersection{wxView::m\_viewTypeName}\label{wxviewmviewtypename} |
a660d684 KB |
38 | |
39 | \member{wxString}{m\_viewTypeName} | |
40 | ||
41 | The view type name given to the wxDocTemplate constructor, copied to this | |
42 | variable when the view is created. Not currently used by the framework. | |
43 | ||
6d06e061 | 44 | \membersection{wxView::wxView}\label{wxviewctor} |
a660d684 | 45 | |
dbdb39b2 | 46 | \func{}{wxView}{\void} |
a660d684 KB |
47 | |
48 | Constructor. Define your own default constructor to initialize application-specific | |
49 | data. | |
50 | ||
6d06e061 | 51 | \membersection{wxView::\destruct{wxView}}\label{wxviewdtor} |
a660d684 KB |
52 | |
53 | \func{}{\destruct{wxView}}{\void} | |
54 | ||
55 | Destructor. Removes itself from the document's list of views. | |
56 | ||
6d06e061 | 57 | \membersection{wxView::Activate}\label{wxviewactivate} |
a660d684 KB |
58 | |
59 | \func{virtual void}{Activate}{\param{bool}{ activate}} | |
60 | ||
61 | Call this from your view frame's OnActivate member to tell the framework which view is | |
62 | currently active. If your windowing system doesn't call OnActivate, you may need to | |
63 | call this function from OnMenuCommand or any place where you know the view must | |
64 | be active, and the framework will need to get the current view. | |
65 | ||
66 | The prepackaged view frame wxDocChildFrame calls wxView::Activate from its OnActivate member | |
67 | and from its OnMenuCommand member. | |
68 | ||
69 | This function calls wxView::OnActivateView. | |
70 | ||
6d06e061 | 71 | \membersection{wxView::Close}\label{wxviewclose} |
a660d684 | 72 | |
cc81d32f | 73 | \func{virtual bool}{Close}{\param{bool}{ deleteWindow = true}} |
a660d684 | 74 | |
cc81d32f | 75 | Closes the view by calling OnClose. If {\it deleteWindow} is true, this function should |
a660d684 KB |
76 | delete the window associated with the view. |
77 | ||
6d06e061 | 78 | \membersection{wxView::GetDocument}\label{wxviewgetdocument} |
a660d684 KB |
79 | |
80 | \constfunc{wxDocument*}{GetDocument}{\void} | |
81 | ||
82 | Gets a pointer to the document associated with the view. | |
83 | ||
6d06e061 | 84 | \membersection{wxView::GetDocumentManager}\label{wxviewgetdocumentmanager} |
a660d684 | 85 | |
9a75ba66 | 86 | \constfunc{wxDocManager*}{GetDocumentManager}{\void} |
a660d684 KB |
87 | |
88 | Returns a pointer to the document manager instance associated with this view. | |
89 | ||
8da89074 | 90 | \membersection{wxView::GetFrame}\label{wxviewgetframe} |
a660d684 | 91 | |
8da89074 | 92 | \func{wxWindow *}{GetFrame}{\void} |
a660d684 | 93 | |
8da89074 VZ |
94 | Gets the frame associated with the view (if any). Note that this ``frame'' is |
95 | not a wxFrame at all in the generic MDI implementation which uses the notebook | |
96 | pages instead of the frames and this is why this method returns a wxWindow and | |
97 | not a wxFrame. | |
a660d684 | 98 | |
6d06e061 | 99 | \membersection{wxView::GetViewName}\label{wxviewgetviewname} |
a660d684 KB |
100 | |
101 | \constfunc{wxString}{GetViewName}{\void} | |
102 | ||
103 | Gets the name associated with the view (passed to the wxDocTemplate constructor). | |
104 | Not currently used by the framework. | |
105 | ||
6d06e061 | 106 | \membersection{wxView::OnActivateView}\label{wxviewonactivateview} |
a660d684 KB |
107 | |
108 | \func{virtual void}{OnActivateView}{\param{bool }{activate}, \param{wxView *}{activeView}, \param{wxView *}{deactiveView}} | |
109 | ||
110 | Called when a view is activated by means of wxView::Activate. The default implementation does | |
111 | nothing. | |
112 | ||
6d06e061 | 113 | \membersection{wxView::OnChangeFilename}\label{wxviewonchangefilename} |
a660d684 KB |
114 | |
115 | \func{virtual void}{OnChangeFilename}{\void} | |
116 | ||
117 | Called when the filename has changed. The default implementation constructs a | |
118 | suitable title and sets the title of the view frame (if any). | |
119 | ||
6d06e061 | 120 | \membersection{wxView::OnClose}\label{wxviewonclose} |
a660d684 KB |
121 | |
122 | \func{virtual bool}{OnClose}{\param{bool}{ deleteWindow}} | |
123 | ||
124 | Implements closing behaviour. The default implementation calls wxDocument::Close | |
125 | to close the associated document. Does not delete the view. The application | |
126 | may wish to do some cleaning up operations in this function, {\it if} a | |
5ab2950d | 127 | call to wxDocument::Close succeeded. For example, if your views |
fe604ccd | 128 | all share the same window, you need to disassociate the window from the view |
cc81d32f | 129 | and perhaps clear the window. If {\it deleteWindow} is true, delete the |
a660d684 KB |
130 | frame associated with the view. |
131 | ||
b23e843b JS |
132 | \membersection{wxView::OnClosingDocument}\label{wxviewonclosingdocument} |
133 | ||
134 | \func{virtual void}{OnClosingDoocument}{\void} | |
135 | ||
136 | Override this to clean up the view when the document is being | |
137 | closed. | |
138 | ||
6d06e061 | 139 | \membersection{wxView::OnCreate}\label{wxviewoncreate} |
a660d684 KB |
140 | |
141 | \func{virtual bool}{OnCreate}{\param{wxDocument* }{doc}, \param{long}{ flags}} | |
142 | ||
6b3d51cc JS |
143 | wxDocManager or wxDocument creates a wxView via a wxDocTemplate. |
144 | Just after the wxDocTemplate creates the wxView, it calls | |
145 | wxView::OnCreate. In its OnCreate member function, the wxView can create a wxDocChildFrame | |
146 | or a derived class. This wxDocChildFrame provides user interface | |
147 | elements to view and/or edit the contents of the wxDocument. | |
148 | ||
cc81d32f | 149 | By default, simply returns true. If the function returns false, the |
6b3d51cc | 150 | view will be deleted. |
a660d684 | 151 | |
6d06e061 | 152 | \membersection{wxView::OnCreatePrintout}\label{wxviewoncreateprintout} |
a660d684 KB |
153 | |
154 | \func{virtual wxPrintout*}{OnCreatePrintout}{\void} | |
155 | ||
156 | If the printing framework is enabled in the library, this function returns a | |
157 | \rtfsp\helpref{wxPrintout}{wxprintout} object for the purposes of printing. It should create a new object | |
2edb0bde | 158 | every time it is called; the framework will delete objects it creates. |
a660d684 KB |
159 | |
160 | By default, this function returns an instance of wxDocPrintout, which prints | |
161 | and previews one page by calling wxView::OnDraw. | |
162 | ||
163 | Override to return an instance of a class other than wxDocPrintout. | |
164 | ||
5ab2950d JS |
165 | \membersection{wxView::OnDraw}\label{onviewondraw} |
166 | ||
167 | \func{virtual void}{OnDraw}{\param{wxDC\& }{dc}} | |
168 | ||
169 | Override this function to render the view on the given device context. | |
170 | ||
6d06e061 | 171 | \membersection{wxView::OnUpdate}\label{onviewonupdate} |
a660d684 KB |
172 | |
173 | \func{virtual void}{OnUpdate}{\param{wxView* }{sender}, \param{wxObject* }{hint}} | |
174 | ||
175 | Called when the view should be updated. {\it sender} is a pointer to the view | |
176 | that sent the update request, or NULL if no single view requested the update (for instance, | |
177 | when the document is opened). {\it hint} is as yet unused but may in future contain | |
178 | application-specific information for making updating more efficient. | |
179 | ||
6d06e061 | 180 | \membersection{wxView::SetDocument}\label{wxviewsetdocument} |
a660d684 KB |
181 | |
182 | \func{void}{SetDocument}{\param{wxDocument* }{doc}} | |
183 | ||
184 | Associates the given document with the view. Normally called by the | |
185 | framework. | |
186 | ||
6d06e061 | 187 | \membersection{wxView::SetFrame}\label{wxviewsetframe} |
a660d684 | 188 | |
8da89074 | 189 | \func{void}{SetFrame}{\param{wxWindow* }{frame}} |
a660d684 KB |
190 | |
191 | Sets the frame associated with this view. The application should call this | |
192 | if possible, to tell the view about the frame. | |
193 | ||
8da89074 VZ |
194 | See \helpref{GetFrame}{wxviewgetframe} for the explanation about the mismatch |
195 | between the ``Frame'' in the method name and the type of its parameter. | |
196 | ||
6d06e061 | 197 | \membersection{wxView::SetViewName}\label{wxviewsetviewname} |
a660d684 KB |
198 | |
199 | \func{void}{SetViewName}{\param{const wxString\& }{name}} | |
200 | ||
201 | Sets the view type name. Should only be called by the framework. | |
202 | ||
203 |