]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxListCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxListCtrl | |
7c913512 | 11 | |
23324ae1 FM |
12 | A list control presents lists in a number of formats: list view, report view, |
13 | icon view and small icon view. In any case, elements are numbered from zero. | |
14 | For all these modes, the items are stored in the control and must be added to | |
15 | it using wxListCtrl::InsertItem method. | |
7c913512 | 16 | |
23324ae1 FM |
17 | A special case of report view quite different from the other modes of the list |
18 | control is a virtual control in which the items data (including text, images | |
19 | and attributes) is managed by the main program and is requested by the control | |
20 | itself only when needed which allows to have controls with millions of items | |
21 | without consuming much memory. To use virtual list control you must use | |
22 | wxListCtrl::SetItemCount first and overload at least | |
23 | wxListCtrl::OnGetItemText (and optionally | |
24 | wxListCtrl::OnGetItemImage or wxListCtrl::OnGetItemColumnImage and | |
25 | wxListCtrl::OnGetItemAttr) to return the information | |
26 | about the items when the control requests it. Virtual list control can be used | |
27 | as a normal one except that no operations which can take time proportional to | |
28 | the number of items in the control happen -- this is required to allow having a | |
29 | practically infinite number of items. For example, in a multiple selection | |
30 | virtual list control, the selections won't be sent when many items are selected | |
31 | at once because this could mean iterating over all the items. | |
7c913512 | 32 | |
23324ae1 FM |
33 | Using many of wxListCtrl features is shown in the |
34 | @ref overview_samplelistctrl "corresponding sample". | |
7c913512 | 35 | |
23324ae1 FM |
36 | To intercept events from a list control, use the event table macros described |
37 | in wxListEvent. | |
7c913512 FM |
38 | |
39 | @b Mac Note: Starting with 2.8, wxListCtrl uses a native implementation for | |
23324ae1 FM |
40 | report mode, and uses a generic implementation for other modes. You can use the |
41 | generic implementation for report mode as well by setting the | |
e54c96f1 | 42 | mac.listctrl.always_use_generic wxSystemOption() to |
23324ae1 | 43 | 1. |
7c913512 | 44 | |
23324ae1 | 45 | @beginStyleTable |
8c6791e4 | 46 | @style{wxLC_LIST} |
23324ae1 FM |
47 | Multicolumn list view, with optional small icons. Columns are |
48 | computed automatically, i.e. you don't set columns as in | |
49 | wxLC_REPORT. In other words, the list wraps, unlike a wxListBox. | |
8c6791e4 | 50 | @style{wxLC_REPORT} |
23324ae1 | 51 | Single or multicolumn report view, with optional header. |
8c6791e4 | 52 | @style{wxLC_VIRTUAL} |
23324ae1 FM |
53 | The application provides items text on demand. May only be used |
54 | with wxLC_REPORT. | |
8c6791e4 | 55 | @style{wxLC_ICON} |
23324ae1 | 56 | Large icon view, with optional labels. |
8c6791e4 | 57 | @style{wxLC_SMALL_ICON} |
23324ae1 | 58 | Small icon view, with optional labels. |
8c6791e4 | 59 | @style{wxLC_ALIGN_TOP} |
23324ae1 | 60 | Icons align to the top. Win32 default, Win32 only. |
8c6791e4 | 61 | @style{wxLC_ALIGN_LEFT} |
23324ae1 | 62 | Icons align to the left. |
8c6791e4 | 63 | @style{wxLC_AUTOARRANGE} |
23324ae1 | 64 | Icons arrange themselves. Win32 only. |
8c6791e4 | 65 | @style{wxLC_EDIT_LABELS} |
23324ae1 FM |
66 | Labels are editable: the application will be notified when editing |
67 | starts. | |
8c6791e4 | 68 | @style{wxLC_NO_HEADER} |
23324ae1 | 69 | No header in report mode. |
8c6791e4 | 70 | @style{wxLC_SINGLE_SEL} |
23324ae1 | 71 | Single selection (default is multiple). |
8c6791e4 | 72 | @style{wxLC_SORT_ASCENDING} |
b45506e8 VZ |
73 | Sort in ascending order. (You must still supply a comparison callback |
74 | in wxListCtrl::SortItems.) | |
8c6791e4 | 75 | @style{wxLC_SORT_DESCENDING} |
b45506e8 VZ |
76 | Sort in descending order. (You must still supply a comparison callback |
77 | in wxListCtrl::SortItems.) | |
8c6791e4 | 78 | @style{wxLC_HRULES} |
23324ae1 | 79 | Draws light horizontal rules between rows in report mode. |
8c6791e4 | 80 | @style{wxLC_VRULES} |
23324ae1 FM |
81 | Draws light vertical rules between columns in report mode. |
82 | @endStyleTable | |
7c913512 | 83 | |
23324ae1 FM |
84 | @library{wxcore} |
85 | @category{ctrl} | |
0c7fe6f2 | 86 | <!-- @appearance{listctrl.png} --> |
7c913512 | 87 | |
b45506e8 | 88 | @see @ref overview_listctrl "wxListCtrl Overview", wxListView, |
e54c96f1 | 89 | wxListBox, wxTreeCtrl, wxImageList, wxListEvent, wxListItem |
23324ae1 FM |
90 | */ |
91 | class wxListCtrl : public wxControl | |
92 | { | |
93 | public: | |
b45506e8 | 94 | /** |
1d7c0c08 | 95 | Default constructor. |
b45506e8 VZ |
96 | */ |
97 | wxListCtrl(); | |
98 | ||
23324ae1 FM |
99 | /** |
100 | Constructor, creating and showing a list control. | |
3c4f71cc | 101 | |
7c913512 | 102 | @param parent |
4cc4bfaf | 103 | Parent window. Must not be @NULL. |
7c913512 | 104 | @param id |
4cc4bfaf | 105 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 106 | @param pos |
4cc4bfaf | 107 | Window position. |
7c913512 | 108 | @param size |
4cc4bfaf | 109 | Window size. If wxDefaultSize is specified then the window is |
b45506e8 | 110 | sized appropriately. |
7c913512 | 111 | @param style |
4cc4bfaf | 112 | Window style. See wxListCtrl. |
7c913512 | 113 | @param validator |
4cc4bfaf | 114 | Window validator. |
7c913512 | 115 | @param name |
4cc4bfaf | 116 | Window name. |
3c4f71cc | 117 | |
4cc4bfaf | 118 | @see Create(), wxValidator |
23324ae1 | 119 | */ |
7c913512 FM |
120 | wxListCtrl(wxWindow* parent, wxWindowID id, |
121 | const wxPoint& pos = wxDefaultPosition, | |
122 | const wxSize& size = wxDefaultSize, | |
123 | long style = wxLC_ICON, | |
124 | const wxValidator& validator = wxDefaultValidator, | |
125 | const wxString& name = wxListCtrlNameStr); | |
23324ae1 FM |
126 | |
127 | /** | |
128 | Destructor, destroying the list control. | |
129 | */ | |
130 | ~wxListCtrl(); | |
131 | ||
132 | /** | |
133 | Arranges the items in icon or small icon view. This only has effect on Win32. | |
4cc4bfaf | 134 | @a flag is one of: |
3c4f71cc | 135 | |
1d7c0c08 RR |
136 | - wxLIST_ALIGN_DEFAULT: Default alignment. |
137 | - wxLIST_ALIGN_LEFT: Align to the left side of the control. | |
138 | - wxLIST_ALIGN_TOP: Align to the top side of the control. | |
139 | - wxLIST_ALIGN_SNAP_TO_GRID: Snap to grid. | |
23324ae1 FM |
140 | */ |
141 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); | |
142 | ||
143 | /** | |
144 | Sets the image list associated with the control and | |
145 | takes ownership of it (i.e. the control will, unlike when using | |
4cc4bfaf | 146 | SetImageList, delete the list when destroyed). @a which is one of |
23324ae1 FM |
147 | wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is |
148 | unimplemented). | |
3c4f71cc | 149 | |
4cc4bfaf | 150 | @see SetImageList() |
23324ae1 FM |
151 | */ |
152 | void AssignImageList(wxImageList* imageList, int which); | |
153 | ||
154 | /** | |
155 | Deletes all items and all columns. | |
156 | */ | |
157 | void ClearAll(); | |
158 | ||
159 | /** | |
160 | Creates the list control. See wxListCtrl() for further details. | |
161 | */ | |
162 | bool Create(wxWindow* parent, wxWindowID id, | |
163 | const wxPoint& pos = wxDefaultPosition, | |
164 | const wxSize& size = wxDefaultSize, | |
165 | long style = wxLC_ICON, | |
166 | const wxValidator& validator = wxDefaultValidator, | |
167 | const wxString& name = wxListCtrlNameStr); | |
168 | ||
169 | /** | |
170 | Deletes all items in the list control. | |
1f1d2182 | 171 | @note This function does @e not send the |
23324ae1 FM |
172 | @c wxEVT_COMMAND_LIST_DELETE_ITEM event because deleting many items |
173 | from the control would be too slow then (unlike wxListCtrl::DeleteItem). | |
174 | */ | |
175 | bool DeleteAllItems(); | |
176 | ||
177 | /** | |
178 | Deletes a column. | |
179 | */ | |
180 | bool DeleteColumn(int col); | |
181 | ||
182 | /** | |
183 | Deletes the specified item. This function sends the | |
184 | @c wxEVT_COMMAND_LIST_DELETE_ITEM event for the item being deleted. | |
23324ae1 FM |
185 | See also: DeleteAllItems() |
186 | */ | |
187 | bool DeleteItem(long item); | |
188 | ||
189 | /** | |
190 | Starts editing the label of the given item. This function generates a | |
191 | EVT_LIST_BEGIN_LABEL_EDIT event which can be vetoed so that no | |
192 | text control will appear for in-place editing. | |
23324ae1 FM |
193 | If the user changed the label (i.e. s/he does not press ESC or leave |
194 | the text control without changes, a EVT_LIST_END_LABEL_EDIT event | |
195 | will be sent which can be vetoed as well. | |
196 | */ | |
197 | void EditLabel(long item); | |
198 | ||
199 | /** | |
200 | Ensures this item is visible. | |
201 | */ | |
202 | bool EnsureVisible(long item); | |
203 | ||
23324ae1 | 204 | /** |
1d7c0c08 RR |
205 | Find an item nearest this position in the specified direction, |
206 | starting from @a start or the beginning if @a start is -1. | |
23324ae1 FM |
207 | */ |
208 | long FindItem(long start, const wxString& str, | |
4cc4bfaf | 209 | bool partial = false); |
1d7c0c08 RR |
210 | /** |
211 | Find an item nearest this position in the specified direction, | |
212 | starting from @a start or the beginning if @a start is -1. | |
213 | */ | |
7c913512 | 214 | long FindItem(long start, long data); |
1d7c0c08 RR |
215 | /** |
216 | Find an item nearest this position in the specified direction, | |
217 | starting from @a start or the beginning if @a start is -1. | |
218 | */ | |
7c913512 | 219 | long FindItem(long start, const wxPoint& pt, int direction); |
23324ae1 FM |
220 | |
221 | /** | |
222 | Gets information about this column. See SetItem() for more | |
223 | information. | |
224 | */ | |
328f5751 | 225 | bool GetColumn(int col, wxListItem& item) const; |
23324ae1 FM |
226 | |
227 | /** | |
228 | Returns the number of columns. | |
229 | */ | |
328f5751 | 230 | int GetColumnCount() const; |
23324ae1 FM |
231 | |
232 | /** | |
233 | Gets the column number by visual order index (report view only). | |
234 | */ | |
328f5751 | 235 | int GetColumnIndexFromOrder(int order) const; |
23324ae1 FM |
236 | |
237 | /** | |
238 | Gets the column visual order index (valid in report view only). | |
239 | */ | |
328f5751 | 240 | int GetColumnOrder(int col) const; |
23324ae1 FM |
241 | |
242 | /** | |
243 | Gets the column width (report view only). | |
244 | */ | |
328f5751 | 245 | int GetColumnWidth(int col) const; |
23324ae1 FM |
246 | |
247 | /** | |
248 | Returns the array containing the orders of all columns. On error, an empty | |
249 | array is returned. | |
250 | */ | |
328f5751 | 251 | wxArrayInt GetColumnsOrder() const; |
23324ae1 FM |
252 | |
253 | /** | |
254 | Gets the number of items that can fit vertically in the | |
255 | visible area of the list control (list or report view) | |
256 | or the total number of items in the list control (icon | |
257 | or small icon view). | |
258 | */ | |
328f5751 | 259 | int GetCountPerPage() const; |
23324ae1 FM |
260 | |
261 | /** | |
262 | Returns the edit control being currently used to edit a label. Returns @NULL | |
263 | if no label is being edited. | |
1f1d2182 | 264 | @note It is currently only implemented for wxMSW and the generic version, |
23324ae1 FM |
265 | not for the native Mac OS X version. |
266 | */ | |
328f5751 | 267 | wxTextCtrl* GetEditControl() const; |
23324ae1 FM |
268 | |
269 | /** | |
4cc4bfaf | 270 | Returns the specified image list. @a which may be one of: |
3c4f71cc | 271 | |
1d7c0c08 RR |
272 | - wxIMAGE_LIST_NORMAL: The normal (large icon) image list. |
273 | - wxIMAGE_LIST_SMALL: The small icon image list. | |
274 | - wxIMAGE_LIST_STATE: The user-defined state image list (unimplemented). | |
23324ae1 | 275 | */ |
328f5751 | 276 | wxImageList* GetImageList(int which) const; |
23324ae1 FM |
277 | |
278 | /** | |
279 | Gets information about the item. See SetItem() for more | |
280 | information. | |
23324ae1 FM |
281 | You must call @e info.SetId() to the ID of item you're interested in |
282 | before calling this method. | |
283 | */ | |
328f5751 | 284 | bool GetItem(wxListItem& info) const; |
23324ae1 FM |
285 | |
286 | /** | |
287 | Returns the colour for this item. If the item has no specific colour, returns | |
288 | an invalid colour (and not the default background control of the control | |
289 | itself). | |
3c4f71cc | 290 | |
4cc4bfaf | 291 | @see GetItemTextColour() |
23324ae1 | 292 | */ |
328f5751 | 293 | wxColour GetItemBackgroundColour(long item) const; |
23324ae1 FM |
294 | |
295 | /** | |
296 | Returns the number of items in the list control. | |
297 | */ | |
328f5751 | 298 | int GetItemCount() const; |
23324ae1 FM |
299 | |
300 | /** | |
301 | Gets the application-defined data associated with this item. | |
302 | */ | |
328f5751 | 303 | long GetItemData(long item) const; |
23324ae1 FM |
304 | |
305 | /** | |
306 | Returns the item's font. | |
307 | */ | |
328f5751 | 308 | wxFont GetItemFont(long item) const; |
23324ae1 FM |
309 | |
310 | /** | |
311 | Returns the position of the item, in icon or small icon view. | |
312 | */ | |
328f5751 | 313 | bool GetItemPosition(long item, wxPoint& pos) const; |
23324ae1 FM |
314 | |
315 | /** | |
316 | Returns the rectangle representing the item's size and position, in physical | |
317 | coordinates. | |
4cc4bfaf | 318 | @a code is one of wxLIST_RECT_BOUNDS, wxLIST_RECT_ICON, wxLIST_RECT_LABEL. |
23324ae1 FM |
319 | */ |
320 | bool GetItemRect(long item, wxRect& rect, | |
328f5751 | 321 | int code = wxLIST_RECT_BOUNDS) const; |
23324ae1 FM |
322 | |
323 | /** | |
324 | Retrieves the spacing between icons in pixels: horizontal spacing is returned | |
325 | as @c x component of the wxSize object and the vertical | |
326 | spacing as its @c y component. | |
327 | */ | |
328f5751 | 328 | wxSize GetItemSpacing() const; |
23324ae1 FM |
329 | |
330 | /** | |
331 | Gets the item state. For a list of state flags, see SetItem(). | |
23324ae1 FM |
332 | The @b stateMask indicates which state flags are of interest. |
333 | */ | |
328f5751 | 334 | int GetItemState(long item, long stateMask) const; |
23324ae1 FM |
335 | |
336 | /** | |
337 | Gets the item text for this item. | |
338 | */ | |
328f5751 | 339 | wxString GetItemText(long item) const; |
23324ae1 FM |
340 | |
341 | /** | |
342 | Returns the colour for this item. If the item has no specific colour, returns | |
343 | an invalid colour (and not the default foreground control of the control itself | |
344 | as this wouldn't allow distinguishing between items having the same colour as | |
345 | the current control foreground and items with default colour which, hence, have | |
346 | always the same colour as the control). | |
347 | */ | |
328f5751 | 348 | wxColour GetItemTextColour(long item) const; |
23324ae1 FM |
349 | |
350 | /** | |
351 | Searches for an item with the given geometry or state, starting from | |
4cc4bfaf | 352 | @a item but excluding the @a item itself. If @a item is -1, |
23324ae1 | 353 | the first item that matches the specified flags will be returned. |
4cc4bfaf | 354 | Returns the first item with given state following @a item or -1 if |
23324ae1 | 355 | no such item found. |
23324ae1 | 356 | This function may be used to find all selected items in the control like this: |
3c4f71cc | 357 | |
4cc4bfaf | 358 | @a geometry can be one of: |
3c4f71cc | 359 | |
23324ae1 | 360 | wxLIST_NEXT_ABOVE |
3c4f71cc | 361 | |
23324ae1 | 362 | Searches for an item above the specified item. |
3c4f71cc | 363 | |
23324ae1 | 364 | wxLIST_NEXT_ALL |
3c4f71cc | 365 | |
23324ae1 | 366 | Searches for subsequent item by index. |
3c4f71cc | 367 | |
23324ae1 | 368 | wxLIST_NEXT_BELOW |
3c4f71cc | 369 | |
23324ae1 | 370 | Searches for an item below the specified item. |
3c4f71cc | 371 | |
23324ae1 | 372 | wxLIST_NEXT_LEFT |
3c4f71cc | 373 | |
23324ae1 | 374 | Searches for an item to the left of the specified item. |
3c4f71cc | 375 | |
23324ae1 | 376 | wxLIST_NEXT_RIGHT |
3c4f71cc | 377 | |
23324ae1 | 378 | Searches for an item to the right of the specified item. |
3c4f71cc | 379 | |
1f1d2182 | 380 | @note this parameter is only supported by wxMSW currently and ignored on |
23324ae1 | 381 | other platforms. |
4cc4bfaf | 382 | @a state can be a bitlist of the following: |
3c4f71cc | 383 | |
23324ae1 | 384 | wxLIST_STATE_DONTCARE |
3c4f71cc | 385 | |
23324ae1 | 386 | Don't care what the state is. |
3c4f71cc | 387 | |
23324ae1 | 388 | wxLIST_STATE_DROPHILITED |
3c4f71cc | 389 | |
23324ae1 | 390 | The item indicates it is a drop target. |
3c4f71cc | 391 | |
23324ae1 | 392 | wxLIST_STATE_FOCUSED |
3c4f71cc | 393 | |
23324ae1 | 394 | The item has the focus. |
3c4f71cc | 395 | |
23324ae1 | 396 | wxLIST_STATE_SELECTED |
3c4f71cc | 397 | |
23324ae1 | 398 | The item is selected. |
3c4f71cc | 399 | |
23324ae1 | 400 | wxLIST_STATE_CUT |
3c4f71cc | 401 | |
23324ae1 FM |
402 | The item is selected as part of a cut and paste operation. |
403 | */ | |
404 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, | |
328f5751 | 405 | int state = wxLIST_STATE_DONTCARE) const; |
23324ae1 FM |
406 | |
407 | /** | |
408 | Returns the number of selected items in the list control. | |
409 | */ | |
328f5751 | 410 | int GetSelectedItemCount() const; |
23324ae1 FM |
411 | |
412 | /** | |
413 | Returns the rectangle representing the size and position, in physical | |
4cc4bfaf | 414 | coordinates, of the given subitem, i.e. the part of the row @a item in the |
23324ae1 | 415 | column @e subItem. |
23324ae1 | 416 | This method is only meaningfull when the wxListCtrl is in the report mode. If |
4cc4bfaf | 417 | @a subItem parameter is equal to the special value |
23324ae1 FM |
418 | @c wxLIST_GETSUBITEMRECT_WHOLEITEM the return value is the same as |
419 | for GetItemRect(). | |
4cc4bfaf | 420 | @a code can be one of @c wxLIST_RECT_BOUNDS, |
23324ae1 | 421 | @c wxLIST_RECT_ICON or @c wxLIST_RECT_LABEL. |
3c4f71cc | 422 | |
1e24c2af | 423 | @since 2.7.0 |
23324ae1 FM |
424 | */ |
425 | bool GetSubItemRect(long item, long subItem, wxRect& rect, | |
328f5751 | 426 | int code = wxLIST_RECT_BOUNDS) const; |
23324ae1 FM |
427 | |
428 | /** | |
429 | Gets the text colour of the list control. | |
430 | */ | |
328f5751 | 431 | wxColour GetTextColour() const; |
23324ae1 FM |
432 | |
433 | /** | |
434 | Gets the index of the topmost visible item when in | |
435 | list or report view. | |
436 | */ | |
328f5751 | 437 | long GetTopItem() const; |
23324ae1 FM |
438 | |
439 | /** | |
440 | Returns the rectangle taken by all items in the control. In other words, if the | |
441 | controls client size were equal to the size of this rectangle, no scrollbars | |
442 | would be needed and no free space would be left. | |
23324ae1 FM |
443 | Note that this function only works in the icon and small icon views, not in |
444 | list or report views (this is a limitation of the native Win32 control). | |
445 | */ | |
328f5751 | 446 | wxRect GetViewRect() const; |
23324ae1 FM |
447 | |
448 | /** | |
449 | Determines which item (if any) is at the specified point, | |
450 | giving details in @e flags. Returns index of the item or @c wxNOT_FOUND | |
451 | if no item is at the specified point. | |
4cc4bfaf | 452 | @a flags will be a combination of the following flags: |
3c4f71cc | 453 | |
23324ae1 | 454 | wxLIST_HITTEST_ABOVE |
3c4f71cc | 455 | |
23324ae1 | 456 | Above the client area. |
3c4f71cc | 457 | |
23324ae1 | 458 | wxLIST_HITTEST_BELOW |
3c4f71cc | 459 | |
23324ae1 | 460 | Below the client area. |
3c4f71cc | 461 | |
23324ae1 | 462 | wxLIST_HITTEST_NOWHERE |
3c4f71cc | 463 | |
23324ae1 | 464 | In the client area but below the last item. |
3c4f71cc | 465 | |
23324ae1 | 466 | wxLIST_HITTEST_ONITEMICON |
3c4f71cc | 467 | |
23324ae1 | 468 | On the bitmap associated with an item. |
3c4f71cc | 469 | |
23324ae1 | 470 | wxLIST_HITTEST_ONITEMLABEL |
3c4f71cc | 471 | |
23324ae1 | 472 | On the label (string) associated with an item. |
3c4f71cc | 473 | |
23324ae1 | 474 | wxLIST_HITTEST_ONITEMRIGHT |
3c4f71cc | 475 | |
23324ae1 | 476 | In the area to the right of an item. |
3c4f71cc | 477 | |
23324ae1 | 478 | wxLIST_HITTEST_ONITEMSTATEICON |
3c4f71cc | 479 | |
23324ae1 | 480 | On the state icon for a tree view item that is in a user-defined state. |
3c4f71cc | 481 | |
23324ae1 | 482 | wxLIST_HITTEST_TOLEFT |
3c4f71cc | 483 | |
23324ae1 | 484 | To the right of the client area. |
3c4f71cc | 485 | |
23324ae1 | 486 | wxLIST_HITTEST_TORIGHT |
3c4f71cc | 487 | |
23324ae1 | 488 | To the left of the client area. |
3c4f71cc | 489 | |
23324ae1 | 490 | wxLIST_HITTEST_ONITEM |
3c4f71cc | 491 | |
23324ae1 FM |
492 | Combination of wxLIST_HITTEST_ONITEMICON, wxLIST_HITTEST_ONITEMLABEL, |
493 | wxLIST_HITTEST_ONITEMSTATEICON. | |
3c4f71cc | 494 | |
4cc4bfaf | 495 | If @a ptrSubItem is not @NULL and the wxListCtrl is in the report |
7c913512 | 496 | mode the subitem (or column) number will also be provided. |
23324ae1 FM |
497 | This feature is only available in version 2.7.0 or higher and is currently only |
498 | implemented under wxMSW and requires at least comctl32.dll of verion 4.70 on | |
4cc4bfaf | 499 | the host system or the value stored in @a ptrSubItem will be always -1. To |
23324ae1 FM |
500 | compile this feature into wxWidgets library you need to have access to |
501 | commctrl.h of version 4.70 that is provided by Microsoft. | |
502 | */ | |
503 | long HitTest(const wxPoint& point, int& flags, | |
328f5751 | 504 | long* ptrSubItem) const; |
23324ae1 | 505 | |
23324ae1 FM |
506 | /** |
507 | For report view mode (only), inserts a column. For more details, see SetItem(). | |
508 | */ | |
509 | long InsertColumn(long col, wxListItem& info); | |
1d7c0c08 RR |
510 | /** |
511 | For report view mode (only), inserts a column. For more details, see SetItem(). | |
512 | */ | |
7c913512 FM |
513 | long InsertColumn(long col, const wxString& heading, |
514 | int format = wxLIST_FORMAT_LEFT, | |
515 | int width = -1); | |
23324ae1 | 516 | |
23324ae1 | 517 | /** |
b45506e8 | 518 | Insert a wxListItem. |
7c913512 | 519 | @param info |
4cc4bfaf | 520 | wxListItem object |
b45506e8 VZ |
521 | */ |
522 | long InsertItem(wxListItem& info); | |
523 | ||
524 | /** | |
525 | Insert an string item. | |
7c913512 | 526 | @param index |
4cc4bfaf | 527 | Index of the new item, supplied by the application |
7c913512 | 528 | @param label |
4cc4bfaf | 529 | String label |
23324ae1 | 530 | */ |
7c913512 | 531 | long InsertItem(long index, const wxString& label); |
b45506e8 VZ |
532 | |
533 | /** | |
534 | Insert an image item. | |
535 | @param index | |
536 | Index of the new item, supplied by the application | |
537 | @param imageIndex | |
538 | Index into the image list associated with this control and view style | |
539 | */ | |
7c913512 | 540 | long InsertItem(long index, int imageIndex); |
b45506e8 VZ |
541 | |
542 | /** | |
543 | Insert an image/string item. | |
544 | @param index | |
545 | Index of the new item, supplied by the application | |
546 | @param label | |
547 | String label | |
548 | @param imageIndex | |
549 | Index into the image list associated with this control and view style | |
550 | */ | |
7c913512 FM |
551 | long InsertItem(long index, const wxString& label, |
552 | int imageIndex); | |
23324ae1 FM |
553 | |
554 | /** | |
555 | This function may be overloaded in the derived class for a control with | |
556 | @c wxLC_VIRTUAL style. It should return the attribute for the | |
557 | for the specified @c item or @NULL to use the default appearance | |
558 | parameters. | |
7c913512 | 559 | wxListCtrl will not delete the pointer or keep a reference of it. You can |
23324ae1 | 560 | return the same wxListItemAttr pointer for every OnGetItemAttr call. |
23324ae1 | 561 | The base class version always returns @NULL. |
3c4f71cc | 562 | |
4cc4bfaf FM |
563 | @see OnGetItemImage(), OnGetItemColumnImage(), |
564 | OnGetItemText() | |
23324ae1 | 565 | */ |
328f5751 | 566 | virtual wxListItemAttr* OnGetItemAttr(long item) const; |
23324ae1 FM |
567 | |
568 | /** | |
569 | Overload this function in the derived class for a control with | |
570 | @c wxLC_VIRTUAL and @c wxLC_REPORT styles in order to specify the image | |
571 | index for the given line and column. | |
23324ae1 FM |
572 | The base class version always calls OnGetItemImage for the first column, else |
573 | it returns -1. | |
3c4f71cc | 574 | |
4cc4bfaf FM |
575 | @see OnGetItemText(), OnGetItemImage(), |
576 | OnGetItemAttr() | |
23324ae1 | 577 | */ |
328f5751 | 578 | virtual int OnGetItemColumnImage(long item, long column) const; |
23324ae1 FM |
579 | |
580 | /** | |
581 | This function must be overloaded in the derived class for a control with | |
b45506e8 | 582 | @c wxLC_VIRTUAL style having an @ref SetImageList() "image list" |
23324ae1 FM |
583 | (if the control doesn't have an image list, it is not necessary to overload |
584 | it). It should return the index of the items image in the controls image list | |
585 | or -1 for no image. | |
586 | In a control with @c wxLC_REPORT style, OnGetItemImage only gets called for | |
587 | the first column of each line. | |
23324ae1 | 588 | The base class version always returns -1. |
3c4f71cc | 589 | |
4cc4bfaf FM |
590 | @see OnGetItemText(), OnGetItemColumnImage(), |
591 | OnGetItemAttr() | |
23324ae1 | 592 | */ |
328f5751 | 593 | virtual int OnGetItemImage(long item) const; |
23324ae1 FM |
594 | |
595 | /** | |
596 | This function @b must be overloaded in the derived class for a control with | |
597 | @c wxLC_VIRTUAL style. It should return the string containing the text of | |
4cc4bfaf | 598 | the given @a column for the specified @c item. |
3c4f71cc | 599 | |
4cc4bfaf FM |
600 | @see SetItemCount(), OnGetItemImage(), |
601 | OnGetItemColumnImage(), OnGetItemAttr() | |
23324ae1 | 602 | */ |
328f5751 | 603 | virtual wxString OnGetItemText(long item, long column) const; |
23324ae1 FM |
604 | |
605 | /** | |
606 | Redraws the given @e item. This is only useful for the virtual list controls | |
607 | as without calling this function the displayed value of the item doesn't change | |
608 | even when the underlying data does change. | |
3c4f71cc | 609 | |
4cc4bfaf | 610 | @see RefreshItems() |
23324ae1 FM |
611 | */ |
612 | void RefreshItem(long item); | |
613 | ||
614 | /** | |
4cc4bfaf | 615 | Redraws the items between @a itemFrom and @e itemTo. The starting item |
23324ae1 | 616 | must be less than or equal to the ending one. |
23324ae1 FM |
617 | Just as RefreshItem() this is only useful for |
618 | virtual list controls. | |
619 | */ | |
620 | void RefreshItems(long itemFrom, long itemTo); | |
621 | ||
622 | /** | |
623 | Scrolls the list control. If in icon, small icon or report view mode, | |
4cc4bfaf FM |
624 | @a dx specifies the number of pixels to scroll. If in list view mode, |
625 | @a dx specifies the number of columns to scroll. @a dy always specifies | |
23324ae1 | 626 | the number of pixels to scroll vertically. |
1f1d2182 | 627 | @note This method is currently only implemented in the Windows version. |
23324ae1 FM |
628 | */ |
629 | bool ScrollList(int dx, int dy); | |
630 | ||
631 | /** | |
632 | Sets the background colour (GetBackgroundColour already implicit in | |
633 | wxWindow class). | |
634 | */ | |
635 | void SetBackgroundColour(const wxColour& col); | |
636 | ||
637 | /** | |
638 | Sets information about this column. See SetItem() for more | |
639 | information. | |
640 | */ | |
641 | bool SetColumn(int col, wxListItem& item); | |
642 | ||
643 | /** | |
644 | Sets the column width. | |
4cc4bfaf | 645 | @a width can be a width in pixels or wxLIST_AUTOSIZE (-1) or |
23324ae1 FM |
646 | wxLIST_AUTOSIZE_USEHEADER (-2). |
647 | wxLIST_AUTOSIZE will resize the column to the length of its longest item. | |
648 | wxLIST_AUTOSIZE_USEHEADER | |
649 | will resize the column to the length of the header (Win32) or 80 pixels (other | |
650 | platforms). | |
4cc4bfaf | 651 | In small or normal icon view, @a col must be -1, and the column width is set |
23324ae1 FM |
652 | for all columns. |
653 | */ | |
654 | bool SetColumnWidth(int col, int width); | |
655 | ||
656 | /** | |
4cc4bfaf | 657 | Sets the order of all columns at once. The @a orders array must have the |
23324ae1 FM |
658 | same number elements as the number of columns and contain each position exactly |
659 | once. | |
23324ae1 FM |
660 | This function is valid in report view only. |
661 | */ | |
328f5751 | 662 | bool SetColumnOrder(const wxArrayInt& orders) const; |
23324ae1 FM |
663 | |
664 | /** | |
4cc4bfaf | 665 | Sets the image list associated with the control. @a which is one of |
23324ae1 FM |
666 | wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is |
667 | unimplemented). | |
23324ae1 FM |
668 | This method does not take ownership of the image list, you have to |
669 | delete it yourself. | |
3c4f71cc | 670 | |
4cc4bfaf | 671 | @see AssignImageList() |
23324ae1 FM |
672 | */ |
673 | void SetImageList(wxImageList* imageList, int which); | |
674 | ||
23324ae1 | 675 | /** |
1d7c0c08 RR |
676 | Sets the data of an item. |
677 | ||
678 | wxListItem is a class with the following members | |
679 | ||
680 | - long m_mask: Indicates which fields are valid. See below. | |
681 | - long m_itemId: Zero based item position. | |
682 | - int m_col: Zero based column index. | |
683 | - long m_state: The state of the item: See below for valid state flags. | |
684 | - long m_stateMask: A mask indicating which state flags are valid. See below. | |
685 | - wxStrign m_text: the label (or header for columns) | |
686 | - int m_image: The zero based index into an image list | |
687 | - long m_data: Application defined data | |
688 | - int m_format: For columns only: Either of wxLIST_FORMAT_LEFT, wxLIST_FORMAT_RIGHT, wxLIST_FORMAT_CENTRE | |
689 | - int m_width: For columns only: the width of the column | |
690 | ||
691 | The @b m_mask member contains a bitlist specifying which of the other fields | |
692 | are valid. The flags are: | |
693 | - wxLIST_MASK_STATE: The m_state field is valid. | |
694 | - wxLIST_MASK_TEXT: The m_text field is valid. | |
695 | - wxLIST_MASK_IMAGE: The m_image field is valid. | |
696 | - wxLIST_MASK_DATA: The m_data field is valid. | |
697 | - wxLIST_MASK_WIDTH: The m_width field is valid. | |
698 | - wxLIST_MASK_FORMAT: The m_format field is valid. | |
699 | ||
700 | The @b m_stateMask and @b m_state members take flags from the following: | |
701 | ||
702 | - wxLIST_STATE_DONTCARE: Don't care what the state is. Win32 only. | |
703 | - wxLIST_STATE_DROPHILITED: The item is highlighted to receive a drop event. Win32 only. | |
704 | - wxLIST_STATE_FOCUSED: The item has the focus. | |
705 | - wxLIST_STATE_SELECTED: The item is selected. | |
706 | - wxLIST_STATE_CUT: The item is in the cut state. Win32 only. | |
707 | ||
708 | The wxListItem object can also contain item-specific colour and font | |
709 | information: for this you need to call one of SetTextColour(), | |
710 | SetBackgroundColour() or SetFont() functions on it passing it the colour/font | |
711 | to use. If the colour/font is not specified, the default list control | |
712 | colour/font is used. | |
23324ae1 FM |
713 | */ |
714 | bool SetItem(wxListItem& info); | |
1d7c0c08 RR |
715 | |
716 | /** | |
717 | Sets a string field at a particular column. | |
718 | */ | |
b45506e8 | 719 | long SetItem(long index, int col, const wxString& label, |
7c913512 | 720 | int imageId = -1); |
23324ae1 FM |
721 | |
722 | /** | |
1d7c0c08 RR |
723 | Sets the background colour for this item. This function only works |
724 | in report view. The colour can be retrieved using GetItemBackgroundColour(). | |
23324ae1 FM |
725 | */ |
726 | void SetItemBackgroundColour(long item, const wxColour& col); | |
727 | ||
728 | /** | |
1d7c0c08 RR |
729 | Sets the image associated with the item. In report view, you can |
730 | specify the column. The image is an index into the image list | |
731 | associated with the list control. | |
23324ae1 FM |
732 | */ |
733 | bool SetItemColumnImage(long item, long column, int image); | |
734 | ||
735 | /** | |
558a6e06 VZ |
736 | This method can only be used with virtual list controls. |
737 | ||
738 | It is used to indicate to the control the number of items it contains. | |
739 | After calling it, the main program should be ready to handle calls to | |
740 | various item callbacks (such as wxListCtrl::OnGetItemText) for all | |
741 | items in the range from 0 to @a count. | |
742 | ||
743 | Notice that the control is not necessarily redrawn after this call as | |
744 | it may be undesirable if an item which is not visible on the screen | |
745 | anyhow was added to or removed from a control displaying many items, if | |
746 | you do need to refresh the display you can just call Refresh() manually. | |
23324ae1 FM |
747 | */ |
748 | void SetItemCount(long count); | |
749 | ||
750 | /** | |
7c913512 | 751 | Associates application-defined data with this item. |
7c913512 FM |
752 | Notice that this function cannot be used to associate pointers with the control |
753 | items, use SetItemPtrData() instead. | |
23324ae1 FM |
754 | */ |
755 | bool SetItemData(long item, long data); | |
756 | ||
757 | /** | |
1d7c0c08 | 758 | Sets the item's font. |
23324ae1 FM |
759 | */ |
760 | void SetItemFont(long item, const wxFont& font); | |
761 | ||
23324ae1 | 762 | /** |
1d7c0c08 RR |
763 | Sets the unselected and selected images associated with the item. The |
764 | images are indices into the image list associated with the list control. | |
23324ae1 FM |
765 | */ |
766 | bool SetItemImage(long item, int image); | |
1d7c0c08 RR |
767 | |
768 | /** | |
769 | Sets the unselected and selected images associated with the item. The | |
770 | images are indices into the image list associated with the list control. | |
771 | This form is deprecated: @a selImage is not used. | |
772 | */ | |
7c913512 | 773 | bool SetItemImage(long item, int image, int selImage); |
23324ae1 FM |
774 | |
775 | /** | |
776 | Sets the position of the item, in icon or small icon view. Windows only. | |
777 | */ | |
778 | bool SetItemPosition(long item, const wxPoint& pos); | |
779 | ||
780 | /** | |
4cc4bfaf | 781 | Associates application-defined data with this item. The @a data parameter may |
23324ae1 FM |
782 | be either an integer or a pointer cast to the @c wxUIntPtr type which is |
783 | guaranteed to be large enough to be able to contain all integer types and | |
784 | pointers. | |
3c4f71cc | 785 | |
1e24c2af | 786 | @since 2.8.4 |
23324ae1 FM |
787 | */ |
788 | bool SetItemPtrData(long item, wxUIntPtr data); | |
789 | ||
790 | /** | |
791 | Sets the item state. For a list of state flags, see SetItem(). | |
23324ae1 FM |
792 | The @b stateMask indicates which state flags are valid. |
793 | */ | |
794 | bool SetItemState(long item, long state, long stateMask); | |
795 | ||
796 | /** | |
797 | Sets the item text for this item. | |
798 | */ | |
799 | void SetItemText(long item, const wxString& text); | |
800 | ||
801 | /** | |
802 | Sets the colour for this item. This function only works in report view. | |
23324ae1 FM |
803 | The colour can be retrieved using |
804 | GetItemTextColour(). | |
805 | */ | |
806 | void SetItemTextColour(long item, const wxColour& col); | |
807 | ||
808 | /** | |
809 | Adds or removes a single window style. | |
810 | */ | |
4cc4bfaf | 811 | void SetSingleStyle(long style, bool add = true); |
23324ae1 FM |
812 | |
813 | /** | |
814 | Sets the text colour of the list control. | |
815 | */ | |
816 | void SetTextColour(const wxColour& col); | |
817 | ||
818 | /** | |
819 | Sets the whole window style, deleting all items. | |
820 | */ | |
821 | void SetWindowStyleFlag(long style); | |
822 | ||
823 | /** | |
824 | Call this function to sort the items in the list control. Sorting is done | |
4cc4bfaf | 825 | using the specified @a fnSortCallBack function. This function must have the |
23324ae1 | 826 | following prototype: |
3c4f71cc | 827 | |
23324ae1 FM |
828 | It is called each time when the two items must be compared and should return 0 |
829 | if the items are equal, negative value if the first item is less than the | |
830 | second one and positive value if the first one is greater than the second one | |
831 | (the same convention as used by @c qsort(3)). | |
3c4f71cc | 832 | |
7c913512 | 833 | @param item1 |
4cc4bfaf | 834 | client data associated with the first item (NOT the index). |
7c913512 | 835 | @param item2 |
4cc4bfaf | 836 | client data associated with the second item (NOT the index). |
7c913512 | 837 | @param data |
4cc4bfaf | 838 | the value passed to SortItems() itself. |
23324ae1 FM |
839 | */ |
840 | bool SortItems(wxListCtrlCompare fnSortCallBack, long data); | |
841 | }; | |
842 | ||
843 | ||
e54c96f1 | 844 | |
23324ae1 FM |
845 | /** |
846 | @class wxListEvent | |
7c913512 | 847 | |
23324ae1 | 848 | A list event holds information about events associated with wxListCtrl objects. |
7c913512 | 849 | |
23324ae1 FM |
850 | @library{wxbase} |
851 | @category{events} | |
7c913512 | 852 | |
e54c96f1 | 853 | @see wxListCtrl |
23324ae1 FM |
854 | */ |
855 | class wxListEvent : public wxNotifyEvent | |
856 | { | |
857 | public: | |
858 | /** | |
859 | Constructor. | |
860 | */ | |
1d497b99 | 861 | wxListEvent(wxEventType commandType = 0, int id = 0); |
23324ae1 FM |
862 | |
863 | /** | |
864 | For @c EVT_LIST_CACHE_HINT event only: return the first item which the | |
865 | list control advises us to cache. | |
866 | */ | |
328f5751 | 867 | long GetCacheFrom() const; |
23324ae1 FM |
868 | |
869 | /** | |
870 | For @c EVT_LIST_CACHE_HINT event only: return the last item (inclusive) | |
871 | which the list control advises us to cache. | |
872 | */ | |
328f5751 | 873 | long GetCacheTo() const; |
23324ae1 FM |
874 | |
875 | /** | |
876 | The column position: it is only used with @c COL events. For the column | |
877 | dragging events, it is the column to the left of the divider being dragged, for | |
878 | the column click events it may be -1 if the user clicked in the list control | |
879 | header outside any column. | |
880 | */ | |
328f5751 | 881 | int GetColumn() const; |
23324ae1 FM |
882 | |
883 | /** | |
884 | The data. | |
885 | */ | |
328f5751 | 886 | long GetData() const; |
23324ae1 FM |
887 | |
888 | /** | |
889 | The image. | |
890 | */ | |
328f5751 | 891 | int GetImage() const; |
23324ae1 FM |
892 | |
893 | /** | |
894 | The item index. | |
895 | */ | |
328f5751 | 896 | long GetIndex() const; |
23324ae1 FM |
897 | |
898 | /** | |
899 | An item object, used by some events. See also wxListCtrl::SetItem. | |
900 | */ | |
328f5751 | 901 | const wxListItem GetItem() const; |
23324ae1 FM |
902 | |
903 | /** | |
904 | Key code if the event is a keypress event. | |
905 | */ | |
328f5751 | 906 | int GetKeyCode() const; |
23324ae1 FM |
907 | |
908 | /** | |
909 | The (new) item label for @c EVT_LIST_END_LABEL_EDIT event. | |
910 | */ | |
328f5751 | 911 | const wxString GetLabel() const; |
23324ae1 FM |
912 | |
913 | /** | |
914 | The mask. | |
915 | */ | |
328f5751 | 916 | long GetMask() const; |
23324ae1 FM |
917 | |
918 | /** | |
919 | The position of the mouse pointer if the event is a drag event. | |
920 | */ | |
328f5751 | 921 | wxPoint GetPoint() const; |
23324ae1 FM |
922 | |
923 | /** | |
924 | The text. | |
925 | */ | |
328f5751 | 926 | const wxString GetText() const; |
23324ae1 FM |
927 | |
928 | /** | |
929 | This method only makes sense for @c EVT_LIST_END_LABEL_EDIT message | |
930 | and returns @true if it the label editing has been cancelled by the user | |
931 | (GetLabel() returns an empty string in this case | |
932 | but it doesn't allow the application to distinguish between really cancelling | |
933 | the edit and | |
934 | the admittedly rare case when the user wants to rename it to an empty string). | |
935 | */ | |
328f5751 | 936 | bool IsEditCancelled() const; |
23324ae1 FM |
937 | }; |
938 | ||
939 | ||
e54c96f1 | 940 | |
23324ae1 FM |
941 | /** |
942 | @class wxListItemAttr | |
7c913512 | 943 | |
23324ae1 FM |
944 | Represents the attributes (color, font, ...) of a |
945 | wxListCtrl wxListItem. | |
7c913512 | 946 | |
23324ae1 FM |
947 | @library{wxbase} |
948 | @category{FIXME} | |
7c913512 | 949 | |
b45506e8 | 950 | @see @ref overview_listctrl "wxListCtrl Overview", wxListCtrl, |
e54c96f1 | 951 | wxListItem |
23324ae1 | 952 | */ |
7c913512 | 953 | class wxListItemAttr |
23324ae1 FM |
954 | { |
955 | public: | |
1d7c0c08 RR |
956 | /** |
957 | Default Constructor. | |
958 | */ | |
959 | wxListItemAttr(); | |
23324ae1 FM |
960 | /** |
961 | Construct a wxListItemAttr with the specified foreground and | |
962 | background colors and font. | |
963 | */ | |
7c913512 FM |
964 | wxListItemAttr(const wxColour colText, |
965 | const wxColour colBack, | |
966 | const wxFont font); | |
23324ae1 FM |
967 | |
968 | /** | |
969 | Returns the currently set background color. | |
970 | */ | |
328f5751 | 971 | const wxColour GetBackgroundColour() const; |
23324ae1 FM |
972 | |
973 | /** | |
974 | Returns the currently set font. | |
975 | */ | |
328f5751 | 976 | const wxFont GetFont() const; |
23324ae1 FM |
977 | |
978 | /** | |
979 | Returns the currently set text color. | |
980 | */ | |
328f5751 | 981 | const wxColour GetTextColour() const; |
23324ae1 FM |
982 | |
983 | /** | |
984 | Returns @true if the currently set background color is valid. | |
985 | */ | |
328f5751 | 986 | bool HasBackgroundColour() const; |
23324ae1 FM |
987 | |
988 | /** | |
989 | Returns @true if the currently set font is valid. | |
990 | */ | |
328f5751 | 991 | bool HasFont() const; |
23324ae1 FM |
992 | |
993 | /** | |
994 | Returns @true if the currently set text color is valid. | |
995 | */ | |
328f5751 | 996 | bool HasTextColour() const; |
23324ae1 FM |
997 | |
998 | /** | |
999 | Sets a new background color. | |
1000 | */ | |
1001 | void SetBackgroundColour(const wxColour& colour); | |
1002 | ||
1003 | /** | |
1004 | Sets a new font. | |
1005 | */ | |
1006 | void SetFont(const wxFont& font); | |
1007 | ||
1008 | /** | |
1009 | Sets a new text color. | |
1010 | */ | |
1011 | void SetTextColour(const wxColour& colour); | |
1012 | }; | |
1013 | ||
1014 | ||
e54c96f1 | 1015 | |
23324ae1 FM |
1016 | /** |
1017 | @class wxListView | |
7c913512 FM |
1018 | |
1019 | This class currently simply presents a simpler to use interface for the | |
23324ae1 | 1020 | wxListCtrl -- it can be thought of as a @e faade |
7c913512 | 1021 | for that complicated class. Using it is preferable to using |
23324ae1 FM |
1022 | wxListCtrl directly whenever possible because in the |
1023 | future some ports might implement wxListView but not the full set of wxListCtrl | |
1024 | features. | |
7c913512 | 1025 | |
23324ae1 FM |
1026 | Other than different interface, this class is identical to wxListCtrl. In |
1027 | particular, it uses the same events, same window styles and so on. | |
7c913512 | 1028 | |
23324ae1 FM |
1029 | @library{wxcore} |
1030 | @category{ctrl} | |
0c7fe6f2 | 1031 | <!-- @appearance{listview.png} --> |
7c913512 | 1032 | |
e54c96f1 | 1033 | @see wxListView::SetColumnImage |
23324ae1 FM |
1034 | */ |
1035 | class wxListView : public wxListCtrl | |
1036 | { | |
1037 | public: | |
1038 | /** | |
1039 | Resets the column image -- after calling this function, no image will be shown. | |
3c4f71cc | 1040 | |
7c913512 | 1041 | @param col |
4cc4bfaf | 1042 | the column to clear image for |
3c4f71cc | 1043 | |
4cc4bfaf | 1044 | @see SetColumnImage() |
23324ae1 FM |
1045 | */ |
1046 | void ClearColumnImage(int col); | |
1047 | ||
1048 | /** | |
1049 | Sets focus to the item with the given @e index. | |
1050 | */ | |
1051 | void Focus(long index); | |
1052 | ||
1053 | /** | |
1054 | Returns the first selected item in a (presumably) multiple selection control. | |
1055 | Together with GetNextSelected() it can be | |
1056 | used to iterate over all selected items in the control. | |
3c4f71cc | 1057 | |
d29a9a8a | 1058 | @return The first selected item, if any, -1 otherwise. |
23324ae1 | 1059 | */ |
328f5751 | 1060 | long GetFirstSelected() const; |
23324ae1 FM |
1061 | |
1062 | /** | |
1063 | Returns the currently focused item or -1 if none. | |
3c4f71cc | 1064 | |
4cc4bfaf | 1065 | @see IsSelected(), Focus() |
23324ae1 | 1066 | */ |
328f5751 | 1067 | long GetFocusedItem() const; |
23324ae1 FM |
1068 | |
1069 | /** | |
1070 | Used together with GetFirstSelected() to | |
1071 | iterate over all selected items in the control. | |
3c4f71cc | 1072 | |
d29a9a8a | 1073 | @return Returns the next selected item or -1 if there are no more of |
4cc4bfaf | 1074 | them. |
23324ae1 | 1075 | */ |
328f5751 | 1076 | long GetNextSelected(long item) const; |
23324ae1 FM |
1077 | |
1078 | /** | |
4cc4bfaf | 1079 | Returns @true if the item with the given @a index is selected, |
23324ae1 | 1080 | @false otherwise. |
3c4f71cc | 1081 | |
4cc4bfaf | 1082 | @see GetFirstSelected(), GetNextSelected() |
23324ae1 | 1083 | */ |
328f5751 | 1084 | bool IsSelected(long index) const; |
23324ae1 FM |
1085 | |
1086 | /** | |
1087 | Selects or unselects the given item. | |
3c4f71cc | 1088 | |
7c913512 | 1089 | @param n |
4cc4bfaf | 1090 | the item to select or unselect |
7c913512 | 1091 | @param on |
4cc4bfaf | 1092 | if @true (default), selects the item, otherwise unselects it |
3c4f71cc | 1093 | |
4cc4bfaf | 1094 | @see wxListCtrl::SetItemState |
23324ae1 | 1095 | */ |
792255cc | 1096 | void Select(long n, bool on = true); |
23324ae1 FM |
1097 | |
1098 | /** | |
1099 | Sets the column image for the specified column. To use the column images, the | |
1100 | control must have a valid image list with at least one image. | |
3c4f71cc | 1101 | |
7c913512 | 1102 | @param col |
4cc4bfaf | 1103 | the column to set image for |
7c913512 | 1104 | @param image |
4cc4bfaf | 1105 | the index of the column image in the controls image list |
23324ae1 FM |
1106 | */ |
1107 | void SetColumnImage(int col, int image); | |
1108 | }; | |
1109 | ||
1110 | ||
e54c96f1 | 1111 | |
23324ae1 FM |
1112 | /** |
1113 | @class wxListItem | |
7c913512 | 1114 | |
23324ae1 | 1115 | This class stores information about a wxListCtrl item or column. |
7c913512 | 1116 | |
23324ae1 FM |
1117 | @library{wxbase} |
1118 | @category{FIXME} | |
1119 | */ | |
1120 | class wxListItem : public wxObject | |
1121 | { | |
1122 | public: | |
1123 | /** | |
1124 | Constructor. | |
1125 | */ | |
1126 | wxListItem(); | |
1127 | ||
1128 | /** | |
1129 | Resets the item state to the default. | |
1130 | */ | |
1131 | void Clear(); | |
1132 | ||
1133 | /** | |
1134 | Returns the alignment for this item. Can be one of | |
1135 | wxLIST_FORMAT_LEFT, wxLIST_FORMAT_RIGHT or wxLIST_FORMAT_CENTRE. | |
1136 | */ | |
328f5751 | 1137 | wxListColumnFormat GetAlign() const; |
23324ae1 FM |
1138 | |
1139 | /** | |
1140 | Returns the background colour for this item. | |
1141 | */ | |
328f5751 | 1142 | wxColour GetBackgroundColour() const; |
23324ae1 FM |
1143 | |
1144 | /** | |
1145 | Returns the zero-based column; meaningful only in report mode. | |
1146 | */ | |
328f5751 | 1147 | int GetColumn() const; |
23324ae1 FM |
1148 | |
1149 | /** | |
1150 | Returns client data associated with the control. Please note that | |
1151 | client data is associated with the item and not with subitems. | |
1152 | */ | |
328f5751 | 1153 | long GetData() const; |
23324ae1 FM |
1154 | |
1155 | /** | |
1156 | Returns the font used to display the item. | |
1157 | */ | |
328f5751 | 1158 | wxFont GetFont() const; |
23324ae1 FM |
1159 | |
1160 | /** | |
1161 | Returns the zero-based item position. | |
1162 | */ | |
328f5751 | 1163 | long GetId() const; |
23324ae1 FM |
1164 | |
1165 | /** | |
1166 | Returns the zero-based index of the image | |
1167 | associated with the item into the image list. | |
1168 | */ | |
328f5751 | 1169 | int GetImage() const; |
23324ae1 FM |
1170 | |
1171 | /** | |
1172 | Returns a bit mask indicating which fields of the structure are valid; | |
1173 | can be any combination of the following values: | |
3c4f71cc | 1174 | |
23324ae1 | 1175 | wxLIST_MASK_STATE |
3c4f71cc | 1176 | |
23324ae1 | 1177 | @b GetState is valid. |
3c4f71cc | 1178 | |
23324ae1 | 1179 | wxLIST_MASK_TEXT |
3c4f71cc | 1180 | |
23324ae1 | 1181 | @b GetText is valid. |
3c4f71cc | 1182 | |
23324ae1 | 1183 | wxLIST_MASK_IMAGE |
3c4f71cc | 1184 | |
23324ae1 | 1185 | @b GetImage is valid. |
3c4f71cc | 1186 | |
23324ae1 | 1187 | wxLIST_MASK_DATA |
3c4f71cc | 1188 | |
23324ae1 | 1189 | @b GetData is valid. |
3c4f71cc | 1190 | |
23324ae1 | 1191 | wxLIST_MASK_WIDTH |
3c4f71cc | 1192 | |
23324ae1 | 1193 | @b GetWidth is valid. |
3c4f71cc | 1194 | |
23324ae1 | 1195 | wxLIST_MASK_FORMAT |
3c4f71cc | 1196 | |
23324ae1 FM |
1197 | @b GetFormat is valid. |
1198 | */ | |
328f5751 | 1199 | long GetMask() const; |
23324ae1 FM |
1200 | |
1201 | /** | |
1202 | Returns a bit field representing the state of the item. Can be any | |
1203 | combination of: | |
3c4f71cc | 1204 | |
23324ae1 | 1205 | wxLIST_STATE_DONTCARE |
3c4f71cc | 1206 | |
7c913512 | 1207 | Don't care what the state is. Win32 only. |
3c4f71cc | 1208 | |
23324ae1 | 1209 | wxLIST_STATE_DROPHILITED |
3c4f71cc | 1210 | |
7c913512 | 1211 | The item is highlighted to receive a drop event. Win32 only. |
3c4f71cc | 1212 | |
23324ae1 | 1213 | wxLIST_STATE_FOCUSED |
3c4f71cc | 1214 | |
23324ae1 | 1215 | The item has the focus. |
3c4f71cc | 1216 | |
23324ae1 | 1217 | wxLIST_STATE_SELECTED |
3c4f71cc | 1218 | |
23324ae1 | 1219 | The item is selected. |
3c4f71cc | 1220 | |
23324ae1 | 1221 | wxLIST_STATE_CUT |
3c4f71cc | 1222 | |
23324ae1 FM |
1223 | The item is in the cut state. Win32 only. |
1224 | */ | |
328f5751 | 1225 | long GetState() const; |
23324ae1 FM |
1226 | |
1227 | /** | |
1228 | Returns the label/header text. | |
1229 | */ | |
328f5751 | 1230 | const wxString GetText() const; |
23324ae1 FM |
1231 | |
1232 | /** | |
1233 | Returns the text colour. | |
1234 | */ | |
328f5751 | 1235 | wxColour GetTextColour() const; |
23324ae1 FM |
1236 | |
1237 | /** | |
1238 | Meaningful only for column headers in report mode. Returns the column width. | |
1239 | */ | |
328f5751 | 1240 | int GetWidth() const; |
23324ae1 FM |
1241 | |
1242 | /** | |
1243 | Sets the alignment for the item. See also | |
1244 | GetAlign() | |
1245 | */ | |
1246 | void SetAlign(wxListColumnFormat align); | |
1247 | ||
1248 | /** | |
1249 | Sets the background colour for the item. | |
1250 | */ | |
1251 | void SetBackgroundColour(const wxColour& colBack); | |
1252 | ||
1253 | /** | |
1254 | Sets the zero-based column. Meaningful only in report mode. | |
1255 | */ | |
1256 | void SetColumn(int col); | |
1257 | ||
1258 | //@{ | |
1259 | /** | |
1260 | Sets client data for the item. Please note that | |
1261 | client data is associated with the item and not with subitems. | |
1262 | */ | |
1263 | void SetData(long data); | |
7c913512 | 1264 | void SetData(void* data); |
23324ae1 FM |
1265 | //@} |
1266 | ||
1267 | /** | |
1268 | Sets the font for the item. | |
1269 | */ | |
1270 | void SetFont(const wxFont& font); | |
1271 | ||
1272 | /** | |
1273 | Sets the zero-based item position. | |
1274 | */ | |
1275 | void SetId(long id); | |
1276 | ||
1277 | /** | |
1278 | Sets the zero-based index of the image associated with the item | |
1279 | into the image list. | |
1280 | */ | |
1281 | void SetImage(int image); | |
1282 | ||
1283 | /** | |
1284 | Sets the mask of valid fields. See GetMask(). | |
1285 | */ | |
1286 | void SetMask(long mask); | |
1287 | ||
1288 | /** | |
1289 | Sets the item state flags (note that the valid state flags are influenced | |
1290 | by the value of the state mask, see | |
1291 | wxListItem::SetStateMask). | |
1292 | See GetState() for valid flag | |
1293 | values. | |
1294 | */ | |
1295 | void SetState(long state); | |
1296 | ||
1297 | /** | |
1298 | Sets the bitmask that is used to determine which of the state flags | |
1299 | are to be set. See also SetState(). | |
1300 | */ | |
1301 | void SetStateMask(long stateMask); | |
1302 | ||
1303 | /** | |
1304 | Sets the text label for the item. | |
1305 | */ | |
1306 | void SetText(const wxString& text); | |
1307 | ||
1308 | /** | |
1309 | Sets the text colour for the item. | |
1310 | */ | |
1311 | void SetTextColour(const wxColour& colText); | |
1312 | ||
1313 | /** | |
1314 | Meaningful only for column headers in report mode. Sets the column width. | |
1315 | */ | |
1316 | void SetWidth(int width); | |
1317 | }; | |
e54c96f1 | 1318 |