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?
|
// 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();
|
std::string tag = elem.Value();
|
||||||
if(tag == "field") {
|
if(tag == "field") {
|
||||||
auto field = parent->parse<cTextField>(elem);
|
auto field = parent->parse<cTextField>(elem);
|
||||||
controls.insert(field);
|
controls.insert(field);
|
||||||
parent->tabOrder.push_back(field);
|
parent->tabOrder.push_back(field);
|
||||||
|
id = field.first;
|
||||||
} else if(tag == "text") {
|
} else if(tag == "text") {
|
||||||
auto text = parent->parse<cTextMsg>(elem);
|
auto text = parent->parse<cTextMsg>(elem);
|
||||||
controls.insert(text);
|
controls.insert(text);
|
||||||
|
id = text.first;
|
||||||
} else if(tag == "pict") {
|
} else if(tag == "pict") {
|
||||||
auto pict = parent->parse<cPict>(elem);
|
auto pict = parent->parse<cPict>(elem);
|
||||||
controls.insert(pict);
|
controls.insert(pict);
|
||||||
|
id = pict.first;
|
||||||
} else if(tag == "slider") {
|
} else if(tag == "slider") {
|
||||||
auto slide = parent->parse<cScrollbar>(elem);
|
auto slide = parent->parse<cScrollbar>(elem);
|
||||||
controls.insert(slide);
|
controls.insert(slide);
|
||||||
|
id = slide.first;
|
||||||
} else if(tag == "button") {
|
} else if(tag == "button") {
|
||||||
auto button = parent->parse<cButton>(elem);
|
auto button = parent->parse<cButton>(elem);
|
||||||
controls.insert(button);
|
controls.insert(button);
|
||||||
|
id = button.first;
|
||||||
} else if(tag == "led") {
|
} else if(tag == "led") {
|
||||||
auto led = parent->parse<cLed>(elem);
|
auto led = parent->parse<cLed>(elem);
|
||||||
controls.insert(led);
|
controls.insert(led);
|
||||||
|
id = led.first;
|
||||||
} else if(tag == "group") {
|
} else if(tag == "group") {
|
||||||
auto group = parent->parse<cLedGroup>(elem);
|
auto group = parent->parse<cLedGroup>(elem);
|
||||||
controls.insert(group);
|
controls.insert(group);
|
||||||
|
id = group.first;
|
||||||
} else return false;
|
} else return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -458,8 +458,9 @@ protected:
|
|||||||
/// Parses a child control.
|
/// Parses a child control.
|
||||||
/// @param elem The element defining the control.
|
/// @param elem The element defining the control.
|
||||||
/// @param controls The map into which the control will be inserted.
|
/// @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.
|
/// @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:
|
public:
|
||||||
/// Create a new container control attached to an arbitrary window, rather than a dialog.
|
/// Create a new container control attached to an arbitrary window, rather than a dialog.
|
||||||
/// @param t The type of the control.
|
/// @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) {
|
bool cScrollPane::parseContent(ticpp::Node& content, int n, std::string tagName, std::string fname, std::string& text) {
|
||||||
if(content.Type() == TiXmlNode::ELEMENT) {
|
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);
|
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) {
|
bool cStack::parseContent(ticpp::Node& content, int n, std::string tagName, std::string fname, std::string& text) {
|
||||||
if(content.Type() == TiXmlNode::ELEMENT) {
|
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);
|
return cContainer::parseContent(content, n, tagName, fname, text);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user