PageRenderTime 32ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://gitlab.com/Hexexpeck/dolphin-emulator
C Header | 398 lines | 174 code | 105 blank | 119 comment | 1 complexity | 9b12e09bc37f7f2ad864142414ae6be5 MD5 | raw file
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/listctrl.h
  3. // Purpose: wxListCtrl 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_LISTCTRL_H_
  11. #define _WX_LISTCTRL_H_
  12. #include "wx/defs.h"
  13. #include "wx/generic/listctrl.h"
  14. #define wxMAC_ALWAYS_USE_GENERIC_LISTCTRL wxT("mac.listctrl.always_use_generic")
  15. class wxMacDataBrowserListCtrlControl;
  16. class wxListCtrlTextCtrlWrapper;
  17. class wxListCtrlRenameTimer;
  18. WX_DECLARE_EXPORTED_LIST(wxListItem, wxColumnList);
  19. class WXDLLIMPEXP_CORE wxListCtrl: public wxListCtrlBase
  20. {
  21. wxDECLARE_DYNAMIC_CLASS(wxListCtrl);
  22. public:
  23. /*
  24. * Public interface
  25. */
  26. wxListCtrl() { Init(); }
  27. wxListCtrl(wxWindow *parent,
  28. wxWindowID id = wxID_ANY,
  29. const wxPoint& pos = wxDefaultPosition,
  30. const wxSize& size = wxDefaultSize,
  31. long style = wxLC_ICON,
  32. const wxValidator& validator = wxDefaultValidator,
  33. const wxString& name = wxListCtrlNameStr)
  34. {
  35. Init();
  36. Create(parent, id, pos, size, style, validator, name);
  37. }
  38. virtual ~wxListCtrl();
  39. bool Create(wxWindow *parent,
  40. wxWindowID id = wxID_ANY,
  41. const wxPoint& pos = wxDefaultPosition,
  42. const wxSize& size = wxDefaultSize,
  43. long style = wxLC_ICON,
  44. const wxValidator& validator = wxDefaultValidator,
  45. const wxString& name = wxListCtrlNameStr);
  46. // Attributes
  47. ////////////////////////////////////////////////////////////////////////////
  48. // Gets information about this column
  49. bool GetColumn(int col, wxListItem& item) const;
  50. // Sets information about this column
  51. bool SetColumn(int col, const wxListItem& item) ;
  52. // Gets the column width
  53. int GetColumnWidth(int col) const;
  54. // Sets the column width
  55. bool SetColumnWidth(int col, int width) ;
  56. // Gets the number of items that can fit vertically in the
  57. // visible area of the list control (list or report view)
  58. // or the total number of items in the list control (icon
  59. // or small icon view)
  60. int GetCountPerPage() const;
  61. // Gets the edit control for editing labels.
  62. wxTextCtrl* GetEditControl() const;
  63. // Gets information about the item
  64. bool GetItem(wxListItem& info) const ;
  65. // Sets information about the item
  66. bool SetItem(wxListItem& info) ;
  67. // Sets a string field at a particular column
  68. long SetItem(long index, int col, const wxString& label, int imageId = -1);
  69. // Gets the item state
  70. int GetItemState(long item, long stateMask) const ;
  71. // Sets the item state
  72. bool SetItemState(long item, long state, long stateMask) ;
  73. void AssignImageList(wxImageList *imageList, int which);
  74. // Sets the item image
  75. bool SetItemImage(long item, int image, int selImage = -1) ;
  76. bool SetItemColumnImage(long item, long column, int image);
  77. // Gets the item text
  78. wxString GetItemText(long item, int col = 0) const ;
  79. // Sets the item text
  80. void SetItemText(long item, const wxString& str) ;
  81. void SetItemTextColour(long item, const wxColour& colour) ;
  82. wxColour GetItemTextColour(long item) const;
  83. void SetItemBackgroundColour(long item, const wxColour& colour) ;
  84. wxColour GetItemBackgroundColour(long item) const;
  85. void SetItemFont( long item, const wxFont &f);
  86. wxFont GetItemFont( long item ) const;
  87. // Gets the item data
  88. long GetItemData(long item) const ;
  89. // Sets the item data
  90. bool SetItemPtrData(long item, wxUIntPtr data);
  91. bool SetItemData(long item, long data) { return SetItemPtrData(item, data); }
  92. // Gets the item rectangle
  93. bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ;
  94. // Gets the item rectangle of a subitem
  95. bool GetSubItemRect( long item, long subItem, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
  96. // Gets the item position
  97. bool GetItemPosition(long item, wxPoint& pos) const ;
  98. // Sets the item position
  99. bool SetItemPosition(long item, const wxPoint& pos) ;
  100. // Gets the number of items in the list control
  101. int GetItemCount() const;
  102. // Gets the number of columns in the list control
  103. int GetColumnCount() const;
  104. void SetItemSpacing( int spacing, bool isSmall = false );
  105. wxSize GetItemSpacing() const;
  106. // Gets the number of selected items in the list control
  107. int GetSelectedItemCount() const;
  108. wxRect GetViewRect() const;
  109. // Gets the text colour of the listview
  110. wxColour GetTextColour() const;
  111. // Sets the text colour of the listview
  112. void SetTextColour(const wxColour& col);
  113. // Gets the index of the topmost visible item when in
  114. // list or report view
  115. long GetTopItem() const ;
  116. // Add or remove a single window style
  117. void SetSingleStyle(long style, bool add = true) ;
  118. // Set the whole window style
  119. void SetWindowStyleFlag(long style) ;
  120. // Searches for an item, starting from 'item'.
  121. // item can be -1 to find the first item that matches the
  122. // specified flags.
  123. // Returns the item or -1 if unsuccessful.
  124. long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
  125. // Gets one of the three image lists
  126. wxImageList *GetImageList(int which) const ;
  127. // Sets the image list
  128. void SetImageList(wxImageList *imageList, int which) ;
  129. // Operations
  130. ////////////////////////////////////////////////////////////////////////////
  131. // Arranges the items
  132. bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
  133. // Deletes an item
  134. bool DeleteItem(long item);
  135. // Deletes all items
  136. bool DeleteAllItems() ;
  137. // Deletes a column
  138. bool DeleteColumn(int col);
  139. // Deletes all columns
  140. bool DeleteAllColumns();
  141. // Clears items, and columns if there are any.
  142. void ClearAll();
  143. // Edit the label
  144. wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl));
  145. // End label editing, optionally cancelling the edit
  146. bool EndEditLabel(bool cancel);
  147. // Ensures this item is visible
  148. bool EnsureVisible(long item) ;
  149. // Find an item whose label matches this string, starting from the item after 'start'
  150. // or the beginning if 'start' is -1.
  151. long FindItem(long start, const wxString& str, bool partial = false);
  152. // Find an item whose data matches this data, starting from the item after 'start'
  153. // or the beginning if 'start' is -1.
  154. long FindItem(long start, long data);
  155. // Find an item nearest this position in the specified direction, starting from
  156. // the item after 'start' or the beginning if 'start' is -1.
  157. long FindItem(long start, const wxPoint& pt, int direction);
  158. // Determines which item (if any) is at the specified point,
  159. // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
  160. // Request the subitem number as well at the given coordinate.
  161. long HitTest(const wxPoint& point, int& flags, long* ptrSubItem = NULL) const;
  162. // Inserts an item, returning the index of the new item if successful,
  163. // -1 otherwise.
  164. // TOD: Should also have some further convenience functions
  165. // which don't require setting a wxListItem object
  166. long InsertItem(wxListItem& info);
  167. // Insert a string item
  168. long InsertItem(long index, const wxString& label);
  169. // Insert an image item
  170. long InsertItem(long index, int imageIndex);
  171. // Insert an image/string item
  172. long InsertItem(long index, const wxString& label, int imageIndex);
  173. // Scrolls the list control. If in icon, small icon or report view mode,
  174. // x specifies the number of pixels to scroll. If in list view mode, x
  175. // specifies the number of columns to scroll.
  176. // If in icon, small icon or list view mode, y specifies the number of pixels
  177. // to scroll. If in report view mode, y specifies the number of lines to scroll.
  178. bool ScrollList(int dx, int dy);
  179. // Sort items.
  180. // fn is a function which takes 3 long arguments: item1, item2, data.
  181. // item1 is the long data associated with a first item (NOT the index).
  182. // item2 is the long data associated with a second item (NOT the index).
  183. // data is the same value as passed to SortItems.
  184. // The return value is a negative number if the first item should precede the second
  185. // item, a positive number of the second item should precede the first,
  186. // or zero if the two items are equivalent.
  187. // data is arbitrary data to be passed to the sort function.
  188. bool SortItems(wxListCtrlCompare fn, wxIntPtr data);
  189. wxMacDataBrowserListCtrlControl* GetListPeer() const;
  190. // these functions are only used for virtual list view controls, i.e. the
  191. // ones with wxLC_VIRTUAL style
  192. void SetItemCount(long count);
  193. void RefreshItem(long item);
  194. void RefreshItems(long itemFrom, long itemTo);
  195. // return the text for the given column of the given item
  196. virtual wxString OnGetItemText(long item, long column) const;
  197. // return the icon for the given item. In report view, OnGetItemImage will
  198. // only be called for the first column. See OnGetItemColumnImage for
  199. // details.
  200. virtual int OnGetItemImage(long item) const;
  201. // return the icon for the given item and column.
  202. virtual int OnGetItemColumnImage(long item, long column) const;
  203. /* Why should we need this function? Leave for now.
  204. * We might need it because item data may have changed,
  205. * but the display needs refreshing (in string callback mode)
  206. // Updates an item. If the list control has the wxLI_AUTO_ARRANGE style,
  207. // the items will be rearranged.
  208. bool Update(long item);
  209. */
  210. void Command(wxCommandEvent& event) { ProcessCommand(event); }
  211. wxListCtrlCompare GetCompareFunc() { return m_compareFunc; }
  212. wxIntPtr GetCompareFuncData() { return m_compareFuncData; }
  213. // public overrides needed for pimpl approach
  214. virtual bool SetFont(const wxFont& font);
  215. virtual bool SetForegroundColour(const wxColour& colour);
  216. virtual bool SetBackgroundColour(const wxColour& colour);
  217. virtual wxColour GetBackgroundColour() const;
  218. virtual void Freeze ();
  219. virtual void Thaw ();
  220. virtual void Update ();
  221. // functions for editing/timer
  222. void OnRenameTimer();
  223. bool OnRenameAccept(long itemEdit, const wxString& value);
  224. void OnRenameCancelled(long itemEdit);
  225. void ChangeCurrent(long current);
  226. void ResetCurrent() { ChangeCurrent((long)-1); }
  227. bool HasCurrent() const { return m_current != (long)-1; }
  228. void OnLeftDown(wxMouseEvent& event);
  229. void OnDblClick(wxMouseEvent& event);
  230. void FinishEditing(wxTextCtrl *text)
  231. {
  232. delete text;
  233. m_textctrlWrapper = NULL;
  234. SetFocus();
  235. }
  236. virtual int GetScrollPos(int orient) const;
  237. void OnRightDown(wxMouseEvent& event);
  238. void OnMiddleDown(wxMouseEvent& event);
  239. void OnChar(wxKeyEvent& event);
  240. virtual void SetFocus();
  241. void FireMouseEvent(wxEventType eventType, wxPoint position);
  242. virtual void SetDropTarget( wxDropTarget *dropTarget );
  243. virtual wxDropTarget* GetDropTarget() const;
  244. // with CG, we need to get the context from an kEventControlDraw event
  245. // unfortunately, the DataBrowser callbacks don't provide the context
  246. // and we need it, so we need to set/remove it before and after draw
  247. // events so we can access it in the callbacks.
  248. void MacSetDrawingContext(void* context) { m_cgContext = context; }
  249. void* MacGetDrawingContext() { return m_cgContext; }
  250. virtual wxVisualAttributes GetDefaultAttributes() const
  251. {
  252. return GetClassDefaultAttributes(GetWindowVariant());
  253. }
  254. static wxVisualAttributes
  255. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  256. protected:
  257. // Implement base class pure virtual methods.
  258. long DoInsertColumn(long col, const wxListItem& info);
  259. // protected overrides needed for pimpl approach
  260. virtual void DoSetSize(int x, int y,
  261. int width, int height,
  262. int sizeFlags = wxSIZE_AUTO);
  263. long m_current;
  264. wxListCtrlTextCtrlWrapper *m_textctrlWrapper;
  265. wxListCtrlRenameTimer *m_renameTimer;
  266. // common part of all ctors
  267. void Init();
  268. wxGenericListCtrl* m_genericImpl; // allow use of the generic impl.
  269. wxMacDataBrowserListCtrlControl* m_dbImpl;
  270. void* m_macListCtrlEventHandler;
  271. void* m_cgContext;
  272. wxListCtrlCompare m_compareFunc;
  273. wxIntPtr m_compareFuncData;
  274. wxTextCtrl* m_textCtrl; // The control used for editing a label
  275. wxImageList * m_imageListNormal; // The image list for normal icons
  276. wxImageList * m_imageListSmall; // The image list for small icons
  277. wxImageList * m_imageListState; // The image list state icons (not implemented yet)
  278. wxColumnList m_colsInfo; // for storing info about each column
  279. wxColour m_textColor;
  280. wxColour m_bgColor;
  281. // keep track of whether or not we should delete the image list ourselves.
  282. bool m_ownsImageListNormal,
  283. m_ownsImageListSmall,
  284. m_ownsImageListState;
  285. long m_baseStyle; // Basic Windows style flags, for recreation purposes
  286. int m_colCount; // Windows doesn't have GetColumnCount so must
  287. // keep track of inserted/deleted columns
  288. int m_count; // for virtual lists, store item count
  289. private:
  290. int CalcColumnAutoWidth(int col) const;
  291. };
  292. #endif
  293. // _WX_LISTCTRL_H_