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

#include <canvas_private.hpp>

Inheritance diagram for gui2::text_shape:

Public Member Functions

 text_shape (const config &cfg, wfl::action_function_symbol_table &functions)
 Constructor. More...
 
 text_shape (const point &origin, font::family_class family, const unsigned size, font::pango_text::FONT_STYLE style, const std::string &align, const unsigned wrap_width)
 
t_string get_text () const
 
void set_text (const t_string &text)
 
std::pair< std::size_t, std::size_t > add_text (const t_string &text)
 
void add_attribute (const std::string &attr_name, const std::string &extra_data="", std::size_t start=PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING, std::size_t end=PANGO_ATTR_INDEX_TO_TEXT_END)
 
void add_attributes (font::attribute_list &&other_attrs)
 
void add_attributes_from (text_shape &tshape2, const unsigned attr_start)
 
void set_wrap_width (const unsigned wrap_width)
 
void draw (wfl::map_formula_callable &variables) override
 Draws the canvas. More...
 
- Public Member Functions inherited from gui2::canvas::shape
 shape ()=default
 
 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...
 
config::attribute_value text_
 The text to draw. More...
 
bool parse_text_as_formula_
 Whether to parse text_ as WFL formula. 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...
 
typed_formula< int > highlight_start_
 Start offset for highlight. More...
 
typed_formula< int > highlight_end_
 End offset for highlight. More...
 
typed_formula< color_thighlight_color_
 The color to be used for highlighting. More...
 
float line_spacing_
 Spacing between lines. More...
 
typed_formula< bool > outline_
 Whether to apply a text outline. More...
 
wfl::formula actions_formula_
 Any extra WFL actions to execute. More...
 
font::attribute_list text_attributes_
 Any custom Pango text attributes. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::rect_bounded_shape
 rect_bounded_shape (const rect &bounds)
 
 rect_bounded_shape (const point &origin, const std::string &w_f, const std::string &h_f)
 
 rect_bounded_shape (const config &cfg)
 Constructor. More...
 
- Protected Attributes inherited from gui2::rect_bounded_shape
typed_formula< int > x_
 The x coordinate of the rectangle. More...
 
typed_formula< int > y_
 The y coordinate of the rectangle. More...
 
typed_formula< int > w_
 The width of the rectangle. More...
 
typed_formula< int > h_
 The height of the rectangle. More...
 

Detailed Description

Definition at line 266 of file canvas_private.hpp.

Constructor & Destructor Documentation

◆ text_shape() [1/2]

gui2::text_shape::text_shape ( const config cfg,
wfl::action_function_symbol_table functions 
)
explicit

Constructor.

Parameters
cfgThe config object to define the text.
functionsWFL functions to execute.

Definition at line 485 of file canvas.cpp.

References cfg, DBG_GUI_P, and debug.

◆ text_shape() [2/2]

gui2::text_shape::text_shape ( const point origin,
font::family_class  family,
const unsigned  size,
font::pango_text::FONT_STYLE  style,
const std::string &  align,
const unsigned  wrap_width 
)

Definition at line 514 of file canvas.cpp.

Member Function Documentation

◆ add_attribute()

void gui2::text_shape::add_attribute ( const std::string &  attr_name,
const std::string &  extra_data = "",
std::size_t  start = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING,
std::size_t  end = PANGO_ATTR_INDEX_TO_TEXT_END 
)

◆ add_attributes()

void gui2::text_shape::add_attributes ( font::attribute_list &&  other_attrs)

◆ add_attributes_from()

void gui2::text_shape::add_attributes_from ( text_shape tshape2,
const unsigned  attr_start 
)

Definition at line 610 of file canvas.cpp.

References font::attribute_list::splice_into(), and text_attributes_.

◆ add_text()

std::pair< std::size_t, std::size_t > gui2::text_shape::add_text ( const t_string text)

◆ draw()

void gui2::text_shape::draw ( wfl::map_formula_callable variables)
overridevirtual

Draws the canvas.

Parameters
variablesThe canvas can have formulas in it's definition, this parameter contains the values for these formulas.

Implements gui2::canvas::shape.

Definition at line 615 of file canvas.cpp.

References actions_formula_, wfl::map_formula_callable::add(), font::add_attribute_bg_color(), font::pango_text::apply_attributes(), wfl::variant::as_bool(), wfl::variant::as_int(), draw::blit(), characters_per_line_, font::pango_text::clear_attributes(), color_, DBG_GUI_D, wfl::formula::evaluate(), wfl::variant::execute_variant(), wfl::formula_callable::fake_ptr(), font_family_, font_size_, font_style_, font::pango_text::get_size(), font::get_text_renderer(), texture::h(), h, gui2::rect_bounded_shape::h_, wfl::formula_callable::has_key(), highlight_color_, highlight_end_, highlight_start_, line_spacing_, link_aware_, link_color_, maximum_height_, maximum_width_, outline_, parse_text_as_formula_, wfl::formula_callable::query_value(), font::pango_text::render_and_get_texture(), font::pango_text::set_add_outline(), font::pango_text::set_alignment(), font::pango_text::set_characters_per_line(), font::pango_text::set_ellipse_mode(), font::pango_text::set_family_class(), font::pango_text::set_font_size(), font::pango_text::set_font_style(), font::pango_text::set_foreground_color(), font::pango_text::set_line_spacing(), font::pango_text::set_link_aware(), font::pango_text::set_link_color(), font::pango_text::set_maximum_height(), font::pango_text::set_maximum_width(), font::pango_text::set_text(), config_attribute_value::t_str(), text_, text_alignment_, text_attributes_, text_markup_, w, texture::w(), gui2::rect_bounded_shape::w_, gui2::rect_bounded_shape::x_, and gui2::rect_bounded_shape::y_.

Referenced by gui2::rich_label::setup_text_renderer().

◆ get_text()

t_string gui2::text_shape::get_text ( ) const

◆ set_text()

void gui2::text_shape::set_text ( const t_string text)

Definition at line 548 of file canvas.cpp.

References text_.

Referenced by add_text().

◆ set_wrap_width()

void gui2::text_shape::set_wrap_width ( const unsigned  wrap_width)

Definition at line 561 of file canvas.cpp.

References maximum_width_, and gui2::typed_formula< T >::set_value().

Member Data Documentation

◆ actions_formula_

wfl::formula gui2::text_shape::actions_formula_
private

Any extra WFL actions to execute.

Definition at line 355 of file canvas_private.hpp.

Referenced by draw().

◆ characters_per_line_

unsigned gui2::text_shape::characters_per_line_
private

The number of characters per line.

Definition at line 334 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 313 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 301 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 304 of file canvas_private.hpp.

Referenced by draw().

◆ font_style_

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

The style of the text.

Definition at line 307 of file canvas_private.hpp.

Referenced by draw().

◆ highlight_color_

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

The color to be used for highlighting.

Definition at line 346 of file canvas_private.hpp.

Referenced by draw().

◆ highlight_end_

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

End offset for highlight.

Definition at line 343 of file canvas_private.hpp.

Referenced by draw().

◆ highlight_start_

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

Start offset for highlight.

Definition at line 340 of file canvas_private.hpp.

Referenced by draw().

◆ line_spacing_

float gui2::text_shape::line_spacing_
private

Spacing between lines.

Definition at line 349 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 325 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 328 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 337 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 331 of file canvas_private.hpp.

Referenced by draw(), and set_wrap_width().

◆ outline_

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

Whether to apply a text outline.

Definition at line 352 of file canvas_private.hpp.

Referenced by draw().

◆ parse_text_as_formula_

bool gui2::text_shape::parse_text_as_formula_
private

Whether to parse text_ as WFL formula.

Definition at line 319 of file canvas_private.hpp.

Referenced by draw().

◆ text_

config::attribute_value gui2::text_shape::text_
private

The text to draw.

Definition at line 316 of file canvas_private.hpp.

Referenced by draw(), get_text(), and set_text().

◆ text_alignment_

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

The alignment of the text.

Definition at line 310 of file canvas_private.hpp.

Referenced by draw().

◆ text_attributes_

font::attribute_list gui2::text_shape::text_attributes_
private

Any custom Pango text attributes.

Definition at line 358 of file canvas_private.hpp.

Referenced by add_attribute(), add_attributes_from(), and draw().

◆ text_markup_

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

The text markup switch of the text.

Definition at line 322 of file canvas_private.hpp.

Referenced by draw().


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