The Battle for Wesnoth  1.17.0-dev
Public Member Functions | Private Attributes | List of all members
gui2::text_shape Class Reference

Key Type Default Description
font_family font_style "sans" The font family used for the text.
More...

#include <canvas_private.hpp>

Inheritance diagram for gui2::text_shape:

Public Member Functions

 text_shape (const config &cfg)
 Constructor. More...
 
void draw (surface &canvas, SDL_Renderer *renderer, const SDL_Rect &viewport, wfl::map_formula_callable &variables) override
 Draws the canvas. More...
 
- Public Member Functions inherited from gui2::canvas::shape
 shape (const config &cfg)
 
virtual ~shape ()
 
bool immutable () const
 

Private Attributes

font::family_class font_family_
 The text font family. More...
 
typed_formula< unsigned > font_size_
 The font size of the text. More...
 
font::pango_text::FONT_STYLE font_style_
 The style of the text. More...
 
typed_formula< PangoAlignment > text_alignment_
 The alignment of the text. More...
 
typed_formula< color_tcolor_
 The color of the text. More...
 
typed_formula< t_stringtext_
 The text to draw. More...
 
typed_formula< bool > text_markup_
 The text markup switch of the text. More...
 
typed_formula< bool > link_aware_
 The link aware switch of the text. More...
 
typed_formula< color_tlink_color_
 The link color of the text. More...
 
typed_formula< int > maximum_width_
 The maximum width for the text. More...
 
unsigned characters_per_line_
 The number of characters per line. More...
 
typed_formula< int > maximum_height_
 The maximum height for the text. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::rect_bounded_shape
 rect_bounded_shape (const config &cfg)
 Constructor. More...
 
calculated_rects calculate_rects (const SDL_Rect &view_bounds, wfl::map_formula_callable &variables) const
 

Detailed Description

Key Type Default Description
font_family font_style "sans" The font family used for the text.

font_size | f_unsigned |mandatory|The size of the text font. font_style | f_unsigned |"" |The style of the text. text_alignment | f_unsigned |"left" |The alignment of the text. color | color |"" |The color of the text. text | f_tstring |"" |The text to draw (translatable). text_markup | f_bool |false |Can the text have mark-up? text_link_aware | f_bool |false |Is the text link aware? text_link_color | string |"#ffff00"|The color of links in the text. maximum_width | f_int |-1 |The maximum width the text is allowed to be. maximum_height | f_int |-1 |The maximum height the text is allowed to be. debug | string |"" |Debug message to show upon creation this message is not stored.

NOTE alignment could only be done with the formulas, but now with the text_alignment flag as well, older widgets might still use the formulas and not all widgets may expose the text alignment yet and when exposed not use it yet.

Variables:

Key Type Description
text_width unsigned The width of the rendered text.
text_height unsigned The height of the rendered text.

Also the general variables are available, see line_shape

Definition at line 435 of file canvas_private.hpp.

Constructor & Destructor Documentation

◆ text_shape()

gui2::text_shape::text_shape ( const config cfg)
explicit

Constructor.

Parameters
cfgThe config object to define the text.

Definition at line 669 of file canvas.cpp.

References _(), DBG_GUI_P, debug, font_size_, gui2::typed_formula< T >::has_formula(), and VALIDATE.

Member Function Documentation

◆ draw()

void gui2::text_shape::draw ( surface canvas,
SDL_Renderer *  renderer,
const SDL_Rect &  view_bounds,
wfl::map_formula_callable variables 
)
overridevirtual

Member Data Documentation

◆ characters_per_line_

unsigned gui2::text_shape::characters_per_line_
private

The number of characters per line.

Definition at line 481 of file canvas_private.hpp.

Referenced by draw().

◆ color_

typed_formula<color_t> gui2::text_shape::color_
private

The color of the text.

Definition at line 463 of file canvas_private.hpp.

Referenced by draw().

◆ font_family_

font::family_class gui2::text_shape::font_family_
private

The text font family.

Definition at line 451 of file canvas_private.hpp.

Referenced by draw().

◆ font_size_

typed_formula<unsigned> gui2::text_shape::font_size_
private

The font size of the text.

Definition at line 454 of file canvas_private.hpp.

Referenced by draw(), and text_shape().

◆ font_style_

font::pango_text::FONT_STYLE gui2::text_shape::font_style_
private

The style of the text.

Definition at line 457 of file canvas_private.hpp.

Referenced by draw().

◆ link_aware_

typed_formula<bool> gui2::text_shape::link_aware_
private

The link aware switch of the text.

Definition at line 472 of file canvas_private.hpp.

Referenced by draw().

◆ link_color_

typed_formula<color_t> gui2::text_shape::link_color_
private

The link color of the text.

Definition at line 475 of file canvas_private.hpp.

Referenced by draw().

◆ maximum_height_

typed_formula<int> gui2::text_shape::maximum_height_
private

The maximum height for the text.

Definition at line 484 of file canvas_private.hpp.

Referenced by draw().

◆ maximum_width_

typed_formula<int> gui2::text_shape::maximum_width_
private

The maximum width for the text.

Definition at line 478 of file canvas_private.hpp.

Referenced by draw().

◆ text_

typed_formula<t_string> gui2::text_shape::text_
private

The text to draw.

Definition at line 466 of file canvas_private.hpp.

Referenced by draw().

◆ text_alignment_

typed_formula<PangoAlignment> gui2::text_shape::text_alignment_
private

The alignment of the text.

Definition at line 460 of file canvas_private.hpp.

Referenced by draw().

◆ text_markup_

typed_formula<bool> gui2::text_shape::text_markup_
private

The text markup switch of the text.

Definition at line 469 of file canvas_private.hpp.

Referenced by draw().


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