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