本文整理汇总了C++中OTMLNodePtr::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ OTMLNodePtr::addChild方法的具体用法?C++ OTMLNodePtr::addChild怎么用?C++ OTMLNodePtr::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTMLNodePtr
的用法示例。
在下文中一共展示了OTMLNodePtr::addChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateStyle
void UIWidget::updateStyle()
{
if(m_destroyed)
return;
if(m_loadingStyle && !m_updateStyleScheduled) {
UIWidgetPtr self = static_self_cast<UIWidget>();
g_dispatcher.addEvent([self] {
self->m_updateStyleScheduled = false;
self->updateStyle();
});
m_updateStyleScheduled = true;
return;
}
if(!m_style)
return;
OTMLNodePtr newStateStyle = OTMLNode::create();
// copy only the changed styles from default style
if(m_stateStyle) {
for(OTMLNodePtr node : m_stateStyle->children()) {
if(OTMLNodePtr otherNode = m_style->get(node->tag()))
newStateStyle->addChild(otherNode->clone());
}
}
// checks for states combination
for(const OTMLNodePtr& style : m_style->children()) {
if(stdext::starts_with(style->tag(), "$")) {
std::string statesStr = style->tag().substr(1);
std::vector<std::string> statesSplit = stdext::split(statesStr, " ");
bool match = true;
for(std::string stateStr : statesSplit) {
if(stateStr.length() == 0)
continue;
bool notstate = (stateStr[0] == '!');
if(notstate)
stateStr = stateStr.substr(1);
bool stateOn = hasState(Fw::translateState(stateStr));
if((!notstate && !stateOn) || (notstate && stateOn))
match = false;
}
// merge states styles
if(match) {
newStateStyle->merge(style);
}
}
}
//TODO: prevent setting already set proprieties
applyStyle(newStateStyle);
m_stateStyle = newStateStyle;
}
示例2: luavalue_cast
bool luavalue_cast(int index, OTMLNodePtr& node)
{
node = OTMLNode::create();
node->setUnique(true);
if(g_lua.isTable(index)) {
g_lua.pushNil();
while(g_lua.next(index < 0 ? index-1 : index)) {
std::string cnodeName;
if(!g_lua.isNumber(-2))
cnodeName = g_lua.toString(-2);
if(g_lua.isTable()) {
OTMLNodePtr cnode;
if(luavalue_cast(-1, cnode)) {
if(cnodeName.empty())
node->setUnique(false);
else
cnode->setTag(cnodeName);
node->addChild(cnode);
}
} else {
std::string value;
if(g_lua.isBoolean())
value = stdext::unsafe_cast<std::string>(g_lua.toBoolean());
else
value = g_lua.toString();
if(cnodeName.empty())
node->writeIn(value);
else
node->writeAt(cnodeName, value);
}
g_lua.pop();
}
return true;
}
return false;
}