// YJPropertyList.cpp : implementation file
//
#include "stdafx.h"
#include "PropertyListDlg.h"
#include "YJPropertyList.h"
#include ".\yjpropertylist.h"
//====
int g_debug=0;
CString YJPropertyItem::GetValue()
{
return this->m_text;
}
YJPropertyItem::YJPropertyItem(int m_nItemIndex,YJItemType m_nType,YJItemStatus m_nStatus,TCHAR* m_szName,YJControlType m_nControlType,bool b):CObject()
{
this->m_nControlType=m_nControlType;
this->m_nItemIndex=m_nItemIndex;
//this->m_nLeft=m_nLeft;
this->m_nStatus=m_nStatus;
this->m_nType=m_nType;
_tcscpy(this->m_szName,m_szName);
m_bShow=b;
//this->YJPropertyItem()
m_nLevel=0;
m_text="选中值";
}
YJPropertyItem::YJPropertyItem():CObject()
{
}
int CYJPropertyList::GetShowItem()
{
int nCount=0;
FormatList();
for(int i=0;i<m_List.GetSize();i++)
{
if(m_List[i]->m_bShow)nCount++;
}
return nCount;
}
void CYJPropertyList::FormatList()
{
if(m_List.GetSize())
{
m_List[0]->m_nLevel=0;
}
bool bShow=true;
int nHideLevel=-1;
for(int i=0;i<m_List.GetSize();i++)
{
if(bShow)
{
if(m_List[i]->m_bShow==false&&m_List[i]->m_nType==YJ_FOLDER)
{
bShow=false;
nHideLevel=m_List[i]->m_nLevel;
m_List[i]->m_nType=YJ_CLOSEFOLDER;
m_List[i]->m_bShow=true;
}
else
{
if(m_List[i]->m_nType==YJ_FOLDER)
m_List[i]->m_nType=YJ_OPENFOLDER;
}
}
else
{
if(m_List[i]->m_nLevel<=nHideLevel)
{
bShow=true;
if(m_List[i]->m_nType==YJ_FOLDER)
{
if(m_List[i]->m_bShow==false)
{
bShow=false;
m_List[i]->m_nType=YJ_CLOSEFOLDER;
}
else
m_List[i]->m_nType=YJ_OPENFOLDER;
}
m_List[i]->m_bShow=true;
}
else
{
if(m_List[i]->m_nType==YJ_FOLDER)
{
if(m_List[i]->m_bShow==false)
{
m_List[i]->m_nType=YJ_CLOSEFOLDER;
}
else
m_List[i]->m_nType=YJ_OPENFOLDER;
}
m_List[i]->m_bShow=false;
}
}
//if(!m_List[i]->m_bClose)nCount++;
}
}
void CYJPropertyList::DrawPlus(bool bPlus,CDC*pDC,const CRect &rect)
{
CBitmap *pBmp=NULL;
if(bPlus) pBmp=&m_bmpPlus;
else
pBmp=&m_bmpSub;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *pOld=memDC.SelectObject(pBmp);
pDC->BitBlt(rect.left,rect.top,rect.right,rect.bottom,&memDC,0,0,SRCCOPY);
memDC.SelectObject(pOld);
}
//===========================================================
// CYJPropertyList
IMPLEMENT_DYNAMIC(CYJPropertyList, CWnd)
CYJPropertyList::CYJPropertyList()
{
m_bmpSub.LoadBitmap(IDB_SUB);
m_bmpPlus.LoadBitmap(IDB_PLUS);
ASSERT(m_bmpPlus.GetSafeHandle());
m_nItemHeight=20;
m_nLeft=0;
/*CString strItem;
for(int i=0;i<10;i++)
{
YJPropertyItem *pItem=new YJPropertyItem(0,YJ_FOLDER,YJ_DEFAULT,_T("项目"),YJLISTBOX,true);
strItem.Format(_T("测试值%d"),i);
pItem->m_text=("测试值列表1");
for(int j=0;j<5;j++)
{
strItem.Format(_T("测试值列表%d"),j+1);
pItem->m_strings.Add(strItem);
}
if(i%2!=0)
{
pItem->m_nLevel=1;
pItem->m_bShow=false;
pItem->m_nStatus=YJ_DISABLE;
}
if(i%4)
{
pItem->m_nControlType=YJEDIT;
}
if(i==9)
pItem->m_nStatus=YJ_DEFAULT;
m_List.Add(pItem);
}*/
}
CYJPropertyList::~CYJPropertyList()
{
for(int i=(int)m_List.GetSize()-1;i>=0;i--)
{
delete m_List[i];
}
}
BEGIN_MESSAGE_MAP(CYJPropertyList, CWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
// ON_WM_CREATE()
ON_CBN_SELCHANGE(190, OnSelChange)
ON_CBN_KILLFOCUS(190, OnCbnKillfocusCombo1)
ON_EN_KILLFOCUS(200, OnEnKillfocusEdit1)
// ON_WM_KEYDOWN()
// ON_WM_KEYUP()
// ON_WM_CHAR()
END_MESSAGE_MAP()
//
void CYJPropertyList::InitPropertyList()
{
}
// CYJPropertyList message handlers
/*
* 列表颜色值
*/
COLORREF color_table[]=
{
0x99a8ac,//border color
0xc8d0d4,//margin color
0xc8d0d4,//line color
//=============
0x000000,//text color
0x99a8ac,//disable text color
0xc56a31,//active select color
0xc8d0c4,//unactive select color
};
void CYJPropertyList::DoDraw(CDC*pDC)
{
ASSERT(pDC);
CRect rectClient;
GetWindowRect(&rectClient);
rectClient.right=rectClient.Width();
rectClient.bottom=rectClient.Height();
rectClient.top=rectClient.left=0;
Draw(pDC,rectClient);
}
void CYJPropertyList::Draw(CDC*pDC,const CRect& rect)
{
ASSERT(pDC);
int nCount=GetShowItem();
CPen border_pen(PS_SOLID,1,color_table[0]);
CPen*pOldPen=pDC->SelectObject(&border_pen);
pDC->Rectangle(rect);
if(nCount<=0)
{
pDC->SelectObject(pOldPen);
return;
}
CBrush margin_brush(color_table[1]);
int nMarginHeight=nCount*m_nItemHeight;
CBrush *pOldBrush=pDC->SelectObject(&margin_brush);
CPen line_pen(PS_SOLID,1,color_table[2]);
pDC->SelectObject(&line_pen);
if(rect.Height()<nMarginHeight+1)
pDC->Rectangle(1,1,MARGIN_WIDTH+1,rect.Height()-1);
else
pDC->Rectangle(1,1,MARGIN_WIDTH+1,nMarginHeight+1);
int nLeft=(rect.Width()-MARGIN_WIDTH-1-1)/2;
//本来 nLeft=m_List[0].m_nLeft
if(m_nLeft<=0) m_nLeft=nLeft;
else
nLeft=m_nLeft;
for(int i=1;i<=nCount;i++)
{
if(i*m_nItemHeight+1>rect.Height()) break;
pDC->MoveTo(MARGIN_WIDTH+1,i*m_nItemHeight+1);
pDC->LineTo(rect.right-1,i*m_nItemHeight+1);
}
pDC->MoveTo(nLeft+MARGIN_WIDTH+1,1);
if(rect.Height()<nMarginHeight+1)
pDC->LineTo(nLeft+MARGIN_WIDTH+1,rect.Height());
else
pDC->LineTo(nLeft+MARGIN_WIDTH+1,nMarginHeight+1);
//====================================
CFont *pFont=this->GetFont();
ASSERT(pFont);
CFont *pOldFont=pDC->SelectObject(pFont);
pOldFont->DeleteObject();
//delete pOldFont;
pDC->SetTextColor(color_table[3]);
CRect rcItem(MARGIN_WIDTH+1+1,2,MARGIN_WIDTH+10,3);
CRect rcRight;
/*
* 跳过关闭的项目
*/
int j=0;
CRect rectPlus;
CString strValue(_T(""));
int n=pDC->GetTextExtent(_T(" ")).cx;
int nTimes=0;
for(int i=0;i<nCount;i++)
{
YJPropertyItem* pItem=m_List[j];
while(pItem&&(pItem->m_bShow==false))
{
j++;
pItem=m_List[j];
}
rcItem.top=1+i*m_nItemHeight;
rcItem.bottom=rcItem.top+m_nItemHeight;
if(rcItem.bottom>rect.Height())
{
//不再画了
break;
}
rcItem.right=rcItem.left+m_nLeft;
rcRight.left=rcItem.right+1;
rcRight.top=rcItem.top;
rcRight.bottom=rcItem.bottom;
rcRight.right=rect.right-1;
rectPlus.top=rcItem.top+(rcItem.Height()-8)/2;
rectPlus.bottom=rcItem.top+(rcItem.Height()+8)/2;
rectPlus.right=(MARGIN_WIDTH+8)/2+1;
rectPlus.left=(MARGIN_WIDTH-8)/2+1;
//==================
if(pItem->m_nStatus==YJ_DISABLE)
{
pDC->SetTextColor(color_table[4]);
}
strValue=pItem->m_szName;
nTimes=0;
for(int k=0;k<pItem->m_nLevel;k++)
{
strValue=_T(" ")+strValue;
nTimes++;
}
rectPlus.right+=nTimes*n;
rectPlus.left+=nTimes*n;
pDC->DrawText(strValue,&rcItem,DT_VCENTER|DT_SINGLELINE);
pDC->DrawText(pItem->m_text,rcRight,DT_VCENTER|DT_SINGLELINE);
if(pItem->m_nStatus==YJ_DISABLE)
{
pDC->SetTextColor(color_table[3]);
}
if(pItem->m_nType==YJ_OPENFOLDER)
{
DrawPlus(false,pDC,rectPlus);
pItem->m_icon=rectPlus;
}
else
if(pItem->m_nType==YJ_CLOSEFOLDER)
{
DrawPlus(true,pDC,rectPlus);
pItem->m_icon=rectPlus;
}
j++;
}
//============================
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
GdiFlush();
//==============================
}
void CYJPropertyList::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
DoDraw(&dc);
if(g_debug)
{
//AfxMessageBox("DDD");
//TRACE("ffffffffffffffffffffffff");
}
}
void CYJPropertyList::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//
int nCount=GetShowItem();
TRACE("%d\n",nCount);
int j=0;
for(int i=0;i<nCount;i++)
{
没有合适的资源?快使用搜索试试~ 我知道了~
商业编程-源码-属性列表的开发.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共22个文件
h:6个
cpp:4个
bmp:2个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 84 浏览量
2022-06-23
14:54:20
上传
评论
收藏 86KB ZIP 举报
温馨提示
商业编程-源码-属性列表的开发.zip
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rplib](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![exe](https://img-home.csdnimg.cn/images/20210720083343.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 22 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
programxh
- 粉丝: 17
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)