X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftext.h;h=db58b2462621aad9dcd0e66db32baa7195d1ae36;hb=d2d5b4c4dedf90a42dd2baff8334318b1d000f64;hp=5daeb9bae70db324014f330ee04b5edf76adba34;hpb=62417b367503a9b26510c75e2332db21af1497bf;p=libs%2Fgltk.git diff --git a/source/text.h b/source/text.h index 5daeb9b..db58b24 100644 --- a/source/text.h +++ b/source/text.h @@ -9,6 +9,7 @@ namespace GLtk { class Geometry; class Part; +class PartCache; class Style; /** @@ -24,28 +25,46 @@ private: unsigned width; }; - const Style *const &style; + struct RenderData; + struct CoordsToGeomData; + + const Style *style; std::string text; std::vector lines; public: - Text(const Style *const &); - Text(const Style *const &, const std::string &); + Text(); + Text(const Style &, const std::string &); + + void set_style(const Style *); unsigned get_width() const; unsigned get_height() const; + void autosize(const Part &, Geometry &) const; void set(const std::string &); void erase(unsigned, unsigned); void insert(unsigned, const std::string &); const std::string &get() const { return text; } unsigned size() const { return text.size(); } + unsigned get_n_lines() const { return lines.size(); } + unsigned get_line_length(unsigned) const; + void offset_to_coords(unsigned, unsigned &, unsigned &) const; + unsigned coords_to_offset(unsigned, unsigned) const; + Geometry coords_to_geometry(const Part &, const Geometry &, unsigned, unsigned, unsigned) const; - void render(const Part &, const Geometry &) const; + void build(const Part &, const Geometry &, PartCache &) const; + void build(const Part &, const Geometry &, unsigned, PartCache &) const; Text &operator=(const std::string &); private: void find_lines(); + + template + void process_lines(const Part &, const Geometry &, unsigned, T &) const; + + void build_line(unsigned, const Geometry &, RenderData &) const; + void coords_to_geom_line(unsigned, const Geometry &, CoordsToGeomData &) const; }; } // namespace GLtk