29 #ifndef Pt_Forms_TextBlock_H
30 #define Pt_Forms_TextBlock_H
32 #include <Pt/Forms/Adjustment.h>
33 #include <Pt/Gfx/Font.h>
34 #include <Pt/Gfx/Size.h>
35 #include <Pt/Gfx/TextMetrics.h>
36 #include <Pt/Gfx/FontMetrics.h>
37 #include <Pt/Gfx/PaintSurface.h>
38 #include <Pt/Gfx/Point.h>
39 #include <Pt/String.h>
46 class PT_FORMS_API TextLine
53 const Gfx::PointF& position()
const;
55 void setPosition(
const Gfx::PointF& p);
57 void setPosition(
double x,
double y);
61 double height()
const;
63 double maxHeight()
const;
65 double ascent()
const;
67 double descent()
const;
73 void setText(
const Pt::String& text,
const Gfx::TextMetrics& tm,
74 const Gfx::FontMetrics& fm);
76 double cursorToX(
const Gfx::Painter& painter, std::size_t n)
const;
78 std::size_t xToCursor(
const Gfx::Painter& painter,
double x)
const;
81 Gfx::PointF _position;
83 Gfx::TextMetrics _textMetrics;
84 Gfx::FontMetrics _fontMetrics;
87 class PT_FORMS_API TextBlock
90 typedef TextLine* Iterator;
91 typedef const TextLine* ConstIterator;
98 const Gfx::PointF& position()
const;
100 void setPosition(
const Gfx::PointF& p);
102 const Gfx::SizeF& size()
const;
104 double width()
const;
106 double height()
const;
108 double maxWidth()
const;
110 void setMaxWidth(
double w);
112 void setAdjustment(Adjustment a);
114 Adjustment adjustment()
const;
116 void setLineSpacing(
double v)
121 double lineSpacing()
const
130 ConstIterator begin()
const;
132 ConstIterator end()
const;
134 void layout(
const Gfx::Painter& painter,
const Pt::String& text);
137 void addLine(
const Pt::String& line,
const Gfx::TextMetrics& tm,
138 const Gfx::FontMetrics& fm);
140 double align(
double v)
const
146 Gfx::PointF _position;
149 Adjustment _adjustment;
150 std::vector<TextLine> _lines;
Unicode capable basic_string.
Definition: String.h:42