本文整理汇总了C++中DuiXmlNode::child方法的典型用法代码示例。如果您正苦于以下问题:C++ DuiXmlNode::child方法的具体用法?C++ DuiXmlNode::child怎么用?C++ DuiXmlNode::child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DuiXmlNode
的用法示例。
在下文中一共展示了DuiXmlNode::child方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例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;
}
示例5: 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);
//.........这里部分代码省略.........
示例6: Load
// 加载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);
}
//.........这里部分代码省略.........
示例7: Load
// 重载加载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;
}
示例8: Load
// 加载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;
}