ListView.pkg 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. $#include "ListView.h"
  2. enum HighlightMode
  3. {
  4. HM_NEVER,
  5. HM_FOCUS,
  6. HM_ALWAYS
  7. };
  8. class ListView : public ScrollView
  9. {
  10. ListView(Context* context);
  11. virtual ~ListView();
  12. void AddItem(UIElement* item);
  13. void InsertItem(unsigned index, UIElement* item, UIElement* parentItem = 0);
  14. void RemoveItem(UIElement* item, unsigned index = 0);
  15. void RemoveItem(unsigned index);
  16. void RemoveAllItems();
  17. void SetSelection(unsigned index);
  18. void SetSelections(const PODVector<unsigned>& indices);
  19. void AddSelection(unsigned index);
  20. void RemoveSelection(unsigned index);
  21. void ToggleSelection(unsigned index);
  22. void ChangeSelection(int delta, bool additive = false);
  23. void ClearSelection();
  24. void SetHighlightMode(HighlightMode mode);
  25. void SetMultiselect(bool enable);
  26. void SetHierarchyMode(bool enable);
  27. void SetBaseIndent(int baseIndent);
  28. void SetClearSelectionOnDefocus(bool enable);
  29. void Expand(unsigned index, bool enable, bool recursive = false);
  30. void ToggleExpand(unsigned index, bool recursive = false);
  31. unsigned GetNumItems() const;
  32. UIElement* GetItem(unsigned index) const;
  33. // PODVector<UIElement*> GetItems() const;
  34. tolua_outside const PODVector<UIElement*>& ListViewGetItems @ GetItems() const;
  35. unsigned FindItem(UIElement* item) const;
  36. unsigned GetSelection() const;
  37. const PODVector<unsigned>& GetSelections() const;
  38. UIElement* GetSelectedItem() const;
  39. // PODVector<UIElement*> GetSelectedItems() const;
  40. tolua_outside const PODVector<UIElement*>& ListViewGetSelectedItems @ GetSelectedItems() const;
  41. bool IsSelected(unsigned index) const;
  42. bool IsExpanded(unsigned index) const;
  43. HighlightMode GetHighlightMode() const;
  44. bool GetMultiselect() const;
  45. bool GetClearSelectionOnDefocus() const;
  46. bool GetHierarchyMode() const;
  47. int GetBaseIndent() const;
  48. tolua_readonly tolua_property__get_set unsigned numItems;
  49. tolua_property__get_set unsigned selection;
  50. tolua_readonly tolua_property__get_set UIElement* selectedItem;
  51. tolua_property__get_set HighlightMode highlightMode;
  52. tolua_property__get_set bool multiselect;
  53. tolua_property__get_set bool clearSelectionOnDefocus;
  54. tolua_property__get_set bool hierarchyMode;
  55. tolua_property__get_set int baseIndent;
  56. };
  57. ${
  58. static const PODVector<UIElement*>& ListViewGetItems(const ListView* listView)
  59. {
  60. static PODVector<UIElement*> items;
  61. items = listView->GetItems();
  62. return items;
  63. }
  64. static const PODVector<UIElement*>& ListViewGetSelectedItems(const ListView* listView)
  65. {
  66. static PODVector<UIElement*> items;
  67. items = listView->GetSelectedItems();
  68. return items;
  69. }
  70. $}