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
25 std::size_t start = 0;
26 std::size_t bytes = 0;
27 std::size_t length = 0;
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(std::size_t, std::size_t);
50 void insert(std::size_t, const std::string &);
51 const std::string &get() const { return text; }
52 std::size_t size() const { return text.size(); }
53 std::size_t get_n_lines() const { return lines.size(); }
54 std::size_t get_visible_lines(const Part &, const Geometry &, unsigned *) const;
55 std::size_t get_line_length(std::size_t) const;
56 std::size_t move_offset(std::size_t, std::ptrdiff_t) const;
57 void offset_to_coords(std::size_t, std::size_t &, std::size_t &) const;
58 std::size_t coords_to_offset(std::size_t, std::size_t) const;
59 Geometry coords_to_geometry(const Part &, const Geometry &, std::size_t, std::size_t, std::size_t) const;
61 void build(const Part &, State, const Geometry &, PartCache &) const;
62 void build(const Part &, State, const Geometry &, std::size_t, PartCache &) const;
64 Text &operator=(const std::string &);
67 std::size_t count_characters(std::size_t, std::size_t) const;
68 void check_alignment(std::size_t) const;
71 void process_lines(const Part &, const Geometry &, std::size_t, void (Text::*)(std::size_t, const Geometry &, T &) const, T &) const;
73 void build_line(std::size_t, const Geometry &, RenderData &) const;
74 void coords_to_geom_line(std::size_t, const Geometry &, CoordsToGeomData &) const;