| 98 | } |
| 99 | |
| 100 | void CtrlrTextEditor::setXmlSource (const String &xmlSource) |
| 101 | { |
| 102 | ScopedPointer <XmlElement> xml (XmlDocument::parse(xmlSource).release()); |
| 103 | if (xml) |
| 104 | { |
| 105 | forEachXmlChildElement (*xml, el) |
| 106 | { |
| 107 | if (el->hasTagName ("font")) |
| 108 | { |
| 109 | Font font; |
| 110 | font = el->hasAttribute("bold") ? font.withStyle (Font::bold) : font; |
| 111 | font = el->hasAttribute("italic") ? font.withStyle (Font::italic) : font; |
| 112 | font = el->hasAttribute("underline") ? font.withStyle (Font::underlined) : font; |
| 113 | |
| 114 | font = el->hasAttribute("height") ? font.withHeight (el->getDoubleAttribute("height")) : font; |
| 115 | |
| 116 | if (el->hasAttribute("name")) |
| 117 | { |
| 118 | if (el->getStringAttribute("name").startsWith(":")) |
| 119 | { |
| 120 | if (el->getStringAttribute("name") == ":Monospaced") |
| 121 | font.setTypefaceName (Font::getDefaultMonospacedFontName()); |
| 122 | if (el->getStringAttribute("name") == ":Sans") |
| 123 | font.setTypefaceName (Font::getDefaultSansSerifFontName()); |
| 124 | if (el->getStringAttribute("name") == ":Serif") |
| 125 | font.setTypefaceName (Font::getDefaultSerifFontName()); |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | font.setTypefaceName (el->getStringAttribute("name")); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | const Colour fgColour = Colour::fromString (el->hasAttribute("colour") ? el->getStringAttribute("colour") : "0xff000000"); |
| 134 | const Colour bgColour = Colour::fromString (el->hasAttribute("background") ? el->getStringAttribute("background") : findColour (TextEditor::backgroundColourId).toString()); |
| 135 | |
| 136 | setFont (font); |
| 137 | setColour (TextEditor::textColourId, fgColour); |
| 138 | setColour (TextEditor::backgroundColourId, bgColour); |
| 139 | |
| 140 | TextEditor::insertTextAtCaret (el->getAllSubText()); |
| 141 | } |
| 142 | |
| 143 | if (el->hasTagName("br")) |
| 144 | { |
| 145 | TextEditor::insertTextAtCaret ("\n"); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } |
no test coverage detected