LMMS
Loading...
Searching...
No Matches
juce::TextLayout Class Referencefinal

#include <juce_TextLayout.h>

Classes

class  DereferencingIterator
class  Glyph
class  Run
class  Line

Public Types

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

Public Member Functions

 TextLayout ()
 TextLayout (const TextLayout &)
TextLayoutoperator= (const TextLayout &)
 TextLayout (TextLayout &&) noexcept
TextLayoutoperator= (TextLayout &&) noexcept
 ~TextLayout ()
void createLayout (const AttributedString &, float maxWidth)
void createLayout (const AttributedString &, float maxWidth, float maxHeight)
void createLayoutWithBalancedLineLengths (const AttributedString &, float maxWidth)
void createLayoutWithBalancedLineLengths (const AttributedString &, float maxWidth, float maxHeight)
void draw (Graphics &, Rectangle< float > area) const
float getWidth () const noexcept
float getHeight () const noexcept
int getNumLines () const noexcept
LinegetLine (int index) const noexcept
void addLine (std::unique_ptr< Line >)
void ensureStorageAllocated (int numLinesNeeded)
iterator begin ()
const_iterator begin () const
const_iterator cbegin () const
iterator end ()
const_iterator end () const
const_iterator cend () const
void recalculateSize ()

Private Member Functions

void createStandardLayout (const AttributedString &)
bool createNativeLayout (const AttributedString &)

Private Attributes

OwnedArray< Linelines
float width
float height
Justification justification

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}

Member Typedef Documentation

◆ const_iterator

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

◆ iterator

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

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().

◆ TextLayout() [2/3]

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

◆ TextLayout() [3/3]

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

◆ ~TextLayout()

juce::TextLayout::~TextLayout ( )

Destructor.

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.

◆ begin() [1/2]

iterator juce::TextLayout::begin ( )
inline

Returns an iterator over the lines of content

◆ begin() [2/2]

const_iterator juce::TextLayout::begin ( ) const
inline

◆ cbegin()

const_iterator juce::TextLayout::cbegin ( ) const
inline

◆ cend()

const_iterator juce::TextLayout::cend ( ) const
inline

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ createNativeLayout()

bool juce::TextLayout::createNativeLayout ( const AttributedString & text)
private

◆ createStandardLayout()

void juce::TextLayout::createStandardLayout ( const AttributedString & text)
private

◆ 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.

◆ end() [1/2]

iterator juce::TextLayout::end ( )
inline

Returns an iterator over the lines of content

◆ end() [2/2]

const_iterator juce::TextLayout::end ( ) const
inline

◆ ensureStorageAllocated()

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

Pre-allocates space for the specified number of lines.

◆ getHeight()

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

Returns the maximum height of the content.

◆ getLine()

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

Returns one of the lines.

◆ getNumLines()

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

Returns the number of lines in the layout.

◆ getWidth()

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

Returns the maximum width of the content.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ recalculateSize()

void juce::TextLayout::recalculateSize ( )

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

Member Data Documentation

◆ height

float juce::TextLayout::height
private

◆ justification

Justification juce::TextLayout::justification
private

◆ lines

OwnedArray<Line> juce::TextLayout::lines
private

◆ width

float juce::TextLayout::width
private

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