xref: /haiku/docs/user/interface/ListItem.dox (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1/*
2 * Copyright 2013 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/ListItem.h	 hrev45555
10 *		src/kits/interface/ListItem.cpp	 hrev45555
11 */
12
13
14/*!
15	\file ListItem.h
16	\ingroup interface
17	\ingroup libbe
18	\brief ListItem class definition.
19*/
20
21
22/*!
23	\class BListItem
24	\ingroup interface
25	\ingroup libbe
26	\brief A list item, a member of a BListView or BOutlineListView.
27
28	\since BeOS R3
29*/
30
31
32/*!
33	\fn BListItem::BListItem(uint32 level, bool expanded)
34	\brief Create a new list item with the specified \a level.
35
36	The \a level and \a expanded arguments are only used if the item is added to
37	a BOutlineListView.
38
39	\param level The level to create the list item on, default level is 0.
40	\param expanded Whether or not the item is expanded.
41
42	\see BOutlineListView::AddItem()
43
44	\since BeOS R3
45*/
46
47
48/*!
49	\fn BListItem::BListItem(BMessage* data)
50	\brief Create a new list item from archived message.
51
52	\param data The message to create the list item from.
53
54	\since BeOS R3
55*/
56
57
58/*!
59	\fn BListItem::~BListItem()
60	\brief Destroy the list item freeing any memory used.
61
62	The default destructor is empty.
63
64	\since BeOS R3
65*/
66
67
68/*!
69	\name Archiving
70*/
71
72
73//! @{
74
75
76/*!
77	\fn status_t BListItem::Archive(BMessage* archive, bool deep) const
78	\brief Archive the list item to a message.
79
80	\param archive The message to archive the list item to.
81	\param deep If \c true also archive child views.
82
83	\since BeOS R3
84*/
85
86
87/*!
88	\fn void BListItem::DrawItem(BView* owner, BRect frame, bool complete)
89	\brief Hook method called when the item is drawn.
90
91	\param owner The view that the list item is a child of.
92	\param frame The frame of the item.
93	\param complete Whether or not to draw the background in addition to the
94	       item's contents.
95
96	\since BeOS R3
97*/
98
99
100//! @}
101
102
103/*!
104	\fn float BListItem::Height() const
105	\brief Return the height of the list item.
106
107	\return The height of the list item as a float.
108
109	\since BeOS R3
110*/
111
112
113/*!
114	\fn float BListItem::Width() const
115	\brief Return the width of the list item.
116
117	\return The width of the list item as a float.
118
119	\since BeOS R3
120*/
121
122
123/*!
124	\fn bool BListItem::IsSelected() const
125	\brief Return whether or not the list item is currently selected.
126
127	\return \c true if the list item is selected, \c false otherwise.
128
129	\since BeOS R3
130*/
131
132
133/*!
134	\fn void BListItem::Select()
135	\brief Select the list item.
136
137	\since BeOS R3
138*/
139
140
141/*!
142	\fn void BListItem::Deselect()
143	\brief Unselect the list item.
144
145	\since BeOS R3
146*/
147
148
149/*!
150	\fn void BListItem::SetEnabled(bool on)
151	\brief Enable or disable the list item.
152
153	\param on Set \c true to enable, \c false to disable the list item.
154
155	\since BeOS R3
156*/
157
158
159/*!
160	\fn bool BListItem::IsEnabled() const
161	\brief Returns whether or not the list item is currently enabled.
162
163	\return \c true if the list item is enabled, \c false if it is disabled.
164
165	\since BeOS R3
166*/
167
168
169/*!
170	\fn void BListItem::SetHeight(float height)
171	\brief Set the height of the list item to \a height.
172
173	\param height The height to set the list item to.
174
175	\note Unlike BeOS, if you change the height then you need to force
176	      the BListView to recalculate the cached tops of the item
177	      selection boxes, otherwise selection highlights will be drawn
178	      in the wrong places and mouse clicks will be misinterpreted.
179	      You can do this by adding and removing a dummy BListItem at
180	      the top of the list, or after hrev50780 by calling
181	      BListView::FrameResized() with the current Frame rectangle
182	      (though the FrameResized() method will additionally call
183	      BListItem::Update() for all items).
184
185	\since BeOS R3
186*/
187
188
189/*!
190	\fn void BListItem::SetWidth(float width)
191	\brief Set the width of the list item to \a width.
192
193	\param width The width to set the list item to.
194
195	\since BeOS R3
196*/
197
198
199/*!
200	\fn void BListItem::Update(BView* owner, const BFont* font)
201	\brief Hook method that's called when the \a owner changes.
202
203	This method gets called when the list item is added to the list view.
204
205	The default implementation sets the width of the list item to the width of
206	\a owner and sets the height to fit \a font.
207
208	\param owner The list item's new \a owner.
209	\param font The font set to the list item's current \a owner.
210
211	\since BeOS R3
212*/
213
214
215/*!
216	\fn status_t BListItem::Perform(perform_code d, void* arg)
217	\brief Performs an action give a perform_code and arg. (Internal Method)
218
219	\param d The perform code.
220	\param arg A pointer to some data to perform on.
221
222	\return A status code.
223
224	\since Haiku R1
225*/
226
227
228/*!
229	\fn void BListItem::SetExpanded(bool expanded)
230	\brief Set the expanded state of the list item. This only makes sense if the
231	       list item is part of a BOutlineListView.
232
233	\param expanded \c true to expand the list item, \c false to un-expand the
234	       list item.
235
236	\since BeOS R3
237*/
238
239
240/*!
241	\fn bool BListItem::IsExpanded() const
242	\brief Returns whether or not the list item is currently expanded.
243
244	\return \c true if the list item is expanded, \c false if it is not expanded.
245
246	\since BeOS R3
247*/
248
249
250/*!
251	\fn uint32 BListItem::OutlineLevel() const
252	\brief Returns the current outline level of the list item. This only makes
253	       sense if the list item is part of a BOutlineListView.
254
255	\return The current outline level of the list item.
256
257	\since BeOS R3
258*/
259
260
261/*!
262	\fn void BListItem::SetOutlineLevel(uint32 level)
263	\brief Set the outline level of the list item.
264
265	\param level The outline level to set the list item to.
266
267	\since BeOS R3
268*/
269