xref: /haiku/docs/user/interface/View.dox (revision 323b65468e5836bb27a5e373b14027d902349437)
1/*
2 * Copyright 2011, Haiku inc.
3 * Distributed under the terms of the MIT License.
4 *
5 * Documentation by:
6 *		John Scipione, jscipione@gmail.com
7 * Corresponds to:
8 *		/trunk/headers/os/interface/View.h	 rev 42794
9 *		/trunk/src/kits/interface/View.cpp	 rev 42794
10 */
11
12
13/*!
14	\file View.h
15	\brief BView class definition and support enums.
16*/
17
18
19/*!
20	\class BView
21	\ingroup interface
22	\ingroup libbe
23
24	\brief View base class.
25*/
26
27
28/*!
29	\fn void BView::AttachedToWindow()
30	\brief Hook method that is called when the object is attached to a
31		window.
32*/
33
34
35/*!
36	\fn void BView::AllAttached()
37	\brief Similar to AttachedToWindow() but this method is triggered after
38		all child views have already been attached to a window.
39*/
40
41
42/*!
43	\fn void BView::DetachedFromWindow()
44	\brief Hook method that is called when the object is detached from a
45		window.
46*/
47
48/*!
49	\fn void BView::AllDetached()
50	\brief Similar to AttachedToWindow() but this method is triggered after
51		all child views have already been detached from a window.
52*/
53
54/*!
55	\fn void BView::Draw(BRect updateRect)
56	\brief Draws the area of the view that intersects \a updateRect.
57
58	Derived classes should override this method to draw their view.
59
60	\note This is an hook method called by the Interface Kit, you don't
61	have to call it yourself. If you need to forcefully redraw the view
62	consider calling Invalidate() instead.
63
64	\param updateRect The rectangular area to be drawn.
65*/
66
67
68/*!
69	\fn void BView::DrawAfterChildren(BRect r)
70	\brief Perform any drawing that needs to be done after child view have
71		already been drawn.
72
73	\param r The rectangular area to be drawn.
74*/
75
76
77/*!
78	\fn void BView::FrameMoved(BPoint newPosition)
79	\brief Hook method that gets called when the view is moved.
80
81	\param newPosition The point of the top left corner of the frame
82		that the view has been moved to.
83*/
84
85
86/*!
87	\fn void BView::FrameResized(float newWidth, float newHeight)
88	\brief Hook method that gets called when the view is resized.
89
90	\param newWidth The new \a width of the view.
91	\param newHeight The new \a height of the view.
92*/
93
94
95/*!
96	\fn void BView::GetPreferredSize(float* _width, float* _height)
97	\brief Fill out the preferred width and height of the view
98		into the \a _width and \a _height parameters.
99
100	Derived classes should override this method to set the preferred
101	size of object.
102
103	\note Either the \a _width or \a _height parameter may be set to \c NULL
104		if you only want to get the other one.
105
106	\param[out] _width Pointer to a \c float to store the width of the view.
107	\param[out] _height Pointer to a \c float to store the height of the view.
108*/
109
110
111/*!
112	\fn void BView::ResizeToPreferred()
113	\brief Resize the view to its preferred size.
114*/
115
116
117/*!
118	\fn void BView::KeyDown(const char* bytes, int32 numBytes)
119	\brief Hook method that is called when a keyboard key is pressed.
120
121	\param bytes The bytes of the key combination pressed.
122	\param numBytes The number of bytes in \a bytes.
123*/
124
125
126/*!
127	\fn void BView::KeyUp(const char* bytes, int32 numBytes)
128	\brief Hook method that is called when a keyboard key is released.
129
130	\param bytes The bytes of the key combination pressed.
131	\param numBytes The number of bytes in \a bytes.
132*/
133
134
135/*!
136	\fn void BView::MouseDown(BPoint where)
137	\brief Hook method that is called when a mouse button is pressed.
138
139	\param where The point on the screen where to mouse pointer is when
140		the mouse button is pressed.
141*/
142
143
144/*!
145	\fn void BView::MouseUp(BPoint where)
146	\brief Hook method that is called when a mouse button is released.
147
148	\param where The point on the screen where to mouse pointer is when
149		the mouse button is released.
150*/
151
152
153/*!
154	\fn void BView::MouseMoved(BPoint where, uint32 code,
155		const BMessage* a_message)
156	\brief Hook method that is called when the mouse is moved.
157*/
158
159
160/*!
161	\fn void BView::Pulse()
162	\brief Hook method that gets invoked when the view receives a
163		\c B_PULSE message.
164
165	An action is performed each time the App Server calls the Pulse() method.
166	The pulse rate is set by SetPulseRate(). You can implement Pulse() to do
167	anything you want. The default version does nothing. The pulse granularity
168	is no better than once per 100,000 microseconds.
169
170	\sa SetPulseRate()
171*/
172
173
174/*!
175	\fn void BView::WindowActivated(bool state)
176	\brief Hook method that is called when the attached window becomes
177		activated or deactivated.
178
179	\param state \c true if the window becomes activated, \c false if the
180		window becomes deactivated.
181*/
182
183
184/*!
185	\fn void BView::MakeFocus(bool focusState)
186	\brief Gives or removes focus from the control.
187
188	\param focusState \a true to set focus, \a false to remove it.
189*/
190
191
192/*!
193	\fn status_t BView::Perform(perform_code code, void* _data)
194	\brief Perform some action. (Internal Method)
195
196	The following perform codes are recognized:
197		- \c PERFORM_CODE_MIN_SIZE:
198		- \c PERFORM_CODE_MAX_SIZE:
199		- \c PERFORM_CODE_PREFERRED_SIZE:
200		- \c PERFORM_CODE_LAYOUT_ALIGNMENT:
201		- \c PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH:
202		- \c PERFORM_CODE_GET_HEIGHT_FOR_WIDTH:
203		- \c PERFORM_CODE_SET_LAYOUT:
204		- \c PERFORM_CODE_INVALIDATE_LAYOUT:
205		- \c PERFORM_CODE_DO_LAYOUT:
206		- \c PERFORM_CODE_GET_TOOL_TIP_AT:
207		- \c PERFORM_CODE_ALL_UNARCHIVED:
208		- \c PERFORM_CODE_ALL_ARCHIVED:
209
210	\param code The perform code.
211	\param _data A pointer to store some data.
212
213	\returns A status code.
214
215	\sa BHandler::Perform()
216*/
217
218
219/*!
220	\fn BSize BView::MinSize()
221	\brief Get the minimum size of the view.
222
223	\return The minimum size of the view as a BSize.
224
225	\sa BAbstractLayout::MinSize()
226*/
227
228
229/*!
230	\fn BSize BView::MaxSize()
231	\brief Get the maximum size of the view.
232
233	\return The maximum size of the view as a BSize.
234
235	\sa BAbstractLayout::MaxSize()
236*/
237
238
239/*!
240	\fn BSize BView::PreferredSize()
241	\brief Get the preferred size of the view.
242
243	\return The preferred size of the view as a BSize.
244
245	\sa BAbstractLayout::PreferredSize()
246*/
247
248
249/*!
250	\fn void BView::SetExplicitMinSize(BSize size)
251	\brief Set this item's explicit min size, to be used by MinSize().
252
253	\sa BAbstractLayout::SetExplicitMinSize()
254*/
255
256
257/*!
258	\fn void BView::SetExplicitMaxSize(BSize size)
259	\brief Set this item's explicit max size, to be used by MaxSize().
260
261	\sa BAbstractLayout::SetExplicitMaxSize()
262*/
263
264
265/*!
266	\fn void BView::SetExplicitPreferredSize(BSize size)
267	\brief Set this item's explicit preferred size, to be used by
268		PreferredSize().
269
270	\sa BAbstractLayout::SetExplicitPreferredSize()
271*/
272
273
274/*!
275	\fn void BView::SetExplicitAlignment(BAlignment alignment)
276	\brief Set this item's explicit alignment, to be used by Alignment().
277
278	\sa BAbstractLayout::SetExplicitAlignment()
279*/
280
281
282/*!
283	\fn void BView::SetLayout(BLayout* layout)
284	\brief Set the \a layout of the view.
285
286	\param layout The \a layout to set.
287*/
288
289
290/*!
291	\fn BLayout* BView::GetLayout() const
292	\brief Get the layout of the view.
293
294	\returns The layout of the view.
295*/
296
297
298