diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-09-15 04:22:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-09-15 04:22:11 +0300 |
commit | c91bc5201596eda73f9df2222d76d9f413426a85 (patch) | |
tree | cbdcf7fb76eee35baf7265e5c04da2f13633ab5d /src/guichan/widgets/dropdown.cpp | |
parent | 255b1c29f47ef3b1e7a9b058c56ef72bfa10c5e3 (diff) | |
download | manaplus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.gz manaplus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.bz2 manaplus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.xz manaplus-c91bc5201596eda73f9df2222d76d9f413426a85.zip |
Remove some diplicated code from embeded guichan.
Diffstat (limited to 'src/guichan/widgets/dropdown.cpp')
-rw-r--r-- | src/guichan/widgets/dropdown.cpp | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 7af01e703..3ecbd75d8 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -122,131 +122,6 @@ namespace gcn setInternalFocusHandler(NULL); } - void DropDown::draw(Graphics* graphics) - { - int h; - - if (mDroppedDown) - h = mFoldedUpHeight; - else - h = getHeight(); - - 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, h - 2); - graphics->setColor(highlightColor); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, h - 1); - graphics->drawLine(0, h - 1, getWidth() - 1, h - 1); - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, getWidth() - 2, h - 2)); - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width, currentClipArea.height)); - - if (isFocused()) - { - graphics->setColor(getSelectionColor()); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width - currentClipArea.height, - currentClipArea.height)); - graphics->setColor(getForegroundColor()); - } - - if (mListBox->getListModel() - && mListBox->getSelected() >= 0) - { - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - - graphics->drawText(mListBox->getListModel()->getElementAt( - mListBox->getSelected()), 1, 0); - } - - // Push a clip area before drawing the button. - graphics->pushClipArea(Rectangle( - currentClipArea.width - currentClipArea.height, - 0, currentClipArea.height, currentClipArea.height)); - drawButton(graphics); - graphics->popClipArea(); - graphics->popClipArea(); - - if (mDroppedDown) - { - // Draw a border around the children. - graphics->setColor(shadowColor); - graphics->drawRectangle(Rectangle(0, mFoldedUpHeight, - getWidth(), getHeight() - mFoldedUpHeight)); - drawChildren(graphics); - } - } - - void DropDown::drawButton(Graphics *graphics) - { - Color faceColor, highlightColor, shadowColor; - int offset; - int alpha = getBaseColor().a; - - if (mPushed) - { - faceColor = getBaseColor() - 0x303030; - faceColor.a = alpha; - highlightColor = faceColor - 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor + 0x303030; - shadowColor.a = alpha; - offset = 1; - } - else - { - faceColor = getBaseColor(); - faceColor.a = alpha; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - offset = 0; - } - - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - graphics->setColor(highlightColor); - graphics->drawLine(0, 0, currentClipArea.width - 1, 0); - graphics->drawLine(0, 1, 0, currentClipArea.height - 1); - graphics->setColor(shadowColor); - graphics->drawLine(currentClipArea.width - 1, 1, - currentClipArea.width - 1, currentClipArea.height - 1); - graphics->drawLine(1, currentClipArea.height - 1, - currentClipArea.width - 2, currentClipArea.height - 1); - - graphics->setColor(faceColor); - graphics->fillRectangle(Rectangle(1, 1, - currentClipArea.width - 2, currentClipArea.height - 2)); - - graphics->setColor(getForegroundColor()); - - int i; - int n = currentClipArea.height / 3; - int dx = currentClipArea.height / 2; - int dy = (currentClipArea.height * 2) / 3; - for (i = 0; i < n; i++) - { - graphics->drawLine(dx - i + offset, dy - i + offset, - dx + i + offset, dy - i + offset); - } - } - int DropDown::getSelected() const { return mListBox->getSelected(); @@ -258,31 +133,6 @@ namespace gcn mListBox->setSelected(selected); } - void DropDown::keyPressed(KeyEvent& keyEvent) - { - if (keyEvent.isConsumed()) - return; - - Key key = keyEvent.getKey(); - - if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) - && !mDroppedDown) - { - dropDown(); - keyEvent.consume(); - } - else if (key.getValue() == Key::UP) - { - setSelected(getSelected() - 1); - keyEvent.consume(); - } - else if (key.getValue() == Key::DOWN) - { - setSelected(getSelected() + 1); - keyEvent.consume(); - } - } - void DropDown::mousePressed(MouseEvent& mouseEvent) { // If we have a mouse press on the widget. |