author | leseb <leseb> | 2002-06-11 16:25:06 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-11 16:25:06 (UTC) |
commit | 2cfbb2adc058b59140a14ba6bbfc057266fea0b8 (patch) (side-by-side diff) | |
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) (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 @@ -1,31 +1,82 @@ #include <qpainter.h> #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*) { bitBlt(this,0,0,pixmap); } + void Field::mousePressEvent(QMouseEvent* mouseevent) { if(mouseevent->button()!=Qt::LeftButton) return; emit click(number); } -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(); +} + + |