10 #include <Aircraft/aircraft.hxx>
12 #include <Include/fg_constants.h>
13 #include <Math/fg_random.h>
14 #include <Math/mat3.h>
15 #include <Math/polar3d.hxx>
16 #include <Scenery/scenery.hxx>
17 #include <Time/fg_timer.hxx>
22 #ifdef USE_HUD_TextList
23 #define textString( x , y, text, font ) TextString( text, x , y )
25 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
28 //======================= Top of instr_label class =========================
35 const char *label_format,
36 const char *pre_label_string,
37 const char *post_label_string,
40 fgLabelJust justification,
44 instr_item( x, y, width, height,
45 data_source, scale_data,options, working ),
46 pformat ( label_format ),
47 pre_str ( pre_label_string ),
48 post_str ( post_label_string ),
49 justify ( justification ),
50 fontSize ( font_size ),
53 if( pre_str != NULL) {
54 if( post_str != NULL ) {
55 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
58 sprintf( format_buffer, "%s%s", pre_str, pformat );
62 if( post_str != NULL ) {
63 sprintf( format_buffer, "%s%s", pformat, post_str );
65 } // else do nothing if both pre and post strings are nulls. Interesting.
69 // I put this in to make it easy to construct a class member using the current
73 lat_label :: ~lat_label()
78 lat_label :: lat_label( const lat_label & image) :
79 instr_item((const instr_item &)image),
80 pformat ( image.pformat ),
81 pre_str ( image.pre_str ),
82 post_str ( image.post_str ),
85 if( pre_str != NULL) {
86 if( post_str != NULL ) {
87 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
90 sprintf( format_buffer, "%s%s", pre_str, pformat );
94 if( post_str != NULL ) {
95 sprintf( format_buffer, "%s%s", pformat, post_str );
97 } // else do nothing if both pre and post strings are nulls. Interesting.
101 lat_label & lat_label ::operator = (const lat_label & rhs )
103 if( !(this == &rhs)) {
104 instr_item::operator = (rhs);
105 pformat = rhs.pformat;
106 fontSize = rhs.fontSize;
108 justify = rhs.justify;
109 pre_str = rhs.pre_str;
110 post_str = rhs.post_str;
111 strcpy(format_buffer,rhs.format_buffer);
117 // draw Draws a label anywhere in the HUD
121 draw( void ) // Required method in base class
123 char label_buffer[80];
126 RECT scrn_rect = get_location();
127 float lat = get_value();
129 if( data_available() ) {
130 sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
133 sprintf( label_buffer, format_buffer );
137 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
138 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
139 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
140 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
143 lenstr = getStringWidth(label_buffer);
145 if( justify == RIGHT_JUST ) {
146 posincr = scrn_rect.right - lenstr;
147 }else if( justify == CENTER_JUST ) {
148 posincr = get_span() - (lenstr/2); // -lenstr*4;
150 // justify == LEFT_JUST
154 if( fontSize == SMALL ) {
155 textString( scrn_rect.left + posincr, scrn_rect.top,
156 label_buffer, GLUT_BITMAP_8_BY_13);
159 if( fontSize == LARGE ) {
160 textString( scrn_rect.left + posincr, scrn_rect.top,
161 label_buffer, GLUT_BITMAP_9_BY_15);