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 Member Functions | Private Attributes | Friends | List of all members
gui2::tcontrol Class Referenceabstract

Base class for all visible items. More...

#include <control.hpp>

Inheritance diagram for gui2::tcontrol:
Inheritance graph

Public Member Functions

 tcontrol (const unsigned canvas_count)
 
 tcontrol (const implementation::tbuilder_control &builder, const unsigned canvas_count, const std::string &control_type)
 Constructor. More...
 
virtual void set_members (const string_map &data)
 Sets the members of the control. More...
 
virtual void set_active (const bool active)=0
 Sets the control's state. More...
 
virtual bool get_active () const =0
 Gets the active state of the control. More...
 
bool disable_click_dismiss () const override
 See twidget::disable_click_dismiss. More...
 
virtual iterator::twalker_create_walker () override
 See twidget::create_walker. More...
 
tpoint get_config_minimum_size () const
 Gets the minimum size as defined in the config. More...
 
tpoint get_config_default_size () const
 Gets the default size as defined in the config. More...
 
tpoint get_config_maximum_size () const
 Gets the best size as defined in the config. More...
 
virtual unsigned get_characters_per_line () const
 Returns the number of characters per line. More...
 
virtual bool get_link_aware () const
 Returns whether the label should be link_aware, in in rendering and in searching for links with get_link. More...
 
virtual std::string get_link_color () const
 Returns the color string to be used with links. More...
 
virtual void layout_initialise (const bool full_initialisation) override
 See twidget::layout_initialise. More...
 
virtual void request_reduce_width (const unsigned maximum_width) override
 See twidget::request_reduce_width. More...
 
virtual void place (const tpoint &origin, const tpoint &size) override
 See twidget::place. More...
 
virtual twidgetfind_at (const tpoint &coordinate, const bool must_be_active) override
 See twidget::find_at. More...
 
virtual const twidgetfind_at (const tpoint &coordinate, const bool must_be_active) const override
 See twidget::find_at. More...
 
twidgetfind (const std::string &id, const bool must_be_active) override
 See twidget::find. More...
 
const twidgetfind (const std::string &id, const bool must_be_active) const override
 See twidget::find. More...
 
void set_definition (const std::string &definition)
 Sets the definition. More...
 
bool get_use_tooltip_on_label_overflow () const
 
void set_use_tooltip_on_label_overflow (const bool use_tooltip=true)
 
const t_stringlabel () const
 
virtual void set_label (const t_string &label)
 
virtual void set_use_markup (bool use_markup)
 
bool get_use_markup () const
 
const t_stringtooltip () const
 
void set_tooltip (const t_string &tooltip)
 
const t_stringhelp_message () const
 
void set_help_message (const t_string &help_message)
 
std::vector< tcanvas > & canvas ()
 
tcanvascanvas (const unsigned index)
 
void set_text_alignment (const PangoAlignment text_alignment)
 
PangoAlignment get_text_alignment () const
 
virtual const std::stringget_control_type () const =0
 Returns the control_type of the control. More...
 
- Public Member Functions inherited from gui2::twidget
 twidget ()
 
 twidget (const tbuilder_widget &builder)
 Constructor. More...
 
virtual ~twidget () override
 
void set_id (const std::string &id)
 
const std::stringid () const
 
twindowget_window ()
 Get the parent window. More...
 
const twindowget_window () const
 The constant version of get_window. More...
 
tdialogdialog ()
 Returns the top-level dialogue. More...
 
void set_parent (twidget *parent)
 
twidgetparent ()
 
virtual void demand_reduce_width (const unsigned maximum_width)
 Tries to reduce the width of a widget. More...
 
virtual void request_reduce_height (const unsigned maximum_height)
 Tries to reduce the height of a widget. More...
 
virtual void demand_reduce_height (const unsigned maximum_height)
 Tries to reduce the height of a widget. More...
 
tpoint get_best_size () const
 Gets the best size for the widget. More...
 
virtual bool can_mouse_focus () const
 Whether the mouse move/click event go 'through' this widget. More...
 
virtual bool can_wrap () const
 Can the widget wrap. More...
 
virtual void set_origin (const tpoint &origin)
 Sets the origin of the widget. More...
 
virtual void set_size (const tpoint &size)
 Sets the size of the widget. More...
 
virtual void move (const int x_offset, const int y_offset)
 Moves a widget. More...
 
virtual void layout_children ()
 Allows a widget to update its children. More...
 
tpoint get_origin () const
 Returns the screen origin of the widget. More...
 
tpoint get_size () const
 Returns the size of the widget. More...
 
SDL_Rect get_rectangle () const
 Gets the bounding rectangle of the widget on the screen. More...
 
int get_x () const
 
int get_y () const
 
unsigned get_width () const
 
unsigned get_height () const
 
void set_linked_group (const std::string &linked_group)
 
SDL_Rect calculate_blitting_rectangle (const int x_offset, const int y_offset)
 Calculates the blitting rectangle of the widget. More...
 
SDL_Rect calculate_clipping_rectangle (const int x_offset, const int y_offset)
 Calculates the clipping rectangle of the widget. More...
 
void draw_background (surface &frame_buffer, int x_offset, int y_offset)
 Draws the background of a widget. More...
 
void draw_children (surface &frame_buffer, int x_offset, int y_offset)
 Draws the children of a widget. More...
 
void draw_foreground (surface &frame_buffer, int x_offset, int y_offset)
 Draws the foreground of the widget. More...
 
void populate_dirty_list (twindow &caller, std::vector< twidget * > &call_stack)
 Adds a widget to the dirty list if it is dirty. More...
 
SDL_Rect get_dirty_rectangle () const
 Gets the dirty rectangle of the widget. More...
 
virtual void set_visible_rectangle (const SDL_Rect &rectangle)
 Sets the visible rectangle for a widget. More...
 
void set_is_dirty (const bool is_dirty)
 
bool get_is_dirty () const
 
void set_visible (const tvisible::scoped_enum visible)
 
tvisible::scoped_enum get_visible () const
 
tredraw_action::scoped_enum get_drawing_action () const
 
void set_debug_border_mode (const unsigned debug_border_mode)
 
void set_debug_border_colour (const unsigned debug_border_colour)
 
virtual bool has_widget (const twidget &widget) const
 Does the widget contain the widget. More...
 
- Public Member Functions inherited from gui2::tevent_executor
 tevent_executor ()
 
virtual ~tevent_executor ()
 
void set_wants_mouse_hover (const bool hover=true)
 
bool wants_mouse_hover () const
 
void set_wants_mouse_left_double_click (const bool click=true)
 
bool wants_mouse_left_double_click () const
 
void set_wants_mouse_middle_double_click (const bool click=true)
 
bool wants_mouse_middle_double_click () const
 
tevent_executorset_wants_mouse_right_double_click (const bool click=true)
 
bool wants_mouse_right_double_click () const
 
- Public Member Functions inherited from gui2::event::tdispatcher
 tdispatcher ()
 
virtual ~tdispatcher ()
 
void connect ()
 Connects the dispatcher to the event handler. More...
 
bool has_event (const tevent event, const tevent_type event_type)
 
bool fire (const tevent event, twidget &target)
 Fires an event which has no extra parameters. More...
 
bool fire (const tevent event, twidget &target, const tpoint &coordinate)
 Fires an event which takes a coordinate parameter. More...
 
bool fire (const tevent event, twidget &target, const SDLKey key, const SDLMod modifier, const utf8::string &unicode)
 Fires an event which takes keyboard parameters. More...
 
bool fire (const tevent event, twidget &target, void *)
 Fires an event which takes notification parameters. More...
 
bool fire (const tevent event, twidget &target, tmessage &message)
 Fires an event which takes message parameters. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event, boost::mpl::int_
< E > > >::type 
connect_signal (const tsignal_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event, boost::mpl::int_
< E > > >::type 
disconnect_signal (const tsignal_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_mouse,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_mouse_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_mouse. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_mouse,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_mouse_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_mouse. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_keyboard,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_keyboard. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_keyboard,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_keyboard. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_notification,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_notification_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_notification. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_notification,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_notification_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_notification. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_message,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_message_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_message. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_message,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_message_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_message. More...
 
void capture_mouse ()
 Captures the mouse. More...
 
void release_mouse ()
 Releases the mouse capture. More...
 
void set_mouse_behavior (const tmouse_behavior mouse_behavior)
 
tmouse_behavior get_mouse_behavior () const
 
void set_want_keyboard_input (const bool want_keyboard_input)
 
bool get_want_keyboard_input () const
 
void register_hotkey (const hotkey::HOTKEY_COMMAND id, const thotkey_function &function)
 Registers a hotkey. More...
 
bool execute_hotkey (const hotkey::HOTKEY_COMMAND id)
 Executes a hotkey. More...
 

Protected Member Functions

virtual unsigned get_state () const =0
 Returns the id of the state. More...
 
virtual tpoint calculate_best_size () const override
 See twidget::calculate_best_size. More...
 
tresolution_definition_ptr config ()
 
tresolution_definition_const_ptr config () const
 
void set_config (tresolution_definition_ptr config)
 
virtual void update_canvas ()
 Updates the canvas(ses). More...
 
int get_text_maximum_width () const
 Returns the maximum width available for the text. More...
 
int get_text_maximum_height () const
 Returns the maximum height available for the text. More...
 
virtual void impl_draw_background (surface &frame_buffer, int x_offset, int y_offset) override
 See twidget::impl_draw_background. More...
 
virtual void impl_draw_foreground (surface &frame_buffer, int x_offset, int y_offset) override
 See twidget::impl_draw_foreground. More...
 
std::string get_label_token (const gui2::tpoint &position, const char *delimiters=" \n\r\t") const
 Exposes font::ttext::get_token, for the text label of this control. More...
 
std::string get_label_link (const gui2::tpoint &position) const
 
- Protected Member Functions inherited from gui2::twidget
void set_layout_size (const tpoint &size)
 
const tpointlayout_size () const
 

Private Member Functions

void load_config ()
 Loads the configuration of the widget. More...
 
virtual void load_config_extra ()
 Load class dependent config settings. More...
 
void definition_load_configuration (const std::string &control_type)
 Loads the configuration of the widget. More...
 
tpoint get_best_text_size (const tpoint &minimum_size, const tpoint &maximum_size=tpoint(0, 0)) const
 Gets the best size for a text. More...
 
void signal_handler_show_tooltip (const event::tevent event, bool &handled, const tpoint &location)
 
void signal_handler_show_helptip (const event::tevent event, bool &handled, const tpoint &location)
 
void signal_handler_notify_remove_tooltip (const event::tevent event, bool &handled)
 

Private Attributes

std::string definition_
 The definition is the id of that widget class. More...
 
t_string label_
 Contain the non-editable text associated with control. More...
 
bool use_markup_
 Use markup for the label? More...
 
bool use_tooltip_on_label_overflow_
 If the text doesn't fit on the label should the text be used as tooltip? More...
 
t_string tooltip_
 Tooltip text. More...
 
t_string help_message_
 Tooltip text. More...
 
std::vector< tcanvascanvas_
 Holds all canvas objects for a control. More...
 
tresolution_definition_ptr config_
 Contains the pointer to the configuration. More...
 
font::ttext renderer_
 Contains a helper cache for the rendering. More...
 
int text_maximum_width_
 The maximum width for the text in a control. More...
 
PangoAlignment text_alignment_
 The alignment of the text in a control. More...
 
bool shrunken_
 Is the widget smaller as it's best size? More...
 

Friends

class tdebug_layout_graph
 
class twindow
 Uses the load function. More...
 

Additional Inherited Members

- Public Types inherited from gui2::event::tdispatcher
enum  tevent_type { pre = 1, child = 2, post = 4 }
 
enum  tposition {
  front_pre_child, back_pre_child, front_child, back_child,
  front_post_child, back_post_child
}
 The position where to add a new callback in the signal handler. More...
 
enum  tmouse_behavior { all, hit, none }
 The behavior of the mouse events. More...
 

Detailed Description

Base class for all visible items.

Definition at line 34 of file control.hpp.

Constructor & Destructor Documentation

gui2::tcontrol::tcontrol ( const unsigned  canvas_count)
explicit
gui2::tcontrol::tcontrol ( const implementation::tbuilder_control builder,
const unsigned  canvas_count,
const std::string control_type 
)

Constructor.

Parameters
builderThe builder object with the settings for the object.
canvas_countThe number of canvasses in the control.

Definition at line 70 of file control.cpp.

References definition_load_configuration(), signal_handler_notify_remove_tooltip(), signal_handler_show_helptip(), and signal_handler_show_tooltip().

Member Function Documentation

tpoint gui2::tcontrol::calculate_best_size ( ) const
overrideprotectedvirtual
std::vector<tcanvas>& gui2::tcontrol::canvas ( )
inline
tcanvas& gui2::tcontrol::canvas ( const unsigned  index)
inline

Definition at line 286 of file control.hpp.

References canvas_.

tresolution_definition_ptr gui2::tcontrol::config ( )
inlineprotected
tresolution_definition_const_ptr gui2::tcontrol::config ( ) const
inlineprotected

Definition at line 303 of file control.hpp.

References config_.

iterator::twalker_ * gui2::tcontrol::create_walker ( )
overridevirtual

See twidget::create_walker.

Implements gui2::twidget.

Reimplemented in gui2::tmatrix, and gui2::tcontainer_.

Definition at line 144 of file control.cpp.

void gui2::tcontrol::definition_load_configuration ( const std::string control_type)
private

Loads the configuration of the widget.

Controls have their definition stored in a definition object. In order to determine sizes and drawing the widget this definition needs to be loaded. The member definition_ contains the name of the definition and function load the proper configuration.

Definition at line 423 of file control.cpp.

References canvas(), config(), definition_, gui2::get_control(), i, LOG_GUI_L, set_config(), and update_canvas().

Referenced by load_config(), and tcontrol().

bool gui2::tcontrol::disable_click_dismiss ( ) const
overridevirtual

See twidget::disable_click_dismiss.

The default behavior is that a widget blocks easy close, if not it should override this function.

Implements gui2::twidget.

Reimplemented in gui2::tmatrix, gui2::tscrollbar_container, gui2::timage, gui2::tspacer, gui2::tdrawing, gui2::tlabel, gui2::tminimap, and gui2::tprogress_bar.

Definition at line 139 of file control.cpp.

References get_active(), gui2::twidget::get_visible(), and gui2::twidget::tvisible::visible.

Referenced by gui2::tcontainer_::disable_click_dismiss().

twidget * gui2::tcontrol::find ( const std::string id,
const bool  must_be_active 
)
overridevirtual

See twidget::find.

Reimplemented from gui2::twidget.

Reimplemented in gui2::twindow, gui2::tmatrix, and gui2::tscrollbar_container.

Definition at line 301 of file control.cpp.

References gui2::twidget::find(), and get_active().

Referenced by gui2::tcontainer_::find().

const twidget * gui2::tcontrol::find ( const std::string id,
const bool  must_be_active 
) const
overridevirtual

See twidget::find.

Reimplemented from gui2::twidget.

Reimplemented in gui2::twindow, gui2::tmatrix, and gui2::tscrollbar_container.

Definition at line 309 of file control.cpp.

References gui2::twidget::find(), and get_active().

twidget * gui2::tcontrol::find_at ( const tpoint coordinate,
const bool  must_be_active 
)
overridevirtual
const twidget * gui2::tcontrol::find_at ( const tpoint coordinate,
const bool  must_be_active 
) const
overridevirtual
virtual bool gui2::tcontrol::get_active ( ) const
pure virtual
tpoint gui2::tcontrol::get_best_text_size ( const tpoint minimum_size,
const tpoint maximum_size = tpoint(0, 0) 
) const
private
unsigned gui2::tcontrol::get_characters_per_line ( ) const
virtual

Returns the number of characters per line.

This value is used to call ttext::set_characters_per_line (indirectly).

Returns
The characters per line. This implementation always returns 0.

Reimplemented in gui2::tlabel.

Definition at line 179 of file control.cpp.

Referenced by get_best_text_size(), and update_canvas().

tpoint gui2::tcontrol::get_config_default_size ( ) const

Gets the default size as defined in the config.

Precondition
config_ != nullptr
Returns
The size.

Definition at line 159 of file control.cpp.

References config_, DBG_GUI_L, and LOG_HEADER.

Referenced by calculate_best_size().

tpoint gui2::tcontrol::get_config_maximum_size ( ) const

Gets the best size as defined in the config.

Precondition
config_ != nullptr
Returns
The size.

Definition at line 169 of file control.cpp.

References config_, DBG_GUI_L, and LOG_HEADER.

Referenced by calculate_best_size(), and gui2::tgrid::tchild::place().

tpoint gui2::tcontrol::get_config_minimum_size ( ) const

Gets the minimum size as defined in the config.

Precondition
config_ != nullptr
Returns
The size.

Definition at line 149 of file control.cpp.

References config_, DBG_GUI_L, and LOG_HEADER.

Referenced by gui2::tcontainer_::calculate_best_size().

virtual const std::string& gui2::tcontrol::get_control_type ( ) const
pure virtual
std::string gui2::tcontrol::get_label_link ( const gui2::tpoint position) const
protected
std::string gui2::tcontrol::get_label_token ( const gui2::tpoint position,
const char *  delimiters = " \n\r\t" 
) const
protected

Exposes font::ttext::get_token, for the text label of this control.

Definition at line 562 of file control.cpp.

References font::ttext::get_token(), and renderer_.

bool gui2::tcontrol::get_link_aware ( ) const
virtual

Returns whether the label should be link_aware, in in rendering and in searching for links with get_link.

This value is used to call ttext::set_link_aware (indirectly).

Returns
The link aware status. This impl always always returns false.

Reimplemented in gui2::tlabel.

Definition at line 184 of file control.cpp.

Referenced by get_best_text_size(), and update_canvas().

std::string gui2::tcontrol::get_link_color ( ) const
virtual

Returns the color string to be used with links.

This value is used to call ttext::set_link_color (indirectly).

Returns
The link color string. This impl returns "#ffff00".

Reimplemented in gui2::tlabel.

Definition at line 189 of file control.cpp.

Referenced by get_best_text_size(), and update_canvas().

virtual unsigned gui2::tcontrol::get_state ( ) const
protectedpure virtual
PangoAlignment gui2::tcontrol::get_text_alignment ( ) const
inline

Definition at line 293 of file control.hpp.

References text_alignment_.

int gui2::tcontrol::get_text_maximum_height ( ) const
protected

Returns the maximum height available for the text.

This value makes sense after the widget has been given a size, since the maximum height is based on the height of the widget.

Definition at line 396 of file control.cpp.

References config_, and gui2::twidget::get_height().

Referenced by gui2::ttext_box::place(), gui2::ttext_box::update_canvas(), and update_canvas().

int gui2::tcontrol::get_text_maximum_width ( ) const
protected

Returns the maximum width available for the text.

This value makes sense after the widget has been given a size, since the maximum width is based on the width of the widget.

Definition at line 388 of file control.cpp.

References config_, gui2::twidget::get_width(), and text_maximum_width_.

Referenced by gui2::ttext_box::place(), gui2::ttext_box::update_canvas(), and update_canvas().

bool gui2::tcontrol::get_use_markup ( ) const
inline

Definition at line 255 of file control.hpp.

References use_markup_.

Referenced by gui2::tcombobox::signal_handler_left_button_click().

bool gui2::tcontrol::get_use_tooltip_on_label_overflow ( ) const
inline

Definition at line 239 of file control.hpp.

References use_tooltip_on_label_overflow_.

const t_string& gui2::tcontrol::help_message ( ) const
inline

Definition at line 271 of file control.hpp.

References help_message_.

Referenced by set_help_message().

void gui2::tcontrol::impl_draw_background ( surface frame_buffer,
int  x_offset,
int  y_offset 
)
overrideprotectedvirtual
void gui2::tcontrol::impl_draw_foreground ( surface frame_buffer,
int  x_offset,
int  y_offset 
)
overrideprotectedvirtual

See twidget::impl_draw_foreground.

Reimplemented from gui2::twidget.

Reimplemented in gui2::ttoggle_panel, and gui2::tpanel.

Definition at line 414 of file control.cpp.

Referenced by gui2::ttoggle_panel::impl_draw_foreground().

const t_string& gui2::tcontrol::label ( ) const
inline
void gui2::tcontrol::layout_initialise ( const bool  full_initialisation)
overridevirtual

See twidget::layout_initialise.

Todo:
Also handle the tooltip state. Handle if shrunken_ && use_tooltip_on_label_overflow_.

Reimplemented from gui2::twidget.

Reimplemented in gui2::tmatrix, gui2::tscrollbar_container, and gui2::tcontainer_.

Definition at line 194 of file control.cpp.

References gui2::twidget::layout_initialise(), and shrunken_.

Referenced by gui2::tcontainer_::layout_initialise().

void gui2::tcontrol::load_config ( )
private

Loads the configuration of the widget.

Controls have their definition stored in a definition object. In order to determine sizes and drawing the widget this definition needs to be loaded. The member definition_ contains the name of the definition and function load the proper configuration.

Deprecated:
definition_load_configuration() is the replacement.

Definition at line 274 of file control.cpp.

References config(), definition_load_configuration(), get_control_type(), and load_config_extra().

Referenced by set_definition(), and gui2::twindow::twindow().

virtual void gui2::tcontrol::load_config_extra ( )
inlineprivatevirtual

Load class dependent config settings.

load_config will call this method after loading the config, by default it does nothing but classes can override it to implement custom behavior.

Reimplemented in gui2::tscrollbar_, gui2::ttext_box, and gui2::tlabel.

Definition at line 405 of file control.hpp.

Referenced by load_config().

void gui2::tcontrol::place ( const tpoint origin,
const tpoint size 
)
overridevirtual
void gui2::tcontrol::request_reduce_width ( const unsigned  maximum_width)
overridevirtual
virtual void gui2::tcontrol::set_active ( const bool  active)
pure virtual
void gui2::tcontrol::set_config ( tresolution_definition_ptr  config)
inlineprotected

Definition at line 308 of file control.hpp.

References config(), and config_.

Referenced by definition_load_configuration().

void gui2::tcontrol::set_definition ( const std::string definition)

Sets the definition.

This function sets the definition of a control and should be called soon after creating the object since a lot of internal functions depend on the definition.

This function should be called one time only!!!

Definition at line 318 of file control.cpp.

References config(), definition_, gui2::init(), and load_config().

Referenced by gui2::tscrollbar_container::finalize_setup(), gui2::implementation::tbuilder_control::init_control(), gui2::tpreferences::initialize_members(), and gui2::twindow::twindow().

void gui2::tcontrol::set_help_message ( const t_string help_message)
inline

Definition at line 276 of file control.hpp.

References help_message(), and help_message_.

Referenced by gui2::implementation::tbuilder_control::init_control(), and set_members().

void gui2::tcontrol::set_label ( const t_string label)
virtual

Reimplemented in gui2::tscroll_label.

Definition at line 330 of file control.cpp.

References label(), label_, gui2::twidget::set_is_dirty(), gui2::twidget::set_layout_size(), and update_canvas().

Referenced by gui2::tsub_player_list::auto_hide(), gui2::tpreferences::bind_status_label(), gui2::tchat_log::model::clear_chat_msg_list(), gui2::tscroll_label::finalize_subclass(), gui2::tsynced_choice_wait::handle_generic_event(), gui2::tmessage_implementation::init_button(), gui2::implementation::tbuilder_control::init_control(), lua_gui2::intf_set_dialog_value(), gui2::tpreferences::max_autosaves_slider_callback(), gui2::taddon_list::on_addon_select(), gui2::tchat_log::model::populate_chat_message_list(), gui2::tsynced_choice_wait::pre_show(), gui2::tlua_interpreter::pre_show(), gui2::tcampaign_selection::pre_show(), gui2::tnetwork_transmission::pre_show(), gui2::tgame_version::pre_show(), gui2::tsimple_item_selector::pre_show(), gui2::tmessage::pre_show(), gui2::twml_message_::pre_show(), gui2::tfield< T, W, CT >::restore(), gui2::tunit_preview_pane::set_displayed_type(), gui2::tgamestate_inspector::model::set_inspect_window_text(), gui2::tscroll_label::set_label(), set_members(), gui2::tcombobox::set_selected(), gui2::tcombobox::set_values(), gui2::tgamestate_inspector::controller::show_title(), gui2::tcombobox::signal_handler_left_button_click(), gui2::tpreferences::status_label_callback(), gui2::tloadscreen::timer_callback(), gui2::tgame_cache_options::update_cache_size_display(), gui2::tlobby_player_info::update_relation(), gui2::tcustom_tod::update_selected_tod_info(), and gui2::tchat_log::controller::update_view_from_model().

void gui2::tcontrol::set_members ( const string_map data)
virtual

Sets the members of the control.

The map contains named members it can set, controls inheriting from us can add additional members to set by this function. The following members can by the following key:

  • label_ label
  • tooltip_ tooltip
  • help_message_ help
Parameters
dataMap with the key value pairs to set the members.
Todo:
document this feature on the wiki.
Todo:
do we need to add the debug colors here as well?

Reimplemented in gui2::ttoggle_button.

Definition at line 99 of file control.cpp.

References gui2::decode_text_alignment(), itor, set_help_message(), gui2::twidget::set_id(), set_label(), gui2::twidget::set_linked_group(), set_text_alignment(), set_tooltip(), set_use_markup(), and utils::string_bool().

Referenced by gui2::tpane::create_item(), gui2::policy::select_action::tshow::init(), gui2::ttree_view_node::init_grid(), gui2::ttoggle_panel::set_child_members(), and gui2::ttoggle_button::set_members().

void gui2::tcontrol::set_text_alignment ( const PangoAlignment  text_alignment)
void gui2::tcontrol::set_tooltip ( const t_string tooltip)
inline
void gui2::tcontrol::set_use_markup ( bool  use_markup)
virtual
void gui2::tcontrol::set_use_tooltip_on_label_overflow ( const bool  use_tooltip = true)
inline
void gui2::tcontrol::signal_handler_notify_remove_tooltip ( const event::tevent  event,
bool &  handled 
)
private

Definition at line 547 of file control.cpp.

References DBG_GUI_E, LOG_HEADER, and gui2::tip::remove().

Referenced by tcontrol().

void gui2::tcontrol::signal_handler_show_helptip ( const event::tevent  event,
bool &  handled,
const tpoint location 
)
private
void gui2::tcontrol::signal_handler_show_tooltip ( const event::tevent  event,
bool &  handled,
const tpoint location 
)
private
const t_string& gui2::tcontrol::tooltip ( ) const
inline

Definition at line 260 of file control.hpp.

References tooltip_.

Referenced by set_tooltip(), and gui2::twindow::show_tooltip().

void gui2::tcontrol::update_canvas ( )
protectedvirtual

Friends And Related Function Documentation

friend class tdebug_layout_graph
friend

Definition at line 36 of file control.hpp.

friend class twindow
friend

Uses the load function.

Note
This doesn't look really clean, but the final goal is refactor more code and call load_config in the ctor, removing the use case for the window. That however is a longer termine refactoring.

Definition at line 209 of file control.hpp.

Member Data Documentation

std::vector<tcanvas> gui2::tcontrol::canvas_
private

Holds all canvas objects for a control.

A control can have multiple states, which are defined in the classes inheriting from us. For every state there is a separate canvas, which is stored here. When drawing the state is determined and that canvas is drawn.

Definition at line 386 of file control.hpp.

Referenced by canvas(), place(), and update_canvas().

tresolution_definition_ptr gui2::tcontrol::config_
private

Contains the pointer to the configuration.

Every control has a definition of how it should look, this contains a pointer to the definition. The definition is resolution dependent, where the resolution is the size of the Wesnoth application window. Depending on the resolution widgets can look different, use different fonts. Windows can use extra scrollbars use abbreviations as text etc.

Definition at line 397 of file control.hpp.

Referenced by calculate_best_size(), config(), get_best_text_size(), get_config_default_size(), get_config_maximum_size(), get_config_minimum_size(), get_text_maximum_height(), get_text_maximum_width(), request_reduce_width(), and set_config().

std::string gui2::tcontrol::definition_
private

The definition is the id of that widget class.

Eg for a button it [button_definition]id. A button can have multiple definitions which all look different but for the engine still is a button.

Definition at line 347 of file control.hpp.

Referenced by definition_load_configuration(), and set_definition().

t_string gui2::tcontrol::help_message_
private

Tooltip text.

The help event can cause a tooltip to be shown, this is the text to be shown. At the moment the tooltip is a single line of text.

Definition at line 376 of file control.hpp.

Referenced by help_message(), set_help_message(), signal_handler_show_helptip(), and signal_handler_show_tooltip().

t_string gui2::tcontrol::label_
private

Contain the non-editable text associated with control.

Definition at line 350 of file control.hpp.

Referenced by calculate_best_size(), get_best_text_size(), impl_draw_background(), label(), place(), request_reduce_width(), set_label(), and update_canvas().

font::ttext gui2::tcontrol::renderer_
mutableprivate

Contains a helper cache for the rendering.

Creating a ttext object is quite expensive and is done on various occasions so it's cached here.

Todo:
Maybe if still too slow we might also copy this cache to the canvas so it can reuse our results, but for now it seems fast enough. Unfortunately that would make the dependency between the classes bigger as wanted.

Definition at line 485 of file control.hpp.

Referenced by get_best_text_size(), get_label_link(), get_label_token(), and place().

bool gui2::tcontrol::shrunken_
private

Is the widget smaller as it's best size?

Definition at line 494 of file control.hpp.

Referenced by layout_initialise().

PangoAlignment gui2::tcontrol::text_alignment_
private

The alignment of the text in a control.

Definition at line 491 of file control.hpp.

Referenced by get_best_text_size(), get_text_alignment(), set_text_alignment(), and update_canvas().

int gui2::tcontrol::text_maximum_width_
private

The maximum width for the text in a control.

Definition at line 488 of file control.hpp.

Referenced by get_best_text_size(), and get_text_maximum_width().

t_string gui2::tcontrol::tooltip_
private

Tooltip text.

The hovering event can cause a small tooltip to be shown, this is the text to be shown. At the moment the tooltip is a single line of text.

Definition at line 368 of file control.hpp.

Referenced by place(), set_tooltip(), signal_handler_show_tooltip(), and tooltip().

bool gui2::tcontrol::use_markup_
private

Use markup for the label?

Definition at line 353 of file control.hpp.

Referenced by get_best_text_size(), get_use_markup(), set_use_markup(), and update_canvas().

bool gui2::tcontrol::use_tooltip_on_label_overflow_
private

If the text doesn't fit on the label should the text be used as tooltip?

This only happens if the tooltip is empty.

Definition at line 360 of file control.hpp.

Referenced by get_use_tooltip_on_label_overflow(), place(), and set_use_tooltip_on_label_overflow().


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