A widget that additionally to the normal menu contents also displays a checkbox in each row. More...
#include <multimenu.hpp>
Public Member Functions | |
multimenu (CVideo &video, const std::vector< std::string > &items, bool click_selects=false, int max_height=-1, int max_width=-1, const sorter *sorter_obj=nullptr, style *menu_style=nullptr, const bool auto_join=true) | |
void | set_active (size_t index, bool active=true) |
bool | is_active (size_t index) const |
Tells if an item is activated. More... | |
const std::vector< bool > & | active_items () const |
Tell each items status. More... | |
virtual void | erase_item (size_t index) |
virtual void | set_items (const std::vector< std::string > &items, bool strip_spaces=true, bool keep_viewport=false) |
Set new items to show and redraw/recalculate everything. More... | |
int | last_changed () |
Returns the item last activated/deactivated. More... | |
Public Member Functions inherited from gui::menu | |
menu (CVideo &video, const std::vector< std::string > &items, bool click_selects=false, int max_height=-1, int max_width=-1, const sorter *sorter_obj=nullptr, style *menu_style=nullptr, const bool auto_join=true) | |
~menu () | |
Default implementation, but defined out-of-line for efficiency reasons. More... | |
int | selection () const |
void | move_selection (size_t id) |
void | move_selection_keeping_viewport (size_t id) |
void | reset_selection () |
const item & | get_item (int index) const |
const item & | get_selected_item () const |
void | change_item (int pos1, int pos2, const std::string &str) |
void | set_heading (const std::vector< std::string > &heading) |
void | set_max_height (const int new_max_height) |
Set a new max height for this menu. More... | |
void | set_max_width (const int new_max_width) |
int | get_max_height () |
int | get_max_width () |
size_t | number_of_items () const |
int | process () |
bool | double_clicked () |
void | set_click_selects (bool value) |
void | set_numeric_keypress_selection (bool value) |
void | scroll (unsigned int pos) |
void | set_sorter (sorter *s) |
void | sort_by (int column) |
int | get_sort_by () |
bool | get_sort_reversed () |
Public Member Functions inherited from gui::scrollarea | |
scrollarea (CVideo &video, bool auto_join=true) | |
Create a zone with automatic handling of scrollbar. More... | |
virtual void | hide (bool value=true) |
Public Member Functions inherited from gui::widget | |
SDL_Rect const & | location () const |
virtual void | set_location (SDL_Rect const &rect) |
void | set_location (int x, int y) |
void | set_width (int w) |
void | set_height (int h) |
void | set_measurements (int w, int h) |
int | width () const |
int | height () const |
bool | focus (const SDL_Event *event) |
void | set_focus (bool focus) |
bool | hidden () const |
virtual void | enable (bool new_val=true) |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | set_volatile (bool val=true) |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_help_string (const std::string &str) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_tooltip_string (int mousex, int mousey) |
Public Member Functions inherited from events::sdl_handler | |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
Protected Member Functions | |
virtual void | draw_row (const size_t row_index, const SDL_Rect &rect, ROW_TYPE type) |
virtual void | handle_event (const SDL_Event &event) |
int | hit_checkbox (int x, int y) const |
Determine which checkbox was hit by a mouse click. More... | |
Protected Member Functions inherited from gui::menu | |
bool | item_ends_with_image (const std::string &item) const |
void | set_inner_location (const SDL_Rect &rect) |
bool | requires_event_focus (const SDL_Event *event=nullptr) const |
const std::vector< int > & | column_widths () const |
int | hit (int x, int y) const |
std::pair< int, int > | hit_cell (int x, int y) const |
int | hit_column (int x) const |
int | hit_heading (int x, int y) const |
void | invalidate_row (size_t id) |
void | invalidate_row_pos (size_t pos) |
void | invalidate_heading () |
Protected Member Functions inherited from gui::scrollarea | |
virtual sdl_handler_vector | handler_members () |
virtual void | update_location (SDL_Rect const &rect) |
virtual void | process_event () |
SDL_Rect | inner_location () const |
unsigned | scrollbar_width () const |
unsigned | get_position () const |
unsigned | get_max_position () const |
void | set_position (unsigned pos) |
void | adjust_position (unsigned pos) |
void | move_position (int dep) |
void | set_shown_size (unsigned h) |
void | set_full_size (unsigned h) |
void | set_scroll_rate (unsigned r) |
bool | has_scrollbar () const |
Protected Member Functions inherited from gui::widget | |
widget (widget const &o) | |
widget (CVideo &video, const bool auto_join=true) | |
virtual | ~widget () |
void | bg_register (SDL_Rect const &rect) |
void | bg_restore () const |
void | bg_restore (SDL_Rect const &rect) const |
void | bg_update () |
void | bg_cancel () |
CVideo & | video () const |
const SDL_Rect * | clip_rect () const |
virtual sdl_handler_vector | member_handlers () |
virtual void | handle_window_event (SDL_Event const &event) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
Private Attributes | |
std::vector< bool > | active_items_ |
int | last_changed_ |
Additional Inherited Members | |
Public Types inherited from gui::menu | |
enum | ROW_TYPE { NORMAL_ROW, SELECTED_ROW, HEADING_ROW } |
Static Public Attributes inherited from gui::menu | |
static style & | default_style = menu::bluebg_style |
static style | simple_style |
static imgsel_style | bluebg_style |
Protected Attributes inherited from gui::menu | |
style * | style_ |
bool | silent_ |
Protected Attributes inherited from gui::widget | |
bool | focus_ |
A widget that additionally to the normal menu contents also displays a checkbox in each row.
An item is considered 'active' if its checkbox is checked, 'inactive' otherwise.
Definition at line 27 of file multimenu.hpp.
gui::multimenu::multimenu | ( | CVideo & | video, |
const std::vector< std::string > & | items, | ||
bool | click_selects = false , |
||
int | max_height = -1 , |
||
int | max_width = -1 , |
||
const sorter * | sorter_obj = nullptr , |
||
menu::style * | menu_style = nullptr , |
||
const bool | auto_join = true |
||
) |
Definition at line 20 of file multimenu.cpp.
|
inline |
Tell each items status.
Definition at line 49 of file multimenu.hpp.
References active_items_.
|
protectedvirtual |
Reimplemented from gui::menu.
Definition at line 25 of file multimenu.cpp.
References active_items_, blit_surface(), gui::menu::draw_row(), image::get_image(), and gui::widget::video().
|
virtual |
Reimplemented from gui::menu.
Definition at line 57 of file multimenu.cpp.
References active_items_, gui::menu::erase_item(), and last_changed_.
|
protectedvirtual |
Reimplemented from gui::menu.
Definition at line 39 of file multimenu.cpp.
References active_items_, gui::menu::handle_event(), hit_checkbox(), gui::menu::invalidate_row_pos(), and last_changed_.
Determine which checkbox was hit by a mouse click.
x | the x coordinate of the click |
y | the y coordinate of the click |
Definition at line 52 of file multimenu.cpp.
References image::get_image(), gui::menu::hit(), and gui::scrollarea::inner_location().
Referenced by handle_event().
|
inline |
Tells if an item is activated.
index | the item's index |
Definition at line 42 of file multimenu.hpp.
References active_items_.
int gui::multimenu::last_changed | ( | ) |
Returns the item last activated/deactivated.
Items changed via set_active don't count, Invoking this function will set the last changed index to -1.
Definition at line 75 of file multimenu.cpp.
References last_changed_.
Referenced by mp::create::process_event_impl().
void gui::multimenu::set_active | ( | size_t | index, |
bool | active = true |
||
) |
Definition at line 70 of file multimenu.cpp.
References active_items_, and gui::menu::invalidate_row_pos().
Referenced by mp::create::update_mod_menu().
|
virtual |
Set new items to show and redraw/recalculate everything.
If strip_spaces is false, spaces will remain at the item edges. If keep_viewport is true, the menu tries to keep the selection at the same position as it were before the items were set.
Reimplemented from gui::menu.
Definition at line 63 of file multimenu.cpp.
References active_items_, last_changed_, and gui::menu::set_items().
Referenced by mp::create::create().
|
private |
Definition at line 78 of file multimenu.hpp.
Referenced by active_items(), draw_row(), erase_item(), handle_event(), is_active(), set_active(), and set_items().
|
private |
Definition at line 79 of file multimenu.hpp.
Referenced by erase_item(), handle_event(), last_changed(), and set_items().