当前位置: 首页>>代码示例>>C++>>正文


C++ DuiXmlNode类代码示例

本文整理汇总了C++中DuiXmlNode的典型用法代码示例。如果您正苦于以下问题:C++ DuiXmlNode类的具体用法?C++ DuiXmlNode怎么用?C++ DuiXmlNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DuiXmlNode类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitUI

// 初始化窗口控件
void CDuiPanel::InitUI(CRect rcClient, DuiXmlNode pNode)
{
	CRect rcTemp;
	int nStartX = 0;
	int nStartY = 0;
	CControlBase * pControlBase = NULL;

	// 加载所有窗口控件
	if(pNode)
	{
		m_nVirtualHeight = 0;
		m_nVirtualWidth = 0;
		for (DuiXmlNode pControlElem = pNode.first_child(); pControlElem; pControlElem=pControlElem.next_sibling())
		{
			if(pControlElem != NULL)
			{
				CString strControlName = pControlElem.name();
				CControlBase* pControl = _CreateControlByName(strControlName);
				if(pControl)
				{
					pControl->Load(pControlElem);
					if(pControl->IsClass(CArea::GetClassName()))
					{
						// Area不能响应鼠标,必须加到Area列表中
						m_vecArea.push_back(pControl);
					}else
					{
						m_vecControl.push_back(pControl);
					}

					CRect rcCtrl = pControl->GetRect();
					if(rcCtrl.bottom > m_nVirtualHeight)
					{
						m_nVirtualHeight = rcCtrl.bottom - m_rc.top;
					}
					if(rcCtrl.right > m_nVirtualWidth)
					{
						m_nVirtualWidth = rcCtrl.right - m_rc.left;
					}
				}
			}
		}

		// 需要的总高度大于显示区高度才会显示垂直滚动条
		m_pControScrollV->SetVisible(m_nVirtualHeight > m_rc.Height());
		((CDuiScrollVertical*)m_pControScrollV)->SetScrollMaxRange(m_nVirtualHeight);

		// 需要的总宽度大于显示区宽度才会显示垂直滚动条
		m_pControScrollH->SetVisible(m_nVirtualWidth > m_rc.Width());
		((CDuiScrollHorizontal*)m_pControScrollH)->SetScrollMaxRange(m_nVirtualWidth);
	}

	m_bInit = true;
}
开发者ID:hezlog,项目名称:DuiVision,代码行数:55,代码来源:Panel.cpp

示例2: Load

// 加载XML节点
BOOL CSelectBox::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	if(!__super::Load(pXmlElem))
	{
		return FALSE;
	}

	// 使用XML节点初始化控件
	if(pXmlElem != NULL)
	{
		// 加载图片和颜色列表
		DuiXmlNode pControlElem;
		for (DuiXmlNode pControlElem = pXmlElem.child(_T("item")); pControlElem; pControlElem=pControlElem.next_sibling(_T("item")))
		{
			CString strImage = pControlElem.attribute(_T("image")).value();
			CString strColor = pControlElem.attribute(_T("color")).value();
			if(!strImage.IsEmpty())
			{
				if(strImage.Find(_T("skin:")) == 0)
				{
				}

				if(strImage.Find(_T(".")) != -1)	// 加载图片文件
				{
					CString strImgFile = DuiSystem::GetExePath() + strImage;
					SetBitmap(strImgFile);
				}else	// 加载图片资源
				{
					UINT nResourceID = _wtoi(strImage);
					if(!SetBitmap(nResourceID, -1, TEXT("PNG")))
					{
						SetBitmap(nResourceID, -1, TEXT("BMP"));
					}
				}
				m_bImage = TRUE;
			}else
				if(!strColor.IsEmpty())
				{
					Color color;
					if(strColor.Find(_T(",")) == -1)
					{
						color = HexStringToColor(strColor);
					}else
					{
						color = StringToColor(strColor);
					}
					SetColor(color);
				}
		}
	}

	return TRUE;
}
开发者ID:Gu-Yue,项目名称:DuiVision,代码行数:54,代码来源:SelectBox.cpp

示例3: Load

// 加载XML节点,解析节点中的属性信息设置到当前控件的属性中
BOOL CDuiObject::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	// pos属性需要特殊处理,放在最后进行设置,否则有些属性会受到影响,不能正确的初始化
	CString strPosValue = _T("");
    for (DuiXmlAttribute pAttrib = pXmlElem.first_attribute(); pAttrib; pAttrib = pAttrib.next_attribute())
    {
		CString strName = pAttrib.name();
		if(strName == _T("pos"))
		{
			strPosValue = pAttrib.value();
		}else
		{
			SetAttribute(pAttrib.name(), pAttrib.value(), TRUE);
		}
    }

	if(!strPosValue.IsEmpty())
	{
		SetAttribute(_T("pos"), strPosValue, TRUE);
	}

	// 初始化
	OnInit();

    return TRUE;
}
开发者ID:blueantst,项目名称:DuiVision,代码行数:27,代码来源:DuiObject.cpp

示例4: Load

// 重载加载XML节点函数,加载下层的div内容
BOOL CDuiLayout::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	__super::Load(pXmlElem);

	if(pXmlElem == NULL)
	{
		return FALSE;
	}
	
	// 加载下层的div节点信息
	for (DuiXmlNode pDivElem = pXmlElem.child(_T("layout-div")); pDivElem; pDivElem=pDivElem.next_sibling(_T("layout-div")))
	{
		CString strDivPos = pDivElem.attribute(_T("div-pos")).value();
		int nMinPos = _ttoi(pDivElem.attribute(_T("min-pos")).value());
		int nMaxPos = _ttoi(pDivElem.attribute(_T("max-pos")).value());

		// 创建div
		CDuiPanel*	pControlPanel = (CDuiPanel*)DuiSystem::CreateControlByName(_T("div"), m_hWnd, this);
 		m_vecControl.push_back(pControlPanel);

		// 加载XML中Tab节点的各个下层控件节点
		pControlPanel->Load(pDivElem);

		LayoutItemInfo itemInfo;
		itemInfo.pControlPanel = pControlPanel;
		ParsePosition(strDivPos, itemInfo.pos);	// 解析pos信息
		itemInfo.nMinPos = nMinPos;
		itemInfo.nMaxPos = nMaxPos;
		itemInfo.nPos = -1;	// 初始化实际的位置值
		itemInfo.rcSplit = CRect(0, 0, 0, 0);	// 初始化分割线区域
		itemInfo.rcThumb = CRect(0, 0, 0, 0);	// 初始化滑块区域
		m_vecItemInfo.push_back(itemInfo);
	}

	// 初始化div中控件的位置
	SetRect(m_rc);

	m_bInit = TRUE;

    return TRUE;
}
开发者ID:blueantst,项目名称:DuiVision,代码行数:42,代码来源:DuiLayout.cpp

示例5: InitUI

// 初始化窗口控件
void CDlgPopup::InitUI(CRect rcClient, DuiXmlNode pNode)
{
	CRect rcTemp;
	int nStartX = 0;
	int nStartY = 0;
	CControlBase * pControlBase = NULL;

	// 加载所有窗口控件
	if(pNode)
	{
		for (DuiXmlNode pControlElem = pNode.first_child(); pControlElem; pControlElem=pControlElem.next_sibling())
		{
			if(pControlElem)
			{
				CString strControlName = pControlElem.name();
				CControlBase* pControl = _CreateControlByName(strControlName);
				if(pControl)
				{
					if(pControl->Load(pControlElem))
					{
						// 如果Load成功,则添加控件
						if(pControl->IsClass(CArea::GetClassName()) || pControl->IsClass(CFrame::GetClassName()))
						{
							// Area和Frame不能响应鼠标,必须加到Area列表中
							m_vecArea.push_back(pControl);
						}else
						{
							m_vecControl.push_back(pControl);
						}
					}else
					{
						// 否则直接删除控件对象指针
						delete pControl;
					}
				}
			}
		}
	}

	m_bInit = true;
}
开发者ID:blueantstudio,项目名称:DuiVision,代码行数:42,代码来源:DlgPopup.cpp

示例6: LoadXmlNode

// 加载XML节点中定义的菜单和其他控件
BOOL CDuiMenu::LoadXmlNode(DuiXmlNode pXmlElem, CString strXmlFile)
{
	if(pXmlElem == NULL)
	{
		return FALSE;
	}

	for (DuiXmlNode pControlElem = pXmlElem.first_child(); pControlElem; pControlElem=pControlElem.next_sibling())
	{
		CString strControlName = pControlElem.name();
			CControlBase* pControl = _CreateControlByName(strControlName);
			if(pControl)
			{
				if(pControl->Load(pControlElem))
				{
					// 如果Load成功,则添加控件
					if(pControl->IsClass(CArea::GetClassName()) || pControl->IsClass(CDuiFrame::GetClassName()))
					{
						// Area和Frame不能响应鼠标,必须加到Area列表中
						m_vecArea.push_back(pControl);
					}else
					{
						m_vecControl.push_back(pControl);
					}
					// 如果是菜单项控件,则设置菜单项的菜单XML属性
					if(pControl->IsClass(CMenuItem::GetClassName()))
					{
						((CMenuItem*)pControl)->SetMenuXml(strXmlFile);
					}
				}else
				{
					// 否则直接删除控件对象指针
					delete pControl;
				}
			}
	}

	return TRUE;
}
开发者ID:Zhuguoping,项目名称:DuiVision,代码行数:40,代码来源:DuiMenu.cpp

示例7: Load

// 加载XML节点
BOOL CPopupList::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	if(!__super::Load(pXmlElem))
	{
		return FALSE;
	}

    // 使用XML节点初始化控件
	if(pXmlElem != NULL)
	{
		// 加载图片和颜色列表
		for (DuiXmlNode pControlElem = pXmlElem.child(_T("item")); pControlElem; pControlElem=pControlElem.next_sibling(_T("item")))
		{
				UINT nResourceID = 0;
				CString strName = pControlElem.attribute(_T("name")).value();
				DuiSystem::Instance()->ParseDuiString(strName);
				CString strDesc = pControlElem.attribute(_T("desc")).value();
				DuiSystem::Instance()->ParseDuiString(strDesc);
				CString strValue = pControlElem.attribute(_T("value")).value();
				DuiSystem::Instance()->ParseDuiString(strValue);
				CString strClrText = pControlElem.attribute(_T("crtext")).value();
				Color clrText = CDuiObject::StringToColor(strClrText, Color(255, 0, 20, 35));
				CString strClrDesc = pControlElem.attribute(_T("crdesc")).value();
				Color clrDesc = CDuiObject::StringToColor(strClrDesc, Color(255, 255, 255, 255));
				CString strImage = pControlElem.attribute(_T("image")).value();
				if(!strImage.IsEmpty())
				{
					if(strImage.Find(_T("skin:")) == 0)
					{
						strImage = DuiSystem::Instance()->GetSkin(strImage);
					}

					if(strImage.Find(_T(".")) != -1)	// 加载图片文件
					{
						//strImage = DuiSystem::GetExePath() + strImage;
					}else	// 加载图片资源
					{
						nResourceID = _ttoi(strImage);
						strImage = _T("");
					}
				}

				AddItem(strName, strDesc, strValue, nResourceID, strImage, clrText, clrDesc);
			}
	}

    return TRUE;
}
开发者ID:Zhuguoping,项目名称:DuiVision,代码行数:49,代码来源:PopupList.cpp

示例8: LoadSubMenu

// 加载指定名字的菜单节点
BOOL CDuiMenu::LoadSubMenu(DuiXmlNode pXmlElem, CString strSubItemName)
{
	if(pXmlElem == NULL)
	{
		return FALSE;
	}

	// 递归遍历下层节点,看是否有指定名字的节点
	for (DuiXmlNode pItemElem = pXmlElem.first_child(); pItemElem; pItemElem=pItemElem.next_sibling())
	{
		CString strName = pItemElem.attribute(_T("name")).value();
		if(strSubItemName == strName)
		{
			// 加载子菜单
			return Load(pItemElem);
		}
		if(LoadSubMenu(pItemElem, strSubItemName))
		{
			// 如果递归加载成功则返回,否则继续向下遍历查找
			return TRUE;
		}
	}
	return FALSE;
}
开发者ID:Zhuguoping,项目名称:DuiVision,代码行数:25,代码来源:DuiMenu.cpp

示例9: Load

// 重载加载XML节点函数,加载下层的item内容
BOOL CDuiComboBox::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	__super::Load(pXmlElem);

	if(pXmlElem == NULL)
	{
		return FALSE;
	}
	
	// 加载下层的item节点信息
	for (DuiXmlNode pItemElem = pXmlElem.child(_T("item")); pItemElem; pItemElem=pItemElem.next_sibling(_T("item")))
	{
		CString strName = pItemElem.attribute(_T("name")).value();
		DuiSystem::Instance()->ParseDuiString(strName);
		CString strDesc = pItemElem.attribute(_T("desc")).value();
		DuiSystem::Instance()->ParseDuiString(strDesc);
		CString strValue = pItemElem.attribute(_T("value")).value();
		DuiSystem::Instance()->ParseDuiString(strValue);
		UINT nResourceID = 0;
		CString strImage = pItemElem.attribute(_T("image")).value();
		if(!strImage.IsEmpty())
		{
			if(strImage.Find(_T("skin:")) == 0)
			{
				strImage = DuiSystem::Instance()->GetSkin(strImage);
			}

			if(strImage.Find(_T(".")) == -1)	// 加载图片资源
			{
				nResourceID = _wtoi(strImage);
				strImage = _T("");
			}
		}

		ComboListItem comboItem;
		comboItem.nResourceID = nResourceID;
		comboItem.strImageFile = strImage;
		comboItem.strName = strName;
		comboItem.strDesc = strDesc;
		comboItem.strValue = strValue;
		m_vecItem.push_back(comboItem);

		// 如果是当前值,则更新编辑框的显示内容
		if(!strValue.IsEmpty() && (strValue == m_strComboValue))
		{
			SetTitle(strName);
		}
	}

    return TRUE;
}
开发者ID:Gu-Yue,项目名称:DuiVision,代码行数:52,代码来源:DuiComboBox.cpp

示例10: Load

// 重载加载XML节点函数,判断是否有子菜单
BOOL CMenuItem::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	BOOL bRet = __super::Load(pXmlElem);

	// 判断是否有定义子菜单
	if(pXmlElem && (pXmlElem.first_child() != NULL))
	{
		m_bIsPopup = TRUE;
	}

	// 如果是嵌套菜单(有menu属性),则通过调用父菜单的Load函数将嵌套菜单作为平级菜单加载
	CDuiMenu* pParentMenu = GetParentMenu();
	if(pParentMenu && !m_strMenuXml.IsEmpty())
	{
		pParentMenu->LoadXmlFile(m_strMenuXml);
		// 如果是嵌套菜单,则返回FALSE,这样就不会创建此菜单项,只会创建嵌套菜单中定义的菜单项
		return FALSE;
	}

	return bRet;
}
开发者ID:ForkProject,项目名称:DuiVision,代码行数:22,代码来源:MenuItem.cpp

示例11: Load

// 重载加载XML节点函数,加载下层的tab页面内容
BOOL CDuiTabCtrl::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	__super::Load(pXmlElem);

	if(pXmlElem == NULL)
	{
		return FALSE;
	}

	// 如果没有设置tabctrl高度,则按照hover图片的高度
	if((m_pImageHover != NULL) && (m_nTabCtrlHeight == 0))
	{
		m_nTabCtrlHeight = m_sizeHover.cy;
	}

	// 如果没有设置tab项的宽度,则按照hover图片的宽度
	if((m_pImageHover != NULL) && (m_nTabItemWidth == 0))
	{
		m_nTabItemWidth = m_sizeHover.cx;
	}

	BOOL bAllVisible = TRUE;
	
	// 加载下层的tab页节点信息
	int nIdIndex = m_vecItemInfo.size();
	for (DuiXmlNode pTabElem = pXmlElem.child(_T("tab")); pTabElem; pTabElem=pTabElem.next_sibling(_T("tab")))
	{
		CString strId = pTabElem.attribute(_T("id")).value();
		int nId = nIdIndex;
		if(strId != _T(""))
		{
			nId = _wtoi(strId);
		}

		CString strName = pTabElem.attribute(_T("name")).value();
		if(GetItemIndex(strName) != -1)
		{
			// 如果已经存在相同名字的tab页,则跳过
			continue;
		}

		CString strTabXml = pTabElem.attribute(_T("tabxml")).value();
		if(!strTabXml.IsEmpty())
		{
			// 从xml文件加载嵌套的tab页
			LoadTabXml(strTabXml);
			nIdIndex = m_vecItemInfo.size();
			continue;
		}

		CString strAction = pTabElem.attribute(_T("action")).value();
		CString strOutLink = pTabElem.attribute(_T("outlink")).value();
		BOOL bOutLink = ((strOutLink == _T("1")) || (strOutLink == _T("true")));
		CString strImage = pTabElem.attribute(_T("image")).value();
		CString strImageIndex = pTabElem.attribute(_T("img-index")).value();
		int nImageIndex = -1;
		if(!strImageIndex.IsEmpty())
		{
			nImageIndex = _wtoi(strImageIndex);
		}
		CString strImageCount = pTabElem.attribute(_T("img-count")).value();
		int nImageCount = -1;
		if(!strImageCount.IsEmpty())
		{
			nImageCount = _wtoi(strImageCount);
		}
		// visible属性可以用visible或show
		CString strVisible = pTabElem.attribute(_T("visible")).value();
		if(strVisible.IsEmpty())
		{
			strVisible = pTabElem.attribute(_T("show")).value();
		}
		BOOL bVisible = ((strVisible == _T("1")) || (strVisible == _T("true")) || (strVisible == _T("")));
		CString strActive = pTabElem.attribute(_T("active")).value();
		CString strDivXml = pTabElem.attribute(_T("div")).value();

		CString strScroll = pTabElem.attribute(_T("scroll")).value();
		BOOL bEnableScroll = (strScroll == _T("1"));

		// 加载Panel控件,每个Tab页都会自动创建一个Panel控件,即使没有加载子XML节点
		CDuiPanel* pControlPanel = (CDuiPanel*)_CreateControlByName(_T("div"));
		pControlPanel->SetName(strName);	// div控件的名字设置为tab的名字
		pControlPanel->SetEnableScroll(bEnableScroll);
		m_vecControl.push_back(pControlPanel);
		if(!strDivXml.IsEmpty())
		{
 			pControlPanel->LoadXmlFile(strDivXml);			
		}

		// 加载XML中Tab节点的各个下层控件节点
		pControlPanel->Load(pTabElem);

		CString strTitle = pControlPanel->GetTitle();
		
		// 通过Skin读取
		CString strSkin = _T("");
		if(strImage.Find(_T("skin:")) == 0)
		{
			strSkin = DuiSystem::Instance()->GetSkin(strImage);
//.........这里部分代码省略.........
开发者ID:anchowee,项目名称:DuiVision,代码行数:101,代码来源:DuiTab.cpp

示例12: InitUI

// 加载XML节点,解析节点中的属性信息设置到当前控件的属性中
BOOL CDuiGridCtrl::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	if(!__super::Load(pXmlElem))
	{
		return FALSE;
	}

    // 使用XML节点初始化div控件
	if(pXmlElem != NULL)
	{
		InitUI(m_rc, pXmlElem);
	}

	// 加载下层的cloumn节点信息
	for (DuiXmlNode pColumnElem = pXmlElem.child(_T("column")); pColumnElem; pColumnElem=pColumnElem.next_sibling(_T("column")))
	{
		CString strTitle = pColumnElem.attribute(_T("title")).value();
		CString strClrText = pColumnElem.attribute(_T("crtext")).value();
		CString strWidth = pColumnElem.attribute(_T("width")).value();
		CString strAlign = pColumnElem.attribute(_T("align")).value();
		CString strVAlign = pColumnElem.attribute(_T("valign")).value();
		DuiSystem::Instance()->ParseDuiString(strTitle);
		Color clrText = Color(0, 0, 0, 0);
		if(!strClrText.IsEmpty())
		{
			clrText = CDuiObject::StringToColor(strClrText);
		}
		int nWidth = -1;
		if(!strWidth.IsEmpty())
		{
			nWidth = _ttoi(strWidth);
		}
		UINT uAlignment = 0xFFFFUL;
		if(strAlign == _T("left"))
		{
			uAlignment = Align_Left;
		}else
		if(strAlign ==_T("center"))
		{
			uAlignment = Align_Center;
		}else
		if(strAlign == _T("right"))
		{
			uAlignment = Align_Right;
		}
		UINT uVAlignment = 0xFFFFUL;
		if(strVAlign == _T("top"))
		{
			uVAlignment = VAlign_Top;
		}else
		if(strVAlign == _T("middle"))
		{
			uVAlignment = VAlign_Middle;
		}else
		if(strVAlign == _T("bottom"))
		{
			uVAlignment = VAlign_Bottom;
		}
		InsertColumn(-1, strTitle, nWidth, clrText, uAlignment, uVAlignment);
	}

	// 加载下层的row节点信息
	for (DuiXmlNode pRowElem = pXmlElem.child(_T("row")); pRowElem; pRowElem=pRowElem.next_sibling(_T("row")))
	{
		CString strId = pRowElem.attribute(_T("id")).value();
		CString strCheck = pRowElem.attribute(_T("check")).value();
		CString strImage = pRowElem.attribute(_T("image")).value();
		CString strRightImage = pRowElem.attribute(_T("right-img")).value();
		CString strClrText = pRowElem.attribute(_T("crtext")).value();

		int nCheck = -1;
		if(!strCheck.IsEmpty())
		{
			nCheck = _ttoi(strCheck);
		}

		// 左边图片,通过Skin读取
		CString strSkin = _T("");
		if(strImage.Find(_T("skin:")) == 0)
		{
			strSkin = DuiSystem::Instance()->GetSkin(strImage);
		}else
		{
			strSkin = strImage;
		}

		int nImageIndex = -1;
		strImage = _T("");
		if(strSkin.Find(_T(".")) != -1)
		{
			// 图片文件
			strImage = strSkin;
		}else
		if(!strSkin.IsEmpty())
		{
			// 图片索引
			nImageIndex = _ttoi(strSkin);
		}

//.........这里部分代码省略.........
开发者ID:LLLiuWeicai,项目名称:webposclient,代码行数:101,代码来源:DuiGridCtrl.cpp

示例13: SetRect

// 重载加载XML节点函数,加载下层的Menu item信息
BOOL CDuiMenu::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	SetRect(CRect(0, 0, m_nWidth, m_nHeight));

	__super::Load(pXmlElem, bLoadSubControl);

	if(pXmlElem == NULL)
	{
		return FALSE;
	}

	if(!bLoadSubControl)
	{
		// 不加载子控件
		return TRUE;
	}

	// 菜单窗口宽度设置为popup窗口的宽度
	m_nWidth = m_size.cx;

	// 创建窗口
	Create(m_pParent, m_point, m_uMessageID);
	
	// 加载下层的item节点信息(正常情况下都使用DlgPopup的Load控件方式加载菜单项,下面的解析比较少用到)
	int nIdIndex = 100;
	for (DuiXmlNode pItemElem = pXmlElem.child(_T("item")); pItemElem; pItemElem=pItemElem.next_sibling())
	{
		CString strId = pItemElem.attribute(_T("id")).value();
		int nId = nIdIndex;
		if(strId != _T(""))
		{
			nId = _ttoi(strId);
		}

		CString strType = pItemElem.attribute(_T("type")).value();
		CString strName = pItemElem.attribute(_T("name")).value();
		CString strImage = pItemElem.attribute(_T("image")).value();
		CString strTitle = pItemElem.attribute(_T("title")).value();
		
		if(strType == _T("separator"))
		{
			// 分隔线也可以用图片的方式
			AddSeparator();
			continue;
		}
		CString strTitleU = strTitle;
		if(strImage.Find(_T(".")) != -1)	// 加载图片文件
		{
			CString strImgFile = strImage;
			AddMenu(strTitleU, nIdIndex, strImgFile);
		}else
		if(!strImage.IsEmpty())
		{
			UINT nResourceID = _ttoi(strImage);
			AddMenu(strTitleU, nIdIndex, nResourceID);
		}else
		{
			AddMenu(strTitleU, nIdIndex);
		}

		nIdIndex++;
	}

	// 刷新各菜单控件的位置
	SetMenuPoint();

	m_bInit = TRUE;

    return TRUE;
}
开发者ID:Zhuguoping,项目名称:DuiVision,代码行数:71,代码来源:DuiMenu.cpp

示例14: InitUI

// 加载XML节点,解析节点中的属性信息设置到当前控件的属性中
BOOL CDuiListCtrl::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	if(!__super::Load(pXmlElem))
	{
		return FALSE;
	}

    // 使用XML节点初始化div控件
	if(pXmlElem != NULL)
	{
		InitUI(m_rc, pXmlElem);
	}

	// 需要的总高度大于显示区高度才会显示滚动条
	m_pControScrollV->SetVisible(((int)m_vecRowInfo.size() * m_nRowHeight) > m_rc.Height());
	((CScrollV*)m_pControScrollV)->SetScrollMaxRange((int)m_vecRowInfo.size() * m_nRowHeight);

	// 加载下层的row节点信息
	for (DuiXmlNode pRowElem = pXmlElem.child(_T("row")); pRowElem; pRowElem=pRowElem.next_sibling(_T("row")))
	{
		CString strId = pRowElem.attribute(_T("id")).value();
		CString strTitle = pRowElem.attribute(_T("title")).value();
		CString strContent = pRowElem.attribute(_T("content")).value();
		CString strTime = pRowElem.attribute(_T("time")).value();
		CString strCheck = pRowElem.attribute(_T("check")).value();
		CString strImage = pRowElem.attribute(_T("image")).value();
		CString strRightImage = pRowElem.attribute(_T("right-img")).value();
		CString strClrText = pRowElem.attribute(_T("crtext")).value();
		CString strLink1 = pRowElem.attribute(_T("link1")).value();
		CString strLinkAction1 = pRowElem.attribute(_T("linkaction1")).value();
		CString strLink2 = pRowElem.attribute(_T("link2")).value();
		CString strLinkAction2 = pRowElem.attribute(_T("linkaction2")).value();

		DuiSystem::Instance()->ParseDuiString(strTitle);
		DuiSystem::Instance()->ParseDuiString(strContent);

		int nCheck = -1;
		if(!strCheck.IsEmpty())
		{
			nCheck = _wtoi(strCheck);
		}

		// 左边图片,通过Skin读取
		CString strSkin = _T("");
		if(strImage.Find(_T("skin:")) == 0)
		{
			strSkin = DuiSystem::Instance()->GetSkin(strImage);
		}else
		{
			strSkin = strImage;
		}

		int nImageIndex = -1;
		strImage = _T("");
		if(strSkin.Find(_T(".")) != -1)
		{
			// 图片文件
			strImage = strSkin;
		}else
		if(!strSkin.IsEmpty())
		{
			// 图片索引
			nImageIndex = _wtoi(strSkin);
		}

		// 右边图片,通过Skin读取
		CString strRightSkin = _T("");
		if(strRightImage.Find(_T("skin:")) == 0)
		{
			strRightSkin = DuiSystem::Instance()->GetSkin(strRightImage);
		}else
		{
			strRightSkin = strRightImage;
		}

		int nRightImageIndex = -1;
		strRightImage = _T("");
		if(strRightSkin.Find(_T(".")) != -1)
		{
			// 图片文件
			strRightImage = strRightSkin;
		}else
		if(!strRightSkin.IsEmpty())
		{
			// 图片索引
			nRightImageIndex = _wtoi(strRightSkin);
		}

		Color clrText = CDuiObject::StringToColor(strClrText);

		InsertItem(-1, strId, strTitle, strContent, strTime, nImageIndex, clrText, strImage, nRightImageIndex, strRightImage,
			strLink1, strLinkAction1, strLink2, strLinkAction2, nCheck);
	}

    return TRUE;
}
开发者ID:anchowee,项目名称:DuiVision,代码行数:97,代码来源:DuiListCtrl.cpp


注:本文中的DuiXmlNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。