CoreComponents 3.0.0
A Modern C++ Toolkit
No Matches
Text Class Reference

Descriptive text displays More...

#include <cc/Text>

Inheritance diagram for Text:

Public Member Functions

 Text ()
 Create a primordial text display.
 Text (const String &text, Font font=Font{})
 Create a new text display.
Textassociate (Out< Text > self)
 Get a weak reference in self.
String text () const
 Get text.
Texttext (const String &newValue)
 Set text
Texttext (Definition< String > &&f)
 Define text.
Font font () const
 Get font.
Textfont (Font newValue)
 Set font
Textfont (Definition< Font > &&f)
 Define font.
Color color () const
 Get text color.
Textcolor (Color newValue)
 Set text color
Textcolor (Definition< Color > &&f)
 Define text color.
Size margin () const
 Get inside margins.
Textmargin (Size newValue)
 Set inside margins
Textmargin (Definition< Size > &&f)
 Define inside margins.
double maxWidth () const
 Get maximum width.
TextmaxWidth (double newValue)
 Set maximum width
TextmaxWidth (Definition< double > &&f)
 Define maximum width.
TextAlign textAlign () const
 Get text alignment.
TexttextAlign (TextAlign newValue)
 Set text alignment
TexttextAlign (Definition< TextAlign > &&f)
 Define text alignment.
Point baselineStart () const
 Get baseline start.
TextbaselineStart (Definition< Point > &&a)
 Anchor the text with its first baseline start to a
FontMetrics fontMetrics () const
 Current font metrics
- Public Member Functions inherited from View
 View ()=default
 Create a primordial view.
 View (double width, double height)
 Create a new view of initial size (width, height)
Viewassociate (Out< View > self)
 Get a weak reference in self.
Viewpopulate (const Function< void(View)> &&f)
 Invoke custom initialization function f.
void touch ()
 Materialize if this view is still primordial.
void show ()
 Convenience method to show this view.
int run ()
 Convenience method to show this view and run the application loop.
Viewpaint (Definition< void > &&f)
 Define foreground.
Color paper () const
 Get background color.
Viewpaper (Color newValue)
 Set background color
Viewpaper (Definition< Color > &&f)
 Define background color.
bool visible () const
 Get visible.
Viewvisible (bool newValue)
 Set visible
Viewvisible (Definition< bool > &&f)
 Define visible.
double opacity () const
 Get opacity.
Viewopacity (double newValue)
 Set opacity
Viewopacity (Definition< double > &&f)
 Define opacity.
ViewopacityEasing (const EasingCurve &easing, double duration)
 Set easing on opacity
bool clip () const
 Get clip.
Viewclip (bool newValue)
 Set clip
Viewclip (Definition< bool > &&f)
 Define clip.
bool moving () const
 Get moving.
Viewmoving (bool newValue)
 Set moving
Viewmoving (Definition< bool > &&f)
 Define moving.
Point pos () const
 Get position.
Viewpos (Point newValue)
 Set position
Viewpos (double x, double y)
 Set position
Viewpos (Definition< Point > &&f)
 Define position.
ViewposEasing (const EasingCurve &easing, double duration, Function< bool()> &&direct=nullptr)
 Set easing on position
Size size () const
 Get size.
double x () const
 Get pos()[0].
double y () const
 Get pos()[1].
double width () const
 Get size()[0].
double height () const
 Get size()[1].
double innerWidth () const
 Get inner width.
double innerHeight () const
 Get inner height.
Viewsize (Size newValue)
 Set size to newValue
Viewsize (double width, double height)
 Set size to Size{width, height}
Viewsize (Definition< Size > &&f)
 Define size.
ViewsizeEasing (const EasingCurve &easing, double duration)
 Set easing on size
Padding padding () const
 Padding to apply when adding this view to a layout
Viewpadding (const Padding &newValue)
 Set padding
Viewpadding (Definition< Padding > &&f)
 Define padding.
Point pivot () const
 Get rotation center.
Viewpivot (Point newValue)
 Set rotation center
Viewpivot (Definition< Point > &&f)
 Define rotation center.
ViewpivotEasing (const EasingCurve &easing, double duration)
 Set easing on rotation center
double angle () const
 Get rotation angle.
Viewangle (double newValue)
 Set rotation angle
Viewangle (Definition< double > &&f)
 Define rotation angle.
ViewangleEasing (const EasingCurve &easing, double duration)
 Set easing on rotation angle
double scale () const
 Get scale factor.
Viewscale (double newValue)
 Set scale factor
Viewscale (Definition< double > &&f)
 Define scale factor.
ViewscaleEasing (const EasingCurve &easing, double duration)
 Set easing on scale
View decoration () const
 Get decoration.
Viewdecoration (const View &newValue)
 Set decoration
Viewdecoration (Definition< View > &&f)
 Define decoration.
Size preferredSize () const
 Get preferred size.
Size minSize () const
 Get minimal size.
Size maxSize () const
 Get maximal size.
Color basePaper () const
 Get the background paper.
const char * objectName () const
 Get the object name (for debugging)
ViewobjectName (const char *name)
 Set the object name
bool hasWindow () const
 Check if this view is already shown in a window.
Window window () const
 Get the window this view is shown in.
bool isHandheld () const
 Get window().display().isHandheld()
Id id () const
 Get view identifier.
List< IdfullId () const
 Get view identifier heritage list.
bool operator== (const View &other) const
 Equality operator.
std::strong_ordering operator<=> (const View &other) const
 Ordering operator.
bool hasParent () const
 Check if this is a child view.
View parent () const
 Get parent view.
View root () const
 Get the root view of this window.
long childrenCount () const
 Number of children.
long count () const
 Number of children.
bool hasChildren () const
 Check if there are any children.
Viewadd (const View &child)
 Add new child placed visually above all existing children.
ViewaddAbove (const View &child)
 Add new child placed visually above all existing children.
ViewaddBelow (const View &child)
 Add child place visually below all existing children.
ViewinsertAt (Locator target, const View &child)
 Insert new child at target.
ViewinsertAt (long index, const View &child)
 Insert new child at index.
void remove (const View &child)
 Remove a child.
Viewpush (const View &child)
 Add new child placed visually above all existing children.
void pop ()
 Remove the top-most visible child.
void deplete ()
 Remove all children.
void moveToTop ()
 Make this view be visible above any other visible sibling.
void moveToBottom ()
 Make this view be visible beneath any other visible sibling.
const Set< View > & children () const
 Get all child views.
const Set< View > & visibleChildren () const
 Get visible child views.
Rect childrenRect () const
 Get bounding box containing all visible child views including their paddings.
Point mapToGlobal (Point l) const
 Map view coordinates l to window coordinates
Point mapToLocal (Point g) const
 Map window coordinates g to view coordinates
Point mapToChild (const View &child, Point l) const
 Map local coordinates l to child coordinates
Point mapToParent (const View &parent, Point l) const
 Map local coordinates l to parent coordinates
bool containsLocal (Point l) const
 Check if local point l lays inside this view.
bool containsGlobal (Point g) const
 Check if global point l lays inside this view.
View findChild (Point l) const
 Find the first child which contains local point l.
Control findControl (Point l) const
 Find the first control which contains local point l.
bool isParentOf (const View &other) const
 Check if this view is parent of other.
bool laysInsideOf (const View &other, double margin) const
 Check if this view is fully visible inside other with given surrounding margin.
void update ()
 Manually force repaint.
template<class T >
void collectVisible (InOut< List< T > > collection) const
 Get a list of all visible children in this view tree which are of type T.
Layout layout () const
 Get layout.
Viewlayout (const Layout &newValue)
 Set layout
void renderTo (Image &image) const
 Capture a rendered image of this view (including its children) as rendered on the screen.
double top () const
 Get y-coordinate of this view's top border.
double bottom () const
 Get y-coordinate of this view's bottom border.
double left () const
 Get x-coordinate of this view's left border.
double right () const
 Get x-coordinate of this view's right border.
Point topLeft () const
 Get this view's top-left corner.
Point topCenter () const
 Get this view's top-center point.
Point topRight () const
 Get this view's top-right corner.
Point bottomLeft () const
 Get this view's bottom-left corner.
Point bottomCenter () const
 Get this view's bottom-center point.
Point bottomRight () const
 Get this view's bottom-right corner.
Point centerLeft () const
 Get this view's center-left point.
Point centerRight () const
 Get this view's center-right point.
ViewtopLeft (Point newValue)
 Make this view's top-left match newValue.
ViewtopCenter (Point newValue)
 Make this view's top-center match newValue.
ViewtopRight (Point newValue)
 Make this view's top-right match newValue.
ViewbottomLeft (Point newValue)
 Make this view's bottom-left match newValue.
ViewbottomCenter (Point newValue)
 Make this view's bottom-center match newValue.
ViewbottomRight (Point newValue)
 Make this view's bottom-right match newValue.
ViewcenterLeft (Point newValue)
 Make this view's center-left match newValue.
ViewcenterRight (Point newValue)
 Make this view's center-right match newValue.
Viewcenter (Point newValue)
 Make this view's center match newValue.
ViewtopLeft (Definition< Point > &&a)
 Anchor the top-left corner to a
ViewtopCenter (Definition< Point > &&a)
 Anchor the top-center corner to a
ViewtopRight (Definition< Point > &&a)
 Anchor the top-right corner to a
ViewbottomLeft (Definition< Point > &&a)
 Anchor the bottom-left corner to a
ViewbottomCenter (Definition< Point > &&a)
 Anchor the bottom-center corner to a
ViewbottomRight (Definition< Point > &&a)
 Anchor the bottom-right corner to a
ViewcenterLeft (Definition< Point > &&a)
 Anchor the center-left to a
ViewcenterRight (Definition< Point > &&a)
 Anchor the center-right to a
Viewcenter (Definition< Point > &&a)
 Anchor the center to a
ViewcenterInParent ()
 Anchor this view's center to its parent's center.
ViewonWindowEntered (Function< void()> &&f)
 Handle window enter event
ViewonWindowLeft (Function< void()> &&f)
 Handle window leave event
ViewonPointerPressed (Filter< PointerEvent > &&f)
 Handle pointer pressed event
ViewonPointerReleased (Filter< PointerEvent > &&f)
 Handle pointer release event
ViewonPointerMoved (Filter< PointerEvent > &&f)
 Handle pointer moved event
ViewonMousePressed (Filter< MouseEvent > &&f)
 Handle move pressed event
ViewonMouseReleased (Filter< MouseEvent > &&f)
 Handle mouse release event
ViewonMouseMoved (Filter< MouseEvent > &&f)
 Handle move moved event
ViewonFingerPressed (Filter< FingerEvent > &&f)
 Handle finger pressed event
ViewonFingerReleased (Filter< FingerEvent > &&f)
 Handle finger released event
ViewonFingerMoved (Filter< FingerEvent > &&f)
 Handle finger moved event
ViewonWheelMoved (Filter< WheelEvent > &&f)
 Handle mouse wheel moved event
ViewonKeyPressed (Filter< KeyEvent > &&f)
 Handle key pressed event
ViewonKeyReleased (Filter< KeyEvent > &&f)
 Handle key released event
ViewonEndOfLife (Function< void()> &&f)
 Get notified when the View's lifetime ends.
Viewattach (const Object &other)
 Attach a non-visual object (e.g.
Viewattach (Function< void()> &&f)
 Convenience method for attaching a monitor.
- Public Member Functions inherited from Surface
 Surface ()=default
 Create a null surface.
void nextPage (bool clear=true)
 Open next page.
cairo_surface_t * cairoSurface ()
 Get a pointer to the underlying Cairo surface.
void polish ()
 Prepare surface before start painting.
- Public Member Functions inherited from Object
 Object ()=default
 Create a null object.
 operator bool () const
 Check if this is a non-null object.
bool isNull () const
 Check if this is a null object.
template<class T >
bool is () const
 Check if this object is of type T.
template<class T >
as () const
 Cast this object to type T.
bool isWeak () const
 Check if the underlying object reference is weak.
bool operator== (const Object &other) const
 Equality operator.
std::strong_ordering operator<=> (const Object &other) const
 Ordering operator.
long useCount () const
 Reference count.

Protected Member Functions

 Text (const String &text, Font font, bool html)
 Text (State *newState)
 Text (CreateState onDemand)
State & me ()
const State & me () const
- Protected Member Functions inherited from View
 View (State *newState)
 Initialize view.
 View (CreateState onDemand)
 Initialize view.
template<class T >
grab ()
 Get a weak reference version of this object.
template<class T >
T & associate (Out< T > self)
 Convenience method to associate a weak reference to this objet.
template<class T >
T & get ()
 Get access to the object's state (create it if needed)
template<class T >
const T & get () const
 Get access to the object's state (create it if needed)
Stateme ()
const Stateme () const
bool operator== (const State *other) const
- Protected Member Functions inherited from Surface
 Surface (State *newState)
State & me ()
const State & me () const
- Protected Member Functions inherited from Object
template<class T >
weak () const
template<class T >
void initOnce ()
 Create the object state when called the first time.
template<class T >
void initOncePerThread ()
 Create a distinct object state for each thread when called the first time in that thread.
 Object (State *newState)
 Initialize object with newState.
 Object (State *state, Alias)
 Object (State *state, Weak)
Objectoperator= (std::nullptr_t)

Additional Inherited Members

- Public Types inherited from View
using Id = double
 View identifier
- Protected Types inherited from View
using CreateState = State *()
- Static Protected Member Functions inherited from View
template<class T >
static View::StateonDemand ()
- Static Protected Member Functions inherited from Object
template<class T >
static T alias (const State *state)
 Create an alias object for the given state.
template<class T >
static T weak (const State *state)
- Protected Attributes inherited from Object
Handle< Stateme
 Internal object state

Detailed Description

Descriptive text displays

See also
HtmlText, Label, TextView

A Text shows descriptive texts, which might be wrapped into multiple lines. When maxWidth() is set the text will be automatically wrapped if necessary. The text() property supports basic HTML tags (<b>, <i>, <u> and <strike>).

Constructor & Destructor Documentation

◆ Text() [1/2]

Text ( )

Create a primordial text display.

◆ Text() [2/2]

Text ( const String & text,
Font font = Font{} )

Create a new text display.

textInitial text
fontInitial font

Member Function Documentation

◆ associate()

Text & associate ( Out< Text > self)

Get a weak reference in self.

◆ text() [1/3]

String text ( ) const

Get text.

◆ text() [2/3]

Text & text ( const String & newValue)

Set text

◆ text() [3/3]

Text & text ( Definition< String > && f)

Define text.

◆ font() [1/3]

Font font ( ) const

Get font.

◆ font() [2/3]

Text & font ( Font newValue)

Set font

◆ font() [3/3]

Text & font ( Definition< Font > && f)

Define font.

◆ color() [1/3]

Color color ( ) const

Get text color.

◆ color() [2/3]

Text & color ( Color newValue)

Set text color

◆ color() [3/3]

Text & color ( Definition< Color > && f)

Define text color.

◆ margin() [1/3]

Size margin ( ) const

Get inside margins.

◆ margin() [2/3]

Text & margin ( Size newValue)

Set inside margins

◆ margin() [3/3]

Text & margin ( Definition< Size > && f)

Define inside margins.

◆ maxWidth() [1/3]

double maxWidth ( ) const

Get maximum width.

◆ maxWidth() [2/3]

Text & maxWidth ( double newValue)

Set maximum width

◆ maxWidth() [3/3]

Text & maxWidth ( Definition< double > && f)

Define maximum width.

◆ textAlign() [1/3]

TextAlign textAlign ( ) const

Get text alignment.

◆ textAlign() [2/3]

Text & textAlign ( TextAlign newValue)

Set text alignment

◆ textAlign() [3/3]

Text & textAlign ( Definition< TextAlign > && f)

Define text alignment.

◆ baselineStart() [1/2]

Point baselineStart ( ) const

Get baseline start.

◆ baselineStart() [2/2]

Text & baselineStart ( Definition< Point > && a)

Anchor the text with its first baseline start to a

◆ fontMetrics()

FontMetrics fontMetrics ( ) const

Current font metrics