12 #include <simgear/constants.h>
13 #include <simgear/math/fg_random.h>
14 #include <simgear/math/polar3d.hxx>
16 #include <Aircraft/aircraft.hxx>
18 #include <Scenery/scenery.hxx>
19 #include <Time/fg_timer.hxx>
24 #ifdef USE_HUD_TextList
25 #define textString( x , y, text, font ) TextString( text, x , y )
27 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
30 //======================= Top of instr_label class =========================
37 const char *label_format,
38 const char *pre_label_string,
39 const char *post_label_string,
42 fgLabelJust justification,
46 instr_item( x, y, width, height,
47 data_source, scale_data,options, working ),
48 pformat ( label_format ),
49 pre_str ( pre_label_string ),
50 post_str ( post_label_string ),
51 justify ( justification ),
52 fontSize ( font_size ),
55 if( pre_str != NULL) {
56 if( post_str != NULL ) {
57 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
60 sprintf( format_buffer, "%s%s", pre_str, pformat );
64 if( post_str != NULL ) {
65 sprintf( format_buffer, "%s%s", pformat, post_str );
67 } // else do nothing if both pre and post strings are nulls. Interesting.
71 // I put this in to make it easy to construct a class member using the current
75 lat_label :: ~lat_label()
80 lat_label :: lat_label( const lat_label & image) :
81 instr_item((const instr_item &)image),
82 pformat ( image.pformat ),
83 pre_str ( image.pre_str ),
84 post_str ( image.post_str ),
87 if( pre_str != NULL) {
88 if( post_str != NULL ) {
89 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
92 sprintf( format_buffer, "%s%s", pre_str, pformat );
96 if( post_str != NULL ) {
97 sprintf( format_buffer, "%s%s", pformat, post_str );
99 } // else do nothing if both pre and post strings are nulls. Interesting.
103 lat_label & lat_label ::operator = (const lat_label & rhs )
105 if( !(this == &rhs)) {
106 instr_item::operator = (rhs);
107 pformat = rhs.pformat;
108 fontSize = rhs.fontSize;
110 justify = rhs.justify;
111 pre_str = rhs.pre_str;
112 post_str = rhs.post_str;
113 strcpy(format_buffer,rhs.format_buffer);
119 // draw Draws a label anywhere in the HUD
123 draw( void ) // Required method in base class
125 char label_buffer[80];
128 RECT scrn_rect = get_location();
129 float lat = get_value();
131 if( data_available() ) {
132 sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
135 sprintf( label_buffer, format_buffer );
139 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
140 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
141 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
142 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
145 lenstr = getStringWidth(label_buffer);
147 if( justify == RIGHT_JUST ) {
148 posincr = scrn_rect.right - lenstr;
149 }else if( justify == CENTER_JUST ) {
150 posincr = get_span() - (lenstr/2); // -lenstr*4;
152 // justify == LEFT_JUST
156 if( fontSize == SMALL ) {
157 textString( scrn_rect.left + posincr, scrn_rect.top,
158 label_buffer, GLUT_BITMAP_8_BY_13);
161 if( fontSize == LARGE ) {
162 textString( scrn_rect.left + posincr, scrn_rect.top,
163 label_buffer, GLUT_BITMAP_9_BY_15);