#include <button.hpp>
Classes | |
struct | error |
Public Types | |
enum | TYPE { TYPE_PRESS, TYPE_CHECK, TYPE_TURBO, TYPE_IMAGE, TYPE_RADIO } |
enum | SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE } |
Public Member Functions | |
button (CVideo &video, const std::string &label, TYPE type=TYPE_PRESS, std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE, const bool auto_join=true, std::string overlay_image="") | |
virtual | ~button () |
Default implementation, but defined out-of-line for efficiency reasons. More... | |
void | set_check (bool check) |
void | set_active (bool active) |
bool | checked () const |
void | set_label (const std::string &val) |
void | set_image (const std::string &image_file_base) |
void | set_overlay (const std::string &image_file_base) |
void | set_image_path_suffix (const std::string &suffix) |
bool | pressed () |
bool | hit (int x, int y) const |
virtual void | enable (bool new_val=true) |
void | release () |
![]() | |
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) |
virtual void | hide (bool value=true) |
bool | hidden () const |
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_help_string (int mousex, int mousey) |
virtual void | process_tooltip_string (int mousex, int mousey) |
![]() | |
virtual void | process_event () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
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 | handle_event (const SDL_Event &event) |
virtual void | mouse_motion (const SDL_MouseMotionEvent &event) |
virtual void | mouse_down (const SDL_MouseButtonEvent &event) |
virtual void | mouse_up (const SDL_MouseButtonEvent &event) |
virtual void | draw_contents () |
![]() | |
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 |
virtual void | draw () |
virtual void | update_location (SDL_Rect const &rect) |
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 () |
![]() | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
virtual std::vector < sdl_handler * > | handler_members () |
Protected Attributes | |
TYPE | type_ |
![]() | |
bool | focus_ |
Private Types | |
enum | STATE { UNINIT, NORMAL, ACTIVE, PRESSED, PRESSED_ACTIVE, TOUCHED_NORMAL, TOUCHED_PRESSED } |
Private Member Functions | |
void | load_images () |
void | calculate_size () |
Definition at line 27 of file button.hpp.
Enumerator | |
---|---|
DEFAULT_SPACE | |
MINIMUM_SPACE |
Definition at line 38 of file button.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
NORMAL | |
ACTIVE | |
PRESSED | |
PRESSED_ACTIVE | |
TOUCHED_NORMAL | |
TOUCHED_PRESSED |
Definition at line 92 of file button.hpp.
enum gui::button::TYPE |
Enumerator | |
---|---|
TYPE_PRESS | |
TYPE_CHECK | |
TYPE_TURBO | |
TYPE_IMAGE | |
TYPE_RADIO |
Definition at line 36 of file button.hpp.
gui::button::button | ( | CVideo & | video, |
const std::string & | label, | ||
button::TYPE | type = TYPE_PRESS , |
||
std::string | button_image = "" , |
||
SPACE_CONSUMPTION | spacing = DEFAULT_SPACE , |
||
const bool | auto_join = true , |
||
std::string | overlay_image = "" |
||
) |
Definition at line 47 of file button.cpp.
References button_image_name_, load_images(), type_, TYPE_CHECK, TYPE_PRESS, TYPE_RADIO, and TYPE_TURBO.
|
virtual |
Default implementation, but defined out-of-line for efficiency reasons.
Definition at line 287 of file button.cpp.
|
private |
Definition at line 291 of file button.cpp.
References base_height_, base_width_, font::BUTTON_COLOR, font::draw_text(), gui::font_size, i, image_, label_text_, gui::widget::location(), font::make_text_ellipsis(), MINIMUM_SPACE, font::parse_markup(), screen_area(), gui::widget::set_height(), gui::widget::set_location(), gui::widget::set_width(), spacing_, textRect_, type_, TYPE_IMAGE, TYPE_PRESS, and TYPE_TURBO.
Referenced by load_images(), and set_label().
bool gui::button::checked | ( | ) | const |
Definition at line 381 of file button.cpp.
References PRESSED, PRESSED_ACTIVE, state_, and TOUCHED_PRESSED.
Referenced by mp::configure::get_parameters(), mp::options::checkbox_display::get_value(), mp::lobby::lobby(), mp::configure::process_event_impl(), mp::lobby::process_event_impl(), and default_map_generator::user_config().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 399 of file button.cpp.
References ACTIVE, activeImage_, CVideo::blit_surface(), blit_surface(), font::BUTTON_COLOR, gui::checkbox_horizontal_padding, disabledImage_, font::draw_text(), gui::widget::enabled(), font::GRAY_COLOR, image_, label_text_, gui::widget::location(), make_neutral_surface(), surface::null(), overlayActiveImage_, overlayDisabledImage_, overlayImage_, overlayPressedDisabledImage_, overlayPressedImage_, PRESSED, PRESSED_ACTIVE, pressedActiveImage_, pressedDisabledImage_, pressedImage_, state_, textRect_, TOUCHED_NORMAL, TOUCHED_PRESSED, touchedImage_, type_, TYPE_CHECK, TYPE_IMAGE, TYPE_PRESS, TYPE_RADIO, update_rect(), and gui::widget::video().
Referenced by release().
|
virtual |
Reimplemented from gui::widget.
Definition at line 386 of file button.cpp.
References gui::widget::enable(), gui::widget::enabled(), NORMAL, pressed_, state_, type_, and TYPE_CHECK.
Referenced by statistics_dialog::action(), mp::configure::configure(), statistics_dialog::display_stats(), mp::lobby::gamelist_updated(), mp::lobby::lobby(), mp::create::process_event_impl(), mp::lobby::process_event_impl(), ng::flg_manager::reset_gender_combo(), ng::flg_manager::reset_leader_combo(), gui::scrollbar::scrollbar(), gui::scrollbar::set_full_size(), gui::scrollbar::set_position(), storyscreen::controller::show(), mp::connect::side::side(), and mp::connect::update_playerlist_state().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 740 of file button.cpp.
References gui::widget::enabled(), gui::widget::handle_event(), gui::widget::hidden(), mouse_down(), gui::widget::mouse_locked(), mouse_motion(), mouse_up(), gui::widget::set_dirty(), and state_.
Definition at line 575 of file button.cpp.
References gui::widget::location(), and sdl::point_in_rect().
Referenced by gui::combo_drag::mouse_down(), mouse_down(), mouse_motion(), and mouse_up().
|
private |
Definition at line 92 of file button.cpp.
References activeImage_, surface::assign(), base_height_, base_width_, button_image_name_, button_image_path_suffix_, button_overlay_image_name_, calculate_size(), disabledImage_, filesystem::ends_with(), ERR_DP, error(), filesystem::file_exists(), image::get_image(), image_, label_text_, gui::widget::location(), surface::null(), overlayActiveImage_, overlayDisabledImage_, overlayImage_, overlayPressedDisabledImage_, overlayPressedImage_, game_config::path, pressedActiveImage_, pressedDisabledImage_, pressedImage_, scale_surface(), set_label(), touchedImage_, type_, TYPE_CHECK, TYPE_IMAGE, TYPE_PRESS, TYPE_RADIO, and TYPE_TURBO.
Referenced by button(), set_image(), set_image_path_suffix(), and set_overlay().
|
protectedvirtual |
Reimplemented in gui::combo_drag.
Definition at line 661 of file button.cpp.
References ACTIVE, game_config::sounds::button_press, hit(), sound::play_UI_sound(), PRESSED, PRESSED_ACTIVE, state_, TOUCHED_NORMAL, TOUCHED_PRESSED, type_, TYPE_CHECK, TYPE_RADIO, and TYPE_TURBO.
Referenced by handle_event(), and gui::combo_drag::mouse_down().
|
protectedvirtual |
Reimplemented in gui::combo_drag.
Definition at line 627 of file button.cpp.
References ACTIVE, hit(), NORMAL, PRESSED, PRESSED_ACTIVE, state_, TOUCHED_NORMAL, TOUCHED_PRESSED, type_, TYPE_CHECK, TYPE_IMAGE, and TYPE_RADIO.
Referenced by handle_event(), and gui::combo_drag::mouse_motion().
|
protectedvirtual |
Reimplemented in location_palette_button, and gui::combo_drag.
Definition at line 689 of file button.cpp.
References ACTIVE, game_config::sounds::button_press, game_config::sounds::checkbox_release, hit(), sound::play_UI_sound(), PRESSED, pressed_, PRESSED_ACTIVE, state_, TOUCHED_NORMAL, TOUCHED_PRESSED, type_, TYPE_CHECK, TYPE_IMAGE, TYPE_PRESS, TYPE_RADIO, and TYPE_TURBO.
Referenced by handle_event(), gui::combo_drag::mouse_up(), and location_palette_button::mouse_up().
bool gui::button::pressed | ( | ) |
Definition at line 770 of file button.cpp.
References PRESSED, pressed_, PRESSED_ACTIVE, state_, TOUCHED_PRESSED, type_, and TYPE_TURBO.
Referenced by storyscreen::part_ui::handle_interface(), location_palette_button::mouse_up(), mp::wait::process_event(), gui::combo::process_event(), mp::create::process_event(), mp::configure::process_event(), help::help_browser::process_event(), gui::scrollbar::process_event(), mp::connect::process_event(), dialogs::units_list_preview_pane::process_event(), dialogs::unit_types_preview_pane::process_event(), mp::options::reset_display::process_event(), mp::lobby::process_event(), mp::create::process_event_impl(), mp::configure::process_event_impl(), mp::lobby::process_event_impl(), about::show_about(), and default_map_generator::user_config().
void gui::button::release | ( | ) |
Definition at line 684 of file button.cpp.
References draw_contents(), NORMAL, and state_.
Referenced by storyscreen::part_ui::handle_interface().
void gui::button::set_active | ( | bool | active | ) |
Definition at line 370 of file button.cpp.
References ACTIVE, NORMAL, gui::widget::set_dirty(), and state_.
void gui::button::set_check | ( | bool | check | ) |
Definition at line 352 of file button.cpp.
References ACTIVE, NORMAL, PRESSED, PRESSED_ACTIVE, gui::widget::set_dirty(), state_, type_, TYPE_CHECK, TYPE_IMAGE, and TYPE_RADIO.
Referenced by gui::dialog::add_option(), mp::options::checkbox_display::checkbox_display(), mp::configure::configure(), mp::lobby::lobby(), mp::options::checkbox_display::set_value(), and default_map_generator::user_config().
void gui::button::set_image | ( | const std::string & | image_file_base | ) |
Definition at line 582 of file button.cpp.
References button_image_name_, gui::is_valid_image(), load_images(), and gui::widget::set_dirty().
|
inline |
Definition at line 54 of file button.hpp.
References button_image_path_suffix_, and load_images().
void gui::button::set_label | ( | const std::string & | val | ) |
Definition at line 604 of file button.cpp.
References calculate_size(), COLUMN_SEPARATOR, gui2::event::find(), i, gui::is_valid_image(), mp_ui_alerts::items, label_text_, gui::widget::set_dirty(), font::ttext::set_text(), and utils::split().
Referenced by statistics_dialog::display_stats(), statistics_dialog::do_scene_selection(), load_images(), and gui::combo::set_selected_internal().
void gui::button::set_overlay | ( | const std::string & | image_file_base | ) |
Definition at line 593 of file button.cpp.
References button_overlay_image_name_, gui::is_valid_image(), load_images(), and gui::widget::set_dirty().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 99 of file button.hpp.
Referenced by calculate_size(), and load_images().
|
private |
Definition at line 99 of file button.hpp.
Referenced by calculate_size(), and load_images().
|
private |
Definition at line 101 of file button.hpp.
Referenced by button(), load_images(), and set_image().
|
private |
Definition at line 103 of file button.hpp.
Referenced by load_images(), and set_image_path_suffix().
|
private |
Definition at line 102 of file button.hpp.
Referenced by load_images(), and set_overlay().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by calculate_size(), draw_contents(), and load_images().
|
private |
Definition at line 76 of file button.hpp.
Referenced by calculate_size(), draw_contents(), load_images(), and set_label().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 95 of file button.hpp.
Referenced by enable(), mouse_up(), and pressed().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
private |
Definition at line 97 of file button.hpp.
Referenced by calculate_size().
|
private |
Definition at line 93 of file button.hpp.
Referenced by checked(), draw_contents(), enable(), handle_event(), mouse_down(), mouse_motion(), mouse_up(), pressed(), release(), set_active(), and set_check().
|
private |
Definition at line 90 of file button.hpp.
Referenced by calculate_size(), and draw_contents().
|
private |
Definition at line 85 of file button.hpp.
Referenced by draw_contents(), and load_images().
|
protected |
Definition at line 68 of file button.hpp.
Referenced by button(), calculate_size(), draw_contents(), enable(), gui::dialog_button::is_option(), load_images(), mouse_down(), mouse_motion(), mouse_up(), pressed(), and set_check().