Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

field.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           field.cpp  -  description
00003                              -------------------
00004     begin                : Thu Dec 30 1999
00005     copyright            : (C) 1999 by Jurrien Loonstra
00006     email                : j.h.loonstra@st.hanze.nl
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #include "objects.h"
00020 
00021 #include "field.h"
00022 
00023 Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) {
00024         setFixedSize(game.scrwidth, game.scrheight);
00025         setBackgroundColor(white);
00026         timer = new QTimer(this);
00027 
00028         playing = false;
00029 
00030         connect(timer, SIGNAL(timeout()), SLOT(Timer()));
00031 }
00032 
00033 Field::~Field(){
00034         delete timer;
00035 }
00036 
00037 void Field::setPixmap(QPixmap *pix) {
00038         this->pix = pix;
00039 }
00040 
00041 // --------------------------------------------------------
00042 
00043 void Field::mousePressEvent(QMouseEvent *e){
00044         game.button_press(e->x(), e->y());
00045 }
00046 
00047 void Field::mouseReleaseEvent(QMouseEvent *e){
00048         game.button_release(e->x(), e->y());
00049 }
00050 
00051 void Field::enterEvent(QEvent *) {
00052         if (playing && !timer->isActive()) {
00053                 playing = true;
00054                 timer->start(250, FALSE);
00055         }
00056 }
00057 
00058 void Field::leaveEvent(QEvent *) {
00059         if (timer->isActive() && playing) {
00060                 playing = true;
00061                 timer->stop();
00062         }
00063 }
00064 
00065 void Field::stopTimer() {
00066         playing = false;
00067         if (timer->isActive())
00068                 timer->stop();
00069 }
00070 
00071 void Field::startTimer() {
00072         playing = true;
00073         if (!timer->isActive())
00074                 timer->start(250, FALSE);
00075 }
00076 
00077 void Field::Timer(){
00078         game.update();
00079 }
00080 
00081 void Field::paintEvent(QPaintEvent *) {
00082         bitBlt(this, 0, 0, pix);
00083 }

Generated on Sat Nov 5 16:17:19 2005 for OPIE by  doxygen 1.4.2