1 //------------------------------------------------------------------------------
2 // emCoreConfigPanel.h
3 //
4 // Copyright (C) 2007-2010,2014-2016,2020 Oliver Hamann.
5 //
6 // Homepage: http://eaglemode.sourceforge.net/
7 //
8 // This program is free software: you can redistribute it and/or modify it under
9 // the terms of the GNU General Public License version 3 as published by the
10 // Free Software Foundation.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for
15 // more details.
16 //
17 // You should have received a copy of the GNU General Public License version 3
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //------------------------------------------------------------------------------
20 
21 #ifndef emCoreConfigPanel_h
22 #define emCoreConfigPanel_h
23 
24 #ifndef emToolkit_h
25 #include <emCore/emToolkit.h>
26 #endif
27 
28 #ifndef emCoreConfig_h
29 #include <emCore/emCoreConfig.h>
30 #endif
31 
32 
33 //==============================================================================
34 //============================= emCoreConfigPanel ==============================
35 //==============================================================================
36 
37 class emCoreConfigPanel : public emLinearGroup {
38 
39 public:
40 
41 	// Class for a panel in which the user can edit the core configuration
42 	// emCoreConfig.
43 
44 	emCoreConfigPanel(ParentArg parent, const emString & name);
45 	virtual ~emCoreConfigPanel();
46 
47 protected:
48 
49 	virtual bool Cycle();
50 	virtual void AutoExpand();
51 	virtual void AutoShrink();
52 
53 private:
54 
55 	// --- member variables ---
56 
57 	emRef<emCoreConfig> Config;
58 	emButton * ResetButton;
59 
60 
61 	// --- sub-classes ---
62 
63 	class FactorField : public emScalarField, private emRecListener {
64 	public:
65 		FactorField(
66 			ParentArg parent, const emString & name,
67 			const emString & caption, const emString & description,
68 			const emImage & icon,
69 			emCoreConfig * config, emDoubleRec * rec,
70 			bool minimumMeansDisabled=false
71 		);
72 		virtual ~FactorField();
73 		virtual void TextOfValue(
74 			char * buf, int bufSize, emInt64 value,
75 			emUInt64 markInterval
76 		) const;
77 	protected:
78 		virtual void ValueChanged();
79 		virtual void OnRecChanged();
80 	private:
81 		void UpdateValue();
82 		double Val2Cfg(emInt64 value) const;
83 		emInt64 Cfg2Val(double d) const;
84 		emRef<emCoreConfig> Config;
85 		bool MinimumMeansDisabled;
86 		emInt64 ValOut;
87 	};
88 
89 	class MouseMiscGroup : public emRasterGroup, private emRecListener {
90 	public:
91 		MouseMiscGroup(ParentArg parent, const emString & name,
92 		               emCoreConfig * config);
93 		virtual ~MouseMiscGroup();
94 	protected:
95 		virtual void OnRecChanged();
96 		virtual bool Cycle();
97 		virtual void AutoExpand();
98 		virtual void AutoShrink();
99 	private:
100 		void UpdateOutput();
101 		emRef<emCoreConfig> Config;
102 		emCheckBox * StickBox;
103 		emCheckBox * EmuBox;
104 		emCheckBox * PanBox;
105 	};
106 
107 	class MouseGroup : public emRasterGroup {
108 	public:
109 		MouseGroup(ParentArg parent, const emString & name,
110 		           emCoreConfig * config);
111 		virtual ~MouseGroup();
112 	protected:
113 		virtual void AutoExpand();
114 	private:
115 		emRef<emCoreConfig> Config;
116 	};
117 
118 	class KBGroup : public emRasterGroup {
119 	public:
120 		KBGroup(ParentArg parent, const emString & name,
121 		        emCoreConfig * config);
122 		virtual ~KBGroup();
123 	protected:
124 		virtual void AutoExpand();
125 	private:
126 		emRef<emCoreConfig> Config;
127 	};
128 
129 	class KineticGroup : public emRasterGroup {
130 	public:
131 		KineticGroup(ParentArg parent, const emString & name,
132 		             emCoreConfig * config);
133 		virtual ~KineticGroup();
134 	protected:
135 		virtual void AutoExpand();
136 	private:
137 		emRef<emCoreConfig> Config;
138 	};
139 
140 	class MaxMemGroup : public emLinearGroup, private emRecListener {
141 	public:
142 		MaxMemGroup(ParentArg parent, const emString & name,
143 		            emCoreConfig * config);
144 		virtual ~MaxMemGroup();
145 	protected:
146 		virtual void OnRecChanged();
147 		virtual bool Cycle();
148 		virtual void AutoExpand();
149 		virtual void AutoShrink();
150 	private:
151 		void UpdateOutput();
152 		static void TextOfMemValue(
153 			char * buf, int bufSize, emInt64 value,
154 			emUInt64 markInterval, void * context
155 		);
156 		emRef<emCoreConfig> Config;
157 		emScalarField * MemField;
158 		emInt64 ValOut;
159 	};
160 
161 	class MaxMemTunnel : public emTunnel {
162 	public:
163 		MaxMemTunnel(ParentArg parent, const emString & name,
164 		             emCoreConfig * config);
165 		virtual ~MaxMemTunnel();
166 	protected:
167 		virtual void AutoExpand();
168 	private:
169 		emRef<emCoreConfig> Config;
170 	};
171 
172 	class PerformanceGroup : public emRasterGroup, private emRecListener {
173 	public:
174 		PerformanceGroup(ParentArg parent, const emString & name,
175 		                 emCoreConfig * config);
176 		virtual ~PerformanceGroup();
177 	protected:
178 		virtual void OnRecChanged();
179 		virtual bool Cycle();
180 		virtual void AutoExpand();
181 		virtual void AutoShrink();
182 	private:
183 		void UpdateOutput();
184 		void InvalidatePaintingOfAllWindows();
185 		static void DownscaleTextOfValueFunc(
186 			char * buf, int bufSize, emInt64 value,
187 			emUInt64 markInterval, void * context
188 		);
189 		static void UpscaleTextOfValueFunc(
190 			char * buf, int bufSize, emInt64 value,
191 			emUInt64 markInterval, void * context
192 		);
193 		emRef<emCoreConfig> Config;
194 		emScalarField * MaxRenderThreadsField;
195 		emCheckBox * AllowSIMDBox;
196 		emScalarField * DownscaleQualityField;
197 		emScalarField * UpscaleQualityField;
198 	};
199 };
200 
201 
202 #endif
203