00001
00002 #include <qpainter.h>
00003
00004 #include "field.h"
00005
00006
00007 Field::Field(QWidget* parent,int i):QWidget(parent)
00008 {
00009 pixmap=new QPixmap(SIZE,SIZE);
00010 CHECK_PTR(pixmap);
00011 number=i;
00012
00013 pattern=NULL;
00014 picture=NULL;
00015 frame=NULL;
00016 }
00017
00018
00019 void Field::paintEvent(QPaintEvent*)
00020 {
00021 bitBlt(this,0,0,pixmap);
00022 }
00023
00024
00025 void Field::mousePressEvent(QMouseEvent* mouseevent)
00026 {
00027 if(mouseevent->button()!=Qt::LeftButton) return;
00028 emit click(number);
00029 }
00030
00031
00032 void Field::draw()
00033 {
00034 QPainter paint;
00035 paint.begin(pixmap);
00036
00037 if(pattern) paint.drawImage(0,0,*pattern);
00038
00039 if(label.length())
00040 {
00041 paint.setPen(white);
00042 paint.setFont(QFont(font().family(),10));
00043 paint.drawText(2,11,label);
00044 }
00045
00046 if(picture) paint.drawImage(0,0,*picture);
00047
00048 if(frame) paint.drawImage(0,0,*frame);
00049
00050 paint.end();
00051 update();
00052 }
00053
00054
00055 void Field::setFrame(QImage* image)
00056 {
00057 frame=image;
00058 draw();
00059 }
00060
00061
00062 void Field::setPicture(QImage* image)
00063 {
00064 picture=image;
00065 draw();
00066 }
00067
00068
00069 void Field::setPattern(QImage* image)
00070 {
00071 pattern=image;
00072 draw();
00073 }
00074
00075
00076 void Field::setLabel(const QString & string)
00077 {
00078 label=string;
00079 draw();
00080 }
00081
00082