diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-04 13:24:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-04 13:24:01 +0300 |
commit | 0c7a1466e8c2c2dd6e15779368c87b62b2da601f (patch) | |
tree | 24be0979382c8844c68365cac1d6de046da16681 /src/gui | |
parent | eed0bccd09e5708eb9b629c14f69022e362f4aa4 (diff) | |
download | manaverse-0c7a1466e8c2c2dd6e15779368c87b62b2da601f.tar.gz manaverse-0c7a1466e8c2c2dd6e15779368c87b62b2da601f.tar.bz2 manaverse-0c7a1466e8c2c2dd6e15779368c87b62b2da601f.tar.xz manaverse-0c7a1466e8c2c2dd6e15779368c87b62b2da601f.zip |
Add text fileds cursor (caret) color.
New theme colors: CARET
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/theme.cpp | 1 | ||||
-rw-r--r-- | src/gui/theme.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/textfield.h | 3 |
4 files changed, 15 insertions, 2 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 7b85c8764..730471ceb 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -696,6 +696,7 @@ static int readColorType(const std::string &type) { "BROWSERBOX", "TEXT", + "CARET", "SHADOW", "OUTLINE", "BORDER", diff --git a/src/gui/theme.h b/src/gui/theme.h index a32237be1..ee9352794 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -166,6 +166,7 @@ class Theme final : public Palette, public ConfigListener { BROWSERBOX = 0, TEXT, + CARET, SHADOW, OUTLINE, BORDER, diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index eb4e2f7cb..ac29eac25 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -56,10 +56,10 @@ TextField::TextField(const std::string &text, const bool loseFocusOnTab, mMinimum(0), mMaximum(0), mLoseFocusOnTab(loseFocusOnTab), - mLastEventPaste(false) + mLastEventPaste(false), + mCaretColor(&Theme::getThemeColor(Theme::CARET)) { setFrameSize(2); - mForegroundColor = Theme::getThemeColor(Theme::TEXTFIELD); if (instances == 0) @@ -440,3 +440,11 @@ void TextField::handleCopy() const std::string text = getText(); sendBuffer(text); } + +void TextField::drawCaret(gcn::Graphics* graphics, int x) +{ + const gcn::Rectangle clipArea = graphics->getCurrentClipArea(); + + graphics->setColor(*mCaretColor); + graphics->drawLine(x, clipArea.height - 2, x, 1); +} diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 72d679052..97048ccba 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -104,6 +104,8 @@ class TextField : public gcn::TextField { mSendAlwaysEvents = b; } protected: + void drawCaret(gcn::Graphics* graphics, int x) override; + bool mSendAlwaysEvents; private: @@ -119,6 +121,7 @@ class TextField : public gcn::TextField unsigned mMaximum; bool mLoseFocusOnTab; int mLastEventPaste; + const gcn::Color *mCaretColor; }; #endif |