Exemple #1
0
VOID XmlMenuParseChild(CDUIMenuBuilder* pThis, CDUIXml& xml, CRefPtr<IDUIControl>  pParentControl)
{
	IDUIApp* pDUIApp = DUIGetAppInstance();
	if(pDUIApp == NULL) return;
	
	IDUIControlFactory* pControlFactory = pDUIApp->GetControlFactory();
	if(pControlFactory == NULL) return;
	
	CDUIString strControlName, strAttriName, strAttriValue;
	CRefPtr<IDUIControl> pControl;
	INT nIndex(0);
	while(xml.FindChildElem())
	{
		xml.IntoElem();
		
		strControlName = xml.GetTagName();
		pControl = pControlFactory->NewControl(strControlName);
		if(pControl.IsNull() && pThis->GetCallBack() != NULL)
		{
			pControl = pThis->GetCallBack()->OnBuilderNewControl(strControlName);
		}
		DUI_ASSERT(!pControl.IsNull());
		
		if(!pControl.IsNull())
		{
			DUI_ASSERT(pControl->GetInterface(IMenu) != NULL 
				|| pControl->GetInterface(IMenuItem) != NULL);

			nIndex = 0;
			do 
			{
				strAttriName = xml.GetAttribName(nIndex++);
				if(strAttriName.size() <= 0) break;
				
				strAttriValue = xml.GetAttrib(strAttriName);
				pControl->SetAttribute(strAttriName, strAttriValue);
				
			} while(TRUE);
			
			if(pThis->GetCallBack() != NULL)
			{
				pThis->GetCallBack()->OnAddChildControl(pParentControl, pControl);
			}
			else
			{
				DefAddChildControl(pParentControl, pControl);
			}
			
			
			XmlMenuParseChild(pThis, xml, pControl);
		}
		
		xml.OutOfElem();
	}
}
Exemple #2
0
VOID CDUIControlFactory::CheckControlStyle(CDUIString& strControlName)
{
	CControlMap::iterator itr = m_mapControl.find(strControlName);
	if(itr == m_mapControl.end())
	{
		DUI_ASSERT(FALSE);
		return;
	}

	CRefPtr<IDUIControl> pControl = itr->second;
	DUI_ASSERT(!pControl.IsNull());


	pControl->SetAttribute(_T("control_style"), strControlName);
}
Exemple #3
0
CRefPtr<IDUIMenu> XmlControlParse(CDUIMenuBuilder* pThis, CDUIXml& xml)
{
	IDUIApp* pDUIApp = DUIGetAppInstance();
	if(pDUIApp == NULL) return NULL;
	
	IDUIControlFactory* pControlFactory = pDUIApp->GetControlFactory();
	if(pControlFactory == NULL) return NULL;
	
	if(!xml.FindElem(_T("menu")))
	{
		DUI_ASSERT(FALSE);
		return NULL;
	}
	CRefPtr<IDUIControl> pRootControl = pControlFactory->NewControl(_T("menu"));
	DUI_ASSERT(!pRootControl.IsNull());
	if(pRootControl.IsNull()) return NULL;

	//parse menu attribute
	CDUIString strAttriName, strAttriValue;
	INT nIndex(0);
	do 
	{
		strAttriName = xml.GetAttribName(nIndex++);
		if(strAttriName.size() <= 0) break;
		
		strAttriValue = xml.GetAttrib(strAttriName);
		pRootControl->SetAttribute(strAttriName, strAttriValue);
		
	} while(TRUE);

	XmlMenuParseChild(pThis, xml, pRootControl);

	if(pThis->GetCallBack() != NULL)
	{
		pThis->GetCallBack()->OnBuilderControlCreated(pRootControl);
	}


	IDUIMenu* pMenuRet =  (IDUIMenu*)pRootControl->GetInterface(IMenu);
	DUI_ASSERT(pMenuRet != NULL);

	return pMenuRet;
}
Exemple #4
0
CRefPtr<IDUIControl> XmlControlParse(CDUIControlBuilder* pThis, CDUIXml& xml)
{
	IDUIApp* pDUIApp = DUIGetAppInstance();
	if(pDUIApp == NULL) return NULL;
	
	IDUIControlFactory* pControlFactory = pDUIApp->GetControlFactory();
	if(pControlFactory == NULL) return NULL;
	
	if(!xml.FindElem(_T("window")))
	{
		DUI_ASSERT(FALSE);
		return NULL;
	}
	
	//parse window attribute
	CDUIString strAttriName, strAttriValue;
	INT nIndex(0);
	do 
	{
		strAttriName = xml.GetAttribName(nIndex++);
		if(strAttriName.size() <= 0) break;
		
		strAttriValue = xml.GetAttrib(strAttriName);
		if(pThis->GetCallBack() != NULL)
		{
			pThis->GetCallBack()->OnBuilderWindowAttribute(strAttriName, strAttriValue);
		}
		
	} while(TRUE);
	
	//parse child control
	CDUIString strControlName;
	CRefPtr<IDUIControl> pRootControl;
	if(xml.FindChildElem(NULL))
	{
		xml.IntoElem();

		strControlName = xml.GetTagName();
		pRootControl = pControlFactory->NewControl(strControlName);
		if(pRootControl.IsNull() && pThis->GetCallBack() != NULL)
		{
			pRootControl = pThis->GetCallBack()->OnBuilderNewControl(strControlName);
		}
		DUI_ASSERT(!pRootControl.IsNull());

		if(!pRootControl.IsNull())
		{
			nIndex = 0;
			do 
			{
				strAttriName = xml.GetAttribName(nIndex++);
				if(strAttriName.size() <= 0) break;

				strAttriValue = xml.GetAttrib(strAttriName);
				pRootControl->SetAttribute(strAttriName, strAttriValue);
				
			} while(TRUE);

			XmlControlParseChild(pThis, xml, pRootControl);

			if(pThis->GetCallBack() != NULL)
			{
				pThis->GetCallBack()->OnBuilderControlCreated(pRootControl);
			}
		}
		
		xml.OutOfElem();
	}

	return pRootControl;
}