1 /*
2 
3 	gadget.h
4 
5 	Base header file for Dave Malcolm's user interface "gadget" code.
6 
7 	Note to "C" programmers: look at the bottom of this file
8 
9 */
10 
11 #ifndef _gadget
12 #define _gadget 1
13 
14 
15 /* Version settings *****************************************************/
16 	#define UseGadgets Yes
17 		/* If this is set to No all gadget code collapses to void macros */
18 
19 	#define EnableStatusPanels	No
20 
21 /* Constants  ***********************************************************/
22 	#define HUD_SPACING 20
23 
24 /* Macros ***************************************************************/
25 
26 /* Type definitions *****************************************************/
27 	#if UseGadgets
28 
29 		#ifndef _projtext
30 		#include "projtext.h"
31 		#endif
32 
33 	#ifdef __cplusplus
34 
35 		#ifndef _r2base
36 		#include "r2base.h"
37 		#endif
38 
39 	class Gadget
40 	{
41 	public:
42 		// Pure virtual render method:
43 		virtual void Render
44 		(
45 			const struct r2pos& R2Pos,
46 			const struct r2rect& R2Rect_Clip,
47 			int FixP_Alpha
48 		) = 0;
49 			// Render yourself at the coordinates given, clipped by the clipping rectangle
50 			// Note that the position need not be at all related to the clipping rectangle;
51 			// it's up to the implementation to behave for these cases.
52 			// Both the coordinate and the clipping rectangle are in absolute screen coordinates
53 			// The alpha value to use is "absolute"
54 
55 		virtual ~Gadget();
56 			// ensure virtual destructor
57 
58 		#if debug
59 		char* GetDebugName(void);
60 		void Render_Report
61 		(
62 			const struct r2pos& R2Pos,
63 			const struct r2rect& R2Rect_Clip,
64 			int FixP_Alpha
65 		);
66 			// use to textprint useful information about a call to "Render"
67 		#endif
68 
69 	protected:
70 		// Protected constructor since abstract base class
71 		#if debug
Gadget(char * DebugName_New)72 		Gadget
73 		(
74 			char* DebugName_New
75 		) : DebugName( DebugName_New )
76 		{
77 			// empty
78 		}
79 		#else
80 		Gadget(){}
81 		#endif
82 
83 	private:
84 		#if debug
85 		char* DebugName;
86 		#endif
87 
88 	}; // end of class Gadget
89 
90 	// Inline methods:
91 	#if debug
GetDebugName(void)92 	inline char* Gadget::GetDebugName(void)
93 	{
94 		return DebugName;
95 	}
96 	#endif
97 
98 	#if 0
99 	class GadgetWithSize : public Gadget
100 	{
101 	// Friends
102 
103 	// Protected data:
104 	protected:
105 		r2size R2Size_Val;
106 
107 	// Public methods:
108 	public:
109 		r2size GetSize(void) const;
110 
111 		void SetSize(r2size R2Size);
112 		virtual void SetSize_PostProcessing(void) {}
113 
114 	// Protected methods:
115 	protected:
116 		// Protected constructor since abstract class
117 		// (It's abstract since Render() remains pure virtual )
118 		GadgetWithSize
119 		(
120 			#if debug
121 			char* DebugName_New,
122 			#endif
123 			r2size R2Size_New
124 		) : Gadget
125 			(
126 				#if debug
127 				DebugName_New
128 				#endif
129 			),
130 			R2Size_Val( R2Size_New ) {}
131 
132 	// Private methods:
133 	private:
134 
135 	// Private data:
136 	private:
137 
138 	// Inline methods:
139 	public:
140 		r2size GetSize(void) const
141 		{
142 			return R2Size_Val;
143 		}
144 		void SetSize( r2size R2Size_New )
145 		{
146 			R2Size_Val = R2Size_New;
147 			SetSize_PostProcessing();
148 		}
149 	protected:
150 	private:
151 
152 	}; // end of class GadgetWithSize
153 	#endif
154 
155 	#endif /* __cplusplus */
156 	#endif /* UseGadgets */
157 
158 /* Exported globals *****************************************************/
159 
160 /* Function prototypes **************************************************/
161 #ifdef __cplusplus
162 	extern "C" {
163 #endif
164 	#if UseGadgets
165 
166 	extern void GADGET_Init(void);
167 		/* expects to be called at program boot-up time */
168 
169 	extern void GADGET_UnInit(void);
170 		/* expects to be called at program shutdown time */
171 
172 	extern void GADGET_Render(void);
173 		/* expects to be called within the rendering part of the main loop */
174 
175 	extern void GADGET_ScreenModeChange_Setup(void);
176 		/* expects to be called immediately before anything happens to the screen
177 		mode */
178 
179 	extern void GADGET_ScreenModeChange_Cleanup(void);
180 		/* expects to be called immediately after anything happens to the screen
181 		mode */
182 
183 	extern void GADGET_NewOnScreenMessage( ProjChar* messagePtr );
184 
185 	extern void RemoveTheConsolePlease(void);
186 
187 	#else /* UseGadgets */
188 
189 		#define GADGET_Init() ((void) 0)
190 		#define GADGET_UnInit() ((void) 0)
191 		#define GADGET_Render() ((void) 0)
192 		#define GADGET_ScreenModeChange_Setup() ((void) 0)
193 		#define GADGET_ScreenModeChange_Cleanup() ((void) 0)
194 		#define GADGET_NewOnScreenMessage(x) ((void) 0)
195 
196 	#endif /* UseGadgets */
197 
198 
199 /* End of the header ****************************************************/
200 
201 
202 #ifdef __cplusplus
203 	};
204 #endif
205 
206 #endif
207