中国象棋控件 2.0.15
载入中...
搜索中...
未找到
信号 | Public 成员函数 | Protected 成员函数 | 属性 | Private 类型 | Private 成员函数 | Private 属性 | 所有成员列表
CFrmChineseChess类 参考

中国象棋窗体,完成中国象棋的界面 更多...

#include <FrmChineseChess.h>

类 CFrmChineseChess 继承关系图:
Inheritance graph
[图例]
CFrmChineseChess 的协作图:
Collaboration graph
[图例]

信号

void sigGoChess (int i, int j, CPiece::ENUM_QiZi chess)
 

Public 成员函数

 CFrmChineseChess (QWidget *parent=nullptr)
 
void AboutBox ()
 
棋局信息
QDateTime GetStartTime ()
 得到开始时间
 
int SetStartTime (const QDateTime &t)
 
QDateTime GetEndTime ()
 
int SetEndTime (const QDateTime &t)
 
QString GetRedName ()
 
int SetRedName (const QString &name)
 
QString GetBlackName ()
 
int SetBlackName (const QString &name)
 
- Public 成员函数 继承自 CChineseChess
int SetBoardLayout (ENUM_BoardLayout layout)
 
ENUM_BoardLayout GetBoardLayout ()
 
bool GoChess (int i, int j, bool bNext=false)
 走棋
 
int NextStep ()
 函数名:NextStep 功 能:下步棋 参 数:无 返回值:走棋步数 作 者:康 林 版 本:1.0.0.1 日 期:2004-10-5 时 间:10:19:33
 
int PreviouStep ()
 函数名:PreviouStep 功 能:上步棋 参 数:无 返回值:走棋步数 作 者:康 林 版 本:1.0.0.1 日 期:2004-10-5 时 间:10:19:51
 
virtual int SaveChessGame (const char *pszFile)
 保存棋局。 根据文件扩展名来保存为相应的格式。 当前支持自定义格式、PGN格式
 
virtual int LoadChessGame (const char *pszFile)
 加载棋局。 根据文件扩展名来解析文件的格式。 当前支持自定义格式、PGN格式
 
time_t GetStartTime ()
 
int SetStartTime (const time_t &t)
 
time_t GetEndTime ()
 
int SetEndTime (const time_t &t)
 
std::string GetRedName ()
 
int SetRedName (const char *pszName)
 
std::string GetBlackName ()
 
int SetBlackName (const char *pszName)
 
std::string GetGameTag (const std::string &tag)
 
int AddGameTag (const std::string &szTag, const std::string &szVal)
 
int EnablePromptSound (bool sound=true)
 
bool getEnablePromptSound ()
 
int EnablePromptMessage (bool bMsg=true)
 
bool getEnablePromptMessage ()
 

静态 Public 成员函数

资源
static int InitResource (const QString szLanguage)
 初始化资源,仅在程序开始时调用一次
 
static int CleanResource ()
 清理资源,仅在程序结束时调用一次
 

Protected 成员函数

virtual void mouseReleaseEvent (QMouseEvent *event) override
 
virtual void paintEvent (QPaintEvent *event) override
 
virtual void resizeEvent (QResizeEvent *event) override
 
virtual int onPromptSound (PROMPT_SOUND sound) override
 
virtual int onPromptMessage (CGoRule::ENUM_ReturnValue val) override
 提示错误消息
 
virtual int onCleanPrompt (int i, int j) override
 清除提示框
 
virtual int onDrawPrompt (int i, int j) override
 画提示框
 
virtual int onGoChess (int i, int j, CPiece::ENUM_QiZi chess) override
 走棋事件
 
- Protected 成员函数 继承自 CChineseChess
int CleanPrompt (int &i, int &j)
 清理提示,并把提示框位置设置成无效值
 
bool IsValidPosition (int i, int j)
 
int Initial ()
 
int ConvertQiPang (const int &i, const int &j, int &x, int &y)
 

属性

QString RedName
 
QString BlackName
 
QDateTime StartTime
 
QDateTime EndTime
 

Private 类型

enum  ENUM_ConvertCoordinate { XYToIJ , IJToXY }
 坐标转换 更多...
 
enum  ENUM_XINWEI { XinWei , Left_XinWei , Right_XinWei }
 棋盘星位 更多...
 

Private 成员函数

bool ConvertCoordinate (long *x, long *y, int *i, int *j, ENUM_ConvertCoordinate eCC=XYToIJ)
 坐标转换
 
bool SetQiPang (int width, int height)
 设置棋盘位置
 
void DrawXinWei (QPainter *pPainter, int i, int j, ENUM_XINWEI xinwei=XinWei)
 画星位
 
bool DrawTiShiBox (QPainter *pPainter, int i, int j)
 画提示框
 
int DrawQiZi (QPainter *pPainter, int i, int j, CPiece::ENUM_QiZi eQiZi)
 画棋子
 
void DrawQiPang (QPainter *pPainter, QRect rect)
 画棋盘
 
int DrawPicture (QPainter *pPainter, int i, int j, QImage image, bool CHHJKL=false)
 画图片
 
int DrawImage (QPainter *pPainter, QRect rect, QImage image)
 在指定位置绘图
 
int SetTransparentImage (QImage &image, const QColor &col=QColor(255, 255, 255))
 设置 QImage 透明
 
int SetTransparentPixmap (QPixmap &pixmap, const QColor &col=QColor(255, 255, 255))
 设置 Pixmap 透明
 

Private 属性

Ui::CFrmChineseChess * ui
 
int m_QiPangStartX
 棋盘的开始横坐标
 
int m_QiPangStartY
 棋盘的开始横坐标
 
int m_QiPangDistance
 棋盘格的距离
 
QColor m_QiPangColor
 棋盘格的颜色
 
QColor m_TiShiBoxColor
 提示框的颜色
 
QImage m_QiPangPicture
 棋盘背景图片
 
棋子图片
QImage m_RedShuai
 红帅
 
QImage m_RedShi
 红仕
 
QImage m_RedXiang
 红相
 
QImage m_RedMa
 红马
 
QImage m_RedChe
 红车
 
QImage m_RedBing
 红兵
 
QImage m_RedPao
 红炮
 
QImage m_BlackShuai
 黑帅
 
QImage m_BlackShi
 黑仕
 
QImage m_BlackXiang
 黑相
 
QImage m_BlackMa
 黑马
 
QImage m_BlackChe
 黑车
 
QImage m_BlackBing
 黑兵
 
QImage m_BlackPao
 黑炮
 
楚河汉界图片
QImage m_Chu
 
 
QImage m_He
 
 
QImage m_Han
 
 
QImage m_Jie
 
 
QImage m_KL
 版本图片
 

额外继承的成员函数

- Public 类型 继承自 CChineseChess
enum  _ENUM_BoardLayout {
  NoQi = 0 , OnlyTopBlack = 1 , OnlyBottomRed = 2 , SwapRedBetweenBlack = 4 ,
  OnlyTopRed = OnlyBottomRed | SwapRedBetweenBlack , OnlyBottomBlack = OnlyTopBlack | SwapRedBetweenBlack , TopBlackAndBottomRed = OnlyTopBlack | OnlyBottomRed , TopRedAndBottomBlack = TopBlackAndBottomRed | SwapRedBetweenBlack
}
 标准棋盘布局:详见《象棋竞赛规则(2011)》第一章 第1条。红棋在下,黑棋在上。 界面可以支持非标准棋盘布局(红在上,黑在下) 更多...
 
typedef enum CChineseChess::_ENUM_BoardLayout ENUM_BoardLayout
 标准棋盘布局:详见《象棋竞赛规则(2011)》第一章 第1条。红棋在下,黑棋在上。 界面可以支持非标准棋盘布局(红在上,黑在下)
 
- Protected 类型 继承自 CChineseChess
enum  PROMPT_SOUND {
  JiangJun , Eat , Go , NoGo ,
  Select
}
 提示音 更多...
 
enum  _ENUM_WalkState { RedReadly , RedWalked , BlackReadly , BlackWalked }
 
typedef enum CChineseChess::_ENUM_WalkState ENUM_WalkState
 
- Protected 属性 继承自 CChineseChess
CPiece::ENUM_QiZi m_ChessBoard [9][10]
 棋盘描述
 
ENUM_BoardLayout m_BoardLayout
 
ENUM_WalkState m_WalkState
 
int m_PreviouPositionX
 
int m_PreviouPositionY
 
int m_CurrentPositionX
 
int m_CurrentPositionY
 

详细描述

中国象棋窗体,完成中国象棋的界面

注解
  • 在程序开始时,仅调用一次 InitResource
  • 在程序结束时,仅调用一次 CleanResource

在文件 FrmChineseChess.h25 行定义.

成员枚举类型说明

◆ ENUM_ConvertCoordinate

坐标转换

在文件 FrmChineseChess.h128 行定义.

◆ ENUM_XINWEI

棋盘星位

在文件 FrmChineseChess.h133 行定义.

构造及析构函数说明

◆ CFrmChineseChess()

CFrmChineseChess::CFrmChineseChess ( QWidget *  parent = nullptr)
explicit

在文件 FrmChineseChess.cpp19 行定义.

◆ ~CFrmChineseChess()

CFrmChineseChess::~CFrmChineseChess ( )
overridevirtual

在文件 FrmChineseChess.cpp73 行定义.

成员函数说明

◆ AboutBox()

void CFrmChineseChess::AboutBox ( )

在文件 FrmChineseChess.cpp217 行定义.

◆ CleanResource()

int CFrmChineseChess::CleanResource ( )
static

清理资源,仅在程序结束时调用一次

在文件 FrmChineseChess.cpp95 行定义.

◆ ConvertCoordinate()

bool CFrmChineseChess::ConvertCoordinate ( long *  x,
long *  y,
int *  i,
int *  j,
ENUM_ConvertCoordinate  eCC = XYToIJ 
)
private

坐标转换

参数
x设备横坐标
y设备纵坐标
i棋盘横坐标[0,8]
j棋盘纵坐标[0,9]
eCC转换方式
  • XYToIJ: 从设备坐标转换到棋盘坐标(默认值)
  • IJToXY: 从棋盘坐标转换到设备坐标
返回
返回真值。成功:返回 true;失败:返回 false。

在文件 FrmChineseChess.cpp289 行定义.

◆ DrawImage()

int CFrmChineseChess::DrawImage ( QPainter *  pPainter,
QRect  rect,
QImage  image 
)
private

在指定位置绘图

参数
pPainter设备上下文
rect绘图区域
image图片
返回
如果成功返回 0,否则返回 非零

在文件 FrmChineseChess.cpp653 行定义.

◆ DrawPicture()

int CFrmChineseChess::DrawPicture ( QPainter *  pPainter,
int  i,
int  j,
QImage  image,
bool  CHHJKL = false 
)
private

画图片

参数
pPainter
i图片位置横坐标[0-8]
j图片位置纵坐标[0-9]
image图片
CHHJKL画楚河汉界(默认值为 false)
返回
如果成功返回 0,否则返回 非零

在文件 FrmChineseChess.cpp627 行定义.

◆ DrawQiPang()

void CFrmChineseChess::DrawQiPang ( QPainter *  pPainter,
QRect  rect 
)
private

画棋盘

参数
pPainter设备上下文
rect控件区域(包括边界)

在文件 FrmChineseChess.cpp333 行定义.

◆ DrawQiZi()

int CFrmChineseChess::DrawQiZi ( QPainter *  pPainter,
int  i,
int  j,
CPiece::ENUM_QiZi  eQiZi 
)
private

画棋子

参数
pPainter设备上下文
i棋盘横坐标[0-8]
j棋盘纵坐标[0-9]
eQiZi棋子
返回
如果成功返回 0,否则返回 非零

在文件 FrmChineseChess.cpp556 行定义.

◆ DrawTiShiBox()

bool CFrmChineseChess::DrawTiShiBox ( QPainter *  pPainter,
int  i,
int  j 
)
private

画提示框

参数
pPainter设备上下文
i棋盘横坐标[0-8]
j棋盘纵坐标[0-9]
返回
返回真值。成功:返回 true;失败:返回 false。

在文件 FrmChineseChess.cpp517 行定义.

◆ DrawXinWei()

void CFrmChineseChess::DrawXinWei ( QPainter *  pPainter,
int  i,
int  j,
ENUM_XINWEI  xinwei = XinWei 
)
private

画星位

参数
pPainter设备上下文
i星位的横坐标[0-8]
j星位的纵坐标[0-9]
xinwei画的位置取下列值勤之一:
  • XinWei:全画(默认值)
  • Left_XinWei:画左边的星位
  • Right_XinWei:画右边的星位

在文件 FrmChineseChess.cpp473 行定义.

◆ GetBlackName()

QString CFrmChineseChess::GetBlackName ( )

在文件 FrmChineseChess.cpp268 行定义.

◆ GetEndTime()

QDateTime CFrmChineseChess::GetEndTime ( )

在文件 FrmChineseChess.cpp246 行定义.

◆ GetRedName()

QString CFrmChineseChess::GetRedName ( )

在文件 FrmChineseChess.cpp258 行定义.

◆ GetStartTime()

QDateTime CFrmChineseChess::GetStartTime ( )

得到开始时间

在文件 FrmChineseChess.cpp233 行定义.

◆ InitResource()

int CFrmChineseChess::InitResource ( const QString  szLanguage)
static

初始化资源,仅在程序开始时调用一次

参数
szLanguage使用语言
返回

在文件 FrmChineseChess.cpp79 行定义.

◆ mouseReleaseEvent()

void CFrmChineseChess::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotectedvirtual

在文件 FrmChineseChess.cpp106 行定义.

◆ onCleanPrompt()

int CFrmChineseChess::onCleanPrompt ( int  i,
int  j 
)
overrideprotectedvirtual

清除提示框

实现了 CChineseChess.

在文件 FrmChineseChess.cpp193 行定义.

◆ onDrawPrompt()

int CFrmChineseChess::onDrawPrompt ( int  i,
int  j 
)
overrideprotectedvirtual

画提示框

实现了 CChineseChess.

在文件 FrmChineseChess.cpp202 行定义.

◆ onGoChess()

int CFrmChineseChess::onGoChess ( int  i,
int  j,
CPiece::ENUM_QiZi  chess 
)
overrideprotectedvirtual

走棋事件

实现了 CChineseChess.

在文件 FrmChineseChess.cpp211 行定义.

◆ onPromptMessage()

int CFrmChineseChess::onPromptMessage ( CGoRule::ENUM_ReturnValue  val)
overrideprotectedvirtual

提示错误消息

实现了 CChineseChess.

在文件 FrmChineseChess.cpp173 行定义.

◆ onPromptSound()

int CFrmChineseChess::onPromptSound ( PROMPT_SOUND  sound)
overrideprotectedvirtual

实现了 CChineseChess.

在文件 FrmChineseChess.cpp136 行定义.

◆ paintEvent()

void CFrmChineseChess::paintEvent ( QPaintEvent *  event)
overrideprotectedvirtual

在文件 FrmChineseChess.cpp120 行定义.

◆ resizeEvent()

void CFrmChineseChess::resizeEvent ( QResizeEvent *  event)
overrideprotectedvirtual

在文件 FrmChineseChess.cpp130 行定义.

◆ SetBlackName()

int CFrmChineseChess::SetBlackName ( const QString &  name)

在文件 FrmChineseChess.cpp273 行定义.

◆ SetEndTime()

int CFrmChineseChess::SetEndTime ( const QDateTime &  t)

在文件 FrmChineseChess.cpp253 行定义.

◆ SetQiPang()

bool CFrmChineseChess::SetQiPang ( int  width,
int  height 
)
private

设置棋盘位置

参数
width控件窗口宽度
height控件窗口高度
返回
返回真值。成功:返回 true;失败:返回 false。

在文件 FrmChineseChess.cpp311 行定义.

◆ SetRedName()

int CFrmChineseChess::SetRedName ( const QString &  name)

在文件 FrmChineseChess.cpp263 行定义.

◆ SetStartTime()

int CFrmChineseChess::SetStartTime ( const QDateTime &  t)

在文件 FrmChineseChess.cpp241 行定义.

◆ SetTransparentImage()

int CFrmChineseChess::SetTransparentImage ( QImage &  image,
const QColor &  col = QColor(255, 255, 255) 
)
private

设置 QImage 透明

参数
image
col透明颜色
返回
如果成功返回 0,否则返回 非零

在文件 FrmChineseChess.cpp673 行定义.

◆ SetTransparentPixmap()

int CFrmChineseChess::SetTransparentPixmap ( QPixmap &  pixmap,
const QColor &  col = QColor(255, 255, 255) 
)
private

设置 Pixmap 透明

参数
pixmap
col透明颜色
返回
如果成功返回 0,否则返回 非零

在文件 FrmChineseChess.cpp687 行定义.

类成员变量说明

◆ m_BlackBing

QImage CFrmChineseChess::m_BlackBing
private

黑兵

在文件 FrmChineseChess.h111 行定义.

◆ m_BlackChe

QImage CFrmChineseChess::m_BlackChe
private

黑车

在文件 FrmChineseChess.h110 行定义.

◆ m_BlackMa

QImage CFrmChineseChess::m_BlackMa
private

黑马

在文件 FrmChineseChess.h109 行定义.

◆ m_BlackPao

QImage CFrmChineseChess::m_BlackPao
private

黑炮

在文件 FrmChineseChess.h112 行定义.

◆ m_BlackShi

QImage CFrmChineseChess::m_BlackShi
private

黑仕

在文件 FrmChineseChess.h107 行定义.

◆ m_BlackShuai

QImage CFrmChineseChess::m_BlackShuai
private

黑帅

在文件 FrmChineseChess.h106 行定义.

◆ m_BlackXiang

QImage CFrmChineseChess::m_BlackXiang
private

黑相

在文件 FrmChineseChess.h108 行定义.

◆ m_Chu

QImage CFrmChineseChess::m_Chu
private

在文件 FrmChineseChess.h119 行定义.

◆ m_Han

QImage CFrmChineseChess::m_Han
private

在文件 FrmChineseChess.h121 行定义.

◆ m_He

QImage CFrmChineseChess::m_He
private

在文件 FrmChineseChess.h120 行定义.

◆ m_Jie

QImage CFrmChineseChess::m_Jie
private

在文件 FrmChineseChess.h122 行定义.

◆ m_KL

QImage CFrmChineseChess::m_KL
private

版本图片

在文件 FrmChineseChess.h123 行定义.

◆ m_QiPangColor

QColor CFrmChineseChess::m_QiPangColor
private

棋盘格的颜色

在文件 FrmChineseChess.h89 行定义.

◆ m_QiPangDistance

int CFrmChineseChess::m_QiPangDistance
private

棋盘格的距离

在文件 FrmChineseChess.h87 行定义.

◆ m_QiPangPicture

QImage CFrmChineseChess::m_QiPangPicture
private

棋盘背景图片

在文件 FrmChineseChess.h92 行定义.

◆ m_QiPangStartX

int CFrmChineseChess::m_QiPangStartX
private

棋盘的开始横坐标

在文件 FrmChineseChess.h85 行定义.

◆ m_QiPangStartY

int CFrmChineseChess::m_QiPangStartY
private

棋盘的开始横坐标

在文件 FrmChineseChess.h86 行定义.

◆ m_RedBing

QImage CFrmChineseChess::m_RedBing
private

红兵

在文件 FrmChineseChess.h103 行定义.

◆ m_RedChe

QImage CFrmChineseChess::m_RedChe
private

红车

在文件 FrmChineseChess.h102 行定义.

◆ m_RedMa

QImage CFrmChineseChess::m_RedMa
private

红马

在文件 FrmChineseChess.h101 行定义.

◆ m_RedPao

QImage CFrmChineseChess::m_RedPao
private

红炮

在文件 FrmChineseChess.h104 行定义.

◆ m_RedShi

QImage CFrmChineseChess::m_RedShi
private

红仕

在文件 FrmChineseChess.h99 行定义.

◆ m_RedShuai

QImage CFrmChineseChess::m_RedShuai
private

红帅

在文件 FrmChineseChess.h98 行定义.

◆ m_RedXiang

QImage CFrmChineseChess::m_RedXiang
private

红相

在文件 FrmChineseChess.h100 行定义.

◆ m_TiShiBoxColor

QColor CFrmChineseChess::m_TiShiBoxColor
private

提示框的颜色

在文件 FrmChineseChess.h90 行定义.

◆ ui

Ui::CFrmChineseChess* CFrmChineseChess::ui
private

在文件 FrmChineseChess.h83 行定义.

属性说明

◆ BlackName

QString CFrmChineseChess::BlackName
readwrite

在文件 FrmChineseChess.h30 行定义.

◆ EndTime

QDateTime CFrmChineseChess::EndTime
readwrite

在文件 FrmChineseChess.h32 行定义.

◆ RedName

QString CFrmChineseChess::RedName
readwrite

在文件 FrmChineseChess.h29 行定义.

◆ StartTime

QDateTime CFrmChineseChess::StartTime
readwrite

在文件 FrmChineseChess.h31 行定义.


该类的文档由以下文件生成: