table-view.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #if defined(Hiro_TableView)
  2. struct mTableView : mWidget {
  3. Declare(TableView)
  4. using mObject::remove;
  5. auto alignment() const -> Alignment;
  6. auto append(sTableViewColumn column) -> type&;
  7. auto append(sTableViewItem item) -> type&;
  8. auto backgroundColor() const -> Color;
  9. auto batchable() const -> bool;
  10. auto batched() const -> vector<TableViewItem>;
  11. auto bordered() const -> bool;
  12. auto column(uint position) const -> TableViewColumn;
  13. auto columnCount() const -> uint;
  14. auto columns() const -> vector<TableViewColumn>;
  15. auto doActivate(sTableViewCell cell) const -> void;
  16. auto doChange() const -> void;
  17. auto doContext() const -> void;
  18. auto doEdit(sTableViewCell cell) const -> void;
  19. auto doSort(sTableViewColumn column) const -> void;
  20. auto doToggle(sTableViewCell cell) const -> void;
  21. auto foregroundColor() const -> Color;
  22. auto headered() const -> bool;
  23. auto item(uint position) const -> TableViewItem;
  24. auto itemCount() const -> uint;
  25. auto items() const -> vector<TableViewItem>;
  26. auto onActivate(const function<void (TableViewCell)>& callback = {}) -> type&;
  27. auto onChange(const function<void ()>& callback = {}) -> type&;
  28. auto onContext(const function<void ()>& callback = {}) -> type&;
  29. auto onEdit(const function<void (TableViewCell)>& callback = {}) -> type&;
  30. auto onSort(const function<void (TableViewColumn)>& callback = {}) -> type&;
  31. auto onToggle(const function<void (TableViewCell)>& callback = {}) -> type&;
  32. auto remove(sTableViewColumn column) -> type&;
  33. auto remove(sTableViewItem item) -> type&;
  34. auto reset() -> type&;
  35. auto resizeColumns() -> type&;
  36. auto selectAll() -> type&;
  37. auto selectNone() -> type&;
  38. auto selected() const -> TableViewItem;
  39. auto setAlignment(Alignment alignment = {}) -> type&;
  40. auto setBackgroundColor(Color color = {}) -> type&;
  41. auto setBatchable(bool batchable = true) -> type&;
  42. auto setBordered(bool bordered = true) -> type&;
  43. auto setForegroundColor(Color color = {}) -> type&;
  44. auto setHeadered(bool headered = true) -> type&;
  45. auto setParent(mObject* parent = nullptr, int offset = -1) -> type& override;
  46. auto setSortable(bool sortable = true) -> type&;
  47. auto sort() -> type&;
  48. auto sortable() const -> bool;
  49. //private:
  50. struct State {
  51. uint activeColumn = 0;
  52. Alignment alignment;
  53. Color backgroundColor;
  54. bool batchable = false;
  55. bool bordered = false;
  56. vector<sTableViewColumn> columns;
  57. Color foregroundColor;
  58. bool headered = false;
  59. vector<sTableViewItem> items;
  60. function<void (TableViewCell)> onActivate;
  61. function<void ()> onChange;
  62. function<void ()> onContext;
  63. function<void (TableViewCell)> onEdit;
  64. function<void (TableViewColumn)> onSort;
  65. function<void (TableViewCell)> onToggle;
  66. bool sortable = false;
  67. } state;
  68. auto destruct() -> void override;
  69. };
  70. #endif