MCPcopy Create free account
hub / github.com/MyGUI/mygui / parseText

Method parseText

UnitTests/UnitTest_HyperTextBox/HyperTextBox.cpp:97–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95 }
96
97 void HyperTextBox::parseText(Widget* _parent, std::string_view _value)
98 {
99 const int defaultSize = 16;
100
101 if (mImage)
102 {
103 if (mImageSize.width == 0 || mImageSize.height == 0)
104 {
105 IResource* resource = ResourceManager::getInstance().getByName(_value, false);
106 if (resource != nullptr)
107 {
108 ResourceImageSet* imageSet = resource->castType<ResourceImageSet>(false);
109 if (imageSet != nullptr)
110 {
111 ImageIndexInfo info = imageSet->getIndexInfo(0, 0);
112 mImageSize = info.size;
113 }
114 }
115 }
116
117 ImageBox* image = _parent->createWidget<ImageBox>(
118 mImageSkin,
119 IntCoord(0, 0, mImageSize.width, mImageSize.height),
120 Align::Default);
121 image->setItemResource(_value);
122 // картинка как урл
123 if (mUrl)
124 {
125 image->setPointer(mLinkPoiner);
126 image->eventMouseButtonClick += newDelegate(this, &HyperTextBox::OnTextClick);
127 image->setUserString("URL", mUrlValue);
128 }
129 }
130 else if (mUrl)
131 {
132 TextBox* text =
133 _parent->createWidget<TextBox>(mTextSkin, IntCoord(0, 0, defaultSize, defaultSize), Align::Default);
134 text->setCaption(MyGUI::UString(_value));
135 text->setPointer(mLinkPoiner);
136 if (mBold)
137 {
138 if (mItalic)
139 text->setFontName(mBoldItalicFont);
140 else
141 text->setFontName(mBoldFont);
142 }
143 else if (mItalic)
144 {
145 text->setFontName(mItalicFont);
146 }
147
148 Widget* line = text->createWidget<Widget>(
149 mLineSkin,
150 IntCoord(0, defaultSize - 1, defaultSize, 1),
151 Align::HStretch | Align::Bottom);
152 line->setColour(Colour::Black);
153 line->setVisible(false);
154 line->setNeedMouseFocus(false);

Callers

nothing calls this directly

Calls 15

newDelegateFunction · 0.85
UStringFunction · 0.85
splitFunction · 0.85
getIndexInfoMethod · 0.80
setItemResourceMethod · 0.80
setUserStringMethod · 0.80
setNeedMouseFocusMethod · 0.80
IntCoordFunction · 0.50
getByNameMethod · 0.45
setPointerMethod · 0.45
setCaptionMethod · 0.45
setFontNameMethod · 0.45

Tested by

no test coverage detected