1 #ifndef MSP_GLTK_TEXT_H_
2 #define MSP_GLTK_TEXT_H_
6 #include "mspgltk_api.h"
18 Stores and renders text. Supports multiline text.
20 class MSPGLTK_API Text
32 struct CoordsToGeomData;
34 const Style *style = nullptr;
36 std::vector<Line> lines;
40 Text(const Style &, const std::string &);
42 void set_style(const Style *);
44 unsigned get_width() const;
45 unsigned get_height() const;
46 void autosize(const Part &, Geometry &) const;
48 void set(const std::string &);
49 void erase(unsigned, unsigned);
50 void insert(unsigned, const std::string &);
51 const std::string &get() const { return text; }
52 unsigned size() const { return text.size(); }
53 unsigned get_n_lines() const { return lines.size(); }
54 unsigned get_visible_lines(const Part &, const Geometry &, unsigned *) const;
55 unsigned get_line_length(unsigned) const;
56 unsigned move_offset(unsigned, int) const;
57 void offset_to_coords(unsigned, unsigned &, unsigned &) const;
58 unsigned coords_to_offset(unsigned, unsigned) const;
59 Geometry coords_to_geometry(const Part &, const Geometry &, unsigned, unsigned, unsigned) const;
61 void build(const Part &, State, const Geometry &, PartCache &) const;
62 void build(const Part &, State, const Geometry &, unsigned, PartCache &) const;
64 Text &operator=(const std::string &);
67 unsigned count_characters(unsigned, unsigned) const;
68 void check_alignment(unsigned) const;
71 void process_lines(const Part &, const Geometry &, unsigned, void (Text::*)(unsigned, const Geometry &, T &) const, T &) const;
73 void build_line(unsigned, const Geometry &, RenderData &) const;
74 void coords_to_geom_line(unsigned, const Geometry &, CoordsToGeomData &) const;