list-view.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #if defined(Hiro_ListView)
  2. struct ListView;
  3. struct ListViewItem;
  4. struct mListView;
  5. struct mListViewItem;
  6. using sListView = shared_pointer<mListView>;
  7. using sListViewItem = shared_pointer<mListViewItem>;
  8. struct mListView : mTableView {
  9. using type = mListView;
  10. using mTableView::append;
  11. using mTableView::remove;
  12. mListView();
  13. auto batched() const -> vector<ListViewItem>;
  14. auto doActivate() const -> void;
  15. auto doChange() const -> void;
  16. auto doContext() const -> void;
  17. auto doToggle(ListViewItem) const -> void;
  18. auto item(uint position) const -> ListViewItem;
  19. auto items() const -> vector<ListViewItem>;
  20. auto onActivate(const function<void ()>& callback) -> type&;
  21. auto onChange(const function<void ()>& callback) -> type&;
  22. auto onContext(const function<void ()>& callback) -> type&;
  23. auto onToggle(const function<void (ListViewItem)>& callback) -> type&;
  24. auto reset() -> type& override;
  25. auto resizeColumn() -> type&;
  26. auto selected() const -> ListViewItem;
  27. auto setVisible(bool visible = true) -> type&;
  28. //private:
  29. struct State {
  30. function<void ()> onActivate;
  31. function<void ()> onChange;
  32. function<void ()> onContext;
  33. function<void (ListViewItem)> onToggle;
  34. } state;
  35. };
  36. struct mListViewItem : mTableViewItem {
  37. using type = mListViewItem;
  38. using mTableViewItem::append;
  39. using mTableViewItem::remove;
  40. mListViewItem();
  41. auto checkable() const -> bool;
  42. auto checked() const -> bool;
  43. auto icon() const -> image;
  44. auto reset() -> type&;
  45. auto setCheckable(bool checkable) -> type&;
  46. auto setChecked(bool checked) -> type&;
  47. auto setIcon(const image& icon = {}) -> type&;
  48. auto setText(const string& text) -> type&;
  49. auto text() const -> string;
  50. };
  51. #endif