PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Externals/wxWidgets3/include/wx/osx/treectrl.h

https://gitlab.com/SplatoonModdingHub/dolphin
C Header | 306 lines | 203 code | 43 blank | 60 comment | 1 complexity | c5d8bdb3dd9e6f80c7276e2d47dc0c09 MD5 | raw file
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/treectrl.h
  3. // Purpose: wxTreeCtrl class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_TREECTRL_H_
  11. #define _WX_TREECTRL_H_
  12. #include "wx/control.h"
  13. #include "wx/event.h"
  14. #include "wx/imaglist.h"
  15. #define wxTREE_MASK_HANDLE 0x0001
  16. #define wxTREE_MASK_STATE 0x0002
  17. #define wxTREE_MASK_TEXT 0x0004
  18. #define wxTREE_MASK_IMAGE 0x0008
  19. #define wxTREE_MASK_SELECTED_IMAGE 0x0010
  20. #define wxTREE_MASK_CHILDREN 0x0020
  21. #define wxTREE_MASK_DATA 0x0040
  22. #define wxTREE_STATE_BOLD 0x0001
  23. #define wxTREE_STATE_DROPHILITED 0x0002
  24. #define wxTREE_STATE_EXPANDED 0x0004
  25. #define wxTREE_STATE_EXPANDEDONCE 0x0008
  26. #define wxTREE_STATE_FOCUSED 0x0010
  27. #define wxTREE_STATE_SELECTED 0x0020
  28. #define wxTREE_STATE_CUT 0x0040
  29. #define wxTREE_HITTEST_ABOVE 0x0001 // Above the client area.
  30. #define wxTREE_HITTEST_BELOW 0x0002 // Below the client area.
  31. #define wxTREE_HITTEST_NOWHERE 0x0004 // In the client area but below the last item.
  32. #define wxTREE_HITTEST_ONITEMBUTTON 0x0010 // On the button associated with an item.
  33. #define wxTREE_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item.
  34. #define wxTREE_HITTEST_ONITEMINDENT 0x0040 // In the indentation associated with an item.
  35. #define wxTREE_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item.
  36. #define wxTREE_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item.
  37. #define wxTREE_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state.
  38. #define wxTREE_HITTEST_TOLEFT 0x0400 // To the right of the client area.
  39. #define wxTREE_HITTEST_TORIGHT 0x0800 // To the left of the client area.
  40. #define wxTREE_HITTEST_ONITEM (wxTREE_HITTEST_ONITEMICON | wxTREE_HITTEST_ONITEMLABEL | wxTREE_HITTEST_ONITEMSTATEICON)
  41. // Flags for GetNextItem
  42. enum {
  43. wxTREE_NEXT_CARET, // Retrieves the currently selected item.
  44. wxTREE_NEXT_CHILD, // Retrieves the first child item. The hItem parameter must be NULL.
  45. wxTREE_NEXT_DROPHILITE, // Retrieves the item that is the target of a drag-and-drop operation.
  46. wxTREE_NEXT_FIRSTVISIBLE, // Retrieves the first visible item.
  47. wxTREE_NEXT_NEXT, // Retrieves the next sibling item.
  48. wxTREE_NEXT_NEXTVISIBLE, // Retrieves the next visible item that follows the specified item.
  49. wxTREE_NEXT_PARENT, // Retrieves the parent of the specified item.
  50. wxTREE_NEXT_PREVIOUS, // Retrieves the previous sibling item.
  51. wxTREE_NEXT_PREVIOUSVISIBLE, // Retrieves the first visible item that precedes the specified item.
  52. wxTREE_NEXT_ROOT // Retrieves the first child item of the root item of which the specified item is a part.
  53. };
  54. #if WXWIN_COMPATIBILITY_2_6
  55. // Flags for InsertItem
  56. enum {
  57. wxTREE_INSERT_LAST = -1,
  58. wxTREE_INSERT_FIRST = -2,
  59. wxTREE_INSERT_SORT = -3
  60. };
  61. #endif
  62. class WXDLLIMPEXP_CORE wxTreeItem: public wxObject
  63. {
  64. DECLARE_DYNAMIC_CLASS(wxTreeItem)
  65. public:
  66. long m_mask;
  67. long m_itemId;
  68. long m_state;
  69. long m_stateMask;
  70. wxString m_text;
  71. int m_image;
  72. int m_selectedImage;
  73. int m_children;
  74. long m_data;
  75. wxTreeItem();
  76. // Accessors
  77. inline long GetMask() const { return m_mask; }
  78. inline long GetItemId() const { return m_itemId; }
  79. inline long GetState() const { return m_state; }
  80. inline long GetStateMask() const { return m_stateMask; }
  81. inline wxString GetText() const { return m_text; }
  82. inline int GetImage() const { return m_image; }
  83. inline int GetSelectedImage() const { return m_selectedImage; }
  84. inline int GetChildren() const { return m_children; }
  85. inline long GetData() const { return m_data; }
  86. inline void SetMask(long mask) { m_mask = mask; }
  87. inline void SetItemId(long id) { m_itemId = m_itemId = id; }
  88. inline void SetState(long state) { m_state = state; }
  89. inline void SetStateMask(long stateMask) { m_stateMask = stateMask; }
  90. inline void GetText(const wxString& text) { m_text = text; }
  91. inline void SetImage(int image) { m_image = image; }
  92. inline void GetSelectedImage(int selImage) { m_selectedImage = selImage; }
  93. inline void SetChildren(int children) { m_children = children; }
  94. inline void SetData(long data) { m_data = data; }
  95. };
  96. class WXDLLIMPEXP_CORE wxTreeCtrl: public wxControl
  97. {
  98. public:
  99. /*
  100. * Public interface
  101. */
  102. // creation
  103. // --------
  104. wxTreeCtrl();
  105. inline wxTreeCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
  106. const wxPoint& pos = wxDefaultPosition,
  107. const wxSize& size = wxDefaultSize,
  108. long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
  109. const wxValidator& validator = wxDefaultValidator,
  110. const wxString& name = "wxTreeCtrl")
  111. {
  112. Create(parent, id, pos, size, style, validator, name);
  113. }
  114. virtual ~wxTreeCtrl();
  115. bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
  116. const wxPoint& pos = wxDefaultPosition,
  117. const wxSize& size = wxDefaultSize,
  118. long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
  119. const wxValidator& validator = wxDefaultValidator,
  120. const wxString& name = "wxTreeCtrl");
  121. // accessors
  122. // ---------
  123. //
  124. virtual unsigned int GetCount() const;
  125. // indent
  126. int GetIndent() const;
  127. void SetIndent(int indent);
  128. // image list
  129. wxImageList *GetImageList(int which = wxIMAGE_LIST_NORMAL) const;
  130. // navigation inside the tree
  131. long GetNextItem(long item, int code) const;
  132. bool ItemHasChildren(long item) const;
  133. long GetChild(long item) const;
  134. long GetItemParent(long item) const;
  135. long GetFirstVisibleItem() const;
  136. long GetNextVisibleItem(long item) const;
  137. long GetSelection() const;
  138. long GetRootItem() const;
  139. // generic function for (g|s)etting item attributes
  140. bool GetItem(wxTreeItem& info) const;
  141. bool SetItem(wxTreeItem& info);
  142. // item state
  143. int GetItemState(long item, long stateMask) const;
  144. bool SetItemState(long item, long state, long stateMask);
  145. // item image
  146. bool SetItemImage(long item, int image, int selImage);
  147. // item text
  148. wxString GetItemText(long item) const;
  149. void SetItemText(long item, const wxString& str);
  150. // custom data associated with the item
  151. long GetItemData(long item) const;
  152. bool SetItemData(long item, long data);
  153. // convenience function
  154. bool IsItemExpanded(long item)
  155. {
  156. return (GetItemState(item, wxTREE_STATE_EXPANDED) &
  157. wxTREE_STATE_EXPANDED) != 0;
  158. }
  159. // bounding rect
  160. bool GetItemRect(long item, wxRect& rect, bool textOnly = false) const;
  161. //
  162. wxTextCtrl* GetEditControl() const;
  163. // operations
  164. // ----------
  165. // adding/deleting items
  166. bool DeleteItem(long item);
  167. #if WXWIN_COMPATIBILITY_2_6
  168. wxDEPRECATED( long InsertItem(long parent, wxTreeItem& info,
  169. long insertAfter = wxTREE_INSERT_LAST) );
  170. // If image > -1 and selImage == -1, the same image is used for
  171. // both selected and unselected items.
  172. wxDEPRECATED( long InsertItem(long parent, const wxString& label,
  173. int image = -1, int selImage = -1,
  174. long insertAfter = wxTREE_INSERT_LAST) );
  175. // use Expand, Collapse, CollapseAndReset or Toggle
  176. wxDEPRECATED( bool ExpandItem(long item, int action) );
  177. wxDEPRECATED( void SetImageList(wxImageList *imageList, int which = wxIMAGE_LIST_NORMAL) );
  178. #endif // WXWIN_COMPATIBILITY_2_6
  179. // changing item state
  180. bool ExpandItem(long item) { return ExpandItem(item, wxTREE_EXPAND_EXPAND); }
  181. bool CollapseItem(long item) { return ExpandItem(item, wxTREE_EXPAND_COLLAPSE); }
  182. bool ToggleItem(long item) { return ExpandItem(item, wxTREE_EXPAND_TOGGLE); }
  183. //
  184. bool SelectItem(long item);
  185. bool ScrollTo(long item);
  186. bool DeleteAllItems();
  187. // Edit the label (tree must have the focus)
  188. wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl));
  189. // End label editing, optionally cancelling the edit
  190. bool EndEditLabel(bool cancel);
  191. long HitTest(const wxPoint& point, int& flags);
  192. // wxImageList *CreateDragImage(long item);
  193. bool SortChildren(long item);
  194. bool EnsureVisible(long item);
  195. void Command(wxCommandEvent& event) { ProcessCommand(event); }
  196. protected:
  197. wxTextCtrl* m_textCtrl;
  198. wxImageList* m_imageListNormal;
  199. wxImageList* m_imageListState;
  200. DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
  201. };
  202. /*
  203. wxEVT_TREE_BEGIN_DRAG,
  204. wxEVT_TREE_BEGIN_RDRAG,
  205. wxEVT_TREE_BEGIN_LABEL_EDIT,
  206. wxEVT_TREE_END_LABEL_EDIT,
  207. wxEVT_TREE_DELETE_ITEM,
  208. wxEVT_TREE_GET_INFO,
  209. wxEVT_TREE_SET_INFO,
  210. wxEVT_TREE_ITEM_EXPANDED,
  211. wxEVT_TREE_ITEM_EXPANDING,
  212. wxEVT_TREE_ITEM_COLLAPSED,
  213. wxEVT_TREE_ITEM_COLLAPSING,
  214. wxEVT_TREE_SEL_CHANGED,
  215. wxEVT_TREE_SEL_CHANGING,
  216. wxEVT_TREE_KEY_DOWN
  217. */
  218. class WXDLLIMPEXP_CORE wxTreeEvent: public wxCommandEvent
  219. {
  220. DECLARE_DYNAMIC_CLASS(wxTreeEvent)
  221. public:
  222. wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
  223. int m_code;
  224. wxTreeItem m_item;
  225. long m_oldItem;
  226. wxPoint m_pointDrag;
  227. inline long GetOldItem() const { return m_oldItem; }
  228. inline wxTreeItem& GetItem() const { return (wxTreeItem&) m_item; }
  229. inline wxPoint GetPoint() const { return m_pointDrag; }
  230. inline int GetCode() const { return m_code; }
  231. };
  232. typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
  233. #define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  234. #define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  235. #define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  236. #define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  237. #define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  238. #define EVT_TREE_GET_INFO(id, fn) { wxEVT_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  239. #define EVT_TREE_SET_INFO(id, fn) { wxEVT_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  240. #define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  241. #define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  242. #define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  243. #define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  244. #define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  245. #define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  246. #define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
  247. // old wxEVT_COMMAND_* constants
  248. #define wxEVT_COMMAND_TREE_BEGIN_DRAG wxEVT_TREE_BEGIN_DRAG
  249. #define wxEVT_COMMAND_TREE_BEGIN_RDRAG wxEVT_TREE_BEGIN_RDRAG
  250. #define wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT wxEVT_TREE_BEGIN_LABEL_EDIT
  251. #define wxEVT_COMMAND_TREE_END_LABEL_EDIT wxEVT_TREE_END_LABEL_EDIT
  252. #define wxEVT_COMMAND_TREE_DELETE_ITEM wxEVT_TREE_DELETE_ITEM
  253. #define wxEVT_COMMAND_TREE_GET_INFO wxEVT_TREE_GET_INFO
  254. #define wxEVT_COMMAND_TREE_SET_INFO wxEVT_TREE_SET_INFO
  255. #define wxEVT_COMMAND_TREE_ITEM_EXPANDED wxEVT_TREE_ITEM_EXPANDED
  256. #define wxEVT_COMMAND_TREE_ITEM_EXPANDING wxEVT_TREE_ITEM_EXPANDING
  257. #define wxEVT_COMMAND_TREE_ITEM_COLLAPSED wxEVT_TREE_ITEM_COLLAPSED
  258. #define wxEVT_COMMAND_TREE_ITEM_COLLAPSING wxEVT_TREE_ITEM_COLLAPSING
  259. #define wxEVT_COMMAND_TREE_SEL_CHANGED wxEVT_TREE_SEL_CHANGED
  260. #define wxEVT_COMMAND_TREE_SEL_CHANGING wxEVT_TREE_SEL_CHANGING
  261. #define wxEVT_COMMAND_TREE_KEY_DOWN wxEVT_TREE_KEY_DOWN
  262. #endif
  263. // _WX_TREECTRL_H_