summaryrefslogtreecommitdiff
path: root/src/avp/support/rebitems.hpp
blob: 37ec9b247961b83cbce3b6fa71613c9fd1648270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/*
	
	rebitems.hpp

	Derived classes for the item types; all except CompositeItem go in this
	file.
*/

#ifndef _rebitems_hpp
#define _rebitems_hpp 1

	#if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
		#pragma once
	#endif

	#ifndef _rebmenus_hpp
		#include "rebmenus.hpp"
	#endif

	#if UseRebMenus
		#ifndef _included_pcmenus_h_
			#include "pcmenus.h"
				// for enum KeyConfigItems 
		#endif

		#ifndef _scstring
			#include "scstring.hpp"
		#endif
	#endif

/* Version settings *****************************************************/

/* Constants  ***********************************************************/

/* Macros ***************************************************************/

/* Type definitions *****************************************************/
#if UseRebMenus
// Derived classes for the item types:
namespace RebMenus
{
	class Item_Unimplemented : public Item
	{
	public:
		Item_Unimplemented
		(
			OnOffAppearance theOnOffApp
		) : Item
			(
				theOnOffApp
			)
		{
		}

		// Process various keypresses:
		OurBool Navigate( enum NavigationOp aNavOp );
			// return = was message processed

		void Diagnostic(OurBool bSelected) const;

		// Methods relating to rendering:
		void Render
		(
			const RenderContext& theContext,
			OurBool bSelected
		) const;

		SizeInfo GetSizeInfo(void) const;

	};

	class Item_Command : public Item
	{
	public:
		Item_Command
		(
			OnOffAppearance theOnOffApp,
			Command* pCommand
		) : Item
			(
				theOnOffApp
			),
			pCommand_Val(pCommand)
		{
			pCommand_Val -> R_AddRef();
		}

		~Item_Command()
		{
			pCommand_Val -> R_Release();
		}

		// Process various keypresses:
		OurBool Navigate( enum NavigationOp aNavOp );
			// return = was message processed

		void Diagnostic(OurBool bSelected) const;

		// Methods relating to rendering:
		void Render
		(
			const RenderContext& theContext,
			OurBool bSelected
		) const;

		SizeInfo GetSizeInfo(void) const;

	private:
		Command *const pCommand_Val;		
	};
		// contains a command; can contain a "goto menu page" command

	class Item_Selection : public Item
	{
	public:
		Item_Selection
		(
			OnOffAppearance theOnOffApp,
			enum Direction initDir,
			SelectionVariable* pSelectionVar
		) : Item
			(
				theOnOffApp
			),
			theDir(initDir),
			pSelectionVar_Val(pSelectionVar)
		{
		}

		// Process various keypresses:
		OurBool Navigate( enum NavigationOp aNavOp );
			// return = was message processed

		void Diagnostic(OurBool bSelected) const;

		void Min(void);
		void Max(void);
		void Inc(void);
		void Dec(void);

		// Methods relating to rendering:
		void Render
		(
			const RenderContext& theContext,
			OurBool bSelected
		) const;

		SizeInfo GetSizeInfo(void) const;

	private:
		// Direction:
		const enum Direction theDir;
		SelectionVariable* const pSelectionVar_Val;

	};

	class Item_Slider : public Item
	{
	public:
		Item_Slider
		(
			OnOffAppearance theOnOffApp,
			enum Direction initDir,
			BoundedExportVariable<int>* pBoundedExpVar
				// takes responsibility for deallocating this
		) : Item
			(
				theOnOffApp
			),
			theDir(initDir),
			pBoundedExpVar_Val(pBoundedExpVar)
		{
		}

		// Process various keypresses:
		OurBool Navigate( enum NavigationOp aNavOp );
			// return = was message processed

		void Diagnostic(OurBool bSelected) const;

		// Handy ways to process discrete movements of the slider
		void SetToMin(void);
		void SetToMax(void);
		void Inc(void);
		void Dec(void);

		// Handy ways to values of the slider:
		int GetMin(void) const
		{
			return pBoundedExpVar_Val -> GetMin();
		}
		int GetMax(void) const
		{
			return pBoundedExpVar_Val -> GetMax();
		}
		int GetRange(void) const
		{
			return ( GetMax()  - GetMin() );
		}
		int GetVal(void) const
		{
			return pBoundedExpVar_Val -> Get();
		}

		// Methods relating to rendering:
		void Render
		(
			const RenderContext& theContext,
			OurBool bSelected
		) const;

		SizeInfo GetSizeInfo(void) const;

	private:
		static void RenderSlider
		(
			const RenderContext& theContext,
			OurBool bSelected,
			float floatPos
		);

		int GetFraction(void) const
		{
			// returns a fractional amout good for a small increment/decrement

			int Amt = (GetRange() / 32);

			return ( (Amt>1) ? Amt : 1);
				// ensure amount is at least 1
		}

	private:
		// Direction:
		const enum Direction theDir;
		BoundedExportVariable<int>* const pBoundedExpVar_Val;

	};

	class Item_Toggle : public Item
	{
	public:
		Item_Toggle
		(
			OnOffAppearance theOnOffApp_Label,

			enum Direction initDir,
			OnOffAppearance theOnOffApp_Choice,
			ExportVariable<OurBool>* pExpVar
				// takes responsibility for deallocating this
		) : Item
			(
				theOnOffApp_Label
			),
			theDir(initDir),
			theOnOffApp_Val(theOnOffApp_Choice),
			pExpVar_Val(pExpVar)
		{
		}

		// Process various keypresses:
		OurBool Navigate( enum NavigationOp aNavOp );
			// return = was message processed

		void Diagnostic(OurBool bSelected) const;

		void Toggle(void);
		void TurnOn(void);
		void TurnOff(void);

		// Methods relating to rendering:
		void Render
		(
			const RenderContext& theContext,
			OurBool bSelected
		) const;

		SizeInfo GetSizeInfo(void) const;

	private:
		// Direction:
		const enum Direction theDir;

		OnOffAppearance theOnOffApp_Val;

		ExportVariable<OurBool>* pExpVar_Val;
	};

	#if 0
	// A 2d analogue of the composite item:
	class Item_Table : public Item
	{
	public:
		Item_Table
		(
			OnOffAppearance theOnOffApp_New
		);

		// Process various keypresses:
		OurBool Navigate( enum NavigationOp aNavOp );
			// return = was message processed

		void Diagnostic(OurBool bSelected) const;

		Item* GetSelected(void) const;
			// will return NULL iff there are no items in the composition

	private:
		#if 1
		void AddControlConfigRow();
		#else
		void AddRow
		(
			Item** ppItem_ToAdd
		);
			// takes a NULL-terminated list of Item*s

		void AddColumn
		(
			Item** ppItem_ToAdd
		);
			// takes a NULL-terminated list of Item*s
		#endif

		// List of selectables:
		enum {MAX_X = 10};
		enum {MAX_Y = 20};

		int NumX;
		int NumY;
		Item* pItem_A[ MAX_X ][ MAX_Y ];

		int SelectedX;
		int SelectedY;

	};
	#endif


	#if 0
	// Decorator contains another item, and passes on calls to it ??
	class Item_Decorator_VScroll : public Item
	{
	public:
	private:
	};
	#endif

};
#endif // UseRebMenus

/* Exported globals *****************************************************/

/* Function prototypes **************************************************/



/* End of the header ****************************************************/
#endif