2019-01-19 22:49:48 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GWidget.h"
|
|
|
|
|
|
|
|
class GListBox final : public GWidget {
|
|
|
|
public:
|
|
|
|
explicit GListBox(GWidget* parent);
|
|
|
|
virtual ~GListBox() override;
|
|
|
|
|
2019-01-20 18:46:08 -05:00
|
|
|
void add_item(String&&);
|
|
|
|
int selected_index() const { return m_selected_index; }
|
2019-01-19 22:49:48 -05:00
|
|
|
|
|
|
|
private:
|
2019-01-20 18:46:08 -05:00
|
|
|
virtual void paint_event(GPaintEvent&) override;
|
|
|
|
virtual void mousedown_event(GMouseEvent&) override;
|
2019-01-19 22:49:48 -05:00
|
|
|
virtual const char* class_name() const override { return "GListBox"; }
|
2019-01-26 05:24:16 -05:00
|
|
|
virtual bool accepts_focus() const override { return true; }
|
2019-01-19 22:49:48 -05:00
|
|
|
|
|
|
|
Rect item_rect(int index) const;
|
|
|
|
|
2019-01-20 18:46:08 -05:00
|
|
|
int m_scroll_offset { 0 };
|
|
|
|
int m_selected_index { -1 };
|
2019-01-19 22:49:48 -05:00
|
|
|
|
|
|
|
Vector<String> m_items;
|
|
|
|
};
|
|
|
|
|