A drawable object which renders a line of text.
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 String & | getText () 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 StrokeOptions & | getStrokeOptions () |
| Returns the currently specified stroke attributes. | |
| void | setFont (const Font &newFont, bool applySizeAndScale) |
| Sets the font to use. | |
| const Font & | getFont () 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< Drawable > | createCopy () 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< String > | getContainedText () 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 String & | getName () 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< Drawable > | createFromImageData (const void *data, size_t numBytes) |
| Tries to turn some kind of image file into a drawable. | |
| static std::unique_ptr< Drawable > | createFromImageDataStream (InputStream &dataSource) |
| Tries to turn a stream containing some kind of image data into a drawable. | |
| static std::unique_ptr< Drawable > | createFromImageFile (const File &file) |
| Tries to turn a file containing some kind of image data into a drawable. | |
| static std::unique_ptr< Drawable > | createFromSVGFile (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< DrawableComposite > | createFromSVGString (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 () |
|
default |
Creates a DrawableText object.
| void juce::DrawableText::setText | ( | const String & | newText | ) |
Sets the text to display.
| 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.
|
inlinenoexcept |
Returns the currently displayed text.
| void juce::DrawableText::setColour | ( | Colour | newColour | ) |
Sets the colour of the text.
| void juce::DrawableText::setFill | ( | const FillType & | newFill | ) |
Sets a fill type for the text.
|
inlinenoexcept |
Returns the current text colour.
| 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.
|
inline |
Returns the currently specified stroke attributes.
A stroke with a width of 0.0f is considered invisible, and will not be drawn.
| 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.
|
inlinenoexcept |
Returns the current font.
| void juce::DrawableText::setJustification | ( | Justification | newJustification | ) |
Changes the justification of the text within the bounding box.
|
inlinenoexcept |
Returns the current justification.
|
inlinenoexcept |
Returns the parallelogram that defines the text bounding box.
| void juce::DrawableText::setBoundingBox | ( | Parallelogram< float > | newBounds | ) |
Sets the bounding box that contains the text.
|
overridevirtual |
Tests whether a given point is inside the Drawable.
Implements juce::Drawable.
|
inlinenoexcept |
| void juce::DrawableText::setFontHeight | ( | float | newHeight | ) |
|
inlinenoexcept |
| void juce::DrawableText::setFontHorizontalScale | ( | float | newScale | ) |
|
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.
|
overridevirtual |
Returns the area that this drawable covers in its original coordinate system.
These bounds are not affected by setDrawableTransform().
Implements juce::Drawable.
|
overridevirtual |
Creates a path that describes the outline of this drawable.
Implements juce::Drawable.
|
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.
|
overridevirtual |
Reimplemented from juce::Drawable.