parseChildControl now returns the control's ID if successful
This commit is contained in:
@@ -416,30 +416,37 @@ void cDialog::loadFromFile(std::string path){
|
||||
}
|
||||
|
||||
// TODO: Move to a dedicated container.cpp?
|
||||
bool cContainer::parseChildControl(ticpp::Element& elem, std::map<std::string,cControl*>& controls) {
|
||||
bool cContainer::parseChildControl(ticpp::Element& elem, std::map<std::string,cControl*>& controls, std::string& id) {
|
||||
std::string tag = elem.Value();
|
||||
if(tag == "field") {
|
||||
auto field = parent->parse<cTextField>(elem);
|
||||
controls.insert(field);
|
||||
parent->tabOrder.push_back(field);
|
||||
id = field.first;
|
||||
} else if(tag == "text") {
|
||||
auto text = parent->parse<cTextMsg>(elem);
|
||||
controls.insert(text);
|
||||
id = text.first;
|
||||
} else if(tag == "pict") {
|
||||
auto pict = parent->parse<cPict>(elem);
|
||||
controls.insert(pict);
|
||||
id = pict.first;
|
||||
} else if(tag == "slider") {
|
||||
auto slide = parent->parse<cScrollbar>(elem);
|
||||
controls.insert(slide);
|
||||
id = slide.first;
|
||||
} else if(tag == "button") {
|
||||
auto button = parent->parse<cButton>(elem);
|
||||
controls.insert(button);
|
||||
id = button.first;
|
||||
} else if(tag == "led") {
|
||||
auto led = parent->parse<cLed>(elem);
|
||||
controls.insert(led);
|
||||
id = led.first;
|
||||
} else if(tag == "group") {
|
||||
auto group = parent->parse<cLedGroup>(elem);
|
||||
controls.insert(group);
|
||||
id = group.first;
|
||||
} else return false;
|
||||
return true;
|
||||
}
|
||||
|
@@ -458,8 +458,9 @@ protected:
|
||||
/// Parses a child control.
|
||||
/// @param elem The element defining the control.
|
||||
/// @param controls The map into which the control will be inserted.
|
||||
/// @param[out] The ID of the new control.
|
||||
/// @return true if the element was a valid control, false otherwise.
|
||||
bool parseChildControl(ticpp::Element& elem, std::map<std::string,cControl*>& controls);
|
||||
bool parseChildControl(ticpp::Element& elem, std::map<std::string,cControl*>& controls, std::string& id);
|
||||
public:
|
||||
/// Create a new container control attached to an arbitrary window, rather than a dialog.
|
||||
/// @param t The type of the control.
|
||||
|
@@ -185,7 +185,8 @@ bool cScrollPane::parseAttribute(ticpp::Attribute& attr, std::string tagName, st
|
||||
|
||||
bool cScrollPane::parseContent(ticpp::Node& content, int n, std::string tagName, std::string fname, std::string& text) {
|
||||
if(content.Type() == TiXmlNode::ELEMENT) {
|
||||
return parseChildControl(dynamic_cast<ticpp::Element&>(content), contents);
|
||||
std::string id;
|
||||
return parseChildControl(dynamic_cast<ticpp::Element&>(content), contents, id);
|
||||
}
|
||||
return cContainer::parseContent(content, n, tagName, fname, text);
|
||||
}
|
||||
|
@@ -168,7 +168,8 @@ bool cStack::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::st
|
||||
|
||||
bool cStack::parseContent(ticpp::Node& content, int n, std::string tagName, std::string fname, std::string& text) {
|
||||
if(content.Type() == TiXmlNode::ELEMENT) {
|
||||
return parseChildControl(dynamic_cast<ticpp::Element&>(content), controls);
|
||||
std::string id;
|
||||
return parseChildControl(dynamic_cast<ticpp::Element&>(content), controls, id);
|
||||
}
|
||||
return cContainer::parseContent(content, n, tagName, fname, text);
|
||||
}
|
||||
|
Reference in New Issue
Block a user