void CGUIControlGroup::AddControl(CGUIControl *control, int position /* = -1*/) { if (!control) return; if (position < 0 || position > (int)m_children.size()) position = (int)m_children.size(); m_children.insert(m_children.begin() + position, control); control->SetParentControl(this); control->SetPushUpdates(m_pushedUpdates); AddLookup(control); SetInvalid(); }
void LocaleStringLookup::AddLookupString(CTSTR lookupVal, CTSTR lpVal) { assert(lookupVal && *lookupVal); if(!lookupVal || !*lookupVal) return; StringLookupNode *child = FindNode(lookupVal); if(child) child->leaf->strValue = lpVal; else { LocaleStringItem *item = new LocaleStringItem; item->lookup = lookupVal; item->strValue = lpVal; cache << item; AddLookup(item->lookup, item); } }
void LocaleStringLookup::AddLookup(CTSTR lookupVal, LocaleStringItem *item, StringLookupNode *node) { if(!node) node = top; if(!lookupVal) return; if(!*lookupVal) { delete node->leaf; node->leaf = item; return; } StringLookupNode *child = node->FindSubNodeByChar(*lookupVal); if(child) { UINT len; for(len=0; len<child->str.Length(); len++) { TCHAR val1 = child->str[len], val2 = lookupVal[len]; if((val1 >= 'A') && (val1 <= 'Z')) val1 += 0x20; if((val2 >= 'A') && (val2 <= 'Z')) val2 += 0x20; if(val1 != val2) break; } if(len == child->str.Length()) return AddLookup(lookupVal+len, item, child); else { StringLookupNode *childSplit = new StringLookupNode; childSplit->str = child->str.Array()+len; childSplit->leaf = child->leaf; childSplit->subNodes.TransferFrom(child->subNodes); child->leaf = NULL; child->str.SetLength(len); child->subNodes << childSplit; if(lookupVal[len] != 0) { StringLookupNode *newNode = new StringLookupNode; newNode->leaf = item; newNode->str = lookupVal+len; child->subNodes << newNode; } else child->leaf = item; } } else { StringLookupNode *newNode = new StringLookupNode; newNode->leaf = item; newNode->str = lookupVal; node->subNodes << newNode; } }