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>
246 double align(
double v)
const
256 std::vector<TextLine> _lines;
Core module.
Definition: Allocator.h:33
void setText(const Pt::String &text, const Gfx::TextMetrics &tm, const Gfx::FontMetrics &fm)
Assigns text and the metrics used to lay it out.
double maxHeight() const
Returns the sum of ascent and descent.
void layout(const Painter &painter, const Pt::String &text)
Wraps text into lines using painter's font metrics.
double width() const
Returns the laid-out width.
void setAdjustment(Adjustment a)
Sets the horizontal alignment of each line.
TextLine * Iterator
Iterator over the laid-out lines.
Definition: TextBlock.h:152
Adjustment adjustment() const
Returns the horizontal alignment of each line.
const Pt::String & text() const
Returns the line text.
double height() const
Returns the laid-out height.
void setPosition(const Gfx::PointF &p)
Sets the position relative to the text block origin.
Metrics that describe a font face at a given size.
Definition: FontMetrics.h:46
void setPosition(double x, double y)
Sets the position relative to the text block origin.
double height() const
Returns the font height of the line.
Represents wrapped text as positioned lines.
Definition: TextBlock.h:148
Size with floating-point width and height.
Definition: Size.h:47
Point with floating-point X and Y coordinates.
Definition: Point.h:47
Iterator begin()
Returns a pointer to the first line, or 0 when empty.
const Gfx::PointF & position() const
Returns the position relative to the text block origin.
void setLineSpacing(double v)
Sets extra space between consecutive lines.
Definition: TextBlock.h:208
void setPosition(const Gfx::PointF &p)
Sets the origin of the block.
const Gfx::PointF & position() const
Returns the origin of the block.
Metrics for a measured line of text.
Definition: TextMetrics.h:46
TextLine()
Creates an empty line.
Iterator end()
Returns a pointer past the last line, or 0 when empty.
ConstIterator end() const
Returns a pointer past the last line, or 0 when empty.
double width() const
Returns the advance width of the line text.
void setMaxWidth(double w)
Sets the maximum width used to wrap lines.
std::size_t xToCursor(const Painter &painter, double x) const
Returns the caret index nearest to x.
double maxWidth() const
Returns the maximum width used to wrap lines.
TextBlock()
Creates an empty text block.
double lineSpacing() const
Returns extra space between consecutive lines.
Definition: TextBlock.h:215
const TextLine * ConstIterator
Const iterator over the laid-out lines.
Definition: TextBlock.h:156
const Gfx::SizeF & size() const
Returns the laid-out width and height.
Unicode capable basic_string.
Definition: Api-String.h:44
double cursorToX(const Painter &painter, std::size_t n) const
Returns the x position of caret index n.
Represents one laid-out line in a TextBlock.
Definition: TextBlock.h:58
double descent() const
Returns the font descent of the line.
ConstIterator begin() const
Returns a pointer to the first line, or 0 when empty.
double ascent() const
Returns the font ascent of the line.