From 60add2c149c9c61bfbede5ae92cfe216927aca8a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Dec 2012 14:42:15 +0300 Subject: Improve a bit draw speed in other controls. --- src/gui/widgets/window.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/gui/widgets/window.cpp') diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 52042f019..ffeac0cb1 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -36,6 +36,7 @@ #include #include +#include #include "debug.h" @@ -267,8 +268,21 @@ void Window::draw(gcn::Graphics *graphics) { g->setColor(mForegroundColor); g->setFont(mCaptionFont); - g->drawText(getCaption(), mCaptionOffsetX, mCaptionOffsetY, - static_cast(mCaptionAlign)); + int x; + switch (static_cast(mCaptionAlign)) + { + case Graphics::LEFT: + default: + x = mCaptionOffsetX; + break; + case Graphics::CENTER: + x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption) / 2; + break; + case Graphics::RIGHT: + x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption); + break; + } + mCaptionFont->drawString(g, mCaption, x, mCaptionOffsetY); } if (update) -- cgit v1.2.3-60-g2f50