📄 qqface.cpp
字号:
// QQFace.cpp: implementation of the CQQFace class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "front.h"
#include "QQFace.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CQQFace::CQQFace()
{
}
CQQFace::~CQQFace()
{
int i;
CFolder *folder;
for(i=0;i<arFolders.GetSize();i++)
{
folder=(CFolder *)arFolders.GetAt(i);
if(folder)delete folder;
}
}
CQQFace::CQQFace(CWnd *parentWnd,UINT id)
{
pParentWnd=parentWnd;
iFolderhigh=22;
ID=id;
iSelFolder=0;
}
CRect CQQFace::GetInsideRect(int ifolder)
{
CRect rcResult=QRect;
int all=arFolders.GetSize();
if(all>0)
{
rcResult.top=QRect.top+(ifolder+1)*iFolderhigh;
rcResult.bottom=QRect.bottom-(all-ifolder-1)*iFolderhigh-1;
}
return rcResult;
}
CQQFace::CFolder::CFolder()
{
}
CQQFace::CFolder::~CFolder()
{
}
void CQQFace::AddFolder(char *cName,int iShape)
{
CFolder *folder=new CFolder;
folder->index=arFolders.GetSize();
folder->button=new CMyLabel(cName,1,iShape,false,false,ID,-1,pParentWnd); //-1是按钮的标示
folder->button->iAct=folder->index;//区别按钮
folder->Items=new CMyList(pParentWnd,ID,false);
folder->Items->iFlag=folder->index;//区别子项框
arFolders.Add((void *)folder);
}
void CQQFace::layout()
{
int i=0,all=arFolders.GetSize();
if(all==0)return;
CFolder *folder;
for(;i<=iSelFolder;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->setPos(QRect.left,QRect.top+i*iFolderhigh,QRect.right,QRect.top+(i+1)*iFolderhigh-1);
if(i==folder->index)
{
CRect rc;
rc=GetInsideRect(iSelFolder);
folder->Items->setPos(rc);
}
}
for(;i<all;i++)
{
((CFolder *)arFolders.GetAt(i))->button->setPos(QRect.left,QRect.bottom-(all-i)*iFolderhigh,QRect.right,QRect.bottom-(all-i-1)*iFolderhigh-1);
}
}
void CQQFace::draw(CDC *pDC)
{
int i,all=arFolders.GetSize();
layout();
CFolder *folder;
for(i=0;i<all;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->DrawLabel(pDC);
if(i==iSelFolder)
{
folder->Items->draw(pDC);
folder->Items->bEnable=true;
}
else folder->Items->bEnable=false;
}
}
void CQQFace::AddItem(int ifolder, char *name, int ishape,bool fromfile,int act,char *filename)
{
CFolder *folder;
folder=(CFolder *)arFolders.GetAt(ifolder);
folder->Items->AddItem(name,ishape,fromfile,act,filename);
}
void CQQFace::OnMouseMove(CPoint point)
{
int i,all=arFolders.GetSize();
CFolder *folder;
for(i=0;i<all;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->OnMouseMove(point);
if(i==iSelFolder)folder->Items->OnMouseMove(point);
}
}
void CQQFace::OnRButtonDown(CPoint point)
{
int i,all=arFolders.GetSize();
CFolder *folder;
for(i=0;i<all;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->OnRButtonDown(point);
if(i==iSelFolder)folder->Items->OnRButtonDown(point);
}
}
void CQQFace::OnLButtonUp(CPoint point)
{
int i,all=arFolders.GetSize();
CFolder *folder;
for(i=0;i<all;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->OnLButtonUp(point);
if(i==iSelFolder)
folder->Items->OnLButtonUp(point);
}
}
void CQQFace::OnLButtonDown(CPoint point)
{
int i,all=arFolders.GetSize();
CFolder *folder;
for(i=0;i<all;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->OnLButtonDown(point);
if(i==iSelFolder)folder->Items->OnLButtonDown(point);
}
}
void CQQFace::OutRect()
{
int i,all=arFolders.GetSize();
CFolder *folder;
for(i=0;i<all;i++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->OutRect();
if(i==iSelFolder)folder->Items->OutRect();
}
}
void CQQFace::AnimateFolderScroll(int hit)
{
if(hit==iSelFolder)return;
CRect selrc,hitrc;
CClientDC dc(pParentWnd);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap bmpHit, bmpSel;
CBitmap * obmp;
CDC * pDC = &memDC;
CFont * of = pDC->SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
int obk = pDC->SetBkMode(TRANSPARENT);
CFolder *folder;
int i,j,k;
//Todo
if(hit<iSelFolder)
{
//算selrc
folder=(CFolder *)arFolders.GetAt(hit);
selrc.SetRect(QRect.left,folder->button->LabelRect.bottom,QRect.right,0);
if(iSelFolder+1==arFolders.GetSize())selrc.bottom=QRect.bottom-1;
else
{
folder=(CFolder *)arFolders.GetAt(iSelFolder+1);
selrc.bottom=folder->button->LabelRect.top-1;
}
bmpSel.CreateCompatibleBitmap(&dc, selrc.Width(),selrc.Height()-1);
obmp = pDC->SelectObject(&bmpSel);
pDC->FloodFill(1,1,folder->Items->col);
for(i=hit+1,k=0;i<=iSelFolder;i++,k++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->setPos(0,k*iFolderhigh,selrc.Width(),(k+1)*iFolderhigh-1);
folder->button->DrawLabel(pDC);
}
folder=(CFolder *)arFolders.GetAt(iSelFolder);
folder->Items->setPos(CRect(0,k*iFolderhigh,folder->Items->ListRect.Width(),k*iFolderhigh+folder->Items->ListRect.Height()));
folder->Items->draw(pDC);
folder=(CFolder *)arFolders.GetAt(hit);
hitrc.SetRect(folder->Items->ListRect.left,folder->button->LabelRect.bottom,folder->Items->ListRect.right,folder->button->LabelRect.bottom+folder->Items->ListRect.Height()-1);
bmpHit.CreateCompatibleBitmap(&dc, hitrc.Width(),hitrc.Height());
pDC->SelectObject(&bmpHit);
pDC->FloodFill(1,1,folder->Items->col);
folder->Items->setPos(CRect(0,0,hitrc.Width(),hitrc.Height()));
folder->Items->draw(pDC);
for(j=1;j<=hitrc.Height();j+=10)
{
pDC->SelectObject(&bmpHit);
dc.BitBlt(hitrc.left,hitrc.top,hitrc.Width(),j,pDC,0,0,SRCCOPY);
pDC->SelectObject(&bmpSel);
dc.BitBlt(selrc.left,selrc.top+j,selrc.Width(),selrc.bottom-selrc.top-j,pDC,0,0,SRCCOPY);
Sleep(2);
}
pDC->SelectObject(obmp);
}
if(hit>iSelFolder)
{
folder=(CFolder *)arFolders.GetAt(iSelFolder);
selrc=folder->Items->ListRect;
bmpSel.CreateCompatibleBitmap(&dc, selrc.Width(),selrc.Height()-1);
obmp = pDC->SelectObject(&bmpSel);
pDC->FloodFill(1,1,folder->Items->col);
folder->Items->setPos(CRect(0,0,selrc.Width(),selrc.Height()));
folder->Items->draw(pDC);
folder=(CFolder *)arFolders.GetAt(iSelFolder);
int temp=folder->Items->ListRect.Height();
folder=(CFolder *)arFolders.GetAt(iSelFolder+1);
hitrc.SetRect(folder->button->LabelRect.left,folder->button->LabelRect.top,folder->button->LabelRect.right,0);
folder=(CFolder *)arFolders.GetAt(hit);
hitrc.bottom=folder->button->LabelRect.bottom+temp;
bmpHit.CreateCompatibleBitmap(&dc, hitrc.Width(),hitrc.Height());
pDC->SelectObject(&bmpHit);
pDC->FloodFill(1,1,folder->Items->col);
hitrc.bottom=folder->button->LabelRect.bottom;
for(i=iSelFolder+1,k=0;i<=hit;i++,k++)
{
folder=(CFolder *)arFolders.GetAt(i);
folder->button->setPos(0,k*iFolderhigh,hitrc.Width(),(k+1)*iFolderhigh);
folder->button->DrawLabel(pDC);
}
folder=(CFolder *)arFolders.GetAt(hit);
folder->Items->setPos(CRect(0,k*iFolderhigh,hitrc.Width(),hitrc.bottom));
folder->Items->draw(pDC);
for(j=0;j<selrc.Height();j+=10)
{
pDC->SelectObject(&bmpSel);
dc.BitBlt(selrc.left,selrc.top,selrc.Width(),selrc.Height()-j,pDC,0,0,SRCCOPY);
pDC->SelectObject(&bmpHit);
dc.BitBlt(hitrc.left,hitrc.top-j,hitrc.Width(),hitrc.Height()+j,pDC,0,0,SRCCOPY);
Sleep(2);
}
pDC->SelectObject(obmp);
}
pDC->SelectObject(of);
pDC->SetBkMode(obk);
}
void CQQFace::setPos(CRect rc)
{
QRect=rc;
}
void CQQFace::ListDown()
{
CFolder *folder=(CFolder *)arFolders.GetAt(iSelFolder);
folder->Items->listdown();
}
void CQQFace::ListUp()
{
CFolder *folder=(CFolder *)arFolders.GetAt(iSelFolder);
folder->Items->listup();
}
void CQQFace::OnTimer()
{
CFolder *folder=(CFolder *)arFolders.GetAt(iSelFolder);
folder->Items->OnTimer();
}
void CQQFace::cleanFolder(int iFolder)
{
((CFolder *)(arFolders.GetAt(iFolder)))->Items->CleanItems();
}
void CQQFace::SetItemAnimate(int folder, int act,bool animate)
{
int All=((CFolder *)(arFolders.GetAt(folder)))->Items->arItems.GetSize();
for(int i=All-1;i>=0;i--)
{
CMyLabel *temp=(CMyLabel *)((CFolder *)(arFolders.GetAt(folder)))->Items->arItems.GetAt(i);
if(temp->iAct==act)
{
temp->setShape3Animate(animate);
}
}
}
void CQQFace::deleteItem(int folder, int act)
{
int All=((CFolder *)(arFolders.GetAt(folder)))->Items->arItems.GetSize();
for(int i=All-1;i>=0;i--)
{
CMyLabel *temp=(CMyLabel *)((CFolder *)(arFolders.GetAt(folder)))->Items->arItems.GetAt(i);
if(temp->iAct==act)
{
delete temp;
((CFolder *)(arFolders.GetAt(folder)))->Items->arItems.RemoveAt(i);
}
}
}
int CQQFace::GetFolderSize(int folder)
{
return ((CFolder *)(arFolders.GetAt(folder)))->Items->GetSize();
}
CMyLabel * CQQFace::GetFolderItem(int folder, int item)
{
return (CMyLabel *)((CFolder *)(arFolders.GetAt(folder)))->Items->arItems.GetAt(item);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -