31 struct builder_rich_label;
67 virtual void set_active(
const bool active)
override;
152 const config& parsed_text,
154 const unsigned init_width,
155 const bool finalize =
false);
253 std::pair<size_t, size_t>
add_text(
config& curr_item,
const std::string& text);
254 void add_attribute(
config& curr_item,
const std::string& attr_name,
size_t start = 0,
size_t end = 0,
const std::string& extra_data =
"");
255 std::pair<size_t, size_t>
add_text_with_attribute(
config& curr_item,
const std::string& text,
const std::string& attr_name =
"",
const std::string& extra_data =
"");
257 void add_image(
config& curr_item,
const std::string& name, std::string align,
bool has_prev_image,
bool floating);
258 void add_link(
config& curr_item,
const std::string& name,
const std::string& dest,
const point& origin,
int img_width);
267 std::vector<std::string>
split_in_width(
const std::string &
s,
const int font_size,
const unsigned width);
270 std::vector<std::pair<rect, std::string>>
links_;
295 static const std::string&
type();
354 virtual std::unique_ptr<widget>
build()
const override;
A config object defines a single node in a WML file, with access to child nodes.
int xy_to_index(const point &position) const
point get_cursor_position(const unsigned column, 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 add_link(config &curr_item, const std::string &name, const std::string &dest, const point &origin, int img_width)
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.
void set_state(const state_t state)
size_t get_split_location(std::string_view text, const point &pos)
color_t text_color_enabled_
Base text color, enabled state.
virtual bool get_active() const override
Gets the active state of the styled_widget.
point get_text_size(config &text_cfg, unsigned width=0) const
size calculation functions
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::function< void(std::string)> link_handler_
std::pair< size_t, size_t > add_text_with_attribute(config &curr_item, const std::string &text, const std::string &attr_name="", const std::string &extra_data="")
const t_string & get_label() const
virtual unsigned get_state() const override
Returns the id of the state.
virtual void update_canvas() override
Updates the canvas(ses).
std::pair< size_t, size_t > add_text(config &curr_item, const std::string &text)
t_string unparsed_text_
The unparsed/raw text.
void signal_handler_mouse_leave(bool &handled)
Mouse leave signal handler: checks if the cursor left a hyperlink.
void add_attribute(config &curr_item, const std::string &attr_name, size_t start=0, size_t end=0, const std::string &extra_data="")
std::vector< std::pair< rect, std::string > > links_
link variables and functions
int font_size_
Base font size.
point get_image_size(config &img_cfg) const
std::vector< std::string > split_in_width(const std::string &s, const int font_size, const unsigned width)
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
unsigned short text_alpha_
std::string font_family_
Base font family.
void set_font_style(const std::string &font_style)
void set_text_color(const color_t &color, bool enabled)
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
void set_can_shrink(bool can_shrink)
point get_xy_from_offset(const unsigned offset) const
void add_image(config &curr_item, const std::string &name, std::string align, bool has_prev_image, bool floating)
std::pair< config, point > get_parsed_text(const config &parsed_text, const point &origin, const unsigned init_width, const bool finalize=false)
virtual void set_active(const bool active) override
Sets the styled_widget's state.
const unsigned init_w_
Width and height of the canvas.
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)
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.
void set_topic(const help::topic *topic)
int get_offset_from_xy(const point &position) const
bool link_aware_
Whether the rich_label is link aware, rendering links with special formatting and handling click even...
void default_text_config(config *txt_ptr, const t_string &text="")
Create template for text config that can be shown in canvas.
virtual unsigned get_characters_per_line() const override
Returns the number of characters per line.
wfl::map_formula_callable setup_text_renderer(config text_cfg, unsigned width=0) const
virtual bool can_wrap() const override
Can the widget wrap.
void set_link_color(const color_t &color)
unsigned padding_
Padding.
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 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
void update_mouse_cursor(bool enable)
Implementation detail for (re)setting the hyperlink cursor.
void set_characters_per_line(const unsigned characters_per_line)
color_t text_color_disabled_
Base text color, disabled state.
config text_dom_
structure tree of the marked up text after parsing
EXIT_STATUS start(bool clear_id, const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
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.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
The basic class for representing 8-bit RGB or RGBA colour values.
typed_formula< unsigned > width
virtual std::unique_ptr< widget > build() const override
builder_rich_label(const config &cfg)
PangoAlignment text_alignment
resolution(const config &cfg)
color_t text_color_enabled
color_t text_color_disabled
rich_label_definition(const config &cfg)
A topic contains a title, an id and some text.
static map_location::direction s