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