TextLine Class Reference

#include <Pt/Forms/TextBlock.h>

Represents one laid-out line in a TextBlock. More...

Public Member Functions

 TextLine ()
 Creates an empty line.
 
 ~TextLine ()
 Destructor.
 
const Gfx::PointFposition () const
 Returns the position relative to the text block origin.
 
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.
 
double width () const
 Returns the advance width of the line text.
 
double height () const
 Returns the font height of the line.
 
double maxHeight () const
 Returns the sum of ascent and descent.
 
double ascent () const
 Returns the font ascent of the line.
 
double descent () const
 Returns the font descent of the line.
 
const Pt::Stringtext () const
 Returns the line text.
 
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 cursorToX (const Painter &painter, std::size_t n) const
 Returns the x position of caret index n.
 
std::size_t xToCursor (const Painter &painter, double x) const
 Returns the caret index nearest to x.
 

Detailed Description

TextBlock::layout() produces TextLine objects. Application code does not construct them as standalone objects. A line stores its text, its position in the block, and the text and font metrics used to lay it out. cursorToX() and xToCursor() map caret indices for editors.