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>
120 Gfx::PointF _position;
180 const Gfx::SizeF&
size()
const;
246 double align(
double v)
const
252 Gfx::PointF _position;
256 std::vector<TextLine> _lines;
Adjustment adjustment() const
Returns the horizontal alignment of each line.
double width() const
Returns the laid-out width.
Iterator begin()
Returns a pointer to the first line, or 0 when empty.
TextLine * Iterator
Iterator over the laid-out lines.
Definition TextBlock.h:152
void setLineSpacing(double v)
Sets extra space between consecutive lines.
Definition TextBlock.h:208
TextBlock()
Creates an empty text block.
double height() const
Returns the laid-out height.
ConstIterator end() const
Returns a pointer past the last line, or 0 when empty.
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::PointF & position() const
Returns the origin of the block.
void layout(const Painter &painter, const Pt::String &text)
Wraps text into lines using painter's font metrics.
const Gfx::SizeF & size() const
Returns the laid-out width and height.
void setMaxWidth(double w)
Sets the maximum width used to wrap lines.
void setPosition(const Gfx::PointF &p)
Sets the origin of the block.
Iterator end()
Returns a pointer past the last line, or 0 when empty.
void setAdjustment(Adjustment a)
Sets the horizontal alignment of each line.
ConstIterator begin() const
Returns a pointer to the first line, or 0 when empty.
double maxWidth() const
Returns the maximum width used to wrap lines.
Represents one laid-out line in a TextBlock.
Definition TextBlock.h:58
TextLine()
Creates an empty line.
double cursorToX(const Painter &painter, std::size_t n) const
Returns the x position of caret index n.
double width() const
Returns the advance width of the line text.
double ascent() const
Returns the font ascent of the line.
double height() const
Returns the font height of the line.
double descent() const
Returns the font descent of the line.
const Pt::String & text() const
Returns the line text.
const Gfx::PointF & position() const
Returns the position relative to the text block origin.
double maxHeight() const
Returns the sum of ascent and descent.
std::size_t xToCursor(const Painter &painter, double x) const
Returns the caret index nearest to x.
void setPosition(const Gfx::PointF &p)
Sets the position relative to the text block origin.
void setPosition(double x, double y)
Sets the position relative to the text block origin.
void setText(const Pt::String &text, const Gfx::TextMetrics &tm, const Gfx::FontMetrics &fm)
Assigns text and the metrics used to lay it out.
Ascent, descent and line height of a font.
Definition FontMetrics.h:50
Width and bounds of a text run.
Definition TextMetrics.h:49
Unicode capable basic_string.
Definition Api-String.h:67
Core module.
Definition Allocator.h:33