⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boarddraw.h

📁 n皇后问题求解(8<=n<=1000) a) 皇后个数的设定 在指定文本框内输入皇后个数即可,注意: 皇后个数在8和1000 之间(包括8和1000) b) 求解 点击<
💻 H
字号:
// BoardDraw.h: interface for the BoardDraw class.
//
//////////////////////////////////////////////////////////////////////

#ifndef BOARDDRAW_JTWU_H
#define BOARDDRAW_JTWU_H

#include "stdafx.h"

class BoardDraw  
{
public:
	BoardDraw();
	BoardDraw(CDC *pDC);
	virtual ~BoardDraw();
	void SetForeColor(const COLORREF & color);
	void Rectangle(int x1, int y1, int x2, int y2);
	void DrawBlock(int x1, int y1, int x2, int y2);
	void DrawWall(int x1, int y1, int x2, int y2);
	void Circle(int x1, int y1, int x2, int y2, int nOffset);
	void ClearRectangle(int x1, int y1, int x2, int y2);
private:
	CDC* m_pDC;
	COLORREF m_forecolor;
};

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

BoardDraw::BoardDraw() {
	m_pDC = NULL;
}

BoardDraw::~BoardDraw() {
	m_pDC = NULL;
}

BoardDraw::BoardDraw(CDC *pDC) {
	m_pDC = pDC;
}

void BoardDraw::SetForeColor(const COLORREF & color) {
	m_forecolor = color;
}

void BoardDraw::Rectangle(int x1, int y1, int x2, int y2) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,m_forecolor);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0xffffff);
	m_pDC->SelectObject(&thebrush);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::ClearRectangle(int x1, int y1, int x2, int y2) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,0xE3DFE0);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0xE3DFE0);
	m_pDC->SelectObject(&thebrush);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::DrawBlock(int x1, int y1, int x2, int y2) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,0xff0000);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0xF70894);
	m_pDC->SelectObject(&thebrush);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::DrawWall(int x1, int y1, int x2, int y2) {
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0x000011);
	m_pDC->SelectObject(&thebrush);
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,0xff0000);
	m_pDC->SelectObject(&thepen);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::Circle(int x1, int y1, int x2, int y2, int nOffset) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,m_forecolor);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0x0000ff);
	m_pDC->SelectObject(&thebrush);
	x1 = x1 + nOffset ;
	y1 = y1 + nOffset ;
	x2 = x2 - nOffset ;
	y2 = y2 - nOffset ;
	m_pDC->Ellipse(x1,y1,x2,y2);
}

#endif // !defined BOARDDRAW_JTWU_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -