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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/***************************************************************************
dlg_promote.cpp - description
-------------------
begin : Fri Jul 13 2001
copyright : (C) 2003 by Troy Corbin Jr.
email : tcorbin@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "definitions.h"
#include "dlg_promote.moc"
#include "knightspixcache.h"
#include <qimage.h>
dlg_promote::dlg_promote(QWidget *parent, const char *name, resource *Rsrc ) :
QDialog( parent, name, TRUE, Qt::WStyle_Customize | Qt::WStyle_DialogBorder )
{
Resource = Rsrc;
Queen = new QPushButton( this );
Bishop = new QPushButton( this );
Knight = new QPushButton( this );
Rook = new QPushButton( this );
Description = new QLabel( this );
}
dlg_promote::~dlg_promote()
{
delete Queen;
delete Bishop;
delete Knight;
delete Rook;
delete Description;
}
void dlg_promote::Init( bool Army )
{
KnightsPixCache *cache = Resource->pixCache;
QImage tempImage;
QPixmap buffer;
int margin;
margin = 2;
buffer.resize( Resource->ThemeSize, Resource->ThemeSize );
Description->setFixedSize( Resource->ThemeSize * 2 , 20 );
Queen->setFixedSize( Resource->ThemeSize, Resource->ThemeSize );
Bishop->setFixedSize( Resource->ThemeSize, Resource->ThemeSize );
Knight->setFixedSize( Resource->ThemeSize, Resource->ThemeSize );
Rook->setFixedSize( Resource->ThemeSize, Resource->ThemeSize );
setFixedSize( ( margin * 4 ) + ( Resource->ThemeSize * 2 ),
( margin * 6 ) + ( Resource->ThemeSize * 2 ) + 20 );
Description->move( margin, margin );
Queen->move( margin, ( margin * 3 ) + 20 );
Bishop->move( ( margin * 3 ) + Resource->ThemeSize, ( margin * 3 ) + 20 );
Knight->move( margin, ( margin * 5 ) + 20 + Resource->ThemeSize );
Rook->move( ( margin * 3 ) + Resource->ThemeSize, ( margin * 5 ) + 20 + Resource->ThemeSize );
/* Queen */
buffer = cache->SquareLight;
if( Army == WHITE ) bitBlt( &buffer, 0, 0, &cache->WhiteQueen, 0, 0, -1, -1, Qt::CopyROP, FALSE);
else bitBlt( &buffer, 0, 0, &cache->BlackQueen, 0, 0, -1, -1, Qt::CopyROP, FALSE);
Queen->setPixmap( buffer );
Queen->show();
/* Bishop */
buffer = cache->SquareDark;
if( Army == WHITE ) bitBlt( &buffer, 0, 0, &cache->WhiteBishop, 0, 0, -1, -1, Qt::CopyROP, FALSE);
else bitBlt( &buffer, 0, 0, &cache->BlackBishop, 0, 0, -1, -1, Qt::CopyROP, FALSE);
Bishop->setPixmap( buffer );
Bishop->show();
/* Knight */
buffer = cache->SquareDark;
if( Army == WHITE ) bitBlt( &buffer, 0, 0, &cache->WhiteKnight, 0, 0, -1, -1, Qt::CopyROP, FALSE);
else bitBlt( &buffer, 0, 0, &cache->BlackKnight, 0, 0, -1, -1, Qt::CopyROP, FALSE);
Knight->setPixmap( buffer );
Knight->show();
/* Rook */
buffer = cache->SquareLight;
if( Army == WHITE ) bitBlt( &buffer, 0, 0, &cache->WhiteRook, 0, 0, -1, -1, Qt::CopyROP, FALSE);
else bitBlt( &buffer, 0, 0, &cache->BlackRook, 0, 0, -1, -1, Qt::CopyROP, FALSE);
Rook->setPixmap( buffer );
Rook->show();
Description->setText( i18n( "Promote your pawn to..." ) );
Description->show();
connect( Queen, SIGNAL( clicked() ), this, SLOT( queenClick() ) );
connect( Bishop, SIGNAL( clicked() ), this, SLOT( bishopClick() ) );
connect( Knight, SIGNAL( clicked() ), this, SLOT( knightClick() ) );
connect( Rook, SIGNAL( clicked() ), this, SLOT( rookClick() ) );
Queen->setFocus();
setCaption( i18n( "Pawn Promotion" ) );
}
void dlg_promote::queenClick( void )
{
done( 'q' );
}
void dlg_promote::bishopClick( void )
{
done( 'b' );
}
void dlg_promote::knightClick( void )
{
done( 'n' );
}
void dlg_promote::rookClick( void )
{
done( 'r' );
}
|