treebase.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: treebase.h
  3. // Purpose: interface of wxTreeItemId
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxTreeItemId
  9. An opaque reference to a tree item.
  10. @library{wxcore}
  11. @category{data}
  12. @see wxTreeCtrl, wxTreeItemData, @ref overview_treectrl
  13. */
  14. class wxTreeItemId
  15. {
  16. public:
  17. /**
  18. Default constructor. A wxTreeItemId is not meant to be constructed
  19. explicitly by the user; only those returned by the wxTreeCtrl functions
  20. should be used.
  21. */
  22. wxTreeItemId();
  23. /**
  24. Returns @true if this instance is referencing a valid tree item.
  25. */
  26. bool IsOk() const;
  27. void* GetID() const;
  28. void Unset();
  29. };
  30. bool operator==(const wxTreeItemId& left, const wxTreeItemId& right);
  31. bool operator!=(const wxTreeItemId& left, const wxTreeItemId& right);
  32. /**
  33. @class wxTreeItemData
  34. wxTreeItemData is some (arbitrary) user class associated with some item. The
  35. main advantage of having this class is that wxTreeItemData objects are
  36. destroyed automatically by the tree and, as this class has virtual
  37. destructor, it means that the memory and any other resources associated with
  38. a tree item will be automatically freed when it is deleted. Note that we
  39. don't use wxObject as the base class for wxTreeItemData because the size of
  40. this class is critical: in many applications, each tree leaf will have
  41. wxTreeItemData associated with it and the number of leaves may be quite big.
  42. Also please note that because the objects of this class are deleted by the
  43. tree using the operator @c delete, they must always be allocated on the heap
  44. using @c new.
  45. @library{wxcore}
  46. @category{containers}
  47. @see wxTreeCtrl
  48. */
  49. class wxTreeItemData : public wxClientData
  50. {
  51. public:
  52. /**
  53. Default constructor.
  54. @beginWxPerlOnly
  55. In wxPerl the constructor accepts a scalar as an optional parameter
  56. and stores it as client data; use
  57. - GetData() to retrieve the value.
  58. - SetData(data) to set it.
  59. @endWxPerlOnly
  60. */
  61. wxTreeItemData();
  62. /**
  63. Virtual destructor.
  64. */
  65. virtual ~wxTreeItemData();
  66. /**
  67. Returns the item associated with this node.
  68. */
  69. const wxTreeItemId& GetId() const;
  70. /**
  71. Sets the item associated with this node.
  72. Notice that this function is automatically called by wxTreeCtrl methods
  73. associating an object of this class with a tree control item such as
  74. wxTreeCtrl::AppendItem(), wxTreeCtrl::InsertItem() and
  75. wxTreeCtrl::SetItemData() so there is usually no need to call it
  76. yourself.
  77. */
  78. void SetId(const wxTreeItemId& id);
  79. };
  80. /**
  81. Indicates which type to associate an image with a wxTreeCtrl item.
  82. @see wxTreeCtrl::GetItemImage(), wxTreeCtrl::SetItemImage()
  83. */
  84. enum wxTreeItemIcon
  85. {
  86. /**
  87. To get/set the item image for when the item is
  88. @b not selected and @b not expanded.
  89. */
  90. wxTreeItemIcon_Normal,
  91. /**
  92. To get/set the item image for when the item is
  93. @b selected and @b not expanded.
  94. */
  95. wxTreeItemIcon_Selected,
  96. /**
  97. To get/set the item image for when the item is
  98. @b not selected and @b expanded.
  99. */
  100. wxTreeItemIcon_Expanded,
  101. /**
  102. To get/set the item image for when the item is
  103. @b selected and @b expanded.
  104. */
  105. wxTreeItemIcon_SelectedExpanded,
  106. wxTreeItemIcon_Max
  107. };
  108. /// special values for the 'state' parameter of wxTreeCtrl::SetItemState()
  109. static const int wxTREE_ITEMSTATE_NONE = -1; // not state (no display state image)
  110. static const int wxTREE_ITEMSTATE_NEXT = -2; // cycle to the next state
  111. static const int wxTREE_ITEMSTATE_PREV = -3; // cycle to the previous state
  112. #define wxTR_NO_BUTTONS 0x0000 // for convenience
  113. #define wxTR_HAS_BUTTONS 0x0001 // draw collapsed/expanded btns
  114. #define wxTR_NO_LINES 0x0004 // don't draw lines at all
  115. #define wxTR_LINES_AT_ROOT 0x0008 // connect top-level nodes
  116. #define wxTR_TWIST_BUTTONS 0x0010 // still used by wxTreeListCtrl
  117. #define wxTR_SINGLE 0x0000 // for convenience
  118. #define wxTR_MULTIPLE 0x0020 // can select multiple items
  119. #define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 // what it says
  120. #define wxTR_EDIT_LABELS 0x0200 // can edit item labels
  121. #define wxTR_ROW_LINES 0x0400 // put border around items
  122. #define wxTR_HIDE_ROOT 0x0800 // don't display root node
  123. #define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space
  124. // make the default control appearance look more native-like depending on the
  125. // platform
  126. #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT)
  127. // values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
  128. // where exactly the specified point is situated:
  129. static const int wxTREE_HITTEST_ABOVE = 0x0001;
  130. static const int wxTREE_HITTEST_BELOW = 0x0002;
  131. static const int wxTREE_HITTEST_NOWHERE = 0x0004;
  132. // on the button associated with an item.
  133. static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0008;
  134. // on the bitmap associated with an item.
  135. static const int wxTREE_HITTEST_ONITEMICON = 0x0010;
  136. // on the indent associated with an item.
  137. static const int wxTREE_HITTEST_ONITEMINDENT = 0x0020;
  138. // on the label (string) associated with an item.
  139. static const int wxTREE_HITTEST_ONITEMLABEL = 0x0040;
  140. // on the right of the label associated with an item.
  141. static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0080;
  142. // on the label (string) associated with an item.
  143. static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0100;
  144. // on the left of the wxTreeCtrl.
  145. static const int wxTREE_HITTEST_TOLEFT = 0x0200;
  146. // on the right of the wxTreeCtrl.
  147. static const int wxTREE_HITTEST_TORIGHT = 0x0400;
  148. // on the upper part (first half) of the item.
  149. static const int wxTREE_HITTEST_ONITEMUPPERPART = 0x0800;
  150. // on the lower part (second half) of the item.
  151. static const int wxTREE_HITTEST_ONITEMLOWERPART = 0x1000;
  152. // anywhere on the item
  153. static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
  154. wxTREE_HITTEST_ONITEMLABEL;