// roseView.cpp : implementation of the CRoseView class
//
#include "stdafx.h"
#include "rose.h"
#include "roseDoc.h"
#include "roseView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "MMSystem.h"
#pragma comment(lib,"winmm.lib")
/////////////////////////////////////////////////////////////////////////////
// CRoseView
void MyDisplayBitmap(CDC*PDC,CBitmap*PBitmap,int x,int y,int daxiao)
{
BITMAP BM;
CDC MemDC;
MemDC.CreateCompatibleDC(NULL);
MemDC.SelectObject(PBitmap);
PBitmap->GetObject(sizeof(BM),&BM);
PDC->StretchBlt
(x,
y,
daxiao,
daxiao,
&MemDC,
0,
0,
BM.bmWidth,
BM.bmHeight,
SRCCOPY);
MemDC.DeleteDC();
}
IMPLEMENT_DYNCREATE(CRoseView, CView)
BEGIN_MESSAGE_MAP(CRoseView, CView)
//{{AFX_MSG_MAP(CRoseView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
ON_WM_CHAR()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRoseView construction/destruction
CRoseView::CRoseView()
{
m_HCross=AfxGetApp()->LoadStandardCursor(IDC_ARROW);
chushihua();
huanchongtime=50;
//竖条
I[0].hight=4;
I[0].ho=1;
I[0].UintX[0]=0;I[0].UintY[0]=0;
I[0].UintX[1]=0;I[0].UintY[1]=-1;
I[0].UintX[2]=0;I[0].UintY[2]=-2;
I[0].UintX[3]=0;I[0].UintY[3]=-3;
I[0].ColorIndex=0;
I[1].hight=1;
I[1].ho=0;
I[1].UintX[0]=0;I[1].UintY[0]=0;
I[1].UintX[1]=1;I[1].UintY[1]=0;
I[1].UintX[2]=2;I[1].UintY[2]=0;
I[1].UintX[3]=-1;I[1].UintY[3]=0;
I[1].ColorIndex=0;
//7
I[2].hight=3;
I[2].ho=3;
I[2].UintX[0]=0;I[2].UintY[0]=-2;
I[2].UintX[1]=1;I[2].UintY[1]=-2;
I[2].UintX[2]=1;I[2].UintY[2]=-1;
I[2].UintX[3]=1;I[2].UintY[3]=0;
I[2].ColorIndex=1;
I[3].hight=2;
I[3].ho=4;
I[3].UintX[0]=0;I[3].UintY[0]=0;
I[3].UintX[1]=1;I[3].UintY[1]=-1;
I[3].UintX[2]=2;I[3].UintY[2]=-1;
I[3].UintX[3]=0;I[3].UintY[3]=-1;
I[3].ColorIndex=1;
I[4].hight=3;
I[4].ho=5;
I[4].UintX[0]=0;I[4].UintY[0]=0;
I[4].UintX[1]=0;I[4].UintY[1]=-1;
I[4].UintX[2]=0;I[4].UintY[2]=-2;
I[4].UintX[3]=1;I[4].UintY[3]=0;
I[4].ColorIndex=1;
I[5].hight=2;
I[5].ho=2;
I[5].UintX[0]=0;I[5].UintY[0]=0;
I[5].UintX[1]=1;I[5].UintY[1]=0;
I[5].UintX[2]=2;I[5].UintY[2]=0;
I[5].UintX[3]=2;I[5].UintY[3]=-1;
I[5].ColorIndex=1;
//反7
I[6].hight=3;
I[6].ho=7;
I[6].UintX[0]=0;I[6].UintY[0]=0;
I[6].UintX[1]=0;I[6].UintY[1]=-1;
I[6].UintX[2]=0;I[6].UintY[2]=-2;
I[6].UintX[3]=1;I[6].UintY[3]=-2;
I[6].ColorIndex=2;
I[7].hight=2;
I[7].ho=8;
I[7].UintX[0]=0;I[7].UintY[0]=0;
I[7].UintX[1]=0;I[7].UintY[1]=-1;
I[7].UintX[2]=1;I[7].UintY[2]=0;
I[7].UintX[3]=2;I[7].UintY[3]=0;
I[7].ColorIndex=2;
I[8].hight=3;
I[8].ho=9;
I[8].UintX[0]=0;I[8].UintY[0]=0;
I[8].UintX[1]=1;I[8].UintY[1]=0;
I[8].UintX[2]=1;I[8].UintY[2]=-2;
I[8].UintX[3]=1;I[8].UintY[3]=-1;
I[8].ColorIndex=2;
I[9].hight=2;
I[9].ho=6;
I[9].UintX[0]=0;I[9].UintY[0]=-1;
I[9].UintX[1]=1;I[9].UintY[1]=-1;
I[9].UintX[2]=2;I[9].UintY[2]=-1;
I[9].UintX[3]=2;I[9].UintY[3]=0;
I[9].ColorIndex=2;
//T
I[10].hight=3;
I[10].ho=11;
I[10].UintX[0]=0;I[10].UintY[0]=0;
I[10].UintX[1]=0;I[10].UintY[1]=-1;
I[10].UintX[2]=0;I[10].UintY[2]=-2;
I[10].UintX[3]=1;I[10].UintY[3]=-1;
I[10].ColorIndex=3;
I[11].hight=2;
I[11].ho=12;
I[11].UintX[0]=0;I[11].UintY[0]=0;
I[11].UintX[1]=1;I[11].UintY[1]=0;
I[11].UintX[2]=2;I[11].UintY[2]=0;
I[11].UintX[3]=1;I[11].UintY[3]=-1;
I[11].ColorIndex=3;
I[12].hight=3;
I[12].ho=13;
I[12].UintX[0]=1;I[12].UintY[0]=0;
I[12].UintX[1]=1;I[12].UintY[1]=-1;
I[12].UintX[2]=1;I[12].UintY[2]=-2;
I[12].UintX[3]=0;I[12].UintY[3]=-1;
I[12].ColorIndex=3;
I[13].hight=2;
I[13].ho=10;
I[13].UintX[0]=0;I[13].UintY[0]=-1;
I[13].UintX[1]=1;I[13].UintY[1]=0;
I[13].UintX[2]=2;I[13].UintY[2]=-1;
I[13].UintX[3]=1;I[13].UintY[3]=-1;
I[13].ColorIndex=3;
//顺
I[14].hight=2;
I[14].ho=15;
I[14].UintX[0]=0;I[14].UintY[0]=0;
I[14].UintX[1]=1;I[14].UintY[1]=0;
I[14].UintX[2]=1;I[14].UintY[2]=-1;
I[14].UintX[3]=2;I[14].UintY[3]=-1;
I[14].ColorIndex=4;
I[15].hight=3;
I[15].ho=14;
I[15].UintX[0]=0;I[15].UintY[0]=-1;
I[15].UintX[1]=0;I[15].UintY[1]=-2;
I[15].UintX[2]=1;I[15].UintY[2]=-1;
I[15].UintX[3]=1;I[15].UintY[3]=0;
I[15].ColorIndex=4;
//逆
I[16].hight=2;
I[16].ho=17;
I[16].UintX[0]=0;I[16].UintY[0]=-1;
I[16].UintX[1]=1;I[16].UintY[1]=-1;
I[16].UintX[2]=1;I[16].UintY[2]=0;
I[16].UintX[3]=2;I[16].UintY[3]=0;
I[16].ColorIndex=5;
I[17].hight=3;
I[17].ho=16;
I[17].UintX[0]=0;I[17].UintY[0]=0;
I[17].UintX[1]=0;I[17].UintY[1]=-1;
I[17].UintX[2]=1;I[17].UintY[2]=-1;
I[17].UintX[3]=1;I[17].UintY[3]=-2;
I[17].ColorIndex=5;
//方块
I[18].hight=2;
I[18].ho=18;
I[18].UintX[0]=0;I[18].UintY[0]=0;
I[18].UintX[1]=1;I[18].UintY[1]=0;
I[18].UintX[2]=0;I[18].UintY[2]=-1;
I[18].UintX[3]=1;I[18].UintY[3]=-1;
I[18].ColorIndex=6;
}
CRoseView::~CRoseView()
{
}
BOOL CRoseView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CRoseView drawing
void CRoseView::OnDraw(CDC* pDC)
{
CRoseDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rc;
GetClientRect(&rc);
int screen_X=rc.right-rc.left;
int screen_Y=rc.bottom-rc.top;
if(screen_Y<75)screen_Y=75;
if(screen_Y>0.75*screen_X)
{
daxiao=screen_X/28;
weizhiX=0;
weizhiY=(int)(screen_Y-screen_X*0.75)/2;
}
else
{
daxiao=screen_Y/21;
weizhiY=0;
weizhiX=(int)(screen_X-screen_Y*1.333)/2;
}
CBrush brushZ;
// CBrush brushZ1;
CBrush *pbrushZ;
brushZ.CreateSolidBrush(RGB(20,50,90));
// brushZ1.CreateSolidBrush(RGB(30,70,130));
pbrushZ=pDC->SelectObject(&brushZ);
pDC->Rectangle(0,0,1600,1200);
// pDC->SelectObject(&brushZ1);
// pDC->Rectangle(0,0,1600,1200);
pDC->SelectObject(pbrushZ);
for(int i=1;i<29;i++)
for(int ii=13;ii<34;ii++)
{
// if(a[i][ii]==3)
// pDC->Rectangle(weizhiX+daxiao*(i-1),weizhiY+daxiao*(ii-13),
// weizhiX+daxiao*(i-1)+daxiao-1,weizhiY+daxiao*(ii-13)+daxiao-1);
if(a[i][ii]==1)
MyDisplayBitmap(pDC,&blok,weizhiX+daxiao*(i-1),
weizhiY+daxiao*(ii-13),daxiao-1);
if(a[i][ii]==0)
MyDisplayBitmap(pDC,&earese,weizhiX+daxiao*(i-1),
weizhiY+daxiao*(ii-13),daxiao-1);
}
CBrush brush,br1;
CBrush *pbrush;
brush.CreateSolidBrush(RGB(160,195,180));
br1.CreateSolidBrush(RGB(30,30,30));
pbrush=pDC->SelectObject(&br1);
for(i=-1;i<5;i++)
for(int ii=0;ii>-4;ii--)
{
MyDisplayBitmap(pDC,&nex,weizhiX+daxiao*(13+i-1),
weizhiY+daxiao*(17+ii-13),daxiao-1);
MyDisplayBitmap(pDC,&nex,weizhiX+daxiao*(13+i-1),
weizhiY+daxiao*(25+ii-13),daxiao-1);
}
pbrush=pDC->SelectObject(&brush);
for(i=0;i<4;i++)
{
MyDisplayBitmap(pDC,&PIC[I[dangqianNo1].ColorIndex],weizhiX+daxiao*(dangqianX1+I[dangqianNo1].UintX[i]-1),
weizhiY+daxiao*(dangqianY1+I[dangqianNo1].UintY[i]-13),daxiao-1);
MyDisplayBitmap(pDC,&PIC[I[dangqianNo2].ColorIndex],weizhiX+daxiao*(dangqianX2+I[dangqianNo2].UintX[i]-1),
weizhiY+daxiao*(dangqianY2+I[dangqianNo2].UintY[i]-13),daxiao-1);
MyDisplayBitmap(pDC,&PIC[I[index[index1+1]].ColorIndex],weizhiX+daxiao*(13+I[index[index1+1]].UintX[i]-1),
weizhiY+daxiao*(17+I[index[index1+1]].UintY[i]-13),daxiao-1);
MyDisplayBitmap(pDC,&PIC[I[index[index2+1]].ColorIndex],weizhiX+daxiao*(13+I[index[index2+1]].UintX[i]-1),
weizhiY+daxiao*(25+I[index[index2+1]].UintY[i]-13),daxiao-1);
}
pDC->SelectObject(pbrush);
wenzi();
}
/////////////////////////////////////////////////////////////////////////////
// CRoseView printing
BOO