Loading...
Searching...
No Matches
juce::DrawableText Class Reference

Detailed Description

A drawable object which renders a line of text.

See also
Drawable

The documentation for this class was generated from the following file:
Inheritance diagram for juce::DrawableText:

Public Member Functions

 DrawableText ()=default
 Creates a DrawableText object.
void setText (const String &newText)
 Sets the text to display.
void setPreserveWhitespace (bool shouldPreserveWhitespace)
 Sets whether whitespace should always be preserved when drawing.
const StringgetText () const noexcept
 Returns the currently displayed text.
void setColour (Colour newColour)
 Sets the colour of the text.
void setFill (const FillType &newFill)
 Sets a fill type for the text.
Colour getColour () const noexcept
 Returns the current text colour.
void setStrokeOptions (const StrokeOptions &newStrokeOptions)
 Changes the properties of the outline that will be drawn around the text.
const StrokeOptionsgetStrokeOptions ()
 Returns the currently specified stroke attributes.
void setFont (const Font &newFont, bool applySizeAndScale)
 Sets the font to use.
const FontgetFont () const noexcept
 Returns the current font.
void setJustification (Justification newJustification)
 Changes the justification of the text within the bounding box.
Justification getJustification () const noexcept
 Returns the current justification.
Parallelogram< float > getBoundingBox () const noexcept
 Returns the parallelogram that defines the text bounding box.
void setBoundingBox (Parallelogram< float > newBounds)
 Sets the bounding box that contains the text.
bool hitTest (Point< float > p) const override
 Tests whether a given point is inside the Drawable.
float getFontHeight () const noexcept
void setFontHeight (float newHeight)
float getFontHorizontalScale () const noexcept
void setFontHorizontalScale (float newScale)
std::unique_ptr< DrawablecreateCopy () const override
 Creates a deep copy of this Drawable object.
Rectangle< float > getDrawableBoundsUntransformed () const override
 Returns the area that this drawable covers in its original coordinate system.
Path getOutlineAsPath () const override
 Creates a path that describes the outline of this drawable.
bool replaceColour (Colour originalColour, Colour replacementColour) override
 Recursively replaces a colour that might be used for filling or stroking.
std::optional< StringgetContainedText () const override
Public Member Functions inherited from juce::Drawable
 Drawable ()=default
 Constructor.
 Drawable (const Drawable &other)
 Copy constructor.
virtual ~Drawable ()=default
 Destructor.
void draw (Graphics &g, float opacity, const AffineTransform &transform=AffineTransform()) const
 Renders this Drawable object.
void drawAt (Graphics &g, float x, float y, float opacity) const
 Renders the Drawable at a given offset within the Graphics context.
void drawWithin (Graphics &g, Rectangle< float > destArea, RectanglePlacement placement, float opacity) const
 Renders the Drawable within a rectangle, scaling it to fit neatly inside without changing its aspect-ratio.
void setClipPath (std::unique_ptr< Drawable > drawableClipPath)
 Sets a the clipping region of this drawable using another drawable.
Rectangle< float > getDrawableBounds () const
 Returns the area that this drawable covers.
int getWidth () const
 Returns the width of the drawable bounds rounded up to the nearest integer.
int getHeight () const
 Returns the height of the drawable bounds rounded up to the nearest integer.
void setDrawableTransform (const AffineTransform &transform)
 Sets a transformation that applies to the same coordinate system in which the rest of the draw calls are made.
void setDrawableTransformToFit (const Rectangle< float > &area, RectanglePlacement placement)
 Calls setDrawableTransform() with a transform that will position this Drawable within the specified area in the untransformed coordinate system of the Drawable.
AffineTransform getDrawableTransform () const
 Returns the transform that is currently being applied to this drawable.
const StringgetName () const
 Returns the name of this Drawable object.
void setName (const String &newName)
 Sets the name of this drawable object.
void addListener (Listener *newListener)
 Adds a listener.
void removeListener (Listener *listenerToRemove)
 Removes a listener.
virtual bool isImage () const
virtual bool requiresBlendBuffer () const

Additional Inherited Members

Static Public Member Functions inherited from juce::Drawable
static std::unique_ptr< DrawablecreateFromImageData (const void *data, size_t numBytes)
 Tries to turn some kind of image file into a drawable.
static std::unique_ptr< DrawablecreateFromImageDataStream (InputStream &dataSource)
 Tries to turn a stream containing some kind of image data into a drawable.
static std::unique_ptr< DrawablecreateFromImageFile (const File &file)
 Tries to turn a file containing some kind of image data into a drawable.
static std::unique_ptr< DrawablecreateFromSVGFile (const File &svgFile)
 Attempts to parse an SVG (Scalable Vector Graphics) document from a file, and to turn this into a Drawable tree.
static std::unique_ptr< DrawableCompositecreateFromSVGString (const String &svgString)
 Attempts to parse an SVG (Scalable Vector Graphics) document from a string, and to turn this into a Drawable tree.
static Path parseSVGPath (const String &svgPath)
 Parses an SVG path string and returns it.
Protected Member Functions inherited from juce::Drawable
void callListeners ()

Constructors and Destructors

◆ DrawableText()

juce::DrawableText::DrawableText ( )
default

Creates a DrawableText object.

Member Functions

◆ setText()

void juce::DrawableText::setText ( const String & newText)

Sets the text to display.

◆ setPreserveWhitespace()

void juce::DrawableText::setPreserveWhitespace ( bool shouldPreserveWhitespace)

Sets whether whitespace should always be preserved when drawing.

The default value is false.

Historically, DrawableText would sometimes trim the provided text during drawing based on its contents. With this value set to true, trimming will never occur.

◆ getText()

const String & juce::DrawableText::getText ( ) const
inlinenoexcept

Returns the currently displayed text.

◆ setColour()

void juce::DrawableText::setColour ( Colour newColour)

Sets the colour of the text.

◆ setFill()

void juce::DrawableText::setFill ( const FillType & newFill)

Sets a fill type for the text.

◆ getColour()

Colour juce::DrawableText::getColour ( ) const
inlinenoexcept

Returns the current text colour.

◆ setStrokeOptions()

void juce::DrawableText::setStrokeOptions ( const StrokeOptions & newStrokeOptions)

Changes the properties of the outline that will be drawn around the text.

By default the text has no stroke. Specifying any StrokeOptions with a width of 0.0f will be similarly not drawn.

See also
setStrokeThickness, setStrokeColour

◆ getStrokeOptions()

const StrokeOptions & juce::DrawableText::getStrokeOptions ( )
inline

Returns the currently specified stroke attributes.

A stroke with a width of 0.0f is considered invisible, and will not be drawn.

See also
setFill

◆ setFont()

void juce::DrawableText::setFont ( const Font & newFont,
bool applySizeAndScale )

Sets the font to use.

Note that the font height and horizontal scale are set using setFontHeight() and setFontHorizontalScale(). If applySizeAndScale is true, then these height and scale values will be changed to match the dimensions of the font supplied; if it is false, then the new font object's height and scale are ignored.

◆ getFont()

const Font & juce::DrawableText::getFont ( ) const
inlinenoexcept

Returns the current font.

◆ setJustification()

void juce::DrawableText::setJustification ( Justification newJustification)

Changes the justification of the text within the bounding box.

◆ getJustification()

Justification juce::DrawableText::getJustification ( ) const
inlinenoexcept

Returns the current justification.

◆ getBoundingBox()

Parallelogram< float > juce::DrawableText::getBoundingBox ( ) const
inlinenoexcept

Returns the parallelogram that defines the text bounding box.

◆ setBoundingBox()

void juce::DrawableText::setBoundingBox ( Parallelogram< float > newBounds)

Sets the bounding box that contains the text.

◆ hitTest()

bool juce::DrawableText::hitTest ( Point< float > p) const
overridevirtual

Tests whether a given point is inside the Drawable.

Implements juce::Drawable.

◆ getFontHeight()

float juce::DrawableText::getFontHeight ( ) const
inlinenoexcept

◆ setFontHeight()

void juce::DrawableText::setFontHeight ( float newHeight)

◆ getFontHorizontalScale()

float juce::DrawableText::getFontHorizontalScale ( ) const
inlinenoexcept

◆ setFontHorizontalScale()

void juce::DrawableText::setFontHorizontalScale ( float newScale)

◆ createCopy()

std::unique_ptr< Drawable > juce::DrawableText::createCopy ( ) const
overridevirtual

Creates a deep copy of this Drawable object.

Use this to create a new copy of this and any sub-objects in the tree.

Implements juce::Drawable.

◆ getDrawableBoundsUntransformed()

Rectangle< float > juce::DrawableText::getDrawableBoundsUntransformed ( ) const
overridevirtual

Returns the area that this drawable covers in its original coordinate system.

These bounds are not affected by setDrawableTransform().

See also
getDrawableBounds

Implements juce::Drawable.

◆ getOutlineAsPath()

Path juce::DrawableText::getOutlineAsPath ( ) const
overridevirtual

Creates a path that describes the outline of this drawable.

Implements juce::Drawable.

◆ replaceColour()

bool juce::DrawableText::replaceColour ( Colour originalColour,
Colour replacementColour )
overridevirtual

Recursively replaces a colour that might be used for filling or stroking.

return true if any instances of this colour were found.

Reimplemented from juce::Drawable.

◆ getContainedText()

std::optional< String > juce::DrawableText::getContainedText ( ) const
overridevirtual

Reimplemented from juce::Drawable.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram