TableView.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibGUI/AbstractTableView.h>
  9. namespace GUI {
  10. class TableView : public AbstractTableView {
  11. C_OBJECT(TableView)
  12. public:
  13. virtual ~TableView() override = default;
  14. enum class GridStyle {
  15. None,
  16. Horizontal,
  17. Vertical,
  18. Both,
  19. };
  20. enum class CursorStyle {
  21. None,
  22. Item,
  23. Row,
  24. };
  25. GridStyle grid_style() const { return m_grid_style; }
  26. void set_grid_style(GridStyle);
  27. void set_highlight_key_column(bool b) { m_highlight_key_column = b; }
  28. bool is_key_column_highlighted() const { return m_highlight_key_column; }
  29. virtual void move_cursor(CursorMovement, SelectionUpdate) override;
  30. protected:
  31. TableView();
  32. virtual void keydown_event(KeyEvent&) override;
  33. virtual void mousedown_event(MouseEvent&) override;
  34. virtual void mouseup_event(MouseEvent&) override;
  35. virtual void mousemove_event(MouseEvent&) override;
  36. virtual void paint_event(PaintEvent&) override;
  37. virtual void second_paint_event(PaintEvent&) override;
  38. private:
  39. GridStyle m_grid_style { GridStyle::None };
  40. bool m_highlight_key_column { true };
  41. bool m_rubber_banding { false };
  42. int m_rubber_band_origin { 0 };
  43. int m_rubber_band_current { 0 };
  44. };
  45. }