From 9d3b975bcb84ad1c61d628de2804751c0d0707dd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 31 May 2011 01:27:37 +0300 Subject: Fix code style and missing members initialisations. --- src/guichan/graphics.cpp | 62 +++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 37 deletions(-) (limited to 'src/guichan/graphics.cpp') diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp index 688362c12..7809223b7 100644 --- a/src/guichan/graphics.cpp +++ b/src/guichan/graphics.cpp @@ -54,9 +54,9 @@ namespace gcn { - Graphics::Graphics() + Graphics::Graphics() : + mFont(NULL) { - mFont = NULL; } bool Graphics::pushClipArea(Rectangle area) @@ -70,7 +70,7 @@ namespace gcn mClipStack.push(carea); return true; } - + if (mClipStack.empty()) { ClipRectangle carea; @@ -94,39 +94,31 @@ namespace gcn // Clamp the pushed clip rectangle. if (carea.x < top.x) - { carea.x = top.x; - } - + if (carea.y < top.y) - { - carea.y = top.y; - } - + carea.y = top.y; + if (carea.x + carea.width > top.x + top.width) { carea.width = top.x + top.width - carea.x; if (carea.width < 0) - { carea.width = 0; - } } - + if (carea.y + carea.height > top.y + top.height) { carea.height = top.y + top.height - carea.y; - + if (carea.height < 0) - { carea.height = 0; - } } - + bool result = carea.isIntersecting(top); - + mClipStack.push(carea); - + return result; } @@ -134,9 +126,7 @@ namespace gcn { if (mClipStack.empty()) - { throw GCN_EXCEPTION("Tried to pop clip area from empty stack."); - } mClipStack.pop(); } @@ -144,16 +134,15 @@ namespace gcn const ClipRectangle& Graphics::getCurrentClipArea() { if (mClipStack.empty()) - { throw GCN_EXCEPTION("The clip area stack is empty."); - } return mClipStack.top(); } void Graphics::drawImage(const Image* image, int dstX, int dstY) { - drawImage(image, 0, 0, dstX, dstY, image->getWidth(), image->getHeight()); + drawImage(image, 0, 0, dstX, dstY, + image->getWidth(), image->getHeight()); } void Graphics::setFont(Font* font) @@ -165,23 +154,22 @@ namespace gcn Alignment alignment) { if (mFont == NULL) - { throw GCN_EXCEPTION("No font set."); - } switch (alignment) { - case LEFT: - mFont->drawString(this, text, x, y); - break; - case CENTER: - mFont->drawString(this, text, x - mFont->getWidth(text) / 2, y); - break; - case RIGHT: - mFont->drawString(this, text, x - mFont->getWidth(text), y); - break; - default: - throw GCN_EXCEPTION("Unknown alignment."); + case LEFT: + mFont->drawString(this, text, x, y); + break; + case CENTER: + mFont->drawString(this, text, x + - mFont->getWidth(text) / 2, y); + break; + case RIGHT: + mFont->drawString(this, text, x - mFont->getWidth(text), y); + break; + default: + throw GCN_EXCEPTION("Unknown alignment."); } } } -- cgit v1.2.3-60-g2f50