summaryrefslogtreecommitdiff
path: root/noncore/games/kcheckers/field.cpp
Unidiff
Diffstat (limited to 'noncore/games/kcheckers/field.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kcheckers/field.cpp57
1 files changed, 54 insertions, 3 deletions
diff --git a/noncore/games/kcheckers/field.cpp b/noncore/games/kcheckers/field.cpp
index 0755008..aacfc1c 100644
--- a/noncore/games/kcheckers/field.cpp
+++ b/noncore/games/kcheckers/field.cpp
@@ -3,29 +3,80 @@
3 3
4#include "field.h" 4#include "field.h"
5 5
6Field::Field(QWidget *parent,int i):QWidget(parent) 6
7Field::Field(QWidget* parent,int i):QWidget(parent)
7{ 8{
8 pixmap=new QPixmap(SIZE,SIZE); 9 pixmap=new QPixmap(SIZE,SIZE);
10 CHECK_PTR(pixmap);
9 number=i; 11 number=i;
12
13 pattern=NULL;
14 picture=NULL;
15 frame=NULL;
10} 16}
11 17
18
12void Field::paintEvent(QPaintEvent*) 19void Field::paintEvent(QPaintEvent*)
13{ 20{
14 bitBlt(this,0,0,pixmap); 21 bitBlt(this,0,0,pixmap);
15} 22}
16 23
24
17void Field::mousePressEvent(QMouseEvent* mouseevent) 25void Field::mousePressEvent(QMouseEvent* mouseevent)
18{ 26{
19 if(mouseevent->button()!=Qt::LeftButton) return; 27 if(mouseevent->button()!=Qt::LeftButton) return;
20 emit click(number); 28 emit click(number);
21} 29}
22 30
23void Field::draw(QImage *image) 31
32void Field::draw()
24{ 33{
25 QPainter paint; 34 QPainter paint;
26 paint.begin(pixmap); 35 paint.begin(pixmap);
27 paint.drawImage(0,0,*image); 36
37 if(pattern) paint.drawImage(0,0,*pattern);
38
39 if(label.length())
40 {
41 paint.setPen(white);
42 paint.setFont(QFont(font().family(),10));
43 paint.drawText(2,11,label);
44 }
45
46 if(picture) paint.drawImage(0,0,*picture);
47
48 if(frame) paint.drawImage(0,0,*frame);
49
28 paint.end(); 50 paint.end();
29 update(); 51 update();
30} 52}
31 53
54
55void Field::setFrame(QImage* image)
56{
57 frame=image;
58 draw();
59}
60
61
62void Field::setPicture(QImage* image)
63{
64 picture=image;
65 draw();
66}
67
68
69void Field::setPattern(QImage* image)
70{
71 pattern=image;
72 draw();
73}
74
75
76void Field::setLabel(const QString & string)
77{
78 label=string;
79 draw();
80}
81
82