Public Member Functions | Private Types | Private Member Functions | Private Attributes

gui2::ttoggle_button Class Reference

Class for a toggle button. More...

#include <toggle_button.hpp>

Inheritance diagram for gui2::ttoggle_button:
Inheritance graph
[legend]
Collaboration diagram for gui2::ttoggle_button:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

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.


Member Enumeration Documentation

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.

Enumerator:
ENABLED 
DISABLED 
FOCUSSED 
ENABLED_SELECTED 
DISABLED_SELECTED 
FOCUSSED_SELECTED 
COUNT 

Definition at line 85 of file toggle_button.hpp.


Constructor & Destructor Documentation

gui2::ttoggle_button::ttoggle_button (  ) 

Member Function Documentation

bool gui2::ttoggle_button::get_active (  )  const [inline]

Inherited from tcontrol.

Definition at line 49 of file toggle_button.hpp.

References DISABLED, and state_.

const std::string & gui2::ttoggle_button::get_control_type (  )  const [private]

Inherited from tcontrol.

Definition at line 130 of file toggle_button.cpp.

References type.

unsigned gui2::ttoggle_button::get_state (  )  const [inline]

Inherited from tcontrol.

Definition at line 53 of file toggle_button.hpp.

References state_.

bool gui2::ttoggle_button::get_value (  )  const [inline, virtual]
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().

Here is the call graph for this function:

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

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

boost::function<void (twidget*) gui2::ttoggle_button::callback_state_change_) [private]
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().

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

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:23:32 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs