summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/field.cpp
Unidiff
Diffstat (limited to 'noncore/games/kbill/field.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kbill/field.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/noncore/games/kbill/field.cpp b/noncore/games/kbill/field.cpp
new file mode 100644
index 0000000..a1b3560
--- a/dev/null
+++ b/noncore/games/kbill/field.cpp
@@ -0,0 +1,84 @@
1/***************************************************************************
2 field.cpp - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <qpainter.h>
19
20#include "objects.h"
21
22#include "field.h"
23
24Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) {
25 setFixedSize(game.scrwidth, game.scrheight);
26 setBackgroundColor(white);
27 timer = new QTimer(this);
28
29 playing = false;
30
31 connect(timer, SIGNAL(timeout()), SLOT(Timer()));
32}
33
34Field::~Field(){
35 delete timer;
36}
37
38void Field::setPixmap(QPixmap *pix) {
39 this->pix = pix;
40}
41
42// --------------------------------------------------------
43
44void Field::mousePressEvent(QMouseEvent *e){
45 game.button_press(e->x(), e->y());
46}
47
48void Field::mouseReleaseEvent(QMouseEvent *e){
49 game.button_release(e->x(), e->y());
50}
51
52void Field::enterEvent(QEvent *) {
53 if (playing && !timer->isActive()) {
54 playing = true;
55 timer->start(250, FALSE);
56 }
57}
58
59void Field::leaveEvent(QEvent *) {
60 if (timer->isActive() && playing) {
61 playing = true;
62 timer->stop();
63 }
64}
65
66void Field::stopTimer() {
67 playing = false;
68 if (timer->isActive())
69 timer->stop();
70}
71
72void Field::startTimer() {
73 playing = true;
74 if (!timer->isActive())
75 timer->start(250, FALSE);
76}
77
78void Field::Timer(){
79 game.update();
80}
81
82void Field::paintEvent(QPaintEvent *) {
83 bitBlt(this, 0, 0, pix);
84 } \ No newline at end of file