| 83 | } |
| 84 | |
| 85 | Widget* WidgetLoader::loadWidgetFromXmlFile( |
| 86 | const std::string& xmlFilename, |
| 87 | const std::string& widgetId, |
| 88 | ui::Widget* widget) |
| 89 | { |
| 90 | m_tooltipManager = NULL; |
| 91 | |
| 92 | XmlDocumentRef doc(open_xml(xmlFilename)); |
| 93 | tinyxml2::XMLHandle handle(doc.get()); |
| 94 | |
| 95 | // Search the requested widget. |
| 96 | tinyxml2::XMLElement* xmlElement = handle |
| 97 | .FirstChildElement("gui") |
| 98 | .FirstChildElement().ToElement(); |
| 99 | |
| 100 | while (xmlElement) { |
| 101 | const char* nodename = xmlElement->Attribute("id"); |
| 102 | |
| 103 | if (nodename && nodename == widgetId) { |
| 104 | widget = convertXmlElementToWidget(xmlElement, NULL, NULL, widget); |
| 105 | break; |
| 106 | } |
| 107 | |
| 108 | xmlElement = xmlElement->NextSiblingElement(); |
| 109 | } |
| 110 | |
| 111 | return widget; |
| 112 | } |
| 113 | |
| 114 | Widget* WidgetLoader::convertXmlElementToWidget(const tinyxml2::XMLElement* elem, Widget* root, Widget* parent, Widget* widget) |
| 115 | { |