summaryrefslogtreecommitdiffhomepage
path: root/X-Plane-SDK/CHeaders/Widgets/XPUIGraphics.h
blob: 24822c6aea956280ad82456b42b0e4544ff14779 (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
359
360
361
362
363
#ifndef _XPUIGraphics_h_
#define _XPUIGraphics_h_

/*
 * Copyright 2005-2012 Sandy Barbour and Ben Supnik
 * 
 * All rights reserved.  See license.txt for usage.
 * 
 * X-Plane SDK Version: 2.1.1                                                  
 *
 */

/*
 *                                                                             
 *
 */

#include "XPWidgetDefs.h"

#ifdef __cplusplus
extern "C" {
#endif

/***************************************************************************
 * UI GRAPHICS
 ***************************************************************************/
/*
 *                                                                             
 *
 */


/*
 * XPWindowStyle
 * 
 * There are a few built-in window styles in X-Plane that you can use. 
 * 
 * Note that X-Plane 6 does not offer real shadow-compositing; you must make 
 * sure to put a window on top of another window of the right style to the 
 * shadows work, etc. This applies to elements with insets and shadows.  The 
 * rules are: 
 * 
 * Sub windows must go on top of main windows, and screens and list views on 
 * top of subwindows.  Only help and main windows can be over the main screen. 
 * 
 * 
 * With X-Plane 7 any window or element may be placed over any other element. 
 * 
 * Some windows are scaled by stretching, some by repeating.  The drawing 
 * routines know which scaling method to use.  The list view cannot be 
 * rescaled in x-plane 6 because it has both a repeating pattern and a 
 * gradient in one element.  All other elements can be rescaled.               
 *
 */
enum {
     /* An LCD screen that shows help.                                              */
     xpWindow_Help                            = 0

     /* A dialog box window.                                                        */
    ,xpWindow_MainWindow                      = 1

     /* A panel or frame within a dialog box window.                                */
    ,xpWindow_SubWindow                       = 2

     /* An LCD screen within a panel to hold text displays.                         */
    ,xpWindow_Screen                          = 4

     /* A list view within a panel for scrolling file names, etc.                   */
    ,xpWindow_ListView                        = 5


};
typedef int XPWindowStyle;

/*
 * XPDrawWindow
 * 
 * This routine draws a window of the given dimensions at the given offset on 
 * the virtual screen in a given style.  The window is automatically scaled as 
 * appropriate using a bitmap scaling technique (scaling or repeating) as 
 * appropriate to the style.                                                   
 *
 */
WIDGET_API void                 XPDrawWindow(
                                   int                  inX1,    
                                   int                  inY1,    
                                   int                  inX2,    
                                   int                  inY2,    
                                   XPWindowStyle        inStyle);    

/*
 * XPGetWindowDefaultDimensions
 * 
 * This routine returns the default dimensions for a window.  Output is either 
 * a minimum or fixed value depending on whether the window is scalable.       
 *
 */
WIDGET_API void                 XPGetWindowDefaultDimensions(
                                   XPWindowStyle        inStyle,    
                                   int *                outWidth,    /* Can be NULL */
                                   int *                outHeight);    /* Can be NULL */

/*
 * XPElementStyle
 * 
 * Elements are individually drawable UI things like push buttons, etc.  The 
 * style defines what kind of element you are drawing.  Elements can be 
 * stretched in one or two dimensions (depending on the element).  Some 
 * elements can be lit. 
 * 
 * In x-plane 6 some elements must be drawn over metal.  Some are scalable and 
 * some are not.  Any element can be drawn anywhere in x-plane 7. 
 * 
 * Scalable Axis			Required Background                                         
 *
 */
enum {
     /* x						metal				                                                            */
     xpElement_TextField                      = 6

     /* none					metal				                                                          */
    ,xpElement_CheckBox                       = 9

     /* none					metal				                                                          */
    ,xpElement_CheckBoxLit                    = 10

     /* none					window header		                                                    */
    ,xpElement_WindowCloseBox                 = 14

     /* none					window header		                                                    */
    ,xpElement_WindowCloseBoxPressed          = 15

     /* x					metal				                                                             */
    ,xpElement_PushButton                     = 16

     /* x					metal				                                                             */
    ,xpElement_PushButtonLit                  = 17

     /* none					any 				                                                           */
    ,xpElement_OilPlatform                    = 24

     /* none					any 				                                                           */
    ,xpElement_OilPlatformSmall               = 25

     /* none					any 				                                                           */
    ,xpElement_Ship                           = 26

     /* none					any 				                                                           */
    ,xpElement_ILSGlideScope                  = 27

     /* none					any 				                                                           */
    ,xpElement_MarkerLeft                     = 28

     /* none					any 				                                                           */
    ,xpElement_Airport                        = 29

     /* none					any 				                                                           */
    ,xpElement_Waypoint                       = 30

     /* none					any 				                                                           */
    ,xpElement_NDB                            = 31

     /* none					any 				                                                           */
    ,xpElement_VOR                            = 32

     /* none					any 				                                                           */
    ,xpElement_RadioTower                     = 33

     /* none					any 				                                                           */
    ,xpElement_AircraftCarrier                = 34

     /* none					any 				                                                           */
    ,xpElement_Fire                           = 35

     /* none					any 				                                                           */
    ,xpElement_MarkerRight                    = 36

     /* none					any 				                                                           */
    ,xpElement_CustomObject                   = 37

     /* none					any 				                                                           */
    ,xpElement_CoolingTower                   = 38

     /* none					any 				                                                           */
    ,xpElement_SmokeStack                     = 39

     /* none					any 				                                                           */
    ,xpElement_Building                       = 40

     /* none					any 				                                                           */
    ,xpElement_PowerLine                      = 41

     /* none					metal				                                                          */
    ,xpElement_CopyButtons                    = 45

     /* none					metal				                                                          */
    ,xpElement_CopyButtonsWithEditingGrid     = 46

     /* x, y					metal				                                                          */
    ,xpElement_EditingGrid                    = 47

     /* THIS CAN PROBABLY BE REMOVED				                                            */
    ,xpElement_ScrollBar                      = 48

     /* none					any 				                                                           */
    ,xpElement_VORWithCompassRose             = 49

     /* none					metal				                                                          */
    ,xpElement_Zoomer                         = 51

     /* x, y					metal				                                                          */
    ,xpElement_TextFieldMiddle                = 52

     /* none					metal				                                                          */
    ,xpElement_LittleDownArrow                = 53

     /* none					metal				                                                          */
    ,xpElement_LittleUpArrow                  = 54

     /* none					metal				                                                          */
    ,xpElement_WindowDragBar                  = 61

     /* none					metal				                                                          */
    ,xpElement_WindowDragBarSmooth            = 62


};
typedef int XPElementStyle;

/*
 * XPDrawElement
 * 
 * XPDrawElement draws a given element at an offset on the virtual screen in 
 * set dimensions. EVEN if the element is not scalable, it will be scaled if 
 * the width and height do not match the preferred dimensions; it'll just look 
 * ugly.  Pass inLit to see the lit version of the element; if the element 
 * cannot be lit this is ignored.                                              
 *
 */
WIDGET_API void                 XPDrawElement(
                                   int                  inX1,    
                                   int                  inY1,    
                                   int                  inX2,    
                                   int                  inY2,    
                                   XPElementStyle       inStyle,    
                                   int                  inLit);    

/*
 * XPGetElementDefaultDimensions
 * 
 * This routine returns the recommended or minimum dimensions of a given UI 
 * element.  outCanBeLit tells whether the element has both a lit and unlit 
 * state.  Pass NULL to not receive any of these parameters.                   
 *
 */
WIDGET_API void                 XPGetElementDefaultDimensions(
                                   XPElementStyle       inStyle,    
                                   int *                outWidth,    /* Can be NULL */
                                   int *                outHeight,    /* Can be NULL */
                                   int *                outCanBeLit);    /* Can be NULL */

/*
 * XPTrackStyle
 * 
 * A track is a UI element that displays a value vertically or horizontally.  
 * X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. 
 * Tracks can be displayed either horizontally or vertically; tracks will 
 * choose their own layout based on the larger dimension of their dimensions 
 * (e.g. they know if they are tall or wide).  Sliders may be lit or unlit 
 * (showing the user manipulating them). 
 * 
 * ScrollBar - this is a standard scroll bar with arrows and a thumb to drag. 
 * Slider -  this is a simple track with a ball in the middle that can be 
 * slid. Progress - this is a progress indicator showing how a long task is 
 * going.                                                                      
 *
 */
enum {
     /* not over metal	can be lit		can be rotated		                                 */
     xpTrack_ScrollBar                        = 0

     /* over metal		can be lit		can be rotated		                                    */
    ,xpTrack_Slider                           = 1

     /* over metal		cannot be lit	cannot be rotated	                                */
    ,xpTrack_Progress                         = 2


};
typedef int XPTrackStyle;

/*
 * XPDrawTrack
 * 
 * This routine draws a track.  You pass in the track dimensions and size; the 
 * track picks the optimal orientation for these dimensions.  Pass in the 
 * track's minimum current and maximum values; the indicator will be 
 * positioned appropriately.  You can also specify whether the track is lit or 
 * not.                                                                        
 *
 */
WIDGET_API void                 XPDrawTrack(
                                   int                  inX1,    
                                   int                  inY1,    
                                   int                  inX2,    
                                   int                  inY2,    
                                   int                  inMin,    
                                   int                  inMax,    
                                   int                  inValue,    
                                   XPTrackStyle         inTrackStyle,    
                                   int                  inLit);    

/*
 * XPGetTrackDefaultDimensions
 * 
 * This routine returns a track's default smaller dimension; all tracks are 
 * scalable in the larger dimension.  It also returns whether a track can be 
 * lit.                                                                        
 *
 */
WIDGET_API void                 XPGetTrackDefaultDimensions(
                                   XPTrackStyle         inStyle,    
                                   int *                outWidth,    
                                   int *                outCanBeLit);    

/*
 * XPGetTrackMetrics
 * 
 * This routine returns the metrics of a track.  If you want to write UI code 
 * to manipulate a track, this routine helps you know where the mouse 
 * locations are. For most other elements, the rectangle the element is drawn 
 * in is enough information. However, the scrollbar drawing routine does some 
 * automatic placement; this routine lets you know where things ended up.  You 
 * pass almost everything you would pass to the draw routine.  You get out the 
 * orientation, and other useful stuff. 
 * 
 * Besides orientation, you get five dimensions for the five parts of a 
 * scrollbar, which are the down button, down area (area before the thumb), 
 * the thumb, and the up area and button.  For horizontal scrollers, the left 
 * button decreases; for vertical scrollers, the top button decreases.         
 *
 */
WIDGET_API void                 XPGetTrackMetrics(
                                   int                  inX1,    
                                   int                  inY1,    
                                   int                  inX2,    
                                   int                  inY2,    
                                   int                  inMin,    
                                   int                  inMax,    
                                   int                  inValue,    
                                   XPTrackStyle         inTrackStyle,    
                                   int *                outIsVertical,    
                                   int *                outDownBtnSize,    
                                   int *                outDownPageSize,    
                                   int *                outThumbSize,    
                                   int *                outUpPageSize,    
                                   int *                outUpBtnSize);    

#ifdef __cplusplus
}
#endif

#endif