summaryrefslogtreecommitdiff
path: root/src/guichan/widgets/textfield.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-15 04:22:11 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-15 04:22:11 +0300
commitc91bc5201596eda73f9df2222d76d9f413426a85 (patch)
treecbdcf7fb76eee35baf7265e5c04da2f13633ab5d /src/guichan/widgets/textfield.cpp
parent255b1c29f47ef3b1e7a9b058c56ef72bfa10c5e3 (diff)
downloadplus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.gz
plus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.bz2
plus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.xz
plus-c91bc5201596eda73f9df2222d76d9f413426a85.zip
Remove some diplicated code from embeded guichan.
Diffstat (limited to 'src/guichan/widgets/textfield.cpp')
-rw-r--r--src/guichan/widgets/textfield.cpp96
1 files changed, 0 insertions, 96 deletions
diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp
index af2b9582f..d224e483f 100644
--- a/src/guichan/widgets/textfield.cpp
+++ b/src/guichan/widgets/textfield.cpp
@@ -89,55 +89,6 @@ namespace gcn
mText = text;
}
- void TextField::draw(Graphics* graphics)
- {
- Color faceColor = getBaseColor();
- Color highlightColor, shadowColor;
- int alpha = getBaseColor().a;
- highlightColor = faceColor + 0x303030;
- highlightColor.a = alpha;
- shadowColor = faceColor - 0x303030;
- shadowColor.a = alpha;
-
- // Draw a border.
- graphics->setColor(shadowColor);
- graphics->drawLine(0, 0, getWidth() - 1, 0);
- graphics->drawLine(0, 1, 0, getHeight() - 2);
- graphics->setColor(highlightColor);
- graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1);
- graphics->drawLine(0, getHeight() - 1,
- getWidth() - 1, getHeight() - 1);
-
- // Push a clip area so the other drawings don't need to worry
- // about the border.
- graphics->pushClipArea(Rectangle(1, 1,
- getWidth() - 2, getHeight() - 2));
-
- graphics->setColor(getBackgroundColor());
- graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
-
- if (isFocused())
- {
- graphics->setColor(getSelectionColor());
- graphics->drawRectangle(Rectangle(0, 0,
- getWidth() - 2, getHeight() - 2));
- graphics->drawRectangle(Rectangle(1, 1,
- getWidth() - 4, getHeight() - 4));
- }
-
- if (isFocused())
- {
- drawCaret(graphics, getFont()->getWidth(
- mText.substr(0, mCaretPosition)) - mXScroll);
- }
-
- graphics->setColor(getForegroundColor());
- graphics->setFont(getFont());
- graphics->drawText(mText, 3 - mXScroll, 1);
-
- graphics->popClipArea();
- }
-
void TextField::drawCaret(Graphics* graphics, int x)
{
// Check the current clip area as a clip area with a different
@@ -164,53 +115,6 @@ namespace gcn
{
mouseEvent.consume();
}
-
- void TextField::keyPressed(KeyEvent& keyEvent)
- {
- Key key = keyEvent.getKey();
-
- if (key.getValue() == Key::LEFT && mCaretPosition > 0)
- {
- --mCaretPosition;
- }
- else if (key.getValue() == Key::RIGHT && mCaretPosition < mText.size())
- {
- ++mCaretPosition;
- }
- else if (key.getValue() == Key::DELETE
- && mCaretPosition < mText.size())
- {
- mText.erase(mCaretPosition, 1);
- }
- else if (key.getValue() == Key::BACKSPACE && mCaretPosition > 0)
- {
- mText.erase(mCaretPosition - 1, 1);
- --mCaretPosition;
- }
- else if (key.getValue() == Key::ENTER)
- {
- distributeActionEvent();
- }
- else if (key.getValue() == Key::HOME)
- {
- mCaretPosition = 0;
- }
- else if (key.getValue() == Key::END)
- {
- mCaretPosition = mText.size();
- }
- else if (key.isCharacter()
- && key.getValue() != Key::TAB)
- {
- mText.insert(mCaretPosition, std::string(1, (char)key.getValue()));
- ++mCaretPosition;
- }
-
- if (key.getValue() != Key::TAB)
- keyEvent.consume();
-
- fixScroll();
- }
void TextField::adjustSize()
{