The Battle for Wesnoth  1.13.10+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::styled_widget Class Referenceabstract

Base class for all visible items. More...

#include <styled_widget.hpp>

Inheritance diagram for gui2::styled_widget:
Inheritance graph

Public Member Functions

 styled_widget (const implementation::builder_styled_widget &builder, const std::string &control_type)
 Constructor. More...
 
virtual void set_members (const string_map &data)
 Sets the members of the styled_widget. More...
 
virtual void set_active (const bool active)=0
 Sets the styled_widget's state. More...
 
virtual bool get_active () const =0
 Gets the active state of the styled_widget. More...
 
bool disable_click_dismiss () const override
 See widget::disable_click_dismiss. More...
 
virtual iteration::walker_basecreate_walker () override
 See widget::create_walker. More...
 
point get_config_minimum_size () const
 Gets the minimum size as defined in the config. More...
 
point get_config_default_size () const
 Gets the default size as defined in the config. More...
 
point 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 color_t get_link_color () const
 Returns the color string to be used with links. More...
 
virtual void layout_initialize (const bool full_initialization) override
 See widget::layout_initialize. More...
 
virtual void request_reduce_width (const unsigned maximum_width) override
 See widget::request_reduce_width. More...
 
virtual void request_reduce_height (const unsigned maximum_height) override
 See widget::request_reduce_height. More...
 
virtual void place (const point &origin, const point &size) override
 See widget::place. More...
 
virtual widgetfind_at (const point &coordinate, const bool must_be_active) override
 See widget::find_at. More...
 
virtual const widgetfind_at (const point &coordinate, const bool must_be_active) const override
 See widget::find_at. More...
 
widgetfind (const std::string &id, const bool must_be_active) override
 See widget::find. More...
 
const widgetfind (const std::string &id, const bool must_be_active) const override
 See widget::find. More...
 
bool get_use_tooltip_on_label_overflow () const
 
void set_use_tooltip_on_label_overflow (const bool use_tooltip=true)
 
const t_stringget_label () 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< canvas > & get_canvases ()
 
canvasget_canvas (const unsigned index)
 
virtual void set_text_alignment (const PangoAlignment text_alignment)
 
PangoAlignment get_text_alignment () const
 
void set_text_ellipse_mode (const PangoEllipsizeMode ellipse_mode)
 
PangoEllipsizeMode get_text_ellipse_mode () const
 Get the text's ellipsize mode. More...
 
virtual const std::string & get_control_type () const =0
 Returns the control_type of the styled_widget. More...
 
- Public Member Functions inherited from gui2::widget
 widget (const widget &)=delete
 
widgetoperator= (const widget &)=delete
 
 widget ()
 
 widget (const builder_widget &builder)
 Constructor. More...
 
virtual ~widget () override
 
void set_id (const std::string &id)
 
const std::string & id () const
 
windowget_window ()
 Get the parent window. More...
 
const windowget_window () const
 The constant version of get_window. More...
 
gridget_parent_grid ()
 Get the parent grid. More...
 
dialogs::modal_dialogdialog ()
 Returns the top-level dialog. More...
 
void set_parent (widget *parent)
 
widgetparent ()
 
virtual void demand_reduce_width (const unsigned maximum_width)
 Tries to reduce the width of a widget. More...
 
virtual void demand_reduce_height (const unsigned maximum_height)
 Tries to reduce the height of a widget. More...
 
point 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 point &origin)
 Sets the origin of the widget. More...
 
virtual void set_size (const point &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 set_horizontal_alignment (const std::string &alignment)
 Sets the horizontal alignment of the widget within its parent grid. More...
 
virtual void set_vertical_alignment (const std::string &alignment)
 Sets the horizontal alignment of the widget within its parent grid. More...
 
virtual void layout_children ()
 Allows a widget to update its children. More...
 
point get_origin () const
 Returns the screen origin of the widget. More...
 
point 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 (window &caller, std::vector< widget * > &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 visibility visible)
 
visibility get_visible () const
 
redraw_action get_drawing_action () const
 
void set_debug_border_mode (const unsigned debug_border_mode)
 
void set_debug_border_color (const color_t debug_border_color)
 
virtual bool has_widget (const widget &widget) const
 Does the widget contain the widget. More...
 
- Public Member Functions inherited from gui2::event_executor
 event_executor ()
 
virtual ~event_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
 
event_executorset_wants_mouse_right_double_click (const bool click=true)
 
bool wants_mouse_right_double_click () const
 
- Public Member Functions inherited from gui2::event::dispatcher
 dispatcher ()
 
virtual ~dispatcher ()
 
void connect ()
 Connects the dispatcher to the event handler. More...
 
bool has_event (const ui_event event, const event_queue_type event_type)
 
bool fire (const ui_event event, widget &target)
 Fires an event which has no extra parameters. More...
 
bool fire (const ui_event event, widget &target, const point &coordinate)
 Fires an event which takes a coordinate parameter. More...
 
bool fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const utf8::string &unicode)
 Fires an event which takes keyboard parameters. More...
 
bool fire (const ui_event event, widget &target, const point &pos, const point &distance)
 Fires an event which takes touch parameters. More...
 
bool fire (const ui_event event, widget &target, void *)
 Fires an event which takes notification parameters. More...
 
bool fire (const ui_event event, widget &target, message &msg)
 Fires an event which takes message parameters. More...
 
bool fire (const ui_event event, widget &target, const SDL_Event &sdlevent)
 Fires an event that's a raw SDL event. More...
 
bool fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len)
 Fires an event which takes text input parameters. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event, E >::value > 
connect_signal (const signal_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event, E >::value > 
disconnect_signal (const signal_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_mouse, E >::value > 
connect_signal (const signal_mouse_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_mouse. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_mouse, E >::value > 
disconnect_signal (const signal_mouse_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_mouse. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_keyboard, E >
::value > 
connect_signal (const signal_keyboard_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_keyboard. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_keyboard, E >
::value > 
disconnect_signal (const signal_keyboard_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_keyboard. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_touch, E >::value > 
connect_signal (const signal_touch_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_touch. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_touch, E >::value > 
disconnect_signal (const signal_touch_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_touch. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_notification, E >
::value > 
connect_signal (const signal_notification_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_notification. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_notification, E >
::value > 
disconnect_signal (const signal_notification_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_notification. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_message, E >
::value > 
connect_signal (const signal_message_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_message. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_message, E >
::value > 
disconnect_signal (const signal_message_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_message. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_raw_event, E >
::value > 
connect_signal (const signal_raw_event_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_raw_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_raw_event, E >
::value > 
disconnect_signal (const signal_raw_event_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_raw_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_text_input, E >
::value > 
connect_signal (const signal_text_input_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_text_input. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_text_input, E >
::value > 
disconnect_signal (const signal_text_input_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_text_input. More...
 
void capture_mouse ()
 Captures the mouse. More...
 
void release_mouse ()
 Releases the mouse capture. More...
 
void set_mouse_behavior (const mouse_behavior mouse_behavior)
 
mouse_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 hotkey_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 point calculate_best_size () const override
 See widget::calculate_best_size. More...
 
resolution_definition_ptr config ()
 
resolution_definition_const_ptr config () const
 
template<typename T >
std::shared_ptr< const
typename T::resolution > 
cast_config_to () const
 Casts the current resolution definition config to the respective type of a derived widget. More...
 
void set_config (resolution_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 widget::impl_draw_background. More...
 
virtual void impl_draw_foreground (surface &frame_buffer, int x_offset, int y_offset) override
 See widget::impl_draw_foreground. More...
 
std::string get_label_token (const point &position, const char *delimiters=" \n\r\t") const
 Exposes font::pango_text::get_token, for the text label of this styled_widget. More...
 
std::string get_label_link (const point &position) const
 
- Protected Member Functions inherited from gui2::widget
void set_layout_size (const point &size)
 
const pointlayout_size () const
 
void clear_layout_size ()
 Throws away layout_size_. More...
 

Private Member Functions

point get_best_text_size (point minimum_size, point maximum_size={0, 0}) const
 Gets the best size for a text. More...
 
virtual bool text_can_shrink ()
 Gets whether a widget can shrink past its optimal size even if it's text-based (such as labels);. More...
 
void signal_handler_show_tooltip (const event::ui_event event, bool &handled, const point &location)
 
void signal_handler_show_helptip (const event::ui_event event, bool &handled, const point &location)
 
void signal_handler_notify_remove_tooltip (const event::ui_event 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 styled_widget. 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...
 
resolution_definition_ptr config_
 Contains the pointer to the configuration. More...
 
std::vector< canvascanvases_
 Holds all canvas objects for a styled_widget. More...
 
font::pango_text renderer_
 Contains a helper cache for the rendering. More...
 
int text_maximum_width_
 The maximum width for the text in a styled_widget. More...
 
PangoAlignment text_alignment_
 The alignment of the text in a styled_widget. More...
 
PangoEllipsizeMode text_ellipse_mode_
 The ellipsize mode of the text in a styled_widget. More...
 
bool shrunken_
 Is the widget smaller as it's best size? More...
 

Friends

class debug_layout_graph
 

Additional Inherited Members

- Public Types inherited from gui2::widget
enum  visibility { visibility::visible, visibility::hidden, visibility::invisible }
 Visibility settings done by the user. More...
 
enum  redraw_action { redraw_action::full, redraw_action::partly, redraw_action::none }
 Visibility set by the engine. More...
 
- Public Types inherited from gui2::event::dispatcher
enum  event_queue_type { pre = 1, child = 2, post = 4 }
 
enum  queue_position {
  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  mouse_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 styled_widget.hpp.

Constructor & Destructor Documentation

gui2::styled_widget::styled_widget ( const implementation::builder_styled_widget builder,
const std::string &  control_type 
)

Constructor.

Parameters
builderThe builder object with the settings for the object.

Definition at line 46 of file styled_widget.cpp.

References canvases_, config_, t_string::empty(), i, gui2::event_executor::set_wants_mouse_hover(), signal_handler_notify_remove_tooltip(), signal_handler_show_helptip(), signal_handler_show_tooltip(), tooltip_, and update_canvas().

Member Function Documentation

point gui2::styled_widget::calculate_best_size ( ) const
overrideprotectedvirtual
template<typename T >
std::shared_ptr<const typename T::resolution> gui2::styled_widget::cast_config_to ( ) const
inlineprotected
resolution_definition_ptr gui2::styled_widget::config ( )
inlineprotected
resolution_definition_const_ptr gui2::styled_widget::config ( ) const
inlineprotected

Definition at line 286 of file styled_widget.hpp.

References config_.

iteration::walker_base * gui2::styled_widget::create_walker ( )
overridevirtual

See widget::create_walker.

Implements gui2::widget.

Reimplemented in gui2::matrix, and gui2::container_base.

Definition at line 134 of file styled_widget.cpp.

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

See widget::disable_click_dismiss.

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

Implements gui2::widget.

Definition at line 129 of file styled_widget.cpp.

References get_active(), gui2::widget::get_visible(), and gui2::widget::visible.

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

widget * gui2::styled_widget::find ( const std::string &  id,
const bool  must_be_active 
)
overridevirtual

See widget::find.

Reimplemented from gui2::widget.

Reimplemented in gui2::window.

Definition at line 305 of file styled_widget.cpp.

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

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

const widget * gui2::styled_widget::find ( const std::string &  id,
const bool  must_be_active 
) const
overridevirtual

See widget::find.

Reimplemented from gui2::widget.

Reimplemented in gui2::window.

Definition at line 313 of file styled_widget.cpp.

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

widget * gui2::styled_widget::find_at ( const point coordinate,
const bool  must_be_active 
)
overridevirtual
const widget * gui2::styled_widget::find_at ( const point coordinate,
const bool  must_be_active 
) const
overridevirtual
virtual bool gui2::styled_widget::get_active ( ) const
pure virtual
point gui2::styled_widget::get_best_text_size ( point  minimum_size,
point  maximum_size = {0, 0} 
) const
private
canvas& gui2::styled_widget::get_canvas ( const unsigned  index)
inline
std::vector<canvas>& gui2::styled_widget::get_canvases ( )
inline
unsigned gui2::styled_widget::get_characters_per_line ( ) const
virtual

Returns the number of characters per line.

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

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

Reimplemented in gui2::label.

Definition at line 169 of file styled_widget.cpp.

Referenced by get_best_text_size(), and update_canvas().

point gui2::styled_widget::get_config_default_size ( ) const

Gets the default size as defined in the config.

Precondition
config_ != nullptr
Returns
The size.

Definition at line 149 of file styled_widget.cpp.

References config_, DBG_GUI_L, and LOG_HEADER.

Referenced by gui2::image::calculate_best_size(), gui2::container_base::calculate_best_size(), and calculate_best_size().

point gui2::styled_widget::get_config_maximum_size ( ) const

Gets the best size as defined in the config.

Precondition
config_ != nullptr
Returns
The size.

Definition at line 159 of file styled_widget.cpp.

References config_, DBG_GUI_L, and LOG_HEADER.

Referenced by gui2::image::calculate_best_size(), calculate_best_size(), and gui2::grid::child::place().

point gui2::styled_widget::get_config_minimum_size ( ) const

Gets the minimum size as defined in the config.

Precondition
config_ != nullptr
Returns
The size.

Definition at line 139 of file styled_widget.cpp.

References config_, DBG_GUI_L, and LOG_HEADER.

Referenced by request_reduce_height(), and request_reduce_width().

virtual const std::string& gui2::styled_widget::get_control_type ( ) const
pure virtual
const t_string& gui2::styled_widget::get_label ( ) const
inline
std::string gui2::styled_widget::get_label_link ( const point position) const
protected
std::string gui2::styled_widget::get_label_token ( const point position,
const char *  delimiters = " \n\r\t" 
) const
protected

Exposes font::pango_text::get_token, for the text label of this styled_widget.

Definition at line 558 of file styled_widget.cpp.

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

bool gui2::styled_widget::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 pango_text::set_link_aware (indirectly).

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

Reimplemented in gui2::label.

Definition at line 174 of file styled_widget.cpp.

Referenced by get_best_text_size(), and update_canvas().

color_t gui2::styled_widget::get_link_color ( ) const
virtual

Returns the color string to be used with links.

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

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

Reimplemented in gui2::label.

Definition at line 179 of file styled_widget.cpp.

References color_t::from_hex_string().

Referenced by get_best_text_size(), and update_canvas().

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

Definition at line 263 of file styled_widget.hpp.

References text_alignment_.

PangoEllipsizeMode gui2::styled_widget::get_text_ellipse_mode ( ) const
inline

Get the text's ellipsize mode.

Note that if can_wrap is true, it override the manual setting.

Definition at line 275 of file styled_widget.hpp.

References gui2::widget::can_wrap(), and text_ellipse_mode_.

Referenced by get_best_text_size(), and update_canvas().

int gui2::styled_widget::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 407 of file styled_widget.cpp.

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

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

int gui2::styled_widget::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 399 of file styled_widget.cpp.

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

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

bool gui2::styled_widget::get_use_markup ( ) const
inline
bool gui2::styled_widget::get_use_tooltip_on_label_overflow ( ) const
inline

Definition at line 202 of file styled_widget.hpp.

References use_tooltip_on_label_overflow_.

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

Definition at line 238 of file styled_widget.hpp.

References help_message_.

Referenced by set_help_message().

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

See widget::impl_draw_foreground.

Reimplemented from gui2::widget.

Reimplemented in gui2::toggle_panel, and gui2::panel.

Definition at line 425 of file styled_widget.cpp.

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

void gui2::styled_widget::layout_initialize ( const bool  full_initialization)
overridevirtual

See widget::layout_initialize.

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

Reimplemented from gui2::widget.

Reimplemented in gui2::matrix, gui2::scrollbar_container, and gui2::container_base.

Definition at line 184 of file styled_widget.cpp.

References gui2::widget::layout_initialize(), and shrunken_.

Referenced by gui2::container_base::layout_initialize().

void gui2::styled_widget::place ( const point origin,
const point size 
)
overridevirtual
void gui2::styled_widget::request_reduce_height ( const unsigned  maximum_height)
overridevirtual
void gui2::styled_widget::request_reduce_width ( const unsigned  maximum_width)
overridevirtual
virtual void gui2::styled_widget::set_active ( const bool  active)
pure virtual
void gui2::styled_widget::set_config ( resolution_definition_ptr  config)
inlineprotected

Definition at line 310 of file styled_widget.hpp.

References config(), and config_.

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

Definition at line 244 of file styled_widget.hpp.

References help_message(), and help_message_.

Referenced by set_members().

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

Reimplemented in gui2::scroll_label.

Definition at line 322 of file styled_widget.cpp.

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

Referenced by gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::dialogs::chat_log::model::clear_chat_msg_list(), gui2::dialogs::gamestate_inspector::view::clear_stuff_list(), gui2::dialogs::story_viewer::display_part(), gui2::scroll_label::finalize_subclass(), gui2::dialogs::synched_choice_wait::handle_generic_event(), gui2::dialogs::message_implementation::init_button(), lua_gui2::intf_set_dialog_value(), gui2::dialogs::addon_manager::on_addon_select(), gui2::dialogs::mp_create_game::on_game_select(), gui2::dialogs::chat_log::model::populate_chat_message_list(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::lua_interpreter::pre_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::synched_choice_wait::pre_show(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::mp_join_game::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::network_transmission::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::simple_item_selector::pre_show(), gui2::dialogs::message::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::field< T, W, CT >::restore(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), gui2::image::set_image(), gui2::scroll_label::set_label(), set_members(), gui2::menu_button::set_selected(), gui2::menu_button::set_values(), gui2::multimenu_button::set_values(), gui2::dialogs::mp_create_game::show_description(), gui2::dialogs::loading_screen::timer_callback(), gui2::dialogs::addon_manager::toggle_details(), gui2::dialogs::gamestate_inspector::view::update(), gui2::dialogs::game_cache_options::update_cache_size_display(), gui2::dialogs::mp_create_game::update_details(), gui2::multimenu_button::update_label(), gui2::dialogs::mp_staging::update_leader_display(), gui2::dialogs::sub_player_list::update_player_count_label(), gui2::dialogs::lobby_player_info::update_relation(), and gui2::dialogs::chat_log::controller::update_view_from_model().

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

Sets the members of the styled_widget.

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::toggle_button.

Definition at line 89 of file styled_widget.cpp.

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

Referenced by gui2::pane::create_item(), gui2::policy::select_action::show::init(), gui2::toggle_panel::set_child_members(), and gui2::toggle_button::set_members().

void gui2::styled_widget::set_text_alignment ( const PangoAlignment  text_alignment)
virtual
void gui2::styled_widget::set_text_ellipse_mode ( const PangoEllipsizeMode  ellipse_mode)
void gui2::styled_widget::set_tooltip ( const t_string tooltip)
inline
void gui2::styled_widget::set_use_markup ( bool  use_markup)
virtual
void gui2::styled_widget::set_use_tooltip_on_label_overflow ( const bool  use_tooltip = true)
inline

Definition at line 207 of file styled_widget.hpp.

References use_tooltip_on_label_overflow_.

void gui2::styled_widget::signal_handler_notify_remove_tooltip ( const event::ui_event  event,
bool &  handled 
)
private

Definition at line 543 of file styled_widget.cpp.

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

Referenced by styled_widget().

void gui2::styled_widget::signal_handler_show_helptip ( const event::ui_event  event,
bool &  handled,
const point location 
)
private
void gui2::styled_widget::signal_handler_show_tooltip ( const event::ui_event  event,
bool &  handled,
const point location 
)
private
virtual bool gui2::styled_widget::text_can_shrink ( )
inlineprivatevirtual

Gets whether a widget can shrink past its optimal size even if it's text-based (such as labels);.

Reimplemented in gui2::label.

Definition at line 446 of file styled_widget.hpp.

Referenced by request_reduce_width().

const t_string& gui2::styled_widget::tooltip ( ) const
inline
void gui2::styled_widget::update_canvas ( )
protectedvirtual

Friends And Related Function Documentation

friend class debug_layout_graph
friend

Definition at line 36 of file styled_widget.hpp.

Member Data Documentation

std::vector<canvas> gui2::styled_widget::canvases_
private

Holds all canvas objects for a styled_widget.

A styled_widget 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 399 of file styled_widget.hpp.

Referenced by get_canvas(), get_canvases(), place(), styled_widget(), and update_canvas().

resolution_definition_ptr gui2::styled_widget::config_
private

Contains the pointer to the configuration.

Every styled_widget 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 389 of file styled_widget.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(), set_config(), and styled_widget().

std::string gui2::styled_widget::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 349 of file styled_widget.hpp.

t_string gui2::styled_widget::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 378 of file styled_widget.hpp.

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

t_string gui2::styled_widget::label_
private
font::pango_text gui2::styled_widget::renderer_
mutableprivate

Contains a helper cache for the rendering.

Creating a pango_text 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 462 of file styled_widget.hpp.

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

bool gui2::styled_widget::shrunken_
private

Is the widget smaller as it's best size?

Definition at line 474 of file styled_widget.hpp.

Referenced by layout_initialize().

PangoAlignment gui2::styled_widget::text_alignment_
private

The alignment of the text in a styled_widget.

Definition at line 468 of file styled_widget.hpp.

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

PangoEllipsizeMode gui2::styled_widget::text_ellipse_mode_
private

The ellipsize mode of the text in a styled_widget.

Definition at line 471 of file styled_widget.hpp.

Referenced by get_text_ellipse_mode(), and set_text_ellipse_mode().

int gui2::styled_widget::text_maximum_width_
private

The maximum width for the text in a styled_widget.

Definition at line 465 of file styled_widget.hpp.

Referenced by get_best_text_size(), and get_text_maximum_width().

t_string gui2::styled_widget::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 370 of file styled_widget.hpp.

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

bool gui2::styled_widget::use_markup_
private

Use markup for the label?

Definition at line 355 of file styled_widget.hpp.

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

bool gui2::styled_widget::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 362 of file styled_widget.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: