1 | /* |
2 | Copyright 2006 Mauricio Piacentini <mauricio@tabuleiro.com> |
3 | begin : Oct 31 2006 |
4 | |
5 | Kmahjongg is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
9 | |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef TILESPRITE_H |
21 | #define TILESPRITE_H |
22 | |
23 | #include "KmTypes.h" |
24 | |
25 | #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API |
26 | #include <libkdegamesprivate/kgamecanvas.h> |
27 | |
28 | #include <QPixmap> |
29 | #include <QObject> |
30 | |
31 | //This class wraps tile drawing, so it can blit the selected or unselected background, plus |
32 | //the tileface, positioned in the correct orientation. |
33 | |
34 | /** |
35 | * This class wraps tile drawing, so it can blit the selected or |
36 | * unselected background, plus the tileface, positioned in the correct |
37 | * orientation. |
38 | * |
39 | * @author Mauricio Piacentini <mauricio@tabuleiro.com> |
40 | */ |
41 | class TileSprite : public QObject, public KGameCanvasItem |
42 | { |
43 | Q_OBJECT |
44 | public: |
45 | |
46 | /** |
47 | * Constructor |
48 | * |
49 | * @param canvas |
50 | * @param backunselected |
51 | * @param backselected |
52 | * @param face |
53 | * @param angle |
54 | * @param selected |
55 | */ |
56 | TileSprite ( KGameCanvasAbstract* canvas, QPixmap& backunselected, QPixmap& backselected, QPixmap& face, TileViewAngle angle, bool selected); |
57 | |
58 | /** |
59 | * Deafault destructor */ |
60 | ~TileSprite(); |
61 | /** |
62 | * Method Description |
63 | * |
64 | * @param p |
65 | * @param prect |
66 | * @param preg |
67 | * @param delta |
68 | * @param cumulative_opacity |
69 | */ |
70 | virtual void paintInternal(QPainter* p, const QRect& prect, const QRegion& preg, |
71 | const QPoint& delta, double cumulative_opacity); |
72 | /** |
73 | * Method Description @param p */ |
74 | virtual void paint(QPainter* p); |
75 | /** |
76 | * Method Description */ |
77 | virtual QRect rect() const; |
78 | /** |
79 | * Method Description |
80 | * @param angle |
81 | * @param backunselected |
82 | * @param backselected |
83 | */ |
84 | void setAngle(TileViewAngle angle, QPixmap& backunselected, QPixmap& backselected); |
85 | |
86 | /** |
87 | * Method Description @param scale */ |
88 | inline void setScale (double scale){ m_scale=scale;} |
89 | /** |
90 | * Method Description @return double m_scale */ |
91 | inline double scale(){ return m_scale;} |
92 | /** |
93 | * Method Description @param enabled */ |
94 | inline void setSelected (bool enabled){ m_selected = enabled; changed();} |
95 | /** |
96 | * Method Description @return double m_selected */ |
97 | inline double selected(){ return m_selected;} |
98 | public slots: |
99 | /** |
100 | * Slot Description */ |
101 | void fadeOut(); |
102 | /** |
103 | * Slot Description */ |
104 | void fadeIn(); |
105 | |
106 | private: |
107 | void updateOffset(); |
108 | |
109 | QPixmap m_backselected; |
110 | QPixmap m_backunselected; |
111 | QPixmap m_face; |
112 | double m_scale; |
113 | bool m_selected; |
114 | bool m_dying; |
115 | short m_woffset; |
116 | short m_hoffset; |
117 | TileViewAngle m_angle; |
118 | QPoint m_faceoffset; |
119 | }; |
120 | |
121 | #endif // TILESPRITE_H |
122 | |