28 struct builder_rich_label;
146 const config& parsed_text,
148 const unsigned init_width,
149 const bool finalize =
false);
246 std::unique_ptr<gui2::text_shape>
new_text_shape(
const point& origin,
const int max_width);
251 const std::string& attr_name =
"",
252 const std::string& extra_data =
"");
256 const std::string& name,
257 const std::string& dest,
269 std::vector<std::pair<rect, std::string>>
links_;
291 static const std::string&
type();
351 virtual std::unique_ptr<widget>
build()
const override;
A config object defines a single node in a WML file, with access to child nodes.
point get_cursor_position(const unsigned offset, const unsigned line=0) const
Gets the location for the cursor, in drawing coordinates.
A rich_label takes marked up text and shows it correctly formatted and wrapped but no scrollbars are ...
point calculate_best_size() const override
See widget::calculate_best_size.
unsigned characters_per_line_
The maximum number of characters per line.
bool disable_click_dismiss() const override
Does the widget disable easy close?
void signal_handler_mouse_motion(bool &handled, const point &coordinate)
Mouse motion signal handler: checks if the cursor is on a hyperlink.
void set_can_wrap(const bool wrap)
state_t state_
Current state of the widget.
virtual void set_active(const bool) override
Sets the styled_widget's state.
void set_state(const state_t state)
color_t text_color_enabled_
Base text color, enabled state.
virtual bool get_active() const override
Gets the active state of the styled_widget.
bool can_wrap_
Holds the rich_label can wrap or not.
virtual color_t get_link_color() const override
Returns the color string to be used with links.
std::unique_ptr< canvas::shape > shape_ptr
std::function< void(std::string)> link_handler_
virtual unsigned get_state() const override
Returns the id of the state.
virtual void update_canvas() override
Updates the canvas(ses).
std::pair< std::vector< shape_ptr >, point > get_parsed_text(const config &parsed_text, const point &origin, const unsigned init_width, const bool finalize=false)
void signal_handler_mouse_leave(bool &handled)
Mouse leave signal handler: checks if the cursor left a hyperlink.
std::vector< std::pair< rect, std::string > > links_
link variables and functions
void place(const point &origin, const point &size) override
See widget::place.
int font_size_
Base font size.
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
void set_width(const int width)
unsigned short text_alpha_
std::unique_ptr< gui2::text_shape > new_text_shape(const point &origin, const int max_width)
Create template for text config that can be shown in canvas.
std::string font_family_
Base font family.
unsigned init_w_
Width and height of the canvas.
void set_font_style(const std::string &font_style)
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
void set_dom(const config &dom)
void set_can_shrink(bool can_shrink)
point get_xy_from_offset(const unsigned offset) const
color_t get_color(const std::string &color)
If color is a predefined color set in resolution, return it, otherwise decode using font::string_to_c...
wfl::map_formula_callable setup_text_renderer(text_shape &tshape, unsigned width) const
size calculation functions
void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
std::string font_style_
Base font style.
state_t
Possible states of the widget.
void register_link_callback(std::function< void(std::string)> link_handler)
virtual void request_reduce_height(const unsigned) override
See widget::request_reduce_height.
void signal_handler_left_button_click(bool &handled)
Left click signal handler: checks if we clicked on a hyperlink.
void set_font_size(int font_size)
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
int get_offset_from_xy(const point &position) const
point get_image_size(const std::string &path) const
bool link_aware_
Whether the rich_label is link aware, rendering links with special formatting and handling click even...
virtual unsigned get_characters_per_line() const override
Returns the number of characters per line.
virtual bool can_wrap() const override
Can the widget wrap.
void set_link_color(const color_t &color)
std::map< std::string, color_t > predef_colors_
Color variables that can be used in place of colors strings, like <row bgcolor=color1>
void set_link_aware(bool l)
virtual bool get_link_aware() const override
Returns whether the label should be link_aware, in in rendering and in searching for links with get_l...
rich_label(const implementation::builder_rich_label &builder)
void add_link(text_shape &tshape, const std::string &name, const std::string &dest, const point &origin, int img_width)
void set_font_family(const std::string &font_family)
virtual bool text_can_shrink() override
Inherited from styled_widget.
void set_text_alpha(unsigned short alpha)
color_t link_color_
What color links will be rendered in.
void set_label(const t_string &text) override
point get_text_size(text_shape &tshape, unsigned width) const
void update_mouse_cursor(bool enable)
Implementation detail for (re)setting the hyperlink cursor.
color_t text_color_disabled_
Base text color, disabled state.
std::pair< std::size_t, std::size_t > add_text_with_attribute(text_shape &tshape, const t_string &text, const std::string &attr_name="", const std::string &extra_data="")
std::size_t get_split_location(std::string_view text, const point &pos)
pango_text & get_text_renderer()
Returns a reference to a static pango_text object.
Contains the implementation details for lexical_cast and shouldn't be used directly.
static log_domain dom("general")
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
The basic class for representing 8-bit RGB or RGBA colour values.
virtual std::unique_ptr< widget > build() const override
builder_rich_label(const config &cfg)
PangoAlignment text_alignment
std::map< std::string, color_t > colors
resolution(const config &cfg)
color_t text_color_enabled
color_t text_color_disabled
rich_label_definition(const config &cfg)