30 : colour (Colours::black),
39 bounds (
other.bounds),
40 fontHeight (
other.fontHeight),
41 fontHScale (
other.fontHScale),
44 colour (
other.colour),
45 justification (
other.justification)
56 return std::make_unique<DrawableText> (*
this);
109void DrawableText::setFontHeight (
float newHeight)
118void DrawableText::setFontHorizontalScale (
float newScale)
127void DrawableText::refreshBounds()
132 auto height =
jlimit (0.01f,
jmax (0.01f, h), fontHeight);
144Rectangle<int> DrawableText::getTextArea (
float w,
float h)
const
146 return Rectangle<float> (w, h).getSmallestIntegerContainer();
149AffineTransform DrawableText::getTextTransform (
float w,
float h)
const
152 Point<float> (w, 0), bounds.topRight,
153 Point<float> (0, h), bounds.bottomLeft);
158 transformContextToCorrectOrigin (g);
167 g.
drawFittedText (text, getTextArea (w, h), justification, 0x100000);
179 auto area = getTextArea (w, h).
toFloat();
183 area.getX(), area.getY(),
184 area.getWidth(), area.getHeight(),
190 for (
auto& glyph :
arr)
217 DrawableTextAccessibilityHandler (
DrawableText& drawableTextToWrap)
219 drawableText (drawableTextToWrap)
223 String getTitle()
const override {
return drawableText.getText(); }
229 return std::make_unique<DrawableTextAccessibilityHandler> (*
this);
Base class for accessible Components.
Represents a colour, also including a transparency value.
void repaint()
Marks the whole component as needing to be redrawn.
A drawable object which renders a line of text.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
Rectangle< float > getDrawableBounds() const override
Returns the area that this drawable covers.
void setJustification(Justification newJustification)
Changes the justification of the text within the bounding box.
std::unique_ptr< Drawable > createCopy() const override
Creates a deep copy of this Drawable object.
void setText(const String &newText)
Sets the text to display.
bool replaceColour(Colour originalColour, Colour replacementColour) override
Recursively replaces a colour that might be used for filling or stroking.
Path getOutlineAsPath() const override
Creates a path that describes the outline of this drawable.
void setColour(Colour newColour)
Sets the colour of the text.
~DrawableText() override
Destructor.
void setFont(const Font &newFont, bool applySizeAndScale)
Sets the font to use.
void paint(Graphics &) override
Components can override this method to draw their content.
DrawableText()
Creates a DrawableText object.
void setBoundingBox(Parallelogram< float > newBounds)
Sets the bounding box that contains the text.
The base class for objects which can draw themselves, e.g.
Represents a particular font, including its size, style, etc.
float getHeight() const noexcept
Returns the total height of this font, in pixels.
void setHorizontalScale(float scaleFactor)
Changes the font's horizontal scale factor.
void setHeight(float newHeight)
Changes the font's height.
float getHorizontalScale() const noexcept
Returns the font's horizontal scale.
A set of glyphs, each with a position.
void addFittedText(const Font &font, const String &text, float x, float y, float width, float height, Justification layout, int maximumLinesToUse, float minimumHorizontalScale=0.0f)
Tries to fit some text within a given space.
A graphics context, used for drawing a component or image.
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void addTransform(const AffineTransform &transform)
Adds a transformation which will be performed on all the graphics operations that the context subsequ...
void setColour(Colour newColour)
Changes the current drawing colour.
Represents a type of justification to be used when positioning graphical items.
Represents a parallelogram that is defined by 3 points.
ValueType getWidth() const noexcept
Returns the width of the parallelogram (i.e.
Rectangle< ValueType > getBoundingBox() const noexcept
Returns the smallest rectangle that encloses this parallelogram.
ValueType getHeight() const noexcept
Returns the height of the parallelogram (i.e.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
void addPath(const Path &pathToAppend)
Adds another path to this one.
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle< float > toFloat() const noexcept
Casts this rectangle to a Rectangle<float>.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...