JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
juce::TextLayout Class Referencefinal

A Pre-formatted piece of text, which may contain multiple fonts and colours. More...

#include "juce_TextLayout.h"

Classes

class  Glyph
 A positioned glyph. More...
 
class  Line
 A line containing a sequence of glyph-runs. More...
 
class  Run
 A sequence of glyphs with a common font and colour. More...
 

Public Types

using iterator = DereferencingIterator< Line *const * >
 
using const_iterator = DereferencingIterator< const Line *const * >
 

Public Member Functions

 TextLayout ()
 Creates an empty layout.
 
 TextLayout (const TextLayout &)
 
TextLayoutoperator= (const TextLayout &)
 
 TextLayout (TextLayout &&) noexcept
 
TextLayoutoperator= (TextLayout &&) noexcept
 
 ~TextLayout ()
 Destructor.
 
void createLayout (const AttributedString &, float maxWidth)
 Creates a layout from the given attributed string.
 
void createLayout (const AttributedString &, float maxWidth, float maxHeight)
 Creates a layout from the given attributed string, given some size constraints.
 
void createLayoutWithBalancedLineLengths (const AttributedString &, float maxWidth)
 Creates a layout, attempting to choose a width which results in lines of a similar length.
 
void createLayoutWithBalancedLineLengths (const AttributedString &, float maxWidth, float maxHeight)
 Creates a layout, attempting to choose a width which results in lines of a similar length.
 
void draw (Graphics &, Rectangle< float > area) const
 Draws the layout within the specified area.
 
float getWidth () const noexcept
 Returns the maximum width of the content.
 
float getHeight () const noexcept
 Returns the maximum height of the content.
 
int getNumLines () const noexcept
 Returns the number of lines in the layout.
 
LinegetLine (int index) const noexcept
 Returns one of the lines.
 
void addLine (std::unique_ptr< Line >)
 Adds a line to the layout.
 
void ensureStorageAllocated (int numLinesNeeded)
 Pre-allocates space for the specified number of lines.
 
iterator begin ()
 Returns an iterator over the lines of content.
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 Returns an iterator over the lines of content.
 
const_iterator end () const
 
const_iterator cend () const
 
void recalculateSize ()
 If you modify the TextLayout after creating it, call this to compute the new dimensions of the content.
 

Detailed Description

A Pre-formatted piece of text, which may contain multiple fonts and colours.

A TextLayout is created from an AttributedString, and once created can be quickly drawn into a Graphics context.

See also
AttributedString

@tags{Graphics}

Definition at line 40 of file juce_TextLayout.h.

Member Typedef Documentation

◆ const_iterator

using juce::TextLayout::const_iterator = DereferencingIterator<const Line* const*>

Definition at line 242 of file juce_TextLayout.h.

◆ iterator

using juce::TextLayout::iterator = DereferencingIterator< Line* const*>

Definition at line 241 of file juce_TextLayout.h.

Constructor & Destructor Documentation

◆ TextLayout() [1/3]

juce::TextLayout::TextLayout ( )

Creates an empty layout.

Having created a TextLayout, you can populate it using createLayout() or createLayoutWithBalancedLineLengths().

Definition at line 140 of file juce_TextLayout.cpp.

◆ TextLayout() [2/3]

juce::TextLayout::TextLayout ( const TextLayout other)

Definition at line 145 of file juce_TextLayout.cpp.

◆ TextLayout() [3/3]

juce::TextLayout::TextLayout ( TextLayout &&  other)
noexcept

Definition at line 152 of file juce_TextLayout.cpp.

◆ ~TextLayout()

juce::TextLayout::~TextLayout ( )

Destructor.

Definition at line 178 of file juce_TextLayout.cpp.

Member Function Documentation

◆ addLine()

void juce::TextLayout::addLine ( std::unique_ptr< Line line)

Adds a line to the layout.

The layout will take ownership of this line object and will delete it when it is no longer needed.

Definition at line 192 of file juce_TextLayout.cpp.

◆ begin() [1/2]

iterator juce::TextLayout::begin ( )

Returns an iterator over the lines of content.

Definition at line 245 of file juce_TextLayout.h.

◆ begin() [2/2]

const_iterator juce::TextLayout::begin ( ) const

Definition at line 246 of file juce_TextLayout.h.

◆ cbegin()

const_iterator juce::TextLayout::cbegin ( ) const

Definition at line 247 of file juce_TextLayout.h.

◆ cend()

const_iterator juce::TextLayout::cend ( ) const

Definition at line 252 of file juce_TextLayout.h.

◆ createLayout() [1/2]

void juce::TextLayout::createLayout ( const AttributedString text,
float  maxWidth 
)

Creates a layout from the given attributed string.

This will replace any data that is currently stored in the layout.

Definition at line 243 of file juce_TextLayout.cpp.

◆ createLayout() [2/2]

void juce::TextLayout::createLayout ( const AttributedString text,
float  maxWidth,
float  maxHeight 
)

Creates a layout from the given attributed string, given some size constraints.

This will replace any data that is currently stored in the layout.

Definition at line 248 of file juce_TextLayout.cpp.

◆ createLayoutWithBalancedLineLengths() [1/2]

void juce::TextLayout::createLayoutWithBalancedLineLengths ( const AttributedString text,
float  maxWidth 
)

Creates a layout, attempting to choose a width which results in lines of a similar length.

This will be slower than the normal createLayout method, but produces a tidier result.

Definition at line 261 of file juce_TextLayout.cpp.

◆ createLayoutWithBalancedLineLengths() [2/2]

void juce::TextLayout::createLayoutWithBalancedLineLengths ( const AttributedString text,
float  maxWidth,
float  maxHeight 
)

Creates a layout, attempting to choose a width which results in lines of a similar length.

This will be slower than the normal createLayout method, but produces a tidier result.

Definition at line 266 of file juce_TextLayout.cpp.

◆ draw()

void juce::TextLayout::draw ( Graphics g,
Rectangle< float area 
) const

Draws the layout within the specified area.

The position of the text within the rectangle is controlled by the justification flags set in the original AttributedString that was used to create this layout.

Definition at line 197 of file juce_TextLayout.cpp.

◆ end() [1/2]

iterator juce::TextLayout::end ( )

Returns an iterator over the lines of content.

Definition at line 250 of file juce_TextLayout.h.

◆ end() [2/2]

const_iterator juce::TextLayout::end ( ) const

Definition at line 251 of file juce_TextLayout.h.

◆ ensureStorageAllocated()

void juce::TextLayout::ensureStorageAllocated ( int  numLinesNeeded)

Pre-allocates space for the specified number of lines.

Definition at line 187 of file juce_TextLayout.cpp.

◆ getHeight()

float juce::TextLayout::getHeight ( ) const
noexcept

Returns the maximum height of the content.

Definition at line 226 of file juce_TextLayout.h.

◆ getLine()

TextLayout::Line & juce::TextLayout::getLine ( int  index) const
noexcept

Returns one of the lines.

Definition at line 182 of file juce_TextLayout.cpp.

◆ getNumLines()

int juce::TextLayout::getNumLines ( ) const
noexcept

Returns the number of lines in the layout.

Definition at line 229 of file juce_TextLayout.h.

◆ getWidth()

float juce::TextLayout::getWidth ( ) const
noexcept

Returns the maximum width of the content.

Definition at line 223 of file juce_TextLayout.h.

◆ operator=() [1/2]

TextLayout & juce::TextLayout::operator= ( const TextLayout other)

Definition at line 168 of file juce_TextLayout.cpp.

◆ operator=() [2/2]

TextLayout & juce::TextLayout::operator= ( TextLayout &&  other)
noexcept

Definition at line 159 of file juce_TextLayout.cpp.

◆ recalculateSize()

void juce::TextLayout::recalculateSize ( )

If you modify the TextLayout after creating it, call this to compute the new dimensions of the content.

Definition at line 577 of file juce_TextLayout.cpp.


The documentation for this class was generated from the following files: