MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / configureSelfFromXml

Method configureSelfFromXml

forms/textedit.cpp:279–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279void TextEdit::configureSelfFromXml(pugi::xml_node *node)
280{
281 Control::configureSelfFromXml(node);
282
283 if (node->attribute("text"))
284 {
285 text = to_u32string(tr(node->attribute("text").as_string()));
286 }
287 auto fontNode = node->child("font");
288 if (fontNode)
289 {
290 font = ui().getFont(fontNode.text().get());
291 }
292 auto alignmentNode = node->child("alignment");
293 if (alignmentNode)
294 {
295 UString hAlign = alignmentNode.attribute("horizontal").as_string();
296 if (hAlign == "left")
297 {
298 TextHAlign = HorizontalAlignment::Left;
299 }
300 else if (hAlign == "centre")
301 {
302 TextHAlign = HorizontalAlignment::Centre;
303 }
304 else if (hAlign == "right")
305 {
306 TextHAlign = HorizontalAlignment::Right;
307 }
308 UString vAlign = alignmentNode.attribute("vertical").as_string();
309 if (vAlign == "top")
310 {
311 TextVAlign = VerticalAlignment::Top;
312 }
313 else if (vAlign == "centre")
314 {
315 TextVAlign = VerticalAlignment::Centre;
316 }
317 else if (vAlign == "bottom")
318 {
319 TextVAlign = VerticalAlignment::Bottom;
320 }
321 }
322}
323}; // namespace OpenApoc

Callers

nothing calls this directly

Calls 4

to_u32stringFunction · 0.85
trFunction · 0.85
getFontMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected