3 This file is part of libmspgltk
4 Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GLTK_TEXT_H_
9 #define MSP_GLTK_TEXT_H_
22 Stores and renders text. Supports multiline text.
35 struct CoordsToGeomData;
39 std::vector<Line> lines;
43 Text(const Style &, const std::string &);
45 void set_style(const Style *);
47 unsigned get_width() const;
48 unsigned get_height() const;
50 void set(const std::string &);
51 void erase(unsigned, unsigned);
52 void insert(unsigned, const std::string &);
53 const std::string &get() const { return text; }
54 unsigned size() const { return text.size(); }
55 unsigned get_n_lines() const { return lines.size(); }
56 unsigned get_line_length(unsigned) 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 render(const Part &, const Geometry &, unsigned = 0) const;
63 Text &operator=(const std::string &);
67 template<typename T, void (Text::*)(unsigned, const Geometry &, T &) const>
68 void process_lines(const Part &, const Geometry &, unsigned, T &) const;
70 void render_line(unsigned, const Geometry &, RenderData &) const;
71 void coords_to_geom_line(unsigned, const Geometry &, CoordsToGeomData &) const;