1 /* ColorCode, a free MasterMind clone with built in solver
2  * Copyright (C) 2009  Dirk Laebisch
3  * http://www.laebisch.com/
4  *
5  * ColorCode 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 3 of the License, or
8  * (at your option) any later version.
9  *
10  * ColorCode 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 ColorCode. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef ROWHINT_H
20 #define ROWHINT_H
21 
22 #include <QGraphicsItem>
23 #include <QColor>
24 #include <QPen>
25 #include <QRadialGradient>
26 #include <iostream>
27 #include <vector>
28 #include "colorcode.h"
29 
30 class RowHint : public QObject, public QGraphicsItem
31 {
32     Q_OBJECT
33     Q_INTERFACES(QGraphicsItem)
34 
35 public:
36     RowHint(QObject* parent = 0);
37     ~RowHint();
38 
39     int mIx;
40     bool mActive;
41     bool mSolved;
42     std::vector<int> mHints;
43 
44     int GetIx() const;
45     bool IsActive() const;
46     std::vector<int> GetHints();
47     void SetIx(const int ix);
48     void SetPegCnt(const int pegcnt);
49     void SetGameMode(const int gamemode);
50     void SetActive(bool b);
51     void SetPaused(const bool b);
52     void DrawHints(std::vector<int> res);
53     void Reset(const int pegcnt, const int gamemode);
54 
55     void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
56     QRectF boundingRect() const;
57     QPainterPath shape() const;
58 
59 signals:
60     void HintPressedSignal(int ix);
61 
62 protected:
63     void mousePressEvent(QGraphicsSceneMouseEvent* e);
64 
65 private:
66     static const int mPegPos[4][5][3];
67 
68     int mPegCnt;
69     int mGameMode;
70 
71     QPen mPen;
72     QBrush mBrush0;
73     QBrush mBrush1;
74 
75     QRectF outlineRect() const;
76 };
77 
78 #endif // ROWHINT_H
79