GListBox.h 644 B

1234567891011121314151617181920212223242526
  1. #pragma once
  2. #include "GWidget.h"
  3. class GListBox final : public GWidget {
  4. public:
  5. explicit GListBox(GWidget* parent);
  6. virtual ~GListBox() override;
  7. void add_item(String&&);
  8. int selected_index() const { return m_selected_index; }
  9. private:
  10. virtual void paint_event(GPaintEvent&) override;
  11. virtual void mousedown_event(GMouseEvent&) override;
  12. virtual const char* class_name() const override { return "GListBox"; }
  13. virtual bool accepts_focus() const override { return true; }
  14. Rect item_rect(int index) const;
  15. int m_scroll_offset { 0 };
  16. int m_selected_index { -1 };
  17. Vector<String> m_items;
  18. };