summaryrefslogtreecommitdiff
path: root/src/guichan/widgets/textfield.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-21 19:33:46 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-21 19:33:46 +0300
commitdfb302bb66f032eb0c7eb4bc0934fdf0571a1d3a (patch)
tree4d312704c7d42bc0d3a0f2ab44e8071a7058d6bb /src/guichan/widgets/textfield.cpp
parentc29b91939d1c8e8f7772a660ad4d4bee83dec668 (diff)
downloadplus-dfb302bb66f032eb0c7eb4bc0934fdf0571a1d3a.tar.gz
plus-dfb302bb66f032eb0c7eb4bc0934fdf0571a1d3a.tar.bz2
plus-dfb302bb66f032eb0c7eb4bc0934fdf0571a1d3a.tar.xz
plus-dfb302bb66f032eb0c7eb4bc0934fdf0571a1d3a.zip
Extend textfield theming.
New theme options: padding frameSize
Diffstat (limited to 'src/guichan/widgets/textfield.cpp')
-rw-r--r--src/guichan/widgets/textfield.cpp29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp
index 64d647631..c0575eace 100644
--- a/src/guichan/widgets/textfield.cpp
+++ b/src/guichan/widgets/textfield.cpp
@@ -115,46 +115,18 @@ namespace gcn
void TextField::adjustSize()
{
- setWidth(getFont()->getWidth(mText) + 7);
- adjustHeight();
-
- fixScroll();
}
void TextField::adjustHeight()
{
- setHeight(getFont()->getHeight() + 4);
}
void TextField::fixScroll()
{
- if (isFocused())
- {
- const int caretX = getFont()->getWidth(
- mText.substr(0, mCaretPosition));
-
- if (caretX - mXScroll >= getWidth() - 4)
- {
- mXScroll = caretX - getWidth() + 4;
- }
- else if (caretX - mXScroll <= 0)
- {
- mXScroll = caretX - getWidth() / 2;
-
- if (mXScroll < 0)
- mXScroll = 0;
- }
- }
}
void TextField::setCaretPosition(unsigned int position)
{
- if (position > mText.size())
- mCaretPosition = static_cast<int>(mText.size());
- else
- mCaretPosition = position;
-
- fixScroll();
}
unsigned int TextField::getCaretPosition() const
@@ -169,6 +141,5 @@ namespace gcn
void TextField::fontChanged()
{
- fixScroll();
}
}