1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __CardWidget__
#define __CardWidget__
#include <assert.h>
#include <tqpushbutton.h>
#include <tqpixmap.h>
class TQLabel;
/**
* This class loads all pictures, first. So they don't have to be loaded after the start again
* @short A help class for loading the pictures
**/
class CardImages : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
CardImages( TQWidget *tqparent = 0, const char *name = 0 );
~CardImages();
// FIXME: Use CardValue instead of int when the cards are in their
// own file.
TQPixmap *getCardImage(int card) const;
TQPixmap *getDeck() const { return m_deck; }
int getWidth() const { return m_cardPixmaps[0].width(); }
int getHeight() const { return m_cardPixmaps[0].height(); }
void loadDeck(TQString path);
void loadCards(TQString cardDir);
private:
static TQPixmap *m_cardPixmaps;
static TQPixmap *m_deck;
};
/**
* This class extends the TQPushButton by some methods / variables to provide a card with held labels and so on
*
* @short The cards
**/
class CardWidget : public TQPushButton
{
Q_OBJECT
TQ_OBJECT
public:
CardWidget( TQWidget *tqparent=0, const char *name=0 );
/**
* Paints the deck if cardType = 0 or the card specified in cardType
* @param cardType the card to be painted. 0 is the deck
**/
void paintCard(int cardType);
/**
* @return The held status of this card
**/
bool getHeld();
/**
* Sets the new held
* @param newHeld specifies the new held
**/
void setHeld(bool newheld);
/**
* Toggle the boolean member m_held.
**/
bool toggleHeld(); /* returns the new value of held*/
void tqrepaintDeck();
signals:
/**
* This signal is emitted by @ref ownClick()
* @param CardWidget is a this pointer
**/
void pClicked(CardWidget *);
protected slots:
/**
* Emits the signal @ref pClicked() when the player clicks on the card
**/
void ownClick();
private:
TQPixmap *m_pm; // the loaded pixmap
bool m_held;
public:
TQLabel *heldLabel;
};
#endif
|