Class for a toggle button. More...
#include <toggle_button.hpp>


Public Member Functions | |
| ttoggle_button () | |
| void | set_members (const string_map &data) |
| Inherited from tcontrol. | |
| void | set_active (const bool active) |
| Inherited from tcontrol. | |
| bool | get_active () const |
| Inherited from tcontrol. | |
| unsigned | get_state () const |
| Inherited from tcontrol. | |
| void | update_canvas () |
| Inherited from tcontrol. | |
| bool | get_value () const |
| Inherited from tselectable_. | |
| void | set_value (const bool selected) |
| Inherited from tselectable_. | |
| void | set_retval (const int retval) |
| void | set_callback_state_change (boost::function< void(twidget *)> callback) |
| Inherited from tselectable_. | |
| void | set_icon_name (const std::string &icon_name) |
| const std::string & | icon_name () const |
Private Types | |
| enum | tstate { ENABLED, DISABLED, FOCUSSED, ENABLED_SELECTED, DISABLED_SELECTED, FOCUSSED_SELECTED, COUNT } |
Possible states of the widget. More... | |
Private Member Functions | |
| void | set_state (const tstate state) |
| const std::string & | get_control_type () const |
| Inherited from tcontrol. | |
| void | signal_handler_mouse_enter (const event::tevent event, bool &handled) |
| void | signal_handler_mouse_leave (const event::tevent event, bool &handled) |
| void | signal_handler_left_button_click (const event::tevent event, bool &handled) |
| void | signal_handler_left_button_double_click (const event::tevent event, bool &handled) |
Private Attributes | |
| tstate | state_ |
| Current state of the widget. | |
| int | retval_ |
| The return value of the button. | |
| boost::function< void(twidget *) | callback_state_change_ ) |
| See tselectable_::set_callback_state_change. | |
| std::string | icon_name_ |
| The toggle button can contain an icon next to the text. | |
Class for a toggle button.
A toggle button is a button with two states 'up' and 'down' or 'selected' and 'deselected'. When the mouse is pressed on it the state changes.
Definition at line 30 of file toggle_button.hpp.
enum gui2::ttoggle_button::tstate [private] |
Possible states of the widget.
Note the order of the states must be the same as defined in settings.hpp. Also note the internals do assume the order for 'up' and 'down' to be the same and also that 'up' is before 'down'. 'up' has no suffix, 'down' has the SELECTED suffix.
Definition at line 85 of file toggle_button.hpp.
| gui2::ttoggle_button::ttoggle_button | ( | ) |
Definition at line 37 of file toggle_button.cpp.
References signal_handler_left_button_click(), signal_handler_left_button_double_click(), signal_handler_mouse_enter(), and signal_handler_mouse_leave().

| bool gui2::ttoggle_button::get_active | ( | ) | const [inline] |
Inherited from tcontrol.
Definition at line 49 of file toggle_button.hpp.
| const std::string & gui2::ttoggle_button::get_control_type | ( | ) | const [private] |
| unsigned gui2::ttoggle_button::get_state | ( | ) | const [inline] |
| bool gui2::ttoggle_button::get_value | ( | ) | const [inline, virtual] |
Inherited from tselectable_.
Implements gui2::tselectable_.
Definition at line 59 of file toggle_button.hpp.
References state_.
Referenced by gui2::tlobby_main::game_filter_reload(), gui2::tunit_create::gender_toggle_callback(), gui2::ttree_view_node::is_folded(), gui2::tlobby_main::player_filter_callback(), gui2::tunit_create::post_show(), gui2::taddon_uninstall_list::post_show(), set_active(), set_value(), gui2::tsub_player_list::show_toggle_callback(), signal_handler_left_button_click(), signal_handler_mouse_enter(), signal_handler_mouse_leave(), gui2::tlobby_main::skip_replay_changed_callback(), gui2::teditor_settings::slider_update_callback(), gui2::tlobby_main::update_playerlist(), gui2::teditor_settings::update_selected_tod_info(), and gui2::tplayer_list::update_sort_icons().

| const std::string& gui2::ttoggle_button::icon_name | ( | ) | const [inline] |
Definition at line 74 of file toggle_button.hpp.
References icon_name_.
| void gui2::ttoggle_button::set_active | ( | const bool | active | ) |
Inherited from tcontrol.
Definition at line 68 of file toggle_button.cpp.
References DISABLED, DISABLED_SELECTED, ENABLED, ENABLED_SELECTED, get_value(), and set_state().

| void gui2::ttoggle_button::set_callback_state_change | ( | boost::function< void(twidget *)> | callback | ) | [inline, virtual] |
Inherited from tselectable_.
Implements gui2::tselectable_.
Definition at line 69 of file toggle_button.hpp.
References callback_state_change_.
Referenced by gui2::tunit_create::pre_show(), gui2::tlobby_main::pre_show(), and gui2::teditor_resize_map::pre_show().

| void gui2::ttoggle_button::set_icon_name | ( | const std::string & | icon_name | ) | [inline] |
Definition at line 72 of file toggle_button.hpp.
References icon_name_, and update_canvas().
Referenced by gui2::teditor_resize_map::set_direction_icon(), set_members(), gui2::tsub_player_list::show_toggle_callback(), and gui2::tplayer_list::update_sort_icons().


| void gui2::ttoggle_button::set_members | ( | const string_map & | data | ) |
Inherited from tcontrol.
Sets the additional member * icon_name_ icon
Definition at line 57 of file toggle_button.cpp.
References set_icon_name().

| void gui2::ttoggle_button::set_retval | ( | const int | retval | ) |
Definition at line 112 of file toggle_button.cpp.
References retval_, and gui2::tevent_executor::set_wants_mouse_left_double_click().

| void gui2::ttoggle_button::set_state | ( | const tstate | state | ) | [private] |
Definition at line 122 of file toggle_button.cpp.
References gui2::twidget::set_dirty(), and state_.
Referenced by set_active(), set_value(), signal_handler_left_button_click(), signal_handler_mouse_enter(), and signal_handler_mouse_leave().


| void gui2::ttoggle_button::set_value | ( | const bool | selected | ) | [virtual] |
Inherited from tselectable_.
Implements gui2::tselectable_.
Definition at line 99 of file toggle_button.cpp.
References ENABLED_SELECTED, get_value(), set_state(), and state_.
Referenced by gui2::teditor_settings::do_next_tod(), gui2::tlobby_main::pre_show(), gui2::teditor_resize_map::pre_show(), and gui2::teditor_resize_map::update_expand_direction().


| void gui2::ttoggle_button::signal_handler_left_button_click | ( | const event::tevent | event, | |
| bool & | handled | |||
| ) | [private] |
Definition at line 162 of file toggle_button.cpp.
References callback_state_change_, DBG_GUI_E, ENABLED, ENABLED_SELECTED, get_value(), LOG_HEADER, sound::play_UI_sound(), set_state(), and gui2::settings::sound_toggle_button_click.
Referenced by ttoggle_button().


| void gui2::ttoggle_button::signal_handler_left_button_double_click | ( | const event::tevent | event, | |
| bool & | handled | |||
| ) | [private] |
Definition at line 181 of file toggle_button.cpp.
References DBG_GUI_E, gui2::twidget::get_window(), LOG_HEADER, retval_, and gui2::twindow::set_retval().
Referenced by ttoggle_button().


| void gui2::ttoggle_button::signal_handler_mouse_enter | ( | const event::tevent | event, | |
| bool & | handled | |||
| ) | [private] |
Definition at line 136 of file toggle_button.cpp.
References DBG_GUI_E, FOCUSSED, FOCUSSED_SELECTED, get_value(), LOG_HEADER, and set_state().
Referenced by ttoggle_button().


| void gui2::ttoggle_button::signal_handler_mouse_leave | ( | const event::tevent | event, | |
| bool & | handled | |||
| ) | [private] |
Definition at line 149 of file toggle_button.cpp.
References DBG_GUI_E, ENABLED, ENABLED_SELECTED, get_value(), LOG_HEADER, and set_state().
Referenced by ttoggle_button().


| void gui2::ttoggle_button::update_canvas | ( | ) |
Inherited from tcontrol.
Definition at line 85 of file toggle_button.cpp.
References gui2::tcontrol::canvas(), icon_name_, gui2::twidget::set_dirty(), and gui2::tcanvas::set_variable().
Referenced by set_icon_name().


boost::function<void (twidget*) gui2::ttoggle_button::callback_state_change_) [private] |
See tselectable_::set_callback_state_change.
Definition at line 109 of file toggle_button.hpp.
Referenced by set_callback_state_change(), and signal_handler_left_button_click().
std::string gui2::ttoggle_button::icon_name_ [private] |
The toggle button can contain an icon next to the text.
Maybe this will move the the tcontrol class if deemed needed.
Definition at line 115 of file toggle_button.hpp.
Referenced by icon_name(), set_icon_name(), and update_canvas().
int gui2::ttoggle_button::retval_ [private] |
The return value of the button.
If this value is not 0 and the button is double clicked it sets the retval of the window and the window closes itself.
Definition at line 106 of file toggle_button.hpp.
Referenced by set_retval(), and signal_handler_left_button_double_click().
tstate gui2::ttoggle_button::state_ [private] |
Current state of the widget.
The state of the widget determines what to render and how the widget reacts to certain 'events'.
Definition at line 98 of file toggle_button.hpp.
Referenced by get_active(), get_state(), get_value(), set_state(), and set_value().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:23:32 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |