1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 09:07:41 +00:00
serenity/LibGUI/GComboBox.h
Andreas Kling 7d17689e17 LibGUI: Add a new GComboBox widget.
This widget combines a GTextEditor, a GButton, a GWindow and a GListView
to implement a nice drop-down list.

It's currently using the GWindowType::Tooltip type because that's the most
appropriately behaving window type available at the moment. This should
definitely be fixed though.
2019-06-22 10:47:29 +02:00

35 lines
823 B
C++

#pragma once
#include <LibGUI/GListView.h>
#include <LibGUI/GWidget.h>
class GButton;
class GTextEditor;
class GComboBox : public GWidget {
public:
explicit GComboBox(GWidget* parent = nullptr);
virtual ~GComboBox() override;
String text() const;
void open();
void close();
GModel* model() { return m_list_view->model(); }
const GModel* model() const { return m_list_view->model(); }
void set_model(NonnullRefPtr<GModel>);
Function<void(const String&)> on_change;
virtual const char* class_name() const override { return "GComboBox"; }
protected:
virtual void resize_event(GResizeEvent&) override;
private:
GTextEditor* m_editor { nullptr };
GButton* m_open_button { nullptr };
GWindow* m_list_window { nullptr };
GListView* m_list_view { nullptr };
};