示例#1
0
void CFileListView::ShowFileInfo( FileInfo& Item )
{
	UInt32 nIndex = 0;

	DeleteAllItems();

	if(m_FileStack.size() > 1)
	{
		InsertItem(nIndex, "..",1);
		SetSubItem(nIndex, 1, DIR_STR);
		SetSubItem(nIndex, 2, DIR_STR);
		++nIndex;
	}

	for (UInt32 i = 0; i < Item.Chlids.size(); ++i,++nIndex)
	{
		FileInfo& info = Item.Chlids[i];
		InsertItem(nIndex, info.szName, info.nFileSize ? 0 : 1);

		if(info.nFileSize > 0)
		{
			SetSubItem(nIndex, 1, (char*)ConvertSize(info.nFileSize));
			SetSubItem(nIndex, 2, (char*)ConvertSize(info.nCompSize));
			SetSubItem(nIndex, 4, info.bDataComplete ? "Y" : "N");
		}
		else
		{
			SetSubItem(nIndex, 1, DIR_STR);
			SetSubItem(nIndex, 2, DIR_STR);
		}

		if(info.FileTime != 0)
			SetSubItem(nIndex, 3, (char*)ConvertTime(&(info.FileTime)));
	}
}
示例#2
0
// 给表格项添加子控件
BOOL CDuiGridCtrl::AddSubItemControl(int nRow, int nItem, CControlBase* pControl)
{
	if((nRow < 0) || (nRow >= (int)m_vecRowInfo.size()))
	{
		return FALSE;
	}
	if((nItem < 0) || (nItem >= (int)m_vecColumnInfo.size()))
	{
		return FALSE;
	}

	GridItemInfo* pItemInfo = GetItemInfo(nRow, nItem);
	if(pItemInfo == NULL)
	{
		SetSubItem(nRow, nItem, _T(""));
		pItemInfo = GetItemInfo(nRow, nItem);
	}
	if(pItemInfo == NULL)
	{
		return FALSE;
	}

	if(pControl)
	{
		pControl->SetParent(this);
		pControl->SetVisible(FALSE);
		// 将控件指针添加到gridctrl控件的子控件列表中
		m_vecControl.push_back(pControl);
		// 将控件指针添加到单元格的控件列表中(仅用于按照单元格查找子控件)
		pItemInfo->vecControl.push_back(pControl);
		UpdateControl(true);
	}

	return TRUE;
}
TLvColumn::TLvColumn(const tstring& text, int width, TFormat how, int subitemIndex)
{
  Init();
  SetText(text);
  SetWidth(width, text);
  SetFormat(how);
  SetSubItem(subitemIndex);
}
BOOL COXTreeItem::SetSubItemText(LPCTSTR lpszText,int nCol)
	{
	if(nCol <= 0)
		{
		// column must be > 0
		ASSERT(FALSE);
		return FALSE;
		}
	return SetSubItem(nCol,OX_SUBITEM_TEXT,lpszText);
	}
TLvColumn::TLvColumn(uint mask_, int subitemIndex, int bufferSize)
{
  Init();
  mask = mask_;
  SetSubItem(subitemIndex);
  if (mask_ & LVCF_TEXT)
  {
    CHECK(bufferSize > 0);
    Buffer.resize(bufferSize);
    SetTextBuffer(&Buffer[0], bufferSize);
  }
}
TLvColumn::TLvColumn(const TListViewCtrl& ctl, int index, uint mask_, int subitemIndex, int bufferSize) 
{
  PRECONDITION(ctl.GetHandle());
  Init();
  mask = mask_;
  SetSubItem(subitemIndex);
  if (mask_ & LVCF_TEXT)
  {
    CHECK(bufferSize > 0);
    Buffer.resize(bufferSize);
    SetTextBuffer(&Buffer[0], bufferSize);
  }
  ctl.GetColumn(index, *this);
}
示例#7
0
// 加载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);
		}

		// 右边图片,通过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 = _ttoi(strRightSkin);
		}

		Color clrText = CDuiObject::StringToColor(strClrText);

		InsertRow(-1, strId, nImageIndex, clrText, strImage, nRightImageIndex, strRightImage, nCheck);

		int nRowIndex = m_vecRowInfo.size()-1;
		int nItemIndex = 0;
		// 加载下层的item节点信息
		for (DuiXmlNode pItemElem = pRowElem.child(_T("item")); pItemElem; pItemElem=pItemElem.next_sibling(_T("item")))
		{
			CString strTitle = pItemElem.attribute(_T("title")).value();
			CString strContent = pItemElem.attribute(_T("content")).value();
			CString strClrText = pItemElem.attribute(_T("crtext")).value();
			CString strImage = pItemElem.attribute(_T("image")).value();
			CString strLink = pItemElem.attribute(_T("link")).value();
			CString strLinkAction = pItemElem.attribute(_T("linkaction")).value();
			CString strFontTitle = pItemElem.attribute(_T("font-title")).value();
			DuiSystem::Instance()->ParseDuiString(strTitle);
			DuiSystem::Instance()->ParseDuiString(strContent);
			DuiSystem::Instance()->ParseDuiString(strLink);
			DuiSystem::Instance()->ParseDuiString(strLinkAction);
			Color clrText = CDuiObject::StringToColor(strClrText);

			// 图片,通过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);
			}

			BOOL bUseTitleFont = (strFontTitle == _T("1"));

			if(!strLink.IsEmpty())
			{
				SetSubItemLink(nRowIndex, nItemIndex, strLink, strLinkAction, nImageIndex, clrText, strImage);
			}else
			{
				SetSubItem(nRowIndex, nItemIndex, strTitle, strContent, bUseTitleFont, nImageIndex, clrText, strImage);
			}

			// 加载下层的控件节点信息
			GridItemInfo* pItemInfo = GetItemInfo(nRowIndex, nItemIndex);
			for (DuiXmlNode pControlElem = pItemElem.first_child(); pControlElem; pControlElem=pControlElem.next_sibling())
			{
				if((pControlElem != NULL) && (pItemInfo != NULL))
				{
					CString strControlName = pControlElem.name();
					CControlBase* pControl = _CreateControlByName(strControlName);
					if(pControl)
					{
						pControl->Load(pControlElem);
						pControl->SetVisible(FALSE);
						// 将控件指针添加到gridctrl控件的子控件列表中
						m_vecControl.push_back(pControl);
						// 将控件指针添加到单元格的控件列表中(仅用于按照单元格查找子控件)
						pItemInfo->vecControl.push_back(pControl);
					}
				}
			}

			nItemIndex++;
		}
	}

	// 计算横向滚动条
	CalcColumnsPos();
	// 计算每一行的位置和滚动条
	CalcRowsPos();

    return TRUE;
}
TLvItem::TLvItem(const tstring& text, int subitemIndex)
{
  Init();
  SetText(text);
  SetSubItem(subitemIndex);
}