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 instr_label :: ~instr_label()
81 instr_label :: instr_label( const instr_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 instr_label & instr_label ::operator = (const instr_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 format_buffer[80];
127 char label_buffer[80];
130 RECT scrn_rect = get_location();
132 if( data_available() ) {
133 sprintf( label_buffer, format_buffer, get_value() );
136 sprintf( label_buffer, format_buffer );
139 lenstr = getStringWidth( label_buffer );
143 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
144 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
145 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
146 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
148 // lenstr = strlen( label_buffer );
150 if( justify == RIGHT_JUST ) {
151 posincr = scrn_rect.right - lenstr;
152 }else if( justify == CENTER_JUST ) {
153 posincr = get_span() - (lenstr/2); // -lenstr*4;
155 // justify == LEFT_JUST
159 if( fontSize == SMALL ) {
160 textString( scrn_rect.left + posincr, scrn_rect.top,
161 label_buffer, GLUT_BITMAP_8_BY_13);
164 if( fontSize == LARGE ) {
165 textString( scrn_rect.left + posincr, scrn_rect.top,
166 label_buffer, GLUT_BITMAP_9_BY_15);