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 PEGFACTORY_H
20 #define PEGFACTORY_H
21 
22 #include <iostream>
23 #include <QRadialGradient>
24 #include "colorcode.h"
25 #include "colorpeg.h"
26 #include "settings.h"
27 
28 
29 class PegFactory : public QObject
30 {
31     Q_OBJECT
32 
33     public:
34         PegFactory();
35 
36         static const int XPOS_BTNS_COL;
37 
38         ColorPeg* CreatePeg(int ix);
39         ColorPeg* GetPegBtn(int ix);
40         void SetPaused();
41         void SetIndicators();
42         void ChangeColorOrder(const int sorttype, const int ix0, const int ix1);
43         void ApplyColorCnt();
44 
45     public slots:
46         void RemovePegSlot(ColorPeg* cp);
47         void ResetColorsOrderSlot();
48         void PegPressSlot(ColorPeg* cp);
49         void PegSortSlot(ColorPeg* cp);
50         void PegReleasedSlot(ColorPeg* cp);
51 
52     signals:
53         void SnapPegSignal(ColorPeg* cp);
54 
55     private:
56         ColorCode* mWin;
57         Settings* mSettings;
58 
59         PegType* mTypesMap[10];
60         ColorPeg* mPegBtns[10];
61         QPoint mBtnPos[10];
62         QRadialGradient mGradMap[10];
63         QRadialGradient mGradBuff[10];
64 
65         std::vector<ColorPeg *> mAllPegs;
66         std::vector<ColorPeg *> mPegBuff;
67 
68         bool mHideColors;
69 
70         void InitTypesMap();
71         void InitPegBtns();
72 };
73 
74 #endif // PEGFACTORY_H
75