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