Page3.cpp
上传用户:sunh8215
上传日期:2010-02-13
资源大小:1616k
文件大小:9k
- // Page3.cpp : implementation file
- //
- #include "stdafx.h"
- #include "qq.h"
- #include "Page3.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /*
- * 常数定义
- */
- const DFrame=2;
- const HFrame=18;
- const NLengthMainFrame=80;
- const NLengthSubFrame=50;
- const nDXWIDTH=NLengthMainFrame-NLengthSubFrame;
- const nX=120+nDXWIDTH;//150
- #include "QQView.h"
- #include "MainFrm.h"
- #include "Tools.h"
- /////////////////////////////////////////////////////////////////////////////
- // CPage3 dialog
- IMPLEMENT_DYNCREATE(CPage3, CDialog)
- /*
- * 静态成员初始化
- */
- long CPage3::xStart=0;
- long CPage3::yStart=0;
- CPoint CPage3::pntArray[30]={CPoint(0,0)};
- BOOL CPage3::bDrawTreeImage=FALSE;
- BOOL CPage3::bDrawFrameImage=FALSE;
- CPage3::CPage3(CWnd* pParent /*=NULL*/)
- : CDialog(CPage3::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CPage3)
- m_ShowType = -1;
- //}}AFX_DATA_INIT
- }
- void CPage3::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPage3)
- DDX_Radio(pDX, IDC_RADIO1, m_ShowType);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CPage3, CDialog)
- //{{AFX_MSG_MAP(CPage3)
- ON_BN_CLICKED(IDC_RADIO1, OnRadio)
- ON_BN_CLICKED(IDC_RADIO2, OnRadio)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPage3 message handlers
- /*
- * pDC: 画图的设备上下文
- * rect: 画图的范围
- */
- void CPage3::DrawFrameImage(CDC *pDC,CRect rect)
- {//画公司的框架图
- int nXWidth=rect.Width()/10;
- int nYHeight=rect.Height()/10;
- //构造可画图矩形区域
- CRect rectDraw(rect.left+nXWidth,rect.top+nYHeight,rect.right-nXWidth,rect.bottom-nYHeight);
- int nDX=rectDraw.Width()/10;
- long XCenter=(rectDraw.left+rectDraw.right)/2;
- DrawRangeText(XCenter-nDX,rectDraw.top,XCenter+nDX,rectDraw.top+nDX,"酒店",pDC);
- }
- void CPage3::DrawRangeText(long x1, long y1, long x2, long y2, CString strTtext, CDC *pDC)
- {//在矩形区域内部画文本
- //如果给定的矩形没有文本那么大,就调整矩形的大小来适应文本
- CSize size=pDC->GetTextExtent(strTtext);//得到文本的大小
- if(abs(x2-x1)<size.cx)
- {
- if(x1<=x2)
- {
- x2=x1+size.cx+1;
- }
- else{x1=x2+size.cx+1;}
- }
- if(abs(y2-y1)<size.cy)
- {
- if(y1<=y2)
- {
- y2=y1+size.cy+1;
- }
- else{y1=y2+size.cy+1;}
- }
- long xStart,yStart;
- xStart=x1+(abs(x2-x1)-size.cx)/2;
- yStart=y1+(abs(y2-y1)-size.cy)/2;
- pDC->MoveTo(x1,y1);
- pDC->LineTo(x2,y1);
- pDC->LineTo(x2,y2);
- pDC->LineTo(x1,y2);
- pDC->LineTo(x1,y1);
- pDC->TextOut(xStart,yStart,strTtext);// [5/22/2003]
- }
- void CPage3::OnRadio()
- {
- // TODO: Add your control notification handler code here
- this->UpdateData(TRUE);
- CQQView* pView=CQQView::GetView();
- CDC* pDC=pView->GetDC();
- CRect rect;
- pView->GetClientRect(&rect);
- long xstart=rect.left+(rect.Width()-350)/2;
- long ystart=rect.top+(rect.Height()-200)/2;
- if(m_ShowType==0)
- {//树型类型
- pView->nImgTypeInView=12;
- pView->bFirstRun=FALSE;
- // pDC->FillSolidRect(rect,pDC->GetBkColor());
- // [6/29/2003-9:36]
- // DrawTreeImage(pDC,CPoint(xstart+65,0));//画酒店树型图
- bDrawTreeImage=TRUE;//画树型图
- pView->Invalidate(TRUE);
- }
- if(m_ShowType==1)
- {//框架类型
- pView->nImgTypeInView=13;//指定为框架图像类型
- pView->bFirstRun=FALSE;
- bDrawFrameImage=TRUE;
- pView->Invalidate(TRUE);//引起重画
- // pDC->FillSolidRect(rect,pDC->GetBkColor());
- // this->DrawFrameImg(pDC,CRect(xstart,ystart,xstart+350,ystart+200));
- xStart=xstart;
- yStart=ystart;
- //拷贝当前屏幕的图像为拖动或者其他的消息引起的重画情况
- // ClientToScreen(&rect);//将客户区域转变成屏幕坐标
- // ScreenToClient(&rect);//有些问题,拖动的时候显示的图像不正确
- // pView->m_CurScreenBitmap=::GetScreenBitmap(&rect);
- }
- }
- void CPage3::DrawFrameImg(CDC *pDC,CRect rect)
- {
- CBitmap bitmap;
- bitmap.LoadBitmap(IDB_FRAMEIMG);
-
- CDC m;
- m.CreateCompatibleDC(pDC);//创建一个于pDC兼容的DC
- m.SelectObject(&bitmap);
- pDC->BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&m,0,0,SRCCOPY);
- m.DeleteDC();
- }
- CPoint CPage3::GetImgOrgPoint()
- {//得到图像相对客户区的坐标
- CQQView* pView=CQQView::GetView();
- CDC* pDC=pView->GetDC();
- return CPoint(xStart,yStart);
- }
- static LPTSTR strTextArray[]=
- {
- "酒店",
- "客房部",
- "接待",
- "楼层",
- "洗衣间",
- "餐饮部",
- "餐厅",
- "酒吧",
- "康乐部",
- "洗浴",
- "娱乐",
- "财务部",
- "购物",
- "库房",
- "收银台",
- NULL
- };
- void CPage3::DrawFrameAndText(CDC *pDC, CPoint LeftTop, CPoint RightButtom, const CString &strDrawedText)
- {
- //画指定的矩形和矩形内的文本
- //画矩形
- pDC->MoveTo(LeftTop);
- pDC->LineTo(RightButtom.x,LeftTop.y);
- pDC->LineTo(RightButtom);
- pDC->LineTo(LeftTop.x,RightButtom.y);
- pDC->LineTo(LeftTop);
- //画矩形内的文本
- CSize sizeText=pDC->GetTextExtent(strDrawedText);
- CRect FrameRect(LeftTop,RightButtom);
-
- if(FrameRect.Width()>sizeText.cx&&FrameRect.Height()>sizeText.cy)
- {
- if(!strDrawedText.IsEmpty())
- {
- long x1=LeftTop.x+(FrameRect.Width()-sizeText.cx)/2;
- long y1=LeftTop.y+(FrameRect.Height()-sizeText.cy)/2;
- long x2=RightButtom.x-(FrameRect.Width()-sizeText.cx)/2;
- long y2=RightButtom.y-(FrameRect.Height()-sizeText.cx)/2;
- CRect rectDrawText(x1,y1,x2,y2);
- pDC->DrawText(strDrawedText,&rectDrawText,DT_CENTER );
- }
- }
- }
- void CPage3::DrawTreeImage(CDC *pDC, CPoint pntStart)
- {
- pntArray[0]=CPoint(0+pntStart.x,0+pntStart.y);pntArray[1]=CPoint(100+pntStart.x,25+pntStart.y);pntArray[2]=CPoint(120+pntStart.x,50+pntStart.y);
- pntArray[10]=CPoint(120+pntStart.x,50+4*(DFrame+HFrame)+pntStart.y);
- pntArray[16]=CPoint(120+pntStart.x,50+7*(DFrame+HFrame)+pntStart.y);
- pntArray[22]=CPoint(120+pntStart.x,50+10*(DFrame+HFrame)+pntStart.y);
- for(int i=0;i<14;i++)
- {
- pntArray[3+i*2]=CPoint(pntStart.x+120+NLengthMainFrame,pntStart.y+50+HFrame+(DFrame+HFrame)*i);
- }
- for(i=0;i<3;i++)
- {//nX=150
- pntArray[4+i*2]=CPoint(pntStart.x+nX,pntStart.y+50+(DFrame+HFrame)*(i+1));
- pntArray[24+i*2]=CPoint(pntStart.x+nX,pntStart.y+50+(DFrame+HFrame)*(i+11));
- }
- for(i=0;i<2;i++)
- {
- pntArray[12+2*i]=CPoint(pntStart.x+nX,pntStart.y+50+(DFrame+HFrame)*(i+5));
- pntArray[18+2*i]=CPoint(pntStart.x+nX,pntStart.y+50+(DFrame+HFrame)*(i+8));
- }
- for(i=0;i<15;i++)
- {
- DrawFrameAndText(pDC,pntArray[i*2],pntArray[2*i+1],strTextArray[i]);
- }
- //画直线
- pDC->MoveTo((pntArray[0].x+pntArray[1].x)/2,pntArray[1].y);
- pDC->LineTo((pntArray[0].x+pntArray[1].x)/2,(pntArray[22].y+pntArray[23].y)/2);
- pDC->LineTo(pntArray[22].x,(pntArray[22].y+pntArray[23].y)/2);
- pDC->MoveTo((pntArray[0].x+pntArray[1].x)/2,(pntArray[2].y+pntArray[3].y)/2);
- pDC->LineTo(pntArray[2].x,(pntArray[2].y+pntArray[3].y)/2);
- pDC->MoveTo((pntArray[0].x+pntArray[1].x)/2,(pntArray[10].y+pntArray[11].y)/2);
- pDC->LineTo(pntArray[10].x,(pntArray[10].y+pntArray[11].y)/2);
- pDC->MoveTo((pntArray[0].x+pntArray[1].x)/2,(pntArray[16].y+pntArray[17].y)/2);
- pDC->LineTo(pntArray[10].x,(pntArray[16].y+pntArray[17].y)/2);
- long nSubCenterX=((pntArray[0].x+pntArray[1].x)/2+pntArray[2].x)/2;
- long nSubCenterY=(pntArray[2].y+pntArray[3].y)/2;
- pDC->MoveTo(nSubCenterX,nSubCenterY);
- pDC->LineTo(nSubCenterX,(pntArray[8].y+pntArray[9].y)/2);
- pDC->LineTo(pntArray[8].x,(pntArray[8].y+pntArray[9].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[4].y+pntArray[5].y)/2);
- pDC->LineTo(pntArray[4].x,(pntArray[4].y+pntArray[5].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[6].y+pntArray[7].y)/2);
- pDC->LineTo(pntArray[6].x,(pntArray[6].y+pntArray[7].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[10].y+pntArray[11].y)/2);
- pDC->LineTo(nSubCenterX,(pntArray[14].y+pntArray[15].y)/2);
- pDC->LineTo(pntArray[14].x,(pntArray[14].y+pntArray[15].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[12].y+pntArray[13].y)/2);
- pDC->LineTo(pntArray[12].x,(pntArray[12].y+pntArray[13].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[16].y+pntArray[17].y)/2);
- pDC->LineTo(nSubCenterX,(pntArray[20].y+pntArray[21].y)/2);
- pDC->LineTo(pntArray[20].x,(pntArray[20].y+pntArray[21].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[18].y+pntArray[19].y)/2);
- pDC->LineTo(pntArray[18].x,(pntArray[18].y+pntArray[19].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[22].y+pntArray[23].y)/2);
- pDC->LineTo(nSubCenterX,(pntArray[28].y+pntArray[29].y)/2);
- pDC->LineTo(pntArray[28].x,(pntArray[28].y+pntArray[29].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[24].y+pntArray[25].y)/2);
- pDC->LineTo(pntArray[24].x,(pntArray[24].y+pntArray[25].y)/2);
- pDC->MoveTo(nSubCenterX,(pntArray[26].y+pntArray[27].y)/2);
- pDC->LineTo(pntArray[26].x,(pntArray[26].y+pntArray[27].y)/2);
- }