The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
gui::multimenu Class Reference

A widget that additionally to the normal menu contents also displays a checkbox in each row. More...

#include <multimenu.hpp>

Inheritance diagram for gui::multimenu:
Inheritance graph

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 itemget_item (int index) const
 
const itemget_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::stringid () 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, inthit_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 ()
 
CVideovideo () 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 styledefault_style = menu::bluebg_style
 
static style simple_style
 
static imgsel_style bluebg_style
 
- Protected Attributes inherited from gui::menu
stylestyle_
 
bool silent_
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

const std::vector<bool>& gui::multimenu::active_items ( ) const
inline

Tell each items status.

Returns
a vector of bools. The n-th item is active if the vector's n-th item is true

Definition at line 49 of file multimenu.hpp.

References active_items_.

void gui::multimenu::draw_row ( const size_t  row_index,
const SDL_Rect &  rect,
menu::ROW_TYPE  type 
)
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().

void gui::multimenu::erase_item ( size_t  index)
virtual

Reimplemented from gui::menu.

Definition at line 57 of file multimenu.cpp.

References active_items_, gui::menu::erase_item(), and last_changed_.

void gui::multimenu::handle_event ( const SDL_Event &  event)
protectedvirtual
int gui::multimenu::hit_checkbox ( int  x,
int  y 
) const
protected

Determine which checkbox was hit by a mouse click.

Parameters
xthe x coordinate of the click
ythe y coordinate of the click
Returns
the row whose checkbox was clicked on, or -1 if the click didn't hit a checkbox

Definition at line 52 of file multimenu.cpp.

References image::get_image(), gui::menu::hit(), and gui::scrollarea::inner_location().

Referenced by handle_event().

bool gui::multimenu::is_active ( size_t  index) const
inline

Tells if an item is activated.

Parameters
indexthe item's index
Returns
true if the item is active, false if not

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.

Returns
the item's index, or -1 if no item was changed since the last invokation

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().

void gui::multimenu::set_items ( const std::vector< std::string > &  items,
bool  strip_spaces = true,
bool  keep_viewport = false 
)
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().

Member Data Documentation

std::vector<bool> gui::multimenu::active_items_
private
int gui::multimenu::last_changed_
private

Definition at line 79 of file multimenu.hpp.

Referenced by erase_item(), handle_event(), last_changed(), and set_items().


The documentation for this class was generated from the following files: