12 #include <simgear/constants.h>
13 #include <simgear/fg_random.h>
14 #include <simgear/mat3.h>
15 #include <simgear/polar3d.hxx>
17 #include <Aircraft/aircraft.hxx>
19 #include <Scenery/scenery.hxx>
20 #include <Time/fg_timer.hxx>
25 #ifdef USE_HUD_TextList
26 #define textString( x , y, text, font ) TextString( text, x , y )
28 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
31 //======================= Top of instr_label class =========================
38 const char *label_format,
39 const char *pre_label_string,
40 const char *post_label_string,
43 fgLabelJust justification,
47 instr_item( x, y, width, height,
48 data_source, scale_data,options, working ),
49 pformat ( label_format ),
50 pre_str ( pre_label_string ),
51 post_str ( post_label_string ),
52 justify ( justification ),
53 fontSize ( font_size ),
56 if( pre_str != NULL) {
57 if( post_str != NULL ) {
58 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
61 sprintf( format_buffer, "%s%s", pre_str, pformat );
65 if( post_str != NULL ) {
66 sprintf( format_buffer, "%s%s", pformat, post_str );
68 } // else do nothing if both pre and post strings are nulls. Interesting.
72 // I put this in to make it easy to construct a class member using the current
76 lat_label :: ~lat_label()
81 lat_label :: lat_label( const lat_label & image) :
82 instr_item((const instr_item &)image),
83 pformat ( image.pformat ),
84 pre_str ( image.pre_str ),
85 post_str ( image.post_str ),
88 if( pre_str != NULL) {
89 if( post_str != NULL ) {
90 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
93 sprintf( format_buffer, "%s%s", pre_str, pformat );
97 if( post_str != NULL ) {
98 sprintf( format_buffer, "%s%s", pformat, post_str );
100 } // else do nothing if both pre and post strings are nulls. Interesting.
104 lat_label & lat_label ::operator = (const lat_label & rhs )
106 if( !(this == &rhs)) {
107 instr_item::operator = (rhs);
108 pformat = rhs.pformat;
109 fontSize = rhs.fontSize;
111 justify = rhs.justify;
112 pre_str = rhs.pre_str;
113 post_str = rhs.post_str;
114 strcpy(format_buffer,rhs.format_buffer);
120 // draw Draws a label anywhere in the HUD
124 draw( void ) // Required method in base class
126 char label_buffer[80];
129 RECT scrn_rect = get_location();
130 float lat = get_value();
132 if( data_available() ) {
133 sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
136 sprintf( label_buffer, format_buffer );
140 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
141 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
142 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
143 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
146 lenstr = getStringWidth(label_buffer);
148 if( justify == RIGHT_JUST ) {
149 posincr = scrn_rect.right - lenstr;
150 }else if( justify == CENTER_JUST ) {
151 posincr = get_span() - (lenstr/2); // -lenstr*4;
153 // justify == LEFT_JUST
157 if( fontSize == SMALL ) {
158 textString( scrn_rect.left + posincr, scrn_rect.top,
159 label_buffer, GLUT_BITMAP_8_BY_13);
162 if( fontSize == LARGE ) {
163 textString( scrn_rect.left + posincr, scrn_rect.top,
164 label_buffer, GLUT_BITMAP_9_BY_15);