1 /*
2  *  tracker/SectionSettings.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  *  SectionSettings.h
25  *  MilkyTracker
26  *
27  *  Created by Peter Barth on Sun Mar 13 2005.
28  *
29  */
30 
31 #ifndef SECTIONSETTINGS__H
32 #define SECTIONSETTINGS__H
33 
34 #include "BasicTypes.h"
35 #include "Event.h"
36 #include "SectionAbstract.h"
37 #include "GlobalColorConfig.h"
38 
39 #ifdef __LOWRES__
40 #define NUMSETTINGSPAGES	4
41 #else
42 #define NUMSETTINGSPAGES	5
43 #endif
44 
45 class PPControl;
46 class PPContainer;
47 class PPListBox;
48 struct TColorPalette;
49 struct TMixerSettings;
50 class ColorPaletteContainer;
51 
52 class SectionSettings : public SectionAbstract
53 {
54 private:
55 	struct TColorDescriptor
56 	{
57 		const char* readableDecription;
58 		PPColor colorCopy;
59 	};
60 
61 	PPContainer* sectionContainer;
62 
63 	PPListBox* listBoxColors;
64 	PPListBox* listBoxFontFamilies;
65 	PPListBox* listBoxFontEntries;
66 	PPColor currentColor, *colorCopy;
67 
68 	bool visible;
69 
70 	pp_int32 currentActiveTabNum;
71 	pp_int32 currentActivePageStart;
72 
73 	PPSimpleVector<PPSimpleVector<class TabPage> > tabPages;
74 
75 	pp_int32 currentActiveSubPageNum[NUMSETTINGSPAGES];
76 
77 	TColorDescriptor colorDescriptors[GlobalColorConfig::ColorLast];
78 	pp_int32 colorMapping[GlobalColorConfig::ColorLast];
79 
80 	// Hold 5 predefined palettes
81 	ColorPaletteContainer* predefinedColorPalettes;
82 	TColorPalette* palette;
83 	bool storePalette;
84 	// backup of the current mixer settings, will be restored on cancel
85 	TMixerSettings* mixerSettings;
86 
87 	PPSystemString lastColorFile;
88 
89 	void showPage(pp_int32 page, pp_int32 subPage = 0);
90 
91 	void showRestartMessageBox();
92 
93 	void initColorDescriptors();
94 	void updateColors();
95 
96 	pp_int32 getColorIndex();
97 
98 protected:
99 	virtual void showSection(bool bShow);
100 
101 public:
102 	SectionSettings(Tracker& tracker);
103 	virtual ~SectionSettings();
104 
105 	// PPEvent listener
106 	virtual pp_int32 handleEvent(PPObject* sender, PPEvent* event);
107 
108 	virtual void init();
109 
110 	virtual void init(pp_int32 x, pp_int32 y);
111 	virtual void show(bool bShow);
112 	virtual void update(bool repaint = true);
113 
114 	void cancelSettings();
115 
isVisible()116 	bool isVisible() { return visible; }
117 
118 private:
119 	// color palette handling
120 	pp_int32 getNumPredefinedColorPalettes();
121 	PPString getEncodedPalette(pp_int32 index);
122 	void setEncodedPalette(pp_int32 index, const PPString& str);
123 
124 	void storeCurrentPaletteToDatabase();
125 
126 	void saveCurrentGlobalPalette();
127 	void restoreCurrentGlobalPalette();
128 
129 	void updateCurrentColors();
130 	void restorePalettes();
131 
132 	// mixer settings handling
133 	void saveCurrentMixerSettings(TMixerSettings& settings);
134 	void restoreCurrentMixerSettings();
135 
136 	// font face handling
137 	void enumerateFontFacesInListBox(pp_uint32 fontID);
138 
139 	// Custom resolution
140 	void storeCustomResolution();
141 
142 	// Show message box with custom resolutions
143 	void showCustomResolutionMessageBox();
144 
145 	// Message box which asks if default palettes should
146 	// be restored
147 	void showRestorePaletteMessageBox();
148 
149 	// Message box which asks for an audio driver
150 	void showSelectDriverMessageBox();
151 
152 	// Message box with list of resampler
153 	void showResamplerMessageBox();
154 
155 	void storeAudioDriver(const char* driverName);
156 	void storeResampler(pp_uint32 resampler);
157 
158 	void importCurrentColorPalette();
159 	void exportCurrentColorPalette();
160 
161 	void retrieveDisplayResolution();
162 
163 	// Responder should be friend
164 	friend class DialogResponderSettings;
165 
166 	friend class TabPageLayout_2;
167 	friend class TabPageLayout_3;
168 
169 	friend class TabPageFonts_1;
170 	friend class TabPageFonts_2;
171 
172 	friend class Tracker;
173 };
174 
175 #endif
176 
177