summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire/canvascardgame.h
Unidiff
Diffstat (limited to 'noncore/games/solitaire/canvascardgame.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardgame.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/noncore/games/solitaire/canvascardgame.h b/noncore/games/solitaire/canvascardgame.h
new file mode 100644
index 0000000..4d32014
--- a/dev/null
+++ b/noncore/games/solitaire/canvascardgame.h
@@ -0,0 +1,95 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef CANVAS_CARD_GAME_H
21#define CANVAS_CARD_GAME_H
22
23#include "cardgame.h"
24#include "canvasshapes.h"
25#include "canvascard.h"
26
27#include <qpe/resource.h>
28#include <qpe/config.h>
29
30#include <qmainwindow.h>
31#include <qpe/qpemenubar.h>
32#include <qpainter.h>
33
34#include <stdlib.h>
35#include <time.h>
36
37
38class CanvasCardPile;
39
40
41class CanvasCardGame : public QCanvasView, public CardGame
42{
43public:
44 CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, const char *name = 0, WFlags f = 0) :
45 QCanvasView( &c, parent, name, f ),
46 moved(FALSE),
47 moving(NULL),
48 alphaCardPile( NULL ),
49 cardXOff(0), cardYOff(0),
50 snapOn(snap),
51 numberToDraw(1) { }
52
53 virtual ~CanvasCardGame();
54
55 virtual Card *newCard( eValue v, eSuit s, bool f ) {
56 return new CanvasCard( v, s, f, canvas() );
57 }
58
59 virtual void readConfig( Config& cfg ) { Q_UNUSED( cfg ); }
60 virtual void writeConfig( Config& cfg ) { Q_UNUSED( cfg ); }
61
62 virtual void gameWon();
63 virtual bool haveWeWon() { return FALSE; }
64
65 virtual bool mousePressCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); return FALSE; }
66 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
67
68 void cancelMoving() { moving = NULL; }
69 void toggleSnap() { snapOn = (snapOn == TRUE) ? FALSE : TRUE; }
70 void toggleCardsDrawn() { numberToDraw = (numberToDraw == 1) ? 3 : 1; }
71 int cardsDrawn() { return numberToDraw; }
72 void setNumberToDraw(int numToDraw) { this->numberToDraw = numToDraw; }
73
74 void readPile( Config& cfg, CardPile *pile, QString name, int& highestZ );
75
76protected:
77 void contentsMousePressEvent(QMouseEvent *e);
78 void contentsMouseReleaseEvent(QMouseEvent *e);
79 void contentsMouseMoveEvent(QMouseEvent *e);
80
81protected:
82 // Mouse event state variables
83 bool moved;
84 CanvasCard *moving;
85 CanvasCardPile *alphaCardPile;
86 int cardXOff, cardYOff;
87
88private:
89 bool snapOn;
90 int numberToDraw;
91};
92
93
94#endif
95