#include <Pt/Forms/LineEditor.h>

Single-line text, caret, and scroll helper. More...

Public Member Functions

 LineEditor ()
 Constructs an empty line editor.
 
 ~LineEditor ()
 Destroys the line editor.
 
const Gfx::PointFposition () const
 Returns the top-left position of the line.
 
void setPosition (const Gfx::PointF &p)
 Sets the top-left position of the line to p.
 
const Gfx::SizeFsize () const
 Returns the size of the line.
 
void setSize (const Gfx::SizeF &s)
 Sets the size of the line to s.
 
Adjustment adjustment () const
 Returns the horizontal adjustment of the text.
 
void setAdjustment (Adjustment a)
 Sets the horizontal adjustment of the text to a.
 
bool isMasked () const
 Returns true if displayText() shows a mask character per character.
 
void setMasked (bool m)
 Sets whether displayText() shows a mask character per character.
 
const Pt::Stringtext () const
 Returns the entered text.
 
void setText (const Pt::String &s)
 Sets the entered text to s.
 
const Pt::StringdisplayText () const
 Returns the text shown for the line. More...
 
std::size_t cursorPosition () const
 Returns the caret index in the entered text.
 
void setCursorPosition (std::size_t n)
 Sets the caret index in the entered text to n.
 
bool isEmpty () const
 Returns true if the entered text is empty.
 
void clear ()
 Clears the entered text, caret, and scroll.
 
void insert (Char ch)
 Inserts ch at the caret and advances the caret.
 
void left ()
 Moves the caret one character to the left.
 
void right ()
 Moves the caret one character to the right.
 
void del ()
 Deletes the character at the caret.
 
void backspace ()
 Deletes the character before the caret.
 
void layout (const Painter &painter, TextLine &line)
 Lays out displayText() into line using painter.
 
void layout (const Painter &painter, const Pt::String &text, TextLine &line)
 Lays out text into line using painter.
 

Detailed Description

A LineEditor stores the entered string, the caret index, and the scroll of one line. It is not a Control. LineEdit, SpinBox, and ComboBox use it to edit text. Applications do not place it in a layout.

text() is the entered string. displayText() is that string, or a mask character per entered character when isMasked() is true. layout() writes a positioned TextLine for painting.

Member Function Documentation

◆ displayText()

const Pt::String& displayText ( ) const

This is the entered text, or a mask string when isMasked() is true.