summaryrefslogtreecommitdiff
path: root/noncore/games/kcheckers/field.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/kcheckers/field.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/kcheckers/field.cpp55
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
@@ -5,2 +5,3 @@
+
Field::Field(QWidget *parent,int i):QWidget(parent)
@@ -8,5 +9,11 @@ Field::Field(QWidget *parent,int i):QWidget(parent)
pixmap=new QPixmap(SIZE,SIZE);
+ CHECK_PTR(pixmap);
number=i;
+
+ pattern=NULL;
+ picture=NULL;
+ frame=NULL;
}
+
void Field::paintEvent(QPaintEvent*)
@@ -16,2 +23,3 @@ void Field::paintEvent(QPaintEvent*)
+
void Field::mousePressEvent(QMouseEvent* mouseevent)
@@ -22,3 +30,4 @@ void Field::mousePressEvent(QMouseEvent* mouseevent)
-void Field::draw(QImage *image)
+
+void Field::draw()
{
@@ -26,3 +35,16 @@ void Field::draw(QImage *image)
paint.begin(pixmap);
- paint.drawImage(0,0,*image);
+
+ if(pattern) paint.drawImage(0,0,*pattern);
+
+ if(label.length())
+ {
+ paint.setPen(white);
+ paint.setFont(QFont(font().family(),10));
+ paint.drawText(2,11,label);
+ }
+
+ if(picture) paint.drawImage(0,0,*picture);
+
+ if(frame) paint.drawImage(0,0,*frame);
+
paint.end();
@@ -31 +53,30 @@ void Field::draw(QImage *image)
+
+void Field::setFrame(QImage* image)
+{
+ frame=image;
+ draw();
+}
+
+
+void Field::setPicture(QImage* image)
+{
+ picture=image;
+ draw();
+}
+
+
+void Field::setPattern(QImage* image)
+{
+ pattern=image;
+ draw();
+}
+
+
+void Field::setLabel(const QString & string)
+{
+ label=string;
+ draw();
+}
+
+