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

gui2::ttoggle_panel Class Reference

Class for a toggle button. More...

#include <toggle_panel.hpp>

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

List of all members.

Public Member Functions

 ttoggle_panel ()
void set_child_members (const std::map< std::string, string_map > &data)
 Sets the members of the child controls.
twidgetfind_at (const tpoint &coordinate, const bool must_be_active)
 Inherited from tcontainer_.
const twidgetfind_at (const tpoint &coordinate, const bool must_be_active) const
 Inherited from tcontainer_.
void set_active (const bool active)
 Inherited from tpanel.
bool get_active () const
 Inherited from tpanel.
unsigned get_state () const
 Inherited from tpanel.
SDL_Rect get_client_rect () const
 Inherited from tpanel.
tpoint border_space () const
 Inherited from tpanel.
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_callback_mouse_left_double_click (boost::function< void(twidget *)> callback)

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)
void impl_draw_background (surface &frame_buffer)
 Inherited from tpanel.
void impl_draw_background (surface &frame_buffer, int x_offset, int y_offset)
 Inherited from tpanel.
void impl_draw_foreground (surface &frame_buffer)
 Inherited from tpanel.
void impl_draw_foreground (surface &frame_buffer, int x_offset, int y_offset)
 Inherited from tpanel.
const std::string & get_control_type () const
 Inherited from tpanel.
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_pre_left_button_click (const event::tevent event)
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.
boost::function< void(twidget *) callback_mouse_left_double_click_ )
 Mouse left double click callback.

Detailed Description

Class for a toggle button.

Quite some code looks like ttoggle_button maybe we should inherit from that but let's test first. the problem is that the toggle_button has an icon we don't want, but maybe look at refactoring later. but maybe we should also ditch the icon, not sure however since it's handy for checkboxes...

Definition at line 31 of file toggle_panel.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 126 of file toggle_panel.hpp.


Constructor & Destructor Documentation

gui2::ttoggle_panel::ttoggle_panel (  ) 

Member Function Documentation

tpoint gui2::ttoggle_panel::border_space (  )  const

Inherited from tpanel.

Todo:
only due to the fact our definition is slightly different from tpanel_definition we need to override this function and do about the same, look at a way to 'fix' that.

Definition at line 115 of file toggle_panel.cpp.

References gui2::tcontrol::config().

Here is the call graph for this function:

twidget* gui2::ttoggle_panel::find_at ( const tpoint coordinate,
const bool  must_be_active 
) [inline]

Inherited from tcontainer_.

Todo:
since there is no mouse event nesting (or event nesting at all) we need to capture all events. This means items on the panel will never receive an event, which gives problems with for example the intended button on the addon panel. So we need to chain mouse events as well and also add a handled flag for them.

Definition at line 49 of file toggle_panel.hpp.

Referenced by find_at().

Here is the caller graph for this function:

const twidget* gui2::ttoggle_panel::find_at ( const tpoint coordinate,
const bool  must_be_active 
) const [inline]

Inherited from tcontainer_.

Definition at line 64 of file toggle_panel.hpp.

References find_at().

Here is the call graph for this function:

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

Inherited from tpanel.

Definition at line 76 of file toggle_panel.hpp.

References DISABLED, and state_.

SDL_Rect gui2::ttoggle_panel::get_client_rect (  )  const

Inherited from tpanel.

Todo:
only due to the fact our definition is slightly different from tpanel_definition we need to override this function and do about the same, look at a way to 'fix' that.

Definition at line 100 of file toggle_panel.cpp.

References gui2::tcontrol::config(), and gui2::twidget::get_rect().

Here is the call graph for this function:

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

Inherited from tpanel.

Definition at line 157 of file toggle_panel.cpp.

References type.

Referenced by signal_handler_pre_left_button_click().

Here is the caller graph for this function:

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

Inherited from tpanel.

Definition at line 80 of file toggle_panel.hpp.

References state_.

bool gui2::ttoggle_panel::get_value (  )  const [inline, virtual]

Inherited from tselectable_.

Implements gui2::tselectable_.

Definition at line 101 of file toggle_panel.hpp.

References state_.

Referenced by set_active(), set_value(), signal_handler_left_button_click(), signal_handler_mouse_enter(), and signal_handler_mouse_leave().

Here is the caller graph for this function:

void gui2::ttoggle_panel::impl_draw_background ( surface frame_buffer,
int  x_offset,
int  y_offset 
) [inline, private]

Inherited from tpanel.

Definition at line 164 of file toggle_panel.hpp.

References impl_draw_background().

Here is the call graph for this function:

void gui2::ttoggle_panel::impl_draw_background ( surface frame_buffer  )  [inline, private]

Inherited from tpanel.

Definition at line 156 of file toggle_panel.hpp.

Referenced by impl_draw_background().

Here is the caller graph for this function:

void gui2::ttoggle_panel::impl_draw_foreground ( surface frame_buffer  )  [inline, private]

Inherited from tpanel.

Definition at line 172 of file toggle_panel.hpp.

Referenced by impl_draw_foreground().

Here is the caller graph for this function:

void gui2::ttoggle_panel::impl_draw_foreground ( surface frame_buffer,
int  x_offset,
int  y_offset 
) [inline, private]

Inherited from tpanel.

Definition at line 180 of file toggle_panel.hpp.

References impl_draw_foreground().

Here is the call graph for this function:

void gui2::ttoggle_panel::set_active ( const bool  active  ) 

Inherited from tpanel.

Definition at line 83 of file toggle_panel.cpp.

References DISABLED, DISABLED_SELECTED, ENABLED, ENABLED_SELECTED, get_value(), and set_state().

Here is the call graph for this function:

void gui2::ttoggle_panel::set_callback_mouse_left_double_click ( boost::function< void(twidget *)>  callback  )  [inline]

Definition at line 114 of file toggle_panel.hpp.

References callback_mouse_left_double_click_.

Referenced by gui2::tlobby_main::adjust_game_row_contents().

Here is the caller graph for this function:

void gui2::ttoggle_panel::set_callback_state_change ( boost::function< void(twidget *)>  callback  )  [inline, virtual]

Inherited from tselectable_.

Implements gui2::tselectable_.

Definition at line 111 of file toggle_panel.hpp.

References callback_state_change_.

void gui2::ttoggle_panel::set_child_members ( const std::map< std::string, string_map > &  data  ) 

Sets the members of the child controls.

Sets the members for all controls which have the proper member id. See tcontrol::set_members for more info.

Parameters:
data Map with the key value pairs to set the members.

Definition at line 71 of file toggle_panel.cpp.

References gui2::tcontainer_::find(), and gui2::tcontrol::set_members().

Referenced by gui2::ttree_view_node::init_grid().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttoggle_panel::set_retval ( const int  retval  ) 

Definition at line 138 of file toggle_panel.cpp.

References retval_.

void gui2::ttoggle_panel::set_state ( const tstate  state  )  [private]

Definition at line 143 of file toggle_panel.cpp.

References gui2::tcontrol::config(), 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_panel::set_value ( const bool  selected  )  [virtual]

Inherited from tselectable_.

Implements gui2::tselectable_.

Definition at line 125 of file toggle_panel.cpp.

References ENABLED_SELECTED, get_value(), set_state(), and state_.

Referenced by signal_handler_pre_left_button_click().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttoggle_panel::signal_handler_left_button_click ( const event::tevent  event,
bool &  handled 
) [private]

Definition at line 200 of file toggle_panel.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_panel_click.

Referenced by ttoggle_panel().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttoggle_panel::signal_handler_left_button_double_click ( const event::tevent  event,
bool &  handled 
) [private]

Definition at line 219 of file toggle_panel.cpp.

References callback_mouse_left_double_click_, DBG_GUI_E, gui2::twidget::get_window(), LOG_HEADER, retval_, and gui2::twindow::set_retval().

Referenced by ttoggle_panel().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttoggle_panel::signal_handler_mouse_enter ( const event::tevent  event,
bool &  handled 
) [private]

Definition at line 163 of file toggle_panel.cpp.

References DBG_GUI_E, FOCUSSED, FOCUSSED_SELECTED, get_value(), LOG_HEADER, and set_state().

Referenced by ttoggle_panel().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttoggle_panel::signal_handler_mouse_leave ( const event::tevent  event,
bool &  handled 
) [private]

Definition at line 176 of file toggle_panel.cpp.

References DBG_GUI_E, ENABLED, ENABLED_SELECTED, get_value(), LOG_HEADER, and set_state().

Referenced by ttoggle_panel().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttoggle_panel::signal_handler_pre_left_button_click ( const event::tevent  event  )  [private]

Definition at line 189 of file toggle_panel.cpp.

References callback_state_change_, DBG_GUI_E, get_control_type(), gui2::twidget::id(), and set_value().

Referenced by ttoggle_panel().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Mouse left double click callback.

Definition at line 153 of file toggle_panel.hpp.

Referenced by set_callback_mouse_left_double_click(), and signal_handler_left_button_double_click().

boost::function<void (twidget*) gui2::ttoggle_panel::callback_state_change_) [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 147 of file toggle_panel.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 139 of file toggle_panel.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:34 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs