Diffstat (limited to 'noncore/games/kcheckers/field.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/kcheckers/field.cpp | 57 |
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 @@ -4,10 +4,17 @@ #include "field.h" -Field::Field(QWidget *parent,int i):QWidget(parent) + +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*) { @@ -15,4 +22,5 @@ void Field::paintEvent(QPaintEvent*) } + void Field::mousePressEvent(QMouseEvent* mouseevent) { @@ -21,11 +29,54 @@ void Field::mousePressEvent(QMouseEvent* mouseevent) } -void Field::draw(QImage *image) + +void Field::draw() { QPainter paint; 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(); update(); } + +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(); +} + + |