26 #include <boost/dynamic_bitset.hpp> 33 class selectable_item;
36 struct builder_listbox;
37 struct builder_horizontal_listbox;
38 struct builder_grid_listbox;
39 struct builder_styled_widget;
51 friend class debug_layout_graph;
106 void remove_row(
const unsigned row,
unsigned count = 1);
112 unsigned get_item_count()
const;
122 void set_row_active(
const unsigned row,
const bool active);
130 void set_row_shown(
const unsigned row,
const bool shown);
144 void set_row_shown(
const boost::dynamic_bitset<>& shown);
151 boost::dynamic_bitset<> get_rows_shown()
const;
153 bool any_rows_shown()
const;
167 const grid* get_row_grid(
const unsigned row)
const;
176 grid* get_row_grid(
const unsigned row);
185 bool select_row(
const unsigned row,
const bool select =
true);
194 return select_row(get_item_count() - 1, select);
213 bool select_row_at(
const unsigned row,
const bool select =
true);
220 bool row_selected(
const unsigned row);
227 int get_selected_row()
const;
230 void list_item_clicked(
widget& caller);
233 virtual void set_self_active(
const bool active)
override;
249 bool update_content_size();
254 virtual void place(
const point& origin,
const point&
size)
override;
262 template<
typename Func>
265 set_column_order(col, {{
266 [
f](
int lhs,
int rhs) {
return f(lhs) <
f(rhs); },
267 [
f](
int lhs,
int rhs) {
return f(lhs) >
f(rhs); }
289 void set_active_sorting_option(
const order_pair& sort_by,
const bool select_first =
false);
294 void mark_as_unsorted();
299 callback_order_change_ = callback;
306 void handle_key_up_arrow(SDL_Keymod modifier,
bool& handled)
override;
309 void handle_key_down_arrow(SDL_Keymod modifier,
bool& handled)
override;
312 void handle_key_left_arrow(SDL_Keymod modifier,
bool& handled)
override;
315 void handle_key_right_arrow(SDL_Keymod modifier,
bool& handled)
override;
319 virtual point calculate_best_size()
const override;
348 void finalize(std::unique_ptr<generator_base>
generator,
351 const std::vector<widget_data>& list_data);
366 typedef std::vector<std::pair<selectable_item*, generator_sort_array>>
torder_list;
388 void resize_content(
const int width_modification,
389 const int height_modification,
390 const int width_modification_pos = -1,
391 const int height_modification_pos = -1);
400 void resize_content(
const widget& row);
403 void update_layout();
406 virtual void set_content_size(
const point& origin,
const point& size)
override;
410 static const std::string&
type();
414 virtual const std::string& get_control_type()
const override;
486 virtual std::unique_ptr<widget>
build()
const override;
534 virtual std::unique_ptr<widget>
build()
const override;
580 virtual std::unique_ptr<widget>
build()
const override;
Base class of a resolution, contains the common keys for a resolution.
std::vector< widget_data > list_data
Listbox data.
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
A grid listbox is a styled_widget that holds several items of the same type.
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
std::pair< int, sort_order::type > order_pair
std::function< bool(unsigned, unsigned)> order_func
void clear(const std::string &key)
std::function< void(unsigned, sort_order::type)> callback_order_change_
bool select_last_row(const bool select=true)
Does exactly as advertised: selects the list's last row.
A horizontal listbox is a control that holds several items of the same type.
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::map< std::string, t_string > widget_item
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
Abstract base class for the generator.
std::vector< std::pair< selectable_item *, generator_sort_array > > torder_list
builder_grid_const_ptr list_builder_
Contains the builder for the new items.
placement
Determines how the items are placed.
builder_grid_ptr list_builder
Basic template class to generate new items.
std::vector< widget_data > list_data
Listbox data.
builder_grid_ptr list_builder
A listbox is a control that holds several items of the same type.
std::vector< widget_data > list_data
Listbox data.
std::shared_ptr< const builder_grid > builder_grid_const_ptr
std::array< generator_base::order_func, 2 > generator_sort_array
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.
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::shared_ptr< builder_grid > builder_grid_ptr
const bool is_horizontal_
std::map< std::string, widget_item > widget_data
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
builder_grid_ptr list_builder
generator_base * generator_
Contains a pointer to the generator.
void register_sorting_option(const int col, const Func &f)
A config object defines a single node in a WML file, with access to child nodes.
std::function< std::string(const int)> translatable_sorter_func_t
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::pair< std::string, unsigned > item