Something went wrong. Try again.
OpenMW is an open implementation of the Morrowind engine
Something went wrong. Try again.
2.5 kB · 80 lines
C++
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081#include "text.hpp"
#include "alignment.hpp"
namespace LuaUi{ LuaText::LuaText() : mAutoSized(true) { }
void LuaText::initialize() { changeWidgetSkin("LuaText"); setEditStatic(true); setVisibleHScroll(false); setVisibleVScroll(false);
WidgetExtension::initialize(); }
void LuaText::updateProperties() { mAutoSized = propertyValue("autoSize", true);
setCaption(propertyValue("text", std::string())); setFontHeight(propertyValue("textSize", 10)); setTextColour(propertyValue("textColor", MyGUI::Colour(0, 0, 0, 1))); setEditMultiLine(propertyValue("multiline", false)); setEditWordWrap(propertyValue("wordWrap", false));
Alignment horizontal(propertyValue("textAlignH", Alignment::Start)); Alignment vertical(propertyValue("textAlignV", Alignment::Start)); setTextAlign(alignmentToMyGui(horizontal, vertical));
setTextShadow(propertyValue("textShadow", false)); setTextShadowColour(propertyValue("textShadowColor", MyGUI::Colour(0, 0, 0, 1)));
WidgetExtension::updateProperties(); }
void LuaText::setCaption(const MyGUI::UString& caption) { MyGUI::TextBox::setCaption(caption); if (mAutoSized) updateCoord(); }
const std::vector<std::string_view>& LuaText::allUsedProperties() const { static std::vector<std::string_view> usedProps = std::invoke([this] { std::vector<std::string_view> props = { "text", "textSize", "textColor", "wordWrap", "textAlignH", "textAlignV", "multiline", "readOnly", "autoSize", "textShadow", "textShadowColor" }; auto baseProps = WidgetExtension::allUsedProperties(); props.insert(props.end(), baseProps.begin(), baseProps.end()); return props; }); return usedProps; }
MyGUI::IntSize LuaText::calculateSize() const { if (mAutoSized) return getTextSize(); else return WidgetExtension::calculateSize(); }
MyGUI::IntCoord LuaText::getTextRegion() const { const MyGUI::IntPoint offset = WidgetExtension::getContentOffset(); const MyGUI::IntSize size = WidgetExtension::getContentSize(); return MyGUI::IntCoord(offset, size); }
MyGUI::IntSize LuaText::getViewSize() const { return WidgetExtension::getContentSize(); }}