]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/text.h
Simplify constructors with C++11
[libs/gltk.git] / source / text.h
index 243c3a617f6cf2806a2272caf71cf4a44f45121e..cdde08c2b081aa42804ec16bf6d0656c343c8d3c 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <string>
 #include <vector>
+#include "mspgltk_api.h"
 #include "state.h"
 
 namespace Msp {
@@ -16,20 +17,21 @@ class Style;
 /**
 Stores and renders text.  Supports multiline text.
 */
-class Text
+class MSPGLTK_API Text
 {
 private:
        struct Line
        {
-               unsigned start;
-               unsigned length;
-               unsigned width;
+               unsigned start = 0;
+               unsigned bytes = 0;
+               unsigned length = 0;
+               unsigned width = 0;
        };
 
        struct RenderData;
        struct CoordsToGeomData;
 
-       const Style *style;
+       const Style *style = 0;
        std::string text;
        std::vector<Line> lines;
 
@@ -51,6 +53,7 @@ public:
        unsigned get_n_lines() const { return lines.size(); }
        unsigned get_visible_lines(const Part &, const Geometry &, unsigned *) const;
        unsigned get_line_length(unsigned) const;
+       unsigned move_offset(unsigned, int) 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;
@@ -61,6 +64,8 @@ public:
        Text &operator=(const std::string &);
 private:
        void find_lines();
+       unsigned count_characters(unsigned, unsigned) const;
+       void check_alignment(unsigned) const;
 
        template<typename T>
        void process_lines(const Part &, const Geometry &, unsigned, void (Text::*)(unsigned, const Geometry &, T &) const, T &) const;