HaikuDepot: CharacterStyle: Added convenience methods
This commit is contained in:
parent
15990b01a2
commit
d922357fa1
@ -73,6 +73,15 @@ CharacterStyle::Font() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CharacterStyle::SetFontSize(float size)
|
||||
{
|
||||
BFont font(Font());
|
||||
font.SetSize(size);
|
||||
return SetFont(font);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CharacterStyle::SetAscent(float ascent)
|
||||
{
|
||||
@ -149,6 +158,13 @@ CharacterStyle::GlyphSpacing() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CharacterStyle::SetForegroundColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
||||
{
|
||||
return SetForegroundColor((rgb_color){ r, g, b, a });
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CharacterStyle::SetForegroundColor(rgb_color color)
|
||||
{
|
||||
@ -168,6 +184,13 @@ CharacterStyle::ForegroundColor() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CharacterStyle::SetBackgroundColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
||||
{
|
||||
return SetBackgroundColor((rgb_color){ r, g, b, a });
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CharacterStyle::SetBackgroundColor(rgb_color color)
|
||||
{
|
||||
|
@ -20,6 +20,8 @@ public:
|
||||
bool SetFont(const BFont& font);
|
||||
const BFont& Font() const;
|
||||
|
||||
bool SetFontSize(float size);
|
||||
|
||||
bool SetAscent(float ascent);
|
||||
float Ascent() const;
|
||||
|
||||
@ -32,9 +34,15 @@ public:
|
||||
bool SetGlyphSpacing(float spacing);
|
||||
float GlyphSpacing() const;
|
||||
|
||||
bool SetForegroundColor(
|
||||
uint8 r, uint8 g, uint8 b,
|
||||
uint8 a = 255);
|
||||
bool SetForegroundColor(rgb_color color);
|
||||
rgb_color ForegroundColor() const;
|
||||
|
||||
bool SetBackgroundColor(
|
||||
uint8 r, uint8 g, uint8 b,
|
||||
uint8 a = 255);
|
||||
bool SetBackgroundColor(rgb_color color);
|
||||
rgb_color BackgroundColor() const;
|
||||
|
||||
|
@ -110,6 +110,18 @@ CharacterStyleData::SetAscent(float ascent)
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
CharacterStyleData::Ascent() const
|
||||
{
|
||||
if (fAscent >= 0.0f)
|
||||
return fAscent;
|
||||
|
||||
font_height fontHeight;
|
||||
fFont.GetHeight(&fontHeight);
|
||||
return fontHeight.ascent;
|
||||
}
|
||||
|
||||
|
||||
CharacterStyleDataRef
|
||||
CharacterStyleData::SetDescent(float descent)
|
||||
{
|
||||
@ -125,6 +137,18 @@ CharacterStyleData::SetDescent(float descent)
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
CharacterStyleData::Descent() const
|
||||
{
|
||||
if (fDescent >= 0.0f)
|
||||
return fDescent;
|
||||
|
||||
font_height fontHeight;
|
||||
fFont.GetHeight(&fontHeight);
|
||||
return fontHeight.descent;
|
||||
}
|
||||
|
||||
|
||||
CharacterStyleDataRef
|
||||
CharacterStyleData::SetWidth(float width)
|
||||
{
|
||||
|
@ -46,12 +46,10 @@ public:
|
||||
{ return fFont; }
|
||||
|
||||
CharacterStyleDataRef SetAscent(float ascent);
|
||||
inline float Ascent() const
|
||||
{ return fAscent; }
|
||||
float Ascent() const;
|
||||
|
||||
CharacterStyleDataRef SetDescent(float descent);
|
||||
inline float Descent() const
|
||||
{ return fDescent; }
|
||||
float Descent() const;
|
||||
|
||||
CharacterStyleDataRef SetWidth(float width);
|
||||
inline float Width() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user