12 #include <simgear/constants.h>
13 #include <simgear/math/fg_random.h>
14 #include <simgear/math/mat3.h>
15 #include <simgear/math/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 // DBLFNPTR data_source,
39 const char *label_format,
40 const char *pre_label_string,
41 const char *post_label_string,
45 fgLabelJust justification,
49 instr_item( x, y, width, height,
50 data_source, scale_data,options, working ),
51 pformat ( label_format ),
52 pre_str ( pre_label_string ),
53 post_str ( post_label_string ),
54 justify ( justification ),
55 fontSize ( font_size ),
58 if( pre_str != NULL) {
59 if( post_str != NULL ) {
60 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
63 sprintf( format_buffer, "%s%s", pre_str, pformat );
67 if( post_str != NULL ) {
68 sprintf( format_buffer, "%s%s", pformat, post_str );
70 } // else do nothing if both pre and post strings are nulls. Interesting.
74 // I put this in to make it easy to construct a class member using the current
78 lon_label :: ~lon_label()
83 lon_label :: lon_label( const lon_label & image) :
84 instr_item((const instr_item &)image),
85 pformat ( image.pformat ),
86 pre_str ( image.pre_str ),
87 post_str ( image.post_str ),
90 if( pre_str != NULL) {
91 if( post_str != NULL ) {
92 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
95 sprintf( format_buffer, "%s%s", pre_str, pformat );
99 if( post_str != NULL ) {
100 sprintf( format_buffer, "%s%s", pformat, post_str );
102 } // else do nothing if both pre and post strings are nulls. Interesting.
106 lon_label & lon_label ::operator = (const lon_label & rhs )
108 if( !(this == &rhs)) {
109 instr_item::operator = (rhs);
110 pformat = rhs.pformat;
111 fontSize = rhs.fontSize;
113 justify = rhs.justify;
114 pre_str = rhs.pre_str;
115 post_str = rhs.post_str;
116 strcpy(format_buffer,rhs.format_buffer);
122 // draw Draws a label anywhere in the HUD
126 draw( void ) // Required method in base class
128 // char format_buffer[80];
129 char label_buffer[80];
132 RECT scrn_rect = get_location();
133 float lon = get_value();
134 // double lon = get_value();
135 if( data_available() ) {
136 // char *lonstring = coord_format_lon(lon);
137 lenstr = sprintf( label_buffer, format_buffer, coord_format_lon(lon) );
140 lenstr = sprintf( label_buffer, format_buffer );
144 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
145 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
146 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
147 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
150 lenstr = getStringWidth(label_buffer);
152 if( justify == RIGHT_JUST ) {
153 posincr = scrn_rect.right - lenstr;
154 }else if( justify == CENTER_JUST ) {
155 posincr = get_span() - (lenstr/2); // -lenstr*4;
157 // justify == LEFT_JUST
161 if( fontSize == SMALL ) {
162 textString( scrn_rect.left + posincr, scrn_rect.top,
163 label_buffer, GLUT_BITMAP_8_BY_13);
166 if( fontSize == LARGE ) {
167 textString( scrn_rect.left + posincr, scrn_rect.top,
168 label_buffer, GLUT_BITMAP_9_BY_15);