26 #include <boost/dynamic_bitset.hpp>
33 class selectable_item;
36 struct builder_listbox;
37 struct builder_horizontal_listbox;
38 struct builder_grid_listbox;
103 void remove_row(
const unsigned row,
unsigned count = 1);
182 bool select_row(
const unsigned row,
const bool select =
true);
210 bool select_row_at(
const unsigned row,
const bool select =
true);
259 template<
typename Func>
263 [
f](
int lhs,
int rhs) {
return f(lhs) <
f(rhs); },
264 [
f](
int lhs,
int rhs) {
return f(lhs) >
f(rhs); }
348 const std::vector<widget_data>& list_data);
363 typedef std::vector<std::pair<selectable_item*, generator_sort_array>>
torder_list;
386 const int height_modification,
387 const int width_modification_pos = -1,
388 const int height_modification_pos = -1);
407 static const std::string&
type();
441 virtual std::unique_ptr<widget>
build()
const override;
468 virtual std::unique_ptr<widget>
build()
const override;
492 virtual std::unique_ptr<widget>
build()
const override;
A config object defines a single node in a WML file, with access to child nodes.
Abstract base class for the generator.
std::function< bool(unsigned, unsigned)> order_func
placement
Determines how the items are placed.
Basic template class to generate new items.
void update_layout()
Updates internal layout.
const bool is_horizontal_
void list_item_clicked(widget &caller)
Function to call after the user clicked on a row.
void mark_as_unsorted()
Deactivates all sorting toggle buttons at the top, making the list look like it's not sorted.
virtual point calculate_best_size() const override
See widget::calculate_best_size.
bool select_last_row(const bool select=true)
Does exactly as advertised: selects the list's last row.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void handle_key_right_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
void set_row_active(const unsigned row, const bool active)
Makes a row active or inactive.
void set_row_shown(const unsigned row, const bool shown)
Makes a row visible or invisible.
void set_active_sorting_option(const order_pair &sort_by, const bool select_first=false)
Sorts the listbox by a pre-set sorting option.
void handle_key_left_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
void order_by_column(unsigned column, widget &widget)
std::pair< int, sort_order::type > order_pair
void resize_content(const int width_modification, const int height_modification, const int width_modification_pos=-1, const int height_modification_pos=-1)
Resizes the content.
void order_by(const generator_base::order_func &func)
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
std::function< std::string(const int)> translatable_sorter_func_t
const grid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
void register_translatable_sorting_option(const int col, translatable_sorter_func_t f)
Registers a special sorting function specifically for translatable values.
virtual void set_content_size(const point &origin, const point &size) override
Inherited from scrollbar_container.
virtual void place(const point &origin, const point &size) override
See widget::place.
friend class debug_layout_graph
void update_visible_area_on_key_event(const KEY_SCROLL_DIRECTION direction)
Helper to update visible area after a key event.
void set_callback_order_change(std::function< void(unsigned, sort_order::type)> callback)
Registers a callback to be called when the active sorting option changes.
std::vector< std::pair< selectable_item *, generator_sort_array > > torder_list
generator_base * generator_
Contains a pointer to the generator.
std::function< void(unsigned, sort_order::type)> callback_order_change_
bool select_row(const unsigned row, const bool select=true)
Selects a row.
bool update_content_size()
Request to update the size of the content after changing the content.
boost::dynamic_bitset get_rows_shown() const
Returns a list of visible rows.
bool any_rows_shown() const
void register_sorting_option(const int col, const Func &f)
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
void finalize(std::unique_ptr< generator_base > generator, builder_grid_const_ptr header, builder_grid_const_ptr footer, const std::vector< widget_data > &list_data)
Finishes the building initialization of the widget.
void handle_key_down_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
void remove_row(const unsigned row, unsigned count=1)
Removes a row in the listbox.
void clear()
Removes all the rows in the listbox, clearing it.
void set_column_order(unsigned col, const generator_sort_array &func)
int get_selected_row() const
Returns the first selected row.
unsigned get_item_count() const
Returns the number of items in the listbox.
bool select_row_at(const unsigned row, const bool select=true)
Selects a row at the given position, regardless of sorting order.
const order_pair get_active_sorting_option()
builder_grid_const_ptr list_builder_
Contains the builder for the new items.
bool row_selected(const unsigned row)
Check if a row is selected.
void handle_key_up_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
std::shared_ptr< builder_grid > builder_grid_ptr
std::array< generator_base::order_func, 2 > generator_sort_array
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
std::shared_ptr< const builder_grid > builder_grid_const_ptr
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
builder_grid_listbox(const config &cfg)
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
virtual std::unique_ptr< widget > build() const override
std::vector< widget_data > list_data
Listbox data.
builder_grid_ptr list_builder
virtual std::unique_ptr< widget > build() const override
std::vector< widget_data > list_data
Listbox data.
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
builder_horizontal_listbox(const config &cfg)
builder_grid_ptr list_builder
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
builder_listbox(const config &cfg)
std::vector< widget_data > list_data
Listbox data.
virtual std::unique_ptr< widget > build() const override
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
builder_grid_ptr list_builder
resolution(const config &cfg)
listbox_definition(const config &cfg)