示例#1
0
	CInterfaceElement* CRootGroup::getElement (const std::string &id)
	{
		if (_Id == id)
		return this;

		if (id.substr(0, _Id.size()) != _Id)
			return NULL;

		std::vector<CViewBase*>::const_iterator itv;
		for (itv = _Views.begin(); itv != _Views.end(); itv++)
		{
			CViewBase *pVB = *itv;
			if (pVB->getId() == id)
				return pVB;
		}

		std::vector<CCtrlBase*>::const_iterator itc;
		for (itc = _Controls.begin(); itc != _Controls.end(); itc++)
		{
			CCtrlBase* ctrl = *itc;
			if (ctrl->getId() == id)
				return ctrl;
		}

		// Accelerate
		std::string sTmp = id;
		sTmp = sTmp.substr(_Id.size()+1,sTmp.size());
		std::string::size_type pos = sTmp.find(':');
		if (pos != std::string::npos)
			sTmp = sTmp.substr(0,pos);

		std::map<std::string,CInterfaceGroup*>::iterator it = _Accel.find(sTmp);
		if (it != _Accel.end())
		{
			CInterfaceGroup *pIG = it->second;
			return pIG->getElement(id);
		}
		return NULL;
	}