summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire/canvasshapes.cpp
Unidiff
Diffstat (limited to 'noncore/games/solitaire/canvasshapes.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvasshapes.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/noncore/games/solitaire/canvasshapes.cpp b/noncore/games/solitaire/canvasshapes.cpp
new file mode 100644
index 0000000..28d0b4e
--- a/dev/null
+++ b/noncore/games/solitaire/canvasshapes.cpp
@@ -0,0 +1,92 @@
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#include <qpainter.h>
21#include <qcanvas.h>
22#include "canvasshapes.h"
23
24
25CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) :
26 QCanvasRectangle( x, y, 23, 36, canvas)
27{
28 setZ(0);
29 show();
30}
31
32
33void CanvasRoundRect::redraw()
34{
35 hide();
36 show();
37}
38
39
40void CanvasRoundRect::drawShape(QPainter &p)
41{
42 p.drawRoundRect( (int)x(), (int)y(), 23, 36);
43}
44
45
46CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) :
47 QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE)
48{
49 show();
50}
51
52
53void CanvasCircleOrCross::redraw()
54{
55 hide();
56 show();
57}
58
59
60void CanvasCircleOrCross::setCircle()
61{
62 circleShape = TRUE;
63 redraw();
64}
65
66
67void CanvasCircleOrCross::setCross()
68{
69 circleShape = FALSE;
70 redraw();
71}
72
73
74void CanvasCircleOrCross::drawShape(QPainter &p)
75{
76 int x1 = (int)x(), y1 = (int)y();
77 // Green circle
78 if (circleShape == TRUE) {
79 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
80 p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
81 p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
82 p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
83 p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
84 p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
85 // Red cross
86 } else {
87 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
88 p.drawLine( x1, y1, x1 + 20, y1 + 20);
89 p.drawLine( x1 + 20, y1, x1, y1 + 20);
90 }
91}
92