listctrl.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/listctrl.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_LISTCTRL_H_BASE_
  11. #define _WX_LISTCTRL_H_BASE_
  12. #include "wx/defs.h" // headers should include this before first wxUSE_XXX check
  13. #if wxUSE_LISTCTRL
  14. #include "wx/listbase.h"
  15. // ----------------------------------------------------------------------------
  16. // constants
  17. // ----------------------------------------------------------------------------
  18. extern WXDLLIMPEXP_DATA_CORE(const char) wxListCtrlNameStr[];
  19. // ----------------------------------------------------------------------------
  20. // include the wxListCtrl class declaration
  21. // ----------------------------------------------------------------------------
  22. #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
  23. #include "wx/msw/listctrl.h"
  24. #elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON
  25. #include "wx/osx/listctrl.h"
  26. #else
  27. #include "wx/generic/listctrl.h"
  28. #endif
  29. // ----------------------------------------------------------------------------
  30. // wxListView: a class which provides a better API for list control
  31. // ----------------------------------------------------------------------------
  32. class WXDLLIMPEXP_CORE wxListView : public wxListCtrl
  33. {
  34. public:
  35. wxListView() { }
  36. wxListView( wxWindow *parent,
  37. wxWindowID winid = wxID_ANY,
  38. const wxPoint& pos = wxDefaultPosition,
  39. const wxSize& size = wxDefaultSize,
  40. long style = wxLC_REPORT,
  41. const wxValidator& validator = wxDefaultValidator,
  42. const wxString &name = wxListCtrlNameStr)
  43. {
  44. Create(parent, winid, pos, size, style, validator, name);
  45. }
  46. // focus/selection stuff
  47. // ---------------------
  48. // [de]select an item
  49. void Select(long n, bool on = true)
  50. {
  51. SetItemState(n, on ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED);
  52. }
  53. // focus and show the given item
  54. void Focus(long index)
  55. {
  56. SetItemState(index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
  57. EnsureVisible(index);
  58. }
  59. // get the currently focused item or -1 if none
  60. long GetFocusedItem() const
  61. {
  62. return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
  63. }
  64. // get first and subsequent selected items, return -1 when no more
  65. long GetNextSelected(long item) const
  66. { return GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); }
  67. long GetFirstSelected() const
  68. { return GetNextSelected(-1); }
  69. // return true if the item is selected
  70. bool IsSelected(long index) const
  71. { return GetItemState(index, wxLIST_STATE_SELECTED) != 0; }
  72. // columns
  73. // -------
  74. void SetColumnImage(int col, int image)
  75. {
  76. wxListItem item;
  77. item.SetMask(wxLIST_MASK_IMAGE);
  78. item.SetImage(image);
  79. SetColumn(col, item);
  80. }
  81. void ClearColumnImage(int col) { SetColumnImage(col, -1); }
  82. private:
  83. DECLARE_DYNAMIC_CLASS_NO_COPY(wxListView)
  84. };
  85. #endif // wxUSE_LISTCTRL
  86. #endif
  87. // _WX_LISTCTRL_H_BASE_