class ButtonWithLabel : public Button
{
public:
ButtonWithLabel();
void setLabelText(TypedText t)
{
typedText = t;
updateTextPosition();
}
TypedText getLabelText() const
{
return typedText;
}
void setLabelColor(colortype col, bool performInvalidate = false)
{
color = col;
if (performInvalidate)
{
invalidate();
}
}
void setLabelColorPressed(colortype col, bool performInvalidate = false)
{
colorPressed = col;
if (performInvalidate)
{
invalidate();
}
}
void setLabelRotation(TextRotation rotation)
{
this->rotation = rotation;
}
TextRotation getLabelRotation()
{
return rotation;
}
void updateTextPosition()
{
const Font* f = typedText.getFont();
const Unicode::UnicodeChar* s = typedText.getText();
textHeightIncludingSpacing = f->getMaxTextHeight(s) * f->getNumberOfLines(s) + f->getSpacingAbove(s);
}
virtual Rect getSolidRect() const
{
return Button::getSolidRect();
};
virtual void draw(const Rect& area) const;
virtual uint16_t getType() const
{
return (uint16_t)TYPE_BUTTONWITHLABEL;
}
protected:
TypedText typedText;
colortype color;
colortype colorPressed;
TextRotation rotation;
uint8_t textHeightIncludingSpacing;
};