1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxView documentation
4 %% Author: wxWidgets Team
8 %% Copyright: (c) wxWidgets Team
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxView
}}\label{wxview
}
14 The view class can be used to model the viewing and editing component of
15 an application's file-based data. It is part of the
document/view framework supported by wxWidgets,
16 and cooperates with the
\helpref{wxDocument
}{wxdocument
},
\helpref{wxDocTemplate
}{wxdoctemplate
}
17 and
\helpref{wxDocManager
}{wxdocmanager
} classes.
19 \wxheading{Derived from
}
21 \helpref{wxEvtHandler
}{wxevthandler
}\\
22 \helpref{wxObject
}{wxobject
}
24 \wxheading{Include files
}
30 \helpref{wxView overview
}{wxviewoverview
},
\helpref{wxDocument
}{wxdocument
},
\helpref{wxDocTemplate
}{wxdoctemplate
},
\rtfsp
31 \helpref{wxDocManager
}{wxdocmanager
}
33 \latexignore{\rtfignore{\wxheading{Members
}}}
35 \membersection{wxView::m
\_viewDocument}\label{wxviewmviewdocument
}
37 \member{wxDocument*
}{m
\_viewDocument}
39 The
document associated with this view. There may be more than one view per
40 document, but there can never be more than one
document for one view.
42 \membersection{wxView::m
\_viewFrame}\label{wxviewmviewframe
}
44 \member{wxFrame*
}{m
\_viewFrame}
46 Frame associated with the view, if any.
48 \membersection{wxView::m
\_viewTypeName}\label{wxviewmviewtypename
}
50 \member{wxString
}{m
\_viewTypeName}
52 The view type name given to the wxDocTemplate constructor, copied to this
53 variable when the view is created. Not currently used by the framework.
55 \membersection{wxView::wxView
}\label{wxviewctor
}
57 \func{}{wxView
}{\void}
59 Constructor. Define your own default constructor to initialize application-specific
62 \membersection{wxView::
\destruct{wxView
}}\label{wxviewdtor
}
64 \func{}{\destruct{wxView
}}{\void}
66 Destructor. Removes itself from the
document's list of views.
68 \membersection{wxView::Activate
}\label{wxviewactivate
}
70 \func{virtual void
}{Activate
}{\param{bool
}{ activate
}}
72 Call this from your view frame's OnActivate member to tell the framework which view is
73 currently active. If your windowing system doesn't call OnActivate, you may need to
74 call this function from any place where you know the view must
75 be active, and the framework will need to get the current view.
77 The prepackaged view frame wxDocChildFrame calls wxView::Activate from its OnActivate member.
79 This function calls wxView::OnActivateView.
81 \membersection{wxView::Close
}\label{wxviewclose
}
83 \func{virtual bool
}{Close
}{\param{bool
}{ deleteWindow = true
}}
85 Closes the view by calling OnClose. If
{\it deleteWindow
} is true, this function should
86 delete the window associated with the view.
88 \membersection{wxView::GetDocument
}\label{wxviewgetdocument
}
90 \constfunc{wxDocument*
}{GetDocument
}{\void}
92 Gets a pointer to the
document associated with the view.
94 \membersection{wxView::GetDocumentManager
}\label{wxviewgetdocumentmanager
}
96 \constfunc{wxDocManager*
}{GetDocumentManager
}{\void}
98 Returns a pointer to the
document manager instance associated with this view.
100 \membersection{wxView::GetFrame
}\label{wxviewgetframe
}
102 \func{wxWindow *
}{GetFrame
}{\void}
104 Gets the frame associated with the view (if any). Note that this ``frame'' is
105 not a wxFrame at all in the generic MDI implementation which uses the notebook
106 pages instead of the frames and this is why this method returns a wxWindow and
109 \membersection{wxView::GetViewName
}\label{wxviewgetviewname
}
111 \constfunc{wxString
}{GetViewName
}{\void}
113 Gets the name associated with the view (passed to the wxDocTemplate constructor).
114 Not currently used by the framework.
116 \membersection{wxView::OnActivateView
}\label{wxviewonactivateview
}
118 \func{virtual void
}{OnActivateView
}{\param{bool
}{activate
},
\param{wxView *
}{activeView
},
\param{wxView *
}{deactiveView
}}
120 Called when a view is activated by means of wxView::Activate. The default implementation does
123 \membersection{wxView::OnChangeFilename
}\label{wxviewonchangefilename
}
125 \func{virtual void
}{OnChangeFilename
}{\void}
127 Called when the filename has changed. The default implementation constructs a
128 suitable title and sets the title of the view frame (if any).
130 \membersection{wxView::OnClose
}\label{wxviewonclose
}
132 \func{virtual bool
}{OnClose
}{\param{bool
}{ deleteWindow
}}
134 Implements closing behaviour. The default implementation calls wxDocument::Close
135 to close the associated
document. Does not delete the view. The application
136 may wish to do some cleaning up operations in this function,
{\it if
} a
137 call to wxDocument::Close succeeded. For example, if your views
138 all share the same window, you need to disassociate the window from the view
139 and perhaps clear the window. If
{\it deleteWindow
} is true, delete the
140 frame associated with the view.
142 \membersection{wxView::OnClosingDocument
}\label{wxviewonclosingdocument
}
144 \func{virtual void
}{OnClosingDocument
}{\void}
146 Override this to clean up the view when the
document is being
149 \membersection{wxView::OnCreate
}\label{wxviewoncreate
}
151 \func{virtual bool
}{OnCreate
}{\param{wxDocument*
}{doc
},
\param{long
}{ flags
}}
153 wxDocManager or wxDocument creates a wxView via a wxDocTemplate.
154 Just after the wxDocTemplate creates the wxView, it calls
155 wxView::OnCreate. In its OnCreate member function, the wxView can create a wxDocChildFrame
156 or a derived class. This wxDocChildFrame provides user interface
157 elements to view and/or edit the contents of the wxDocument.
159 By default, simply returns true. If the function returns false, the
160 view will be deleted.
162 \membersection{wxView::OnCreatePrintout
}\label{wxviewoncreateprintout
}
164 \func{virtual wxPrintout*
}{OnCreatePrintout
}{\void}
166 If the printing framework is enabled in the library, this function returns a
167 \rtfsp\helpref{wxPrintout
}{wxprintout
} object for the purposes of printing. It should create a new object
168 every time it is called; the framework will delete objects it creates.
170 By default, this function returns an instance of wxDocPrintout, which prints
171 and previews one page by calling wxView::OnDraw.
173 Override to return an instance of a class other than wxDocPrintout.
175 \membersection{wxView::OnDraw
}\label{onviewondraw
}
177 \func{virtual void
}{OnDraw
}{\param{wxDC*
}{dc
}}
179 Override this function to render the view on the given device context.
181 \membersection{wxView::OnUpdate
}\label{onviewonupdate
}
183 \func{virtual void
}{OnUpdate
}{\param{wxView*
}{sender
},
\param{wxObject*
}{hint
}}
185 Called when the view should be updated.
{\it sender
} is a pointer to the view
186 that sent the update request, or NULL if no single view requested the update (for instance,
187 when the
document is opened).
{\it hint
} is as yet unused but may in future contain
188 application-specific information for making updating more efficient.
190 \membersection{wxView::SetDocument
}\label{wxviewsetdocument
}
192 \func{void
}{SetDocument
}{\param{wxDocument*
}{doc
}}
194 Associates the given
document with the view. Normally called by the
197 \membersection{wxView::SetFrame
}\label{wxviewsetframe
}
199 \func{void
}{SetFrame
}{\param{wxWindow*
}{frame
}}
201 Sets the frame associated with this view. The application should call this
202 if possible, to tell the view about the frame.
204 See
\helpref{GetFrame
}{wxviewgetframe
} for the explanation about the mismatch
205 between the ``Frame'' in the method name and the type of its parameter.
207 \membersection{wxView::SetViewName
}\label{wxviewsetviewname
}
209 \func{void
}{SetViewName
}{\param{const wxString\&
}{name
}}
211 Sets the view type name. Should only be called by the framework.