From 0e2f673e74b2817029653f418a88f6ae8ac2ff74 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 9 Oct 2012 20:55:06 +0300 Subject: Remove typeinfo from textpreview class. --- src/gui/widgets/textpreview.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index ab5a8ce28..a8591b22a 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -29,8 +29,6 @@ #include "gui/gui.h" #include "gui/sdlfont.h" -#include - #include "debug.h" float TextPreview::mAlpha = 1.0; @@ -65,18 +63,21 @@ void TextPreview::draw(gcn::Graphics* graphics) graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } - if (mTextBGColor && typeid(*mFont) == typeid(SDLFont)) + if (mTextBGColor) { - const SDLFont *const font = static_cast(mFont); - const int x = font->getWidth(mText) + 1 - + 2 * ((mOutline || mShadow) ? 1 :0); - const int y = font->getHeight() + 1 - + 2 * ((mOutline || mShadow) ? 1 : 0); - graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), - static_cast(mTextBGColor->g), - static_cast(mTextBGColor->b), - static_cast(mAlpha * 255.0f))); - graphics->fillRectangle(gcn::Rectangle(1, 1, x, y)); + const SDLFont *const font = dynamic_cast(mFont); + if (font) + { + const int x = font->getWidth(mText) + 1 + + 2 * ((mOutline || mShadow) ? 1 :0); + const int y = font->getHeight() + 1 + + 2 * ((mOutline || mShadow) ? 1 : 0); + graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), + static_cast(mTextBGColor->g), + static_cast(mTextBGColor->b), + static_cast(mAlpha * 255.0f))); + graphics->fillRectangle(gcn::Rectangle(1, 1, x, y)); + } } TextRenderer::renderText(graphics, mText, 2, 2, gcn::Graphics::LEFT, -- cgit v1.2.3-60-g2f50