14#include <egt/detail/meta.h>
17#include <egt/signal.h>
18#include <egt/string.h>
19#include <egt/widget.h>
59 using ItemArray = std::vector<std::shared_ptr<StringItem>>;
84 const Rect& rect = {})
noexcept;
114 using Widget::min_size_hint;
131 EGT_NODISCARD ssize_t
selected()
const {
return m_list.selected(); }
136 void add_item(
const std::shared_ptr<StringItem>& item);
152 auto i = std::shared_ptr<StringItem>(&item, [](
StringItem*) {});
164 EGT_NODISCARD std::shared_ptr<StringItem>
item_at(
size_t index)
const
166 return m_list.item_at(index);
174 return m_list.item_count();
202 std::shared_ptr<detail::ComboBoxPopup>
m_popup;
204 friend class detail::ComboBoxPopup;
208 static Size default_combobox_size_value;
210 static void register_handler();
211 static void unregister_handler();
213 void initialize(
bool init_inherited_properties =
true);
Combo box widget.
Definition combo.h:45
static Size default_size()
Default combobox size.
EGT_NODISCARD Size min_size_hint() const override
Get a minimum size hint for the Widget.
ComboBox(Serializer::Properties &props, bool is_derived) noexcept
Signal on_selected_changed
Event signal.
Definition combo.h:55
EGT_NODISCARD size_t item_count() const
Return the number of items in the list.
Definition combo.h:172
void show_popup() const
Show the ComboBox popup.
EGT_NODISCARD ssize_t selected() const
Get the index of the selected item.
Definition combo.h:131
ComboBox(Serializer::Properties &props) noexcept
Definition combo.h:89
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
ComboBox(const ItemArray &items=ItemArray()) noexcept
std::vector< std::shared_ptr< StringItem > > ItemArray
Item array type.
Definition combo.h:59
void selected(size_t index)
Set the index of the selected item.
void resize(const Size &s) override
Resize the widget.
static void default_size(const Size &size)
Change default combobox size.
static void default_draw(ComboBox &widget, Painter &painter, const Rect &rect)
Default draw method for the ComboBox.
ListBox m_list
Internal list.
Definition combo.h:199
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
void hide_popup() const
Hide the ComboBox popup.
void remove_item(StringItem *item)
Remove an item from a ComboBox.
void handle(Event &event) override
Handle an event.
void clear()
Remove all items from the list.
void add_item(const std::shared_ptr< StringItem > &item)
Append a new item to the ComboBox.
void set_parent(Widget *parent) override
Set this widget's parent.
void move(const Point &point) override
Move the Widget to a new position.
void add_item(StringItem &item)
Append a new item to the ComboBox.
Definition combo.h:147
std::shared_ptr< detail::ComboBoxPopup > m_popup
Popup associated with the ComboBox.
Definition combo.h:202
EGT_NODISCARD std::shared_ptr< StringItem > item_at(size_t index) const
Get an item at the specified index.
Definition combo.h:164
A Frame is a Widget that has children widgets.
Definition frame.h:45
ListBox that manages a selectable list of widgets.
Definition list.h:42
Drawing interface for 2D graphics.
Definition painter.h:45
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
uint32_t RegisterHandle
Handle type.
Definition signal.h:46
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255
List string helper.
Definition string.h:34