summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire/canvascard.cpp
Unidiff
Diffstat (limited to 'noncore/games/solitaire/canvascard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascard.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp
index c36da6c..cd298ef 100644
--- a/noncore/games/solitaire/canvascard.cpp
+++ b/noncore/games/solitaire/canvascard.cpp
@@ -11,25 +11,25 @@
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "canvascard.h" 21#include "canvascard.h"
22 22
23#include <qpe/resource.h> 23#include <opie2/oresource.h>
24 24
25#include <qgfx_qws.h> // Needed to get the device's width 25#include <qgfx_qws.h> // Needed to get the device's width
26 26
27#include <math.h> 27#include <math.h>
28 28
29#if defined( QT_QWS_CASSIOPEIA ) 29#if defined( QT_QWS_CASSIOPEIA )
30#define SLOW_HARDWARE 30#define SLOW_HARDWARE
31#endif 31#endif
32 32
33// Seems to be fast enough to me even without Transformations in the library 33// Seems to be fast enough to me even without Transformations in the library
34//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) 34//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ )
35//#define SLOW_HARDWARE 35//#define SLOW_HARDWARE
@@ -90,79 +90,83 @@ QPixmap *CanvasCard::cardsFaces = NULL;
90QPixmap *CanvasCard::cardsBacks = NULL; 90QPixmap *CanvasCard::cardsBacks = NULL;
91QBitmap *CanvasCard::cardsChars = NULL; 91QBitmap *CanvasCard::cardsChars = NULL;
92QBitmap *CanvasCard::cardsSuits = NULL; 92QBitmap *CanvasCard::cardsSuits = NULL;
93QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; 93QBitmap *CanvasCard::cardsCharsUpsideDown = NULL;
94QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; 94QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL;
95 95
96 96
97CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : 97CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
98 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) 98 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0)
99{ 99{
100 if ( !cardsFaces ) { 100 if ( !cardsFaces ) {
101 if ( qt_screen->deviceWidth() < 200 ) { 101 if ( qt_screen->deviceWidth() < 200 ) {
102 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) ); 102 cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face_small" ) );
103 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); 103 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) );
104 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) ); 104 cardsChars = new QBitmap();
105 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) ); 105 *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars_small" );
106 cardsSuits = new QBitmap();
107 *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits_small" );
106 } else { 108 } else {
107 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) ); 109 cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face" ) );
108 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); 110 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) );
109 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) ); 111 cardsChars = new QBitmap();
110 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); 112 *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars" );
113 cardsSuits = new QBitmap();
114 *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits" );
111 } 115 }
112 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); 116 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars );
113 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); 117 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits );
114 } 118 }
115 xOff = cardsFaces->width() / 2; 119 xOff = cardsFaces->width() / 2;
116 yOff = cardsFaces->height() / 2; 120 yOff = cardsFaces->height() / 2;
117 setSize( cardsFaces->width(), cardsFaces->height() ); 121 setSize( cardsFaces->width(), cardsFaces->height() );
118 setPen( NoPen ); 122 setPen( NoPen );
119 flipping = FALSE; 123 flipping = FALSE;
120} 124}
121 125
122 126
123void CanvasCard::setCardBack(int b) 127void CanvasCard::setCardBack(int b)
124{ 128{
125 if ( cardBack != b ) { 129 if ( cardBack != b ) {
126 130
127 cardBack = b; 131 cardBack = b;
128 132
129 if ( cardsBacks ) 133 if ( cardsBacks )
130 delete cardsBacks; 134 delete cardsBacks;
131 135
132 if ( qt_screen->deviceWidth() < 200 ) { 136 if ( qt_screen->deviceWidth() < 200 ) {
133 switch (cardBack) { 137 switch (cardBack) {
134 case 0: 138 case 0:
135 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break; 139 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); break;
136 case 1: 140 case 1:
137 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break; 141 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002_small" ) ); break;
138 case 2: 142 case 2:
139 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break; 143 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003_small" ) ); break;
140 case 3: 144 case 3:
141 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break; 145 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004_small" ) ); break;
142 case 4: 146 case 4:
143 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break; 147 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005_small" ) ); break;
144 } 148 }
145 } else { 149 } else {
146 switch (cardBack) { 150 switch (cardBack) {
147 case 0: 151 case 0:
148 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break; 152 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); break;
149 case 1: 153 case 1:
150 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break; 154 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002" ) ); break;
151 case 2: 155 case 2:
152 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break; 156 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003" ) ); break;
153 case 3: 157 case 3:
154 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break; 158 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004" ) ); break;
155 case 4: 159 case 4:
156 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break; 160 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005" ) ); break;
157 } 161 }
158 } 162 }
159 163
160 if ( !isFacing() ) 164 if ( !isFacing() )
161 redraw(); 165 redraw();
162 } 166 }
163} 167}
164 168
165 169
166void CanvasCard::draw(QPainter &painter) 170void CanvasCard::draw(QPainter &painter)
167{ 171{
168 int ix = (int)x(), iy = (int)y(); 172 int ix = (int)x(), iy = (int)y();
@@ -172,35 +176,26 @@ void CanvasCard::draw(QPainter &painter)
172 176
173 if ((scaleX <= 0.98) || (scaleY <= 0.98)) 177 if ((scaleX <= 0.98) || (scaleY <= 0.98))
174 { 178 {
175 p = new QPainter(); 179 p = new QPainter();
176 unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() ); 180 unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() );
177 p->begin(unscaledCard); 181 p->begin(unscaledCard);
178 ix = 0; 182 ix = 0;
179 iy = 0; 183 iy = 0;
180 } 184 }
181 185
182 if ( isFacing() ) { 186 if ( isFacing() ) {
183 187
184/*
185 // Now add the joker and card backs to the list of pixmaps
186 QPixmap *CardsBack = new QPixmap( Resource::loadPixmap( "cards/card_joker.png" ) );
187 QPoint *newBackHotspot = new QPoint( 0, 0 );
188 pixmaps->append((const QPixmap *)CardsBack);
189 hotspots->append((const QPoint *)newBackHotspot);
190*/
191
192 int w = cardsFaces->width(), h = cardsFaces->height(); 188 int w = cardsFaces->width(), h = cardsFaces->height();
193 189
194 //p->setBrush( NoBrush );
195 p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); 190 p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) );
196 191
197 if ( isRed() == TRUE ) 192 if ( isRed() == TRUE )
198 p->setPen( QColor( 0xFF, 0, 0 ) ); 193 p->setPen( QColor( 0xFF, 0, 0 ) );
199 else 194 else
200 p->setPen( QColor( 0, 0, 0 ) ); 195 p->setPen( QColor( 0, 0, 0 ) );
201 196
202 if ( qt_screen->deviceWidth() < 200 ) { 197 if ( qt_screen->deviceWidth() < 200 ) {
203 p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); 198 p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
204 p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 ); 199 p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 );
205 p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 ); 200 p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 );
206 p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 ); 201 p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 );