]>
Commit | Line | Data |
---|---|---|
e81a301c | 1 | /////////////////////////////////////////////////////////////////////////////// |
e409b62a | 2 | // Name: wx/listbase.h |
e81a301c JS |
3 | // Purpose: wxListCtrl class |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 04.12.99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
e81a301c JS |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_LISTBASE_H_BASE_ | |
13 | #define _WX_LISTBASE_H_BASE_ | |
14 | ||
87f086bc | 15 | #include "wx/colour.h" |
ec64c745 | 16 | #include "wx/font.h" |
87f086bc | 17 | #include "wx/gdicmn.h" |
87f086bc | 18 | #include "wx/event.h" |
0dc45ad6 | 19 | #include "wx/control.h" |
ec64c745 | 20 | |
94248d2e VZ |
21 | class WXDLLIMPEXP_FWD_CORE wxImageList; |
22 | ||
e81a301c JS |
23 | // ---------------------------------------------------------------------------- |
24 | // types | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | // type of compare function for wxListCtrl sort operation | |
6e2f3084 | 28 | typedef |
d3ca8487 | 29 | int (wxCALLBACK *wxListCtrlCompare)(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData); |
e81a301c JS |
30 | |
31 | // ---------------------------------------------------------------------------- | |
32 | // wxListCtrl constants | |
33 | // ---------------------------------------------------------------------------- | |
34 | ||
35 | // style flags | |
36 | #define wxLC_VRULES 0x0001 | |
37 | #define wxLC_HRULES 0x0002 | |
38 | ||
39 | #define wxLC_ICON 0x0004 | |
40 | #define wxLC_SMALL_ICON 0x0008 | |
41 | #define wxLC_LIST 0x0010 | |
42 | #define wxLC_REPORT 0x0020 | |
43 | ||
44 | #define wxLC_ALIGN_TOP 0x0040 | |
45 | #define wxLC_ALIGN_LEFT 0x0080 | |
46 | #define wxLC_AUTOARRANGE 0x0100 | |
47 | #define wxLC_VIRTUAL 0x0200 | |
48 | #define wxLC_EDIT_LABELS 0x0400 | |
49 | #define wxLC_NO_HEADER 0x0800 | |
50 | #define wxLC_NO_SORT_HEADER 0x1000 | |
51 | #define wxLC_SINGLE_SEL 0x2000 | |
52 | #define wxLC_SORT_ASCENDING 0x4000 | |
53 | #define wxLC_SORT_DESCENDING 0x8000 | |
54 | ||
55 | #define wxLC_MASK_TYPE (wxLC_ICON | wxLC_SMALL_ICON | wxLC_LIST | wxLC_REPORT) | |
56 | #define wxLC_MASK_ALIGN (wxLC_ALIGN_TOP | wxLC_ALIGN_LEFT) | |
57 | #define wxLC_MASK_SORT (wxLC_SORT_ASCENDING | wxLC_SORT_DESCENDING) | |
58 | ||
59 | // for compatibility only | |
60 | #define wxLC_USER_TEXT wxLC_VIRTUAL | |
61 | ||
62 | // Omitted because | |
63 | // (a) too much detail | |
64 | // (b) not enough style flags | |
65 | // (c) not implemented anyhow in the generic version | |
66 | // | |
67 | // #define wxLC_NO_SCROLL | |
68 | // #define wxLC_NO_LABEL_WRAP | |
69 | // #define wxLC_OWNERDRAW_FIXED | |
70 | // #define wxLC_SHOW_SEL_ALWAYS | |
71 | ||
72 | // Mask flags to tell app/GUI what fields of wxListItem are valid | |
73 | #define wxLIST_MASK_STATE 0x0001 | |
74 | #define wxLIST_MASK_TEXT 0x0002 | |
75 | #define wxLIST_MASK_IMAGE 0x0004 | |
76 | #define wxLIST_MASK_DATA 0x0008 | |
77 | #define wxLIST_SET_ITEM 0x0010 | |
78 | #define wxLIST_MASK_WIDTH 0x0020 | |
79 | #define wxLIST_MASK_FORMAT 0x0040 | |
80 | ||
81 | // State flags for indicating the state of an item | |
82 | #define wxLIST_STATE_DONTCARE 0x0000 | |
83 | #define wxLIST_STATE_DROPHILITED 0x0001 // MSW only | |
84 | #define wxLIST_STATE_FOCUSED 0x0002 | |
85 | #define wxLIST_STATE_SELECTED 0x0004 | |
86 | #define wxLIST_STATE_CUT 0x0008 // MSW only | |
c220541d DW |
87 | #define wxLIST_STATE_DISABLED 0x0010 // OS2 only |
88 | #define wxLIST_STATE_FILTERED 0x0020 // OS2 only | |
89 | #define wxLIST_STATE_INUSE 0x0040 // OS2 only | |
90 | #define wxLIST_STATE_PICKED 0x0080 // OS2 only | |
91 | #define wxLIST_STATE_SOURCE 0x0100 // OS2 only | |
e81a301c JS |
92 | |
93 | // Hit test flags, used in HitTest | |
94 | #define wxLIST_HITTEST_ABOVE 0x0001 // Above the client area. | |
95 | #define wxLIST_HITTEST_BELOW 0x0002 // Below the client area. | |
96 | #define wxLIST_HITTEST_NOWHERE 0x0004 // In the client area but below the last item. | |
97 | #define wxLIST_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item. | |
98 | #define wxLIST_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item. | |
99 | #define wxLIST_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item. | |
100 | #define wxLIST_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state. | |
101 | #define wxLIST_HITTEST_TOLEFT 0x0400 // To the left of the client area. | |
102 | #define wxLIST_HITTEST_TORIGHT 0x0800 // To the right of the client area. | |
103 | ||
104 | #define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL | wxLIST_HITTEST_ONITEMSTATEICON) | |
105 | ||
164a7972 VZ |
106 | // GetSubItemRect constants |
107 | #define wxLIST_GETSUBITEMRECT_WHOLEITEM -1l | |
108 | ||
e81a301c JS |
109 | // Flags for GetNextItem (MSW only except wxLIST_NEXT_ALL) |
110 | enum | |
111 | { | |
112 | wxLIST_NEXT_ABOVE, // Searches for an item above the specified item | |
113 | wxLIST_NEXT_ALL, // Searches for subsequent item by index | |
114 | wxLIST_NEXT_BELOW, // Searches for an item below the specified item | |
115 | wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item | |
116 | wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item | |
117 | }; | |
118 | ||
119 | // Alignment flags for Arrange (MSW only except wxLIST_ALIGN_LEFT) | |
120 | enum | |
121 | { | |
122 | wxLIST_ALIGN_DEFAULT, | |
123 | wxLIST_ALIGN_LEFT, | |
124 | wxLIST_ALIGN_TOP, | |
125 | wxLIST_ALIGN_SNAP_TO_GRID | |
126 | }; | |
127 | ||
128 | // Column format (MSW only except wxLIST_FORMAT_LEFT) | |
129 | enum wxListColumnFormat | |
130 | { | |
131 | wxLIST_FORMAT_LEFT, | |
132 | wxLIST_FORMAT_RIGHT, | |
133 | wxLIST_FORMAT_CENTRE, | |
134 | wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE | |
135 | }; | |
136 | ||
137 | // Autosize values for SetColumnWidth | |
138 | enum | |
139 | { | |
140 | wxLIST_AUTOSIZE = -1, | |
141 | wxLIST_AUTOSIZE_USEHEADER = -2 // partly supported by generic version | |
142 | }; | |
143 | ||
144 | // Flag values for GetItemRect | |
145 | enum | |
146 | { | |
147 | wxLIST_RECT_BOUNDS, | |
148 | wxLIST_RECT_ICON, | |
149 | wxLIST_RECT_LABEL | |
150 | }; | |
151 | ||
152 | // Flag values for FindItem (MSW only) | |
153 | enum | |
154 | { | |
155 | wxLIST_FIND_UP, | |
156 | wxLIST_FIND_DOWN, | |
157 | wxLIST_FIND_LEFT, | |
158 | wxLIST_FIND_RIGHT | |
159 | }; | |
160 | ||
161 | // ---------------------------------------------------------------------------- | |
162 | // wxListItemAttr: a structure containing the visual attributes of an item | |
163 | // ---------------------------------------------------------------------------- | |
164 | ||
bdcb8820 VZ |
165 | // TODO: this should be renamed to wxItemAttr or something general like this |
166 | // and used as base class for wxTextAttr which duplicates this class | |
167 | // entirely currently | |
53a2db12 | 168 | class WXDLLIMPEXP_CORE wxListItemAttr |
e81a301c JS |
169 | { |
170 | public: | |
171 | // ctors | |
172 | wxListItemAttr() { } | |
173 | wxListItemAttr(const wxColour& colText, | |
174 | const wxColour& colBack, | |
175 | const wxFont& font) | |
bdcb8820 VZ |
176 | : m_colText(colText), m_colBack(colBack), m_font(font) |
177 | { | |
178 | } | |
179 | ||
180 | // default copy ctor, assignment operator and dtor are ok | |
181 | ||
e81a301c JS |
182 | |
183 | // setters | |
184 | void SetTextColour(const wxColour& colText) { m_colText = colText; } | |
185 | void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } | |
186 | void SetFont(const wxFont& font) { m_font = font; } | |
187 | ||
188 | // accessors | |
a1b806b9 DS |
189 | bool HasTextColour() const { return m_colText.IsOk(); } |
190 | bool HasBackgroundColour() const { return m_colBack.IsOk(); } | |
191 | bool HasFont() const { return m_font.IsOk(); } | |
e81a301c JS |
192 | |
193 | const wxColour& GetTextColour() const { return m_colText; } | |
194 | const wxColour& GetBackgroundColour() const { return m_colBack; } | |
195 | const wxFont& GetFont() const { return m_font; } | |
196 | ||
bdcb8820 VZ |
197 | |
198 | // this is almost like assignment operator except it doesn't overwrite the | |
199 | // fields unset in the source attribute | |
200 | void AssignFrom(const wxListItemAttr& source) | |
201 | { | |
202 | if ( source.HasTextColour() ) | |
203 | SetTextColour(source.GetTextColour()); | |
204 | if ( source.HasBackgroundColour() ) | |
205 | SetBackgroundColour(source.GetBackgroundColour()); | |
206 | if ( source.HasFont() ) | |
207 | SetFont(source.GetFont()); | |
208 | } | |
209 | ||
e81a301c JS |
210 | private: |
211 | wxColour m_colText, | |
212 | m_colBack; | |
213 | wxFont m_font; | |
214 | }; | |
215 | ||
216 | // ---------------------------------------------------------------------------- | |
217 | // wxListItem: the item or column info, used to exchange data with wxListCtrl | |
218 | // ---------------------------------------------------------------------------- | |
219 | ||
53a2db12 | 220 | class WXDLLIMPEXP_CORE wxListItem : public wxObject |
e81a301c JS |
221 | { |
222 | public: | |
223 | wxListItem() { Init(); m_attr = NULL; } | |
224 | wxListItem(const wxListItem& item) | |
225 | : wxObject(), | |
226 | m_mask(item.m_mask), | |
227 | m_itemId(item.m_itemId), | |
228 | m_col(item.m_col), | |
229 | m_state(item.m_state), | |
230 | m_stateMask(item.m_stateMask), | |
231 | m_text(item.m_text), | |
232 | m_image(item.m_image), | |
233 | m_data(item.m_data), | |
234 | m_format(item.m_format), | |
235 | m_width(item.m_width), | |
236 | m_attr(NULL) | |
237 | { | |
238 | // copy list item attributes | |
bdcb8820 | 239 | if ( item.HasAttributes() ) |
e81a301c JS |
240 | m_attr = new wxListItemAttr(*item.GetAttributes()); |
241 | } | |
b2c31e32 VZ |
242 | |
243 | wxListItem& operator=(const wxListItem& item) | |
244 | { | |
17520c84 VZ |
245 | if ( &item != this ) |
246 | { | |
247 | m_mask = item.m_mask; | |
248 | m_itemId = item.m_itemId; | |
249 | m_col = item.m_col; | |
250 | m_state = item.m_state; | |
251 | m_stateMask = item.m_stateMask; | |
252 | m_text = item.m_text; | |
253 | m_image = item.m_image; | |
254 | m_data = item.m_data; | |
255 | m_format = item.m_format; | |
256 | m_width = item.m_width; | |
257 | m_attr = item.m_attr ? new wxListItemAttr(*item.m_attr) : NULL; | |
258 | } | |
b2c31e32 VZ |
259 | |
260 | return *this; | |
261 | } | |
262 | ||
e81a301c JS |
263 | virtual ~wxListItem() { delete m_attr; } |
264 | ||
265 | // resetting | |
266 | void Clear() { Init(); m_text.clear(); ClearAttributes(); } | |
267 | void ClearAttributes() { if ( m_attr ) { delete m_attr; m_attr = NULL; } } | |
268 | ||
269 | // setters | |
6770762d VZ |
270 | void SetMask(long mask) |
271 | { m_mask = mask; } | |
272 | void SetId(long id) | |
273 | { m_itemId = id; } | |
274 | void SetColumn(int col) | |
275 | { m_col = col; } | |
276 | void SetState(long state) | |
277 | { m_mask |= wxLIST_MASK_STATE; m_state = state; m_stateMask |= state; } | |
278 | void SetStateMask(long stateMask) | |
279 | { m_stateMask = stateMask; } | |
280 | void SetText(const wxString& text) | |
281 | { m_mask |= wxLIST_MASK_TEXT; m_text = text; } | |
282 | void SetImage(int image) | |
283 | { m_mask |= wxLIST_MASK_IMAGE; m_image = image; } | |
284 | void SetData(long data) | |
285 | { m_mask |= wxLIST_MASK_DATA; m_data = data; } | |
286 | void SetData(void *data) | |
0d01dd51 | 287 | { m_mask |= wxLIST_MASK_DATA; m_data = wxPtrToUInt(data); } |
6770762d VZ |
288 | |
289 | void SetWidth(int width) | |
290 | { m_mask |= wxLIST_MASK_WIDTH; m_width = width; } | |
291 | void SetAlign(wxListColumnFormat align) | |
292 | { m_mask |= wxLIST_MASK_FORMAT; m_format = align; } | |
e81a301c JS |
293 | |
294 | void SetTextColour(const wxColour& colText) | |
295 | { Attributes().SetTextColour(colText); } | |
296 | void SetBackgroundColour(const wxColour& colBack) | |
297 | { Attributes().SetBackgroundColour(colBack); } | |
298 | void SetFont(const wxFont& font) | |
299 | { Attributes().SetFont(font); } | |
300 | ||
301 | // accessors | |
302 | long GetMask() const { return m_mask; } | |
303 | long GetId() const { return m_itemId; } | |
304 | int GetColumn() const { return m_col; } | |
305 | long GetState() const { return m_state & m_stateMask; } | |
306 | const wxString& GetText() const { return m_text; } | |
307 | int GetImage() const { return m_image; } | |
0d01dd51 | 308 | wxUIntPtr GetData() const { return m_data; } |
e81a301c JS |
309 | |
310 | int GetWidth() const { return m_width; } | |
311 | wxListColumnFormat GetAlign() const { return (wxListColumnFormat)m_format; } | |
312 | ||
313 | wxListItemAttr *GetAttributes() const { return m_attr; } | |
314 | bool HasAttributes() const { return m_attr != NULL; } | |
315 | ||
316 | wxColour GetTextColour() const | |
317 | { return HasAttributes() ? m_attr->GetTextColour() : wxNullColour; } | |
318 | wxColour GetBackgroundColour() const | |
319 | { return HasAttributes() ? m_attr->GetBackgroundColour() | |
320 | : wxNullColour; } | |
321 | wxFont GetFont() const | |
322 | { return HasAttributes() ? m_attr->GetFont() : wxNullFont; } | |
323 | ||
324 | // this conversion is necessary to make old code using GetItem() to | |
325 | // compile | |
326 | operator long() const { return m_itemId; } | |
327 | ||
328 | // these members are public for compatibility | |
329 | ||
330 | long m_mask; // Indicates what fields are valid | |
331 | long m_itemId; // The zero-based item position | |
332 | int m_col; // Zero-based column, if in report mode | |
333 | long m_state; // The state of the item | |
334 | long m_stateMask;// Which flags of m_state are valid (uses same flags) | |
335 | wxString m_text; // The label/header text | |
336 | int m_image; // The zero-based index into an image list | |
0d01dd51 | 337 | wxUIntPtr m_data; // App-defined data |
e81a301c JS |
338 | |
339 | // For columns only | |
340 | int m_format; // left, right, centre | |
341 | int m_width; // width of column | |
342 | ||
c220541d DW |
343 | #ifdef __WXPM__ |
344 | int m_miniImage; // handle to the mini image for OS/2 | |
345 | #endif | |
346 | ||
e81a301c JS |
347 | protected: |
348 | // creates m_attr if we don't have it yet | |
349 | wxListItemAttr& Attributes() | |
350 | { | |
351 | if ( !m_attr ) | |
352 | m_attr = new wxListItemAttr; | |
353 | ||
354 | return *m_attr; | |
355 | } | |
356 | ||
357 | void Init() | |
358 | { | |
359 | m_mask = 0; | |
1e40bd4c | 360 | m_itemId = -1; |
e81a301c JS |
361 | m_col = 0; |
362 | m_state = 0; | |
363 | m_stateMask = 0; | |
8f35356e | 364 | m_image = -1; |
e81a301c JS |
365 | m_data = 0; |
366 | ||
367 | m_format = wxLIST_FORMAT_CENTRE; | |
368 | m_width = 0; | |
369 | } | |
370 | ||
371 | wxListItemAttr *m_attr; // optional pointer to the items style | |
372 | ||
373 | private: | |
e81a301c JS |
374 | DECLARE_DYNAMIC_CLASS(wxListItem) |
375 | }; | |
376 | ||
26df5dd3 VZ |
377 | // ---------------------------------------------------------------------------- |
378 | // wxListCtrlBase: the base class for the main control itself. | |
379 | // ---------------------------------------------------------------------------- | |
380 | ||
381 | // Unlike other base classes, this class doesn't currently define the API of | |
382 | // the real control class but is just used for implementation convenience. We | |
383 | // should define the public class functions as pure virtual here in the future | |
384 | // however. | |
385 | class WXDLLIMPEXP_CORE wxListCtrlBase : public wxControl | |
386 | { | |
387 | public: | |
388 | wxListCtrlBase() { } | |
a9bd911f | 389 | |
94248d2e VZ |
390 | // Image list methods. |
391 | // ------------------- | |
392 | ||
393 | // Associate the given (possibly NULL to indicate that no images will be | |
394 | // used) image list with the control. The ownership of the image list | |
395 | // passes to the control, i.e. it will be deleted when the control itself | |
396 | // is destroyed. | |
397 | // | |
398 | // The value of "which" must be one of wxIMAGE_LIST_{NORMAL,SMALL,STATE}. | |
399 | virtual void AssignImageList(wxImageList* imageList, int which) = 0; | |
400 | ||
401 | // Same as AssignImageList() but the control does not delete the image list | |
402 | // so it can be shared among several controls. | |
403 | virtual void SetImageList(wxImageList* imageList, int which) = 0; | |
404 | ||
405 | // Return the currently used image list, may be NULL. | |
406 | virtual wxImageList* GetImageList(int which) const = 0; | |
407 | ||
408 | ||
409 | // Column-related methods. | |
410 | // ----------------------- | |
411 | ||
412 | // All these methods can only be used in report view mode. | |
413 | ||
c23edb1b VZ |
414 | // Appends a new column. |
415 | // | |
416 | // Returns the index of the newly inserted column or -1 on error. | |
417 | long AppendColumn(const wxString& heading, | |
418 | int format = wxLIST_FORMAT_LEFT, | |
419 | int width = -1); | |
420 | ||
94248d2e VZ |
421 | // Add a new column to the control at the position "col". |
422 | // | |
423 | // Returns the index of the newly inserted column or -1 on error. | |
424 | long InsertColumn(long col, const wxListItem& info); | |
425 | long InsertColumn(long col, | |
426 | const wxString& heading, | |
427 | int format = wxLIST_FORMAT_LEFT, | |
0fb731b8 | 428 | int width = wxLIST_AUTOSIZE); |
94248d2e VZ |
429 | |
430 | // Delete the given or all columns. | |
431 | virtual bool DeleteColumn(int col) = 0; | |
432 | virtual bool DeleteAllColumns() = 0; | |
433 | ||
434 | // Return the current number of columns. | |
435 | virtual int GetColumnCount() const = 0; | |
436 | ||
437 | // Get or update information about the given column. Set item mask to | |
438 | // indicate the fields to retrieve or change. | |
439 | // | |
440 | // Returns false on error, e.g. if the column index is invalid. | |
441 | virtual bool GetColumn(int col, wxListItem& item) const = 0; | |
442 | virtual bool SetColumn(int col, const wxListItem& item) = 0; | |
443 | ||
444 | // Convenient wrappers for the above methods which get or update just the | |
445 | // column width. | |
446 | virtual int GetColumnWidth(int col) const = 0; | |
447 | virtual bool SetColumnWidth(int col, int width) = 0; | |
448 | ||
0ee169da VZ |
449 | // return the attribute for the item (may return NULL if none) |
450 | virtual wxListItemAttr *OnGetItemAttr(long item) const; | |
94248d2e VZ |
451 | |
452 | // Other miscellaneous accessors. | |
453 | // ------------------------------ | |
454 | ||
a9bd911f VZ |
455 | // Convenient functions for testing the list control mode: |
456 | bool InReportView() const { return HasFlag(wxLC_REPORT); } | |
457 | bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); } | |
94248d2e | 458 | |
d34d31f6 VZ |
459 | // Enable or disable beep when incremental match doesn't find any item. |
460 | // Only implemented in the generic version currently. | |
461 | virtual void EnableBellOnNoMatch(bool WXUNUSED(on) = true) { } | |
462 | ||
0ee169da VZ |
463 | void EnableAlternateRowColours(bool enable = true); |
464 | void SetAlternateRowColour(const wxColour& colour); | |
465 | ||
94248d2e VZ |
466 | protected: |
467 | // Real implementations methods to which our public forwards. | |
468 | virtual long DoInsertColumn(long col, const wxListItem& info) = 0; | |
469 | ||
470 | // Overridden methods of the base class. | |
471 | virtual wxSize DoGetBestClientSize() const; | |
0ee169da VZ |
472 | |
473 | private: | |
474 | // user defined color to draw row lines, may be invalid | |
475 | wxListItemAttr m_alternateRowColour; | |
26df5dd3 VZ |
476 | }; |
477 | ||
e81a301c JS |
478 | // ---------------------------------------------------------------------------- |
479 | // wxListEvent - the event class for the wxListCtrl notifications | |
480 | // ---------------------------------------------------------------------------- | |
481 | ||
53a2db12 | 482 | class WXDLLIMPEXP_CORE wxListEvent : public wxNotifyEvent |
e81a301c JS |
483 | { |
484 | public: | |
921176c5 DE |
485 | wxListEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) |
486 | : wxNotifyEvent(commandType, winid) | |
fb4079af VZ |
487 | , m_code(-1) |
488 | , m_oldItemIndex(-1) | |
489 | , m_itemIndex(-1) | |
490 | , m_col(-1) | |
e81a301c JS |
491 | , m_pointDrag() |
492 | , m_item() | |
d2ed74b9 | 493 | , m_editCancelled(false) |
e81a301c JS |
494 | { } |
495 | ||
496 | wxListEvent(const wxListEvent& event) | |
497 | : wxNotifyEvent(event) | |
498 | , m_code(event.m_code) | |
499 | , m_oldItemIndex(event.m_oldItemIndex) | |
500 | , m_itemIndex(event.m_itemIndex) | |
501 | , m_col(event.m_col) | |
502 | , m_pointDrag(event.m_pointDrag) | |
503 | , m_item(event.m_item) | |
d2ed74b9 | 504 | , m_editCancelled(event.m_editCancelled) |
e81a301c JS |
505 | { } |
506 | ||
507 | int GetKeyCode() const { return m_code; } | |
508 | long GetIndex() const { return m_itemIndex; } | |
509 | int GetColumn() const { return m_col; } | |
510 | wxPoint GetPoint() const { return m_pointDrag; } | |
511 | const wxString& GetLabel() const { return m_item.m_text; } | |
512 | const wxString& GetText() const { return m_item.m_text; } | |
513 | int GetImage() const { return m_item.m_image; } | |
5c33522f | 514 | long GetData() const { return static_cast<long>(m_item.m_data); } |
e81a301c JS |
515 | long GetMask() const { return m_item.m_mask; } |
516 | const wxListItem& GetItem() const { return m_item; } | |
517 | ||
518 | // for wxEVT_COMMAND_LIST_CACHE_HINT only | |
519 | long GetCacheFrom() const { return m_oldItemIndex; } | |
520 | long GetCacheTo() const { return m_itemIndex; } | |
521 | ||
d2ed74b9 VZ |
522 | // was label editing canceled? (for wxEVT_COMMAND_LIST_END_LABEL_EDIT only) |
523 | bool IsEditCancelled() const { return m_editCancelled; } | |
524 | void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } | |
525 | ||
e81a301c JS |
526 | virtual wxEvent *Clone() const { return new wxListEvent(*this); } |
527 | ||
528 | //protected: -- not for backwards compatibility | |
529 | int m_code; | |
530 | long m_oldItemIndex; // only for wxEVT_COMMAND_LIST_CACHE_HINT | |
531 | long m_itemIndex; | |
532 | int m_col; | |
533 | wxPoint m_pointDrag; | |
534 | ||
535 | wxListItem m_item; | |
536 | ||
d2ed74b9 VZ |
537 | protected: |
538 | bool m_editCancelled; | |
539 | ||
e81a301c | 540 | private: |
fc7a2a60 | 541 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListEvent) |
e81a301c JS |
542 | }; |
543 | ||
544 | // ---------------------------------------------------------------------------- | |
545 | // wxListCtrl event macros | |
546 | // ---------------------------------------------------------------------------- | |
547 | ||
9b11752c VZ |
548 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_BEGIN_DRAG, wxListEvent ); |
549 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_BEGIN_RDRAG, wxListEvent ); | |
550 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, wxListEvent ); | |
551 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEvent ); | |
552 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_DELETE_ITEM, wxListEvent ); | |
553 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, wxListEvent ); | |
554 | ||
555 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEvent ); | |
556 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEvent ); | |
557 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_KEY_DOWN, wxListEvent ); | |
558 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_INSERT_ITEM, wxListEvent ); | |
559 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_COL_CLICK, wxListEvent ); | |
560 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEvent ); | |
561 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, wxListEvent ); | |
562 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEvent ); | |
563 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_CACHE_HINT, wxListEvent ); | |
564 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_COL_RIGHT_CLICK, wxListEvent ); | |
565 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEvent ); | |
566 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_COL_DRAGGING, wxListEvent ); | |
567 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_COL_END_DRAG, wxListEvent ); | |
568 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LIST_ITEM_FOCUSED, wxListEvent ); | |
e81a301c JS |
569 | |
570 | typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); | |
571 | ||
7fa03f04 | 572 | #define wxListEventHandler(func) \ |
3c778901 | 573 | wxEVENT_HANDLER_CAST(wxListEventFunction, func) |
7fa03f04 VZ |
574 | |
575 | #define wx__DECLARE_LISTEVT(evt, id, fn) \ | |
576 | wx__DECLARE_EVT1(wxEVT_COMMAND_LIST_ ## evt, id, wxListEventHandler(fn)) | |
577 | ||
578 | #define EVT_LIST_BEGIN_DRAG(id, fn) wx__DECLARE_LISTEVT(BEGIN_DRAG, id, fn) | |
579 | #define EVT_LIST_BEGIN_RDRAG(id, fn) wx__DECLARE_LISTEVT(BEGIN_RDRAG, id, fn) | |
580 | #define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) wx__DECLARE_LISTEVT(BEGIN_LABEL_EDIT, id, fn) | |
581 | #define EVT_LIST_END_LABEL_EDIT(id, fn) wx__DECLARE_LISTEVT(END_LABEL_EDIT, id, fn) | |
582 | #define EVT_LIST_DELETE_ITEM(id, fn) wx__DECLARE_LISTEVT(DELETE_ITEM, id, fn) | |
583 | #define EVT_LIST_DELETE_ALL_ITEMS(id, fn) wx__DECLARE_LISTEVT(DELETE_ALL_ITEMS, id, fn) | |
584 | #define EVT_LIST_KEY_DOWN(id, fn) wx__DECLARE_LISTEVT(KEY_DOWN, id, fn) | |
585 | #define EVT_LIST_INSERT_ITEM(id, fn) wx__DECLARE_LISTEVT(INSERT_ITEM, id, fn) | |
586 | ||
587 | #define EVT_LIST_COL_CLICK(id, fn) wx__DECLARE_LISTEVT(COL_CLICK, id, fn) | |
588 | #define EVT_LIST_COL_RIGHT_CLICK(id, fn) wx__DECLARE_LISTEVT(COL_RIGHT_CLICK, id, fn) | |
589 | #define EVT_LIST_COL_BEGIN_DRAG(id, fn) wx__DECLARE_LISTEVT(COL_BEGIN_DRAG, id, fn) | |
590 | #define EVT_LIST_COL_DRAGGING(id, fn) wx__DECLARE_LISTEVT(COL_DRAGGING, id, fn) | |
591 | #define EVT_LIST_COL_END_DRAG(id, fn) wx__DECLARE_LISTEVT(COL_END_DRAG, id, fn) | |
592 | ||
593 | #define EVT_LIST_ITEM_SELECTED(id, fn) wx__DECLARE_LISTEVT(ITEM_SELECTED, id, fn) | |
594 | #define EVT_LIST_ITEM_DESELECTED(id, fn) wx__DECLARE_LISTEVT(ITEM_DESELECTED, id, fn) | |
595 | #define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) wx__DECLARE_LISTEVT(ITEM_RIGHT_CLICK, id, fn) | |
596 | #define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) wx__DECLARE_LISTEVT(ITEM_MIDDLE_CLICK, id, fn) | |
597 | #define EVT_LIST_ITEM_ACTIVATED(id, fn) wx__DECLARE_LISTEVT(ITEM_ACTIVATED, id, fn) | |
598 | #define EVT_LIST_ITEM_FOCUSED(id, fn) wx__DECLARE_LISTEVT(ITEM_FOCUSED, id, fn) | |
599 | ||
600 | #define EVT_LIST_CACHE_HINT(id, fn) wx__DECLARE_LISTEVT(CACHE_HINT, id, fn) | |
601 | ||
602 | ||
e81a301c JS |
603 | #endif |
604 | // _WX_LISTCTRL_H_BASE_ |