1 /*
2  *  ppui/RadioGroup.h
3  *
4  *  Copyright 2009 Peter Barth
5  *
6  *  This file is part of Milkytracker.
7  *
8  *  Milkytracker is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  Milkytracker is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with Milkytracker.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 /////////////////////////////////////////////////////////////////
24 //
25 //	PPRadioGroup control class
26 //
27 /////////////////////////////////////////////////////////////////
28 #ifndef RADIOGROUP__H
29 #define RADIOGROUP__H
30 
31 #include "BasicTypes.h"
32 #include "Control.h"
33 #include "SimpleVector.h"
34 
35 // Forwards
36 class PPGraphicsAbstract;
37 class PPFont;
38 class PPButton;
39 
40 class PPRadioGroup : public PPControl
41 {
42 private:
43 	const PPColor* radioButtonColor;
44 	const PPColor* textColor;
45 
46 	PPSimpleVector<PPString> items;
47 
48 	pp_uint32 spacerHeight;
49 
50 	pp_uint32 choice;
51 
52 	PPFont* font;
53 
54 	bool horizontal;
55 
56 	pp_int32 maxWidth;
57 
58 public:
59 	enum
60 	{
61 		DefaultSpacerHeight = 5,
62 		DefaultRadioWidth = 14
63 	};
64 
65 	PPRadioGroup(pp_int32 id, PPScreen* parentScreen, EventListenerInterface* eventListener,
66 				 const PPPoint& location, const PPSize& size,
67 				 pp_uint32 spacerHeight = DefaultSpacerHeight);
68 
69 	virtual ~PPRadioGroup();
70 
setColor(const PPColor & color)71 	void setColor(const PPColor& color) { this->radioButtonColor = &color; }
72 
73 	void addItem(const PPString& item);
74 	const PPString& getItem(pp_int32 index) const;
75 
setSpacerHeight(pp_uint32 spacerHeight)76 	void setSpacerHeight(pp_uint32 spacerHeight) { this->spacerHeight = spacerHeight; }
77 
setFont(PPFont * font)78 	void setFont(PPFont* font) { this->font = font; }
79 
setHorizontal(bool b)80 	void setHorizontal(bool b) { horizontal = b; }
81 
setChoice(pp_uint32 choice)82 	void setChoice(pp_uint32 choice) { this->choice = choice; }
83 
getChoice()84 	pp_uint32 getChoice() const { return choice; }
85 
86 	virtual void paint(PPGraphicsAbstract* graphics);
87 
88 	virtual pp_int32 dispatchEvent(PPEvent* event);
89 
90 	void fitSize();
91 };
92 
93 #endif
94