-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathPanel.cpp
83 lines (72 loc) · 1.97 KB
/
Panel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Panel.cpp: implementation of the CPanel class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "俄罗斯方块.h"
#include "Panel.h"
#include "Manager.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CMyApp theApp;
extern CManager* pManager;
CPanel::CPanel()
{
}
CPanel::~CPanel()
{
}
void CPanel::DrawPanel(CDC* pDC)
{
CBrush brush;
CPen pen(PS_DOT,2,RGB(10,10,255)),GridPen(PS_SOLID,1,RGB(190,190,190));
brush.CreateSolidBrush(PanelColor);
pDC->SelectObject(&pen);
CBrush *pOldBrush=pDC->SelectObject(&brush);
//DrawBegin
RECT Rect=PanelRect;
Rect.bottom=PanelRect.bottom;
Rect.right=PanelRect.right;
pDC->Rectangle(&Rect);
pDC->Rectangle(&TextRect);
//Text
CString str;
pDC->SetTextColor(RGB(255,0,255));
pDC->SetBkColor(PanelColor);
str="姓名: " + pManager->Name;
pDC->TextOut(TextRect.left+10,TextRect.top+10,str);
str.Format("等级: %d",pManager->Level);
pDC->TextOut(TextRect.left+10,TextRect.top+40,str);
str.Format("消掉行数:%d",pManager->LineNumber);
pDC->TextOut(TextRect.left+10,TextRect.top+70,str);
str.Format("分值: %d",pManager->Result);
pDC->TextOut(TextRect.left+10,TextRect.top+100,str);
//DrawLine
pDC->SelectObject(&GridPen);
for(int iy=PanelRect.top;iy<PanelRect.bottom;iy+=GridSize.cy)
{
pDC->MoveTo(PanelRect.left,iy);
pDC->LineTo(PanelRect.right,iy);
}
for(int ix=PanelRect.left;ix<PanelRect.right;ix+=GridSize.cx)
{
pDC->MoveTo(ix,PanelRect.top);
pDC->LineTo(ix,PanelRect.bottom);
}
//DrawEnd
pDC->SelectObject(pOldBrush);
brush.DeleteObject();
}
void CPanel::PanelPosToPos(POINT &PanelPos)
{
PanelPos.x=PanelRect.left+PanelPos.x*GridSize.cx;
PanelPos.y=PanelRect.top +PanelPos.y*GridSize.cy;
}
void CPanel::PosToPanelPos(POINT &Pos)
{
}