30 struct builder_rich_label;
66 virtual void set_active(
const bool active)
override;
132 const config& parsed_text,
134 const unsigned init_width,
135 const bool finalize =
false);
213 std::pair<size_t, size_t>
add_text(
config& curr_item, std::string text);
214 void add_attribute(
config& curr_item, std::string attr_name,
size_t start = 0,
size_t end = 0, std::string extra_data =
"");
215 std::pair<size_t, size_t>
add_text_with_attribute(
config& curr_item, std::string text, std::string attr_name =
"", std::string extra_data =
"");
217 void add_image(
config& curr_item, std::string name, std::string align,
bool has_prev_image,
bool floating);
218 void add_link(
config& curr_item, std::string name, std::string dest,
const point& origin,
int img_width);
227 std::vector<std::string>
split_in_width(
const std::string &
s,
const int font_size,
const unsigned width);
230 std::vector<std::pair<rect, std::string>>
links_;
255 static const std::string&
type();
311 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 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)
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_
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, std::string text)
void default_text_config(config *txt_ptr, t_string text="")
Create template for text config that can be shown in canvas.
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.
std::vector< std::pair< rect, std::string > > links_
link variables and functions
void add_link(config &curr_item, std::string name, std::string dest, const point &origin, int img_width)
int font_size_
Base font size.
std::pair< size_t, size_t > add_text_with_attribute(config &curr_item, std::string text, std::string attr_name="", std::string extra_data="")
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)
void add_attribute(config &curr_item, std::string attr_name, size_t start=0, size_t end=0, std::string extra_data="")
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
unsigned short text_alpha_
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
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.
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 add_image(config &curr_item, std::string name, std::string align, bool has_prev_image, bool floating)
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)
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)
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)
rich_label_definition(const config &cfg)
A topic contains a title, an id and some text.
static map_location::direction s