From 2b7ea89d14cc75ede0c96b67c3eb126545016d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 5 Sep 2013 10:23:11 +0200 Subject: [PATCH] HaikuDepot: Give access to glyph spacing * The implementation for the get-accessors was missing from CharacterStyle. --- .../haiku-depot/textview/CharacterStyle.cpp | 89 +++++++++++++++++++ .../haiku-depot/textview/CharacterStyle.h | 3 + .../textview/CharacterStyleData.cpp | 15 ++++ .../haiku-depot/textview/CharacterStyleData.h | 4 + 4 files changed, 111 insertions(+) diff --git a/src/apps/haiku-depot/textview/CharacterStyle.cpp b/src/apps/haiku-depot/textview/CharacterStyle.cpp index 9923bb21ee..07a120e1dd 100644 --- a/src/apps/haiku-depot/textview/CharacterStyle.cpp +++ b/src/apps/haiku-depot/textview/CharacterStyle.cpp @@ -66,6 +66,13 @@ CharacterStyle::SetFont(const BFont& font) } +const BFont& +CharacterStyle::Font() const +{ + return fStyleData->Font(); +} + + bool CharacterStyle::SetAscent(float ascent) { @@ -78,6 +85,13 @@ CharacterStyle::SetAscent(float ascent) } +float +CharacterStyle::Ascent() const +{ + return fStyleData->Ascent(); +} + + bool CharacterStyle::SetDescent(float descent) { @@ -90,6 +104,13 @@ CharacterStyle::SetDescent(float descent) } +float +CharacterStyle::Descent() const +{ + return fStyleData->Descent(); +} + + bool CharacterStyle::SetWidth(float width) { @@ -102,6 +123,32 @@ CharacterStyle::SetWidth(float width) } +float +CharacterStyle::Width() const +{ + return fStyleData->Width(); +} + + +bool +CharacterStyle::SetGlyphSpacing(float spacing) +{ + CharacterStyleDataRef data = fStyleData->SetGlyphSpacing(spacing); + if (data == fStyleData) + return data->GlyphSpacing() == spacing; + + fStyleData = data; + return true; +} + + +float +CharacterStyle::GlyphSpacing() const +{ + return fStyleData->GlyphSpacing(); +} + + bool CharacterStyle::SetForegroundColor(rgb_color color) { @@ -114,6 +161,13 @@ CharacterStyle::SetForegroundColor(rgb_color color) } +rgb_color +CharacterStyle::ForegroundColor() const +{ + return fStyleData->ForegroundColor(); +} + + bool CharacterStyle::SetBackgroundColor(rgb_color color) { @@ -126,6 +180,13 @@ CharacterStyle::SetBackgroundColor(rgb_color color) } +rgb_color +CharacterStyle::BackgroundColor() const +{ + return fStyleData->BackgroundColor(); +} + + bool CharacterStyle::SetStrikeOutColor(rgb_color color) { @@ -138,6 +199,13 @@ CharacterStyle::SetStrikeOutColor(rgb_color color) } +rgb_color +CharacterStyle::StrikeOutColor() const +{ + return fStyleData->StrikeOutColor(); +} + + bool CharacterStyle::SetUnderlineColor(rgb_color color) { @@ -150,6 +218,13 @@ CharacterStyle::SetUnderlineColor(rgb_color color) } +rgb_color +CharacterStyle::UnderlineColor() const +{ + return fStyleData->UnderlineColor(); +} + + bool CharacterStyle::SetStrikeOut(uint8 strikeOut) { @@ -162,6 +237,13 @@ CharacterStyle::SetStrikeOut(uint8 strikeOut) } +uint8 +CharacterStyle::StrikeOut() const +{ + return fStyleData->StrikeOut(); +} + + bool CharacterStyle::SetUnderline(uint8 underline) { @@ -174,3 +256,10 @@ CharacterStyle::SetUnderline(uint8 underline) } +uint8 +CharacterStyle::Underline() const +{ + return fStyleData->Underline(); +} + + diff --git a/src/apps/haiku-depot/textview/CharacterStyle.h b/src/apps/haiku-depot/textview/CharacterStyle.h index eb6a7e6678..c294eebfe3 100644 --- a/src/apps/haiku-depot/textview/CharacterStyle.h +++ b/src/apps/haiku-depot/textview/CharacterStyle.h @@ -29,6 +29,9 @@ public: bool SetWidth(float width); float Width() const; + bool SetGlyphSpacing(float spacing); + float GlyphSpacing() const; + bool SetForegroundColor(rgb_color color); rgb_color ForegroundColor() const; diff --git a/src/apps/haiku-depot/textview/CharacterStyleData.cpp b/src/apps/haiku-depot/textview/CharacterStyleData.cpp index a5a04011d0..d5f23fa811 100644 --- a/src/apps/haiku-depot/textview/CharacterStyleData.cpp +++ b/src/apps/haiku-depot/textview/CharacterStyleData.cpp @@ -140,6 +140,21 @@ CharacterStyleData::SetWidth(float width) } +CharacterStyleDataRef +CharacterStyleData::SetGlyphSpacing(float glyphSpacing) +{ + if (fGlyphSpacing == glyphSpacing) + return CharacterStyleDataRef(this); + + CharacterStyleData* ret = new(std::nothrow) CharacterStyleData(*this); + if (ret == NULL) + return CharacterStyleDataRef(this); + + ret->fGlyphSpacing = glyphSpacing; + return CharacterStyleDataRef(ret, true); +} + + CharacterStyleDataRef CharacterStyleData::SetForegroundColor(rgb_color color) { diff --git a/src/apps/haiku-depot/textview/CharacterStyleData.h b/src/apps/haiku-depot/textview/CharacterStyleData.h index c445aa883d..35789942fe 100644 --- a/src/apps/haiku-depot/textview/CharacterStyleData.h +++ b/src/apps/haiku-depot/textview/CharacterStyleData.h @@ -57,6 +57,10 @@ public: inline float Width() const { return fWidth; } + CharacterStyleDataRef SetGlyphSpacing(float glyphSpacing); + inline float GlyphSpacing() const + { return fGlyphSpacing; } + CharacterStyleDataRef SetForegroundColor(rgb_color color); inline rgb_color ForegroundColor() const { return fFgColor; }