X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftext.h;fp=source%2Ftext.h;h=46bd18f9075844cf7401bd7193119e817e0fd8ff;hb=1e06dc208a02e68cf1bb127927e3ad5af3657c58;hp=0000000000000000000000000000000000000000;hpb=8a0058b5b90bb7e9eacf1646142f4d73b426fd66;p=libs%2Fgltk.git diff --git a/source/text.h b/source/text.h new file mode 100644 index 0000000..46bd18f --- /dev/null +++ b/source/text.h @@ -0,0 +1,53 @@ +#ifndef MSP_GLTK_TEXT_H_ +#define MSP_GLTK_TEXT_H_ + +#include +#include + +namespace Msp { +namespace GLtk { + +class Geometry; +class Part; +class Style; + +/** +Stores and renders text. Supports multiline text. +*/ +class Text +{ +private: + struct Line + { + unsigned start; + unsigned length; + unsigned width; + }; + + const Style *const &style; + std::string text; + std::vector lines; + +public: + Text(const Style *const &); + Text(const Style *const &, const std::string &); + + unsigned get_width() const; + unsigned get_height() 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(); } + + void render(const Part &, const Geometry &) const; + + Text &operator=(const std::string &); + //operator const std::string &() const { return text; } +}; + +} // namespace GLtk +} // namespace Msp + +#endif