summaryrefslogtreecommitdiff
path: root/src/gui/widgets/textbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-27 14:42:15 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:05 +0300
commit60add2c149c9c61bfbede5ae92cfe216927aca8a (patch)
tree9ded097faa108eb07b9ca1c8ce4490882e238a44 /src/gui/widgets/textbox.cpp
parent2babe1d6491f5231b0e97349ccb198b92bb90ba9 (diff)
downloadmv-60add2c149c9c61bfbede5ae92cfe216927aca8a.tar.gz
mv-60add2c149c9c61bfbede5ae92cfe216927aca8a.tar.bz2
mv-60add2c149c9c61bfbede5ae92cfe216927aca8a.tar.xz
mv-60add2c149c9c61bfbede5ae92cfe216927aca8a.zip
Improve a bit draw speed in other controls.
Diffstat (limited to 'src/gui/widgets/textbox.cpp')
-rw-r--r--src/gui/widgets/textbox.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 51933708b..976d7f772 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -338,3 +338,32 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent)
keyEvent.consume();
}
+
+void TextBox::draw(gcn::Graphics* graphics)
+{
+ BLOCK_START("TextBox::draw")
+ if (mOpaque)
+ {
+ graphics->setColor(mBackgroundColor);
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ }
+
+ if (isFocused() && isEditable())
+ {
+ drawCaret(graphics, getFont()->getWidth(
+ mTextRows[mCaretRow].substr(0, mCaretColumn)),
+ mCaretRow * getFont()->getHeight());
+ }
+
+ graphics->setColor(mForegroundColor);
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
+ const int fontHeight = font->getHeight();
+
+ for (size_t i = 0, sz = mTextRows.size(); i < sz; i++)
+ {
+ // Move the text one pixel so we can have a caret before a letter.
+ font->drawString(graphics, mTextRows[i], 1, i * fontHeight);
+ }
+ BLOCK_END("TextBox::draw")
+}