diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-31 01:27:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-31 01:27:37 +0300 |
commit | 9d3b975bcb84ad1c61d628de2804751c0d0707dd (patch) | |
tree | fe7494b1ecd561a40dc96d088c77d69b6d4ce13e /src/guichan/widgets/imagebutton.cpp | |
parent | 1d0044cbc81e547ad688a295288910d58e1a3fb1 (diff) | |
download | manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.tar.gz manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.tar.bz2 manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.tar.xz manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.zip |
Fix code style and missing members initialisations.
Diffstat (limited to 'src/guichan/widgets/imagebutton.cpp')
-rw-r--r-- | src/guichan/widgets/imagebutton.cpp | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/guichan/widgets/imagebutton.cpp b/src/guichan/widgets/imagebutton.cpp index f09bca30d..a340face3 100644 --- a/src/guichan/widgets/imagebutton.cpp +++ b/src/guichan/widgets/imagebutton.cpp @@ -52,17 +52,17 @@ namespace gcn { - ImageButton::ImageButton() - : mImage(0), - mInternalImage(false) + ImageButton::ImageButton() : + mImage(0), + mInternalImage(false) { setWidth(0); setHeight(0); } - ImageButton::ImageButton(const std::string& filename) - : mImage(0), - mInternalImage(false) + ImageButton::ImageButton(const std::string& filename) : + mImage(0), + mInternalImage(false) { mImage = Image::load(filename); mInternalImage = true; @@ -70,9 +70,9 @@ namespace gcn setHeight(mImage->getHeight() + mImage->getHeight() / 2); } - ImageButton::ImageButton(const Image* image) - : mImage(image), - mInternalImage(false) + ImageButton::ImageButton(const Image* image) : + mImage(image), + mInternalImage(false) { setWidth(mImage->getWidth() + mImage->getWidth() / 2); setHeight(mImage->getHeight() + mImage->getHeight() / 2); @@ -81,17 +81,13 @@ namespace gcn ImageButton::~ImageButton() { if (mInternalImage) - { delete mImage; - } } void ImageButton::setImage(const Image* image) { if (mInternalImage) - { delete mImage; - } mImage = image; mInternalImage = false; @@ -126,10 +122,8 @@ namespace gcn } graphics->setColor(faceColor); - graphics->fillRectangle(Rectangle(1, - 1, - getDimension().width - 1, - getHeight() - 1)); + graphics->fillRectangle(Rectangle(1, 1, + getDimension().width - 1, getHeight() - 1)); graphics->setColor(highlightColor); graphics->drawLine(0, 0, getWidth() - 1, 0); @@ -137,29 +131,30 @@ namespace gcn graphics->setColor(shadowColor); graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1); - graphics->drawLine(1, getHeight() - 1, getWidth() - 1, getHeight() - 1); + graphics->drawLine(1, getHeight() - 1, + getWidth() - 1, getHeight() - 1); graphics->setColor(getForegroundColor()); - const int textX = (getWidth() - (mImage ? mImage->getWidth() : 0) ) / 2; - const int textY = (getHeight() - (mImage ? mImage->getHeight() : 0) ) / 2; + const int textX = (getWidth() - (mImage + ? mImage->getWidth() : 0) ) / 2; + const int textY = (getHeight() - (mImage + ? mImage->getHeight() : 0) ) / 2; if (isPressed()) { - if(mImage) + if (mImage) graphics->drawImage(mImage, textX + 1, textY + 1); } else { - if(mImage) + if (mImage) graphics->drawImage(mImage, textX, textY); if (isFocused()) { - graphics->drawRectangle(Rectangle(2, - 2, - getWidth() - 4, - getHeight() - 4)); + graphics->drawRectangle(Rectangle(2, 2, + getWidth() - 4, getHeight() - 4)); } } } |