Something went wrong. Try again.
OpenMW is an open implementation of the Morrowind engine
Something went wrong. Try again.
1.5 kB · 59 lines
C++
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include "windowcaption.hpp"
#include <stdexcept>
namespace Gui{
WindowCaption::WindowCaption() : mLeft(nullptr) , mRight(nullptr) , mClient(nullptr) { }
void WindowCaption::initialiseOverride() { Base::initialiseOverride();
assignWidget(mLeft, "Left"); assignWidget(mRight, "Right");
assignWidget(mClient, "Client"); if (!mClient) throw std::runtime_error("WindowCaption needs an EditBox Client widget in its skin"); }
void WindowCaption::setCaption(const MyGUI::UString& value) { EditBox::setCaption(value); align(); }
void WindowCaption::setSize(const MyGUI::IntSize& value) { Base::setSize(value); align(); }
void WindowCaption::setCoord(const MyGUI::IntCoord& value) { Base::setCoord(value); align(); }
void WindowCaption::align() { MyGUI::IntSize textSize = getTextSize(); MyGUI::Widget* caption = mClient; caption->setSize(textSize.width + 24, caption->getHeight());
int barwidth = (getWidth() - caption->getWidth()) / 2; caption->setPosition(barwidth, caption->getTop()); if (mLeft) mLeft->setCoord(0, mLeft->getTop(), barwidth, mLeft->getHeight()); if (mRight) mRight->setCoord(barwidth + caption->getWidth(), mRight->getTop(), barwidth, mRight->getHeight()); }
}