diff options
Diffstat (limited to 'src/gui/widgets/window.cpp')
-rw-r--r-- | src/gui/widgets/window.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
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 <guichan/exception.hpp> #include <guichan/focushandler.hpp> +#include <guichan/font.hpp> #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<gcn::Graphics::Alignment>(mCaptionAlign)); + int x; + switch (static_cast<gcn::Graphics::Alignment>(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) |