author | leseb <leseb> | 2002-06-11 16:25:06 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-11 16:25:06 (UTC) |
commit | 2cfbb2adc058b59140a14ba6bbfc057266fea0b8 (patch) (unidiff) | |
tree | 2dc8756a9d691cdfb46b537955453f46171ceeff /noncore/games/kcheckers/field.cpp | |
parent | d709dd35dc07d4a204380354f00a89ceb4d1f845 (diff) | |
download | opie-2cfbb2adc058b59140a14ba6bbfc057266fea0b8.zip opie-2cfbb2adc058b59140a14ba6bbfc057266fea0b8.tar.gz opie-2cfbb2adc058b59140a14ba6bbfc057266fea0b8.tar.bz2 |
Version 0.3 port
Diffstat (limited to 'noncore/games/kcheckers/field.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/kcheckers/field.cpp | 55 |
1 files changed, 53 insertions, 2 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 | |||
@@ -1,31 +1,82 @@ | |||
1 | 1 | ||
2 | #include <qpainter.h> | 2 | #include <qpainter.h> |
3 | 3 | ||
4 | #include "field.h" | 4 | #include "field.h" |
5 | 5 | ||
6 | |||
6 | Field::Field(QWidget *parent,int i):QWidget(parent) | 7 | Field::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 | |||
12 | void Field::paintEvent(QPaintEvent*) | 19 | void Field::paintEvent(QPaintEvent*) |
13 | { | 20 | { |
14 | bitBlt(this,0,0,pixmap); | 21 | bitBlt(this,0,0,pixmap); |
15 | } | 22 | } |
16 | 23 | ||
24 | |||
17 | void Field::mousePressEvent(QMouseEvent* mouseevent) | 25 | void 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 | ||
23 | void Field::draw(QImage *image) | 31 | |
32 | void 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 | |||
55 | void Field::setFrame(QImage* image) | ||
56 | { | ||
57 | frame=image; | ||
58 | draw(); | ||
59 | } | ||
60 | |||
61 | |||
62 | void Field::setPicture(QImage* image) | ||
63 | { | ||
64 | picture=image; | ||
65 | draw(); | ||
66 | } | ||
67 | |||
68 | |||
69 | void Field::setPattern(QImage* image) | ||
70 | { | ||
71 | pattern=image; | ||
72 | draw(); | ||
73 | } | ||
74 | |||
75 | |||
76 | void Field::setLabel(const QString & string) | ||
77 | { | ||
78 | label=string; | ||
79 | draw(); | ||
80 | } | ||
81 | |||
82 | |||