listbase.h 24 KB

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