| 465 | } |
| 466 | |
| 467 | void UIRichText::loadFromXmlNode( const pugi::xml_node& node ) { |
| 468 | beginAttributesTransaction(); |
| 469 | |
| 470 | UIWidget::loadFromXmlNode( node ); |
| 471 | |
| 472 | for ( pugi::xml_node child = node.first_child(); child; child = child.next_sibling() ) { |
| 473 | if ( child.type() == pugi::node_element ) { |
| 474 | if ( mTag == "pre" && String::iequals( child.name(), "code" ) ) { |
| 475 | // Use a UICodeEditor for <pre><code> |
| 476 | UICodeEditor* editor = UICodeEditor::New(); |
| 477 | if ( editor ) { |
| 478 | editor->setParent( this ); |
| 479 | editor->loadFromXmlNode( child ); |
| 480 | editor->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); |
| 481 | editor->setLineWrapMode( LineWrapMode::Word ); |
| 482 | editor->setLineWrapType( LineWrapType::Viewport ); |
| 483 | editor->disableEditorFeatures( false ); |
| 484 | editor->setCursorVisible( false ); |
| 485 | editor->setAllowSelectingTextFromGutter( false ); |
| 486 | editor->setDisableCursorBlinkingAfterAMinuteOfInactivity( false ); |
| 487 | editor->setCursorBlinkTime( Time::Zero ); |
| 488 | editor->setShowLineNumber( false ); |
| 489 | editor->setShowFoldingRegion( false ); |
| 490 | editor->setLocked( true ); |
| 491 | |
| 492 | auto langIt = mDataProperties.find( "data-language" ); |
| 493 | if ( langIt != mDataProperties.end() ) { |
| 494 | editor->applyProperty( langIt->second ); |
| 495 | } |
| 496 | } |
| 497 | } else { |
| 498 | // Let parent logic load standard child widget |
| 499 | UIWidget* uiwidget = UIWidgetCreator::createFromName( child.name() ); |
| 500 | if ( uiwidget ) { |
| 501 | uiwidget->setParent( this ); |
| 502 | uiwidget->loadFromXmlNode( child ); |
| 503 | |
| 504 | if ( !uiwidget->loadsItsChildren() ) { |
| 505 | if ( child.first_child() && !uiwidget->loadsItsChildren() ) { |
| 506 | getUISceneNode()->loadNode( child.first_child(), uiwidget, 0 ); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | uiwidget->onWidgetCreated(); |
| 511 | } |
| 512 | } |
| 513 | } else if ( child.type() == pugi::node_pcdata ) { |
| 514 | String text = Tools::HTMLFormatter::collapseXmlWhitespace( child.value(), child ); |
| 515 | if ( !text.empty() ) { |
| 516 | UITextSpan* span = UITextSpan::New(); |
| 517 | span->setParent( this ); |
| 518 | span->setInheritedStyle( mRichText.getFontStyleConfig() ); |
| 519 | span->setText( text ); |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | endAttributesTransaction(); |
nothing calls this directly
no test coverage detected