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>
21 #ifdef USE_HUD_TextList
22 #define textString( x , y, text, font ) TextString( text, x , y )
24 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
27 //======================= Top of instr_label class =========================
34 const char *label_format,
35 const char *pre_label_string,
36 const char *post_label_string,
39 fgLabelJust justification,
43 instr_item( x, y, width, height,
44 data_source, scale_data,options, working ),
45 pformat ( label_format ),
46 pre_str ( pre_label_string ),
47 post_str ( post_label_string ),
48 justify ( justification ),
49 fontSize ( font_size ),
52 if( pre_str != NULL) {
53 if( post_str != NULL ) {
54 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
57 sprintf( format_buffer, "%s%s", pre_str, pformat );
61 if( post_str != NULL ) {
62 sprintf( format_buffer, "%s%s", pformat, post_str );
64 } // else do nothing if both pre and post strings are nulls. Interesting.
68 // I put this in to make it easy to construct a class member using the current
72 instr_label :: ~instr_label()
77 instr_label :: instr_label( const instr_label & image) :
78 instr_item((const instr_item &)image),
79 pformat ( image.pformat ),
80 pre_str ( image.pre_str ),
81 post_str ( image.post_str ),
84 if( pre_str != NULL) {
85 if( post_str != NULL ) {
86 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
89 sprintf( format_buffer, "%s%s", pre_str, pformat );
93 if( post_str != NULL ) {
94 sprintf( format_buffer, "%s%s", pformat, post_str );
96 } // else do nothing if both pre and post strings are nulls. Interesting.
100 instr_label & instr_label ::operator = (const instr_label & rhs )
102 if( !(this == &rhs)) {
103 instr_item::operator = (rhs);
104 pformat = rhs.pformat;
105 fontSize = rhs.fontSize;
107 justify = rhs.justify;
108 pre_str = rhs.pre_str;
109 post_str = rhs.post_str;
110 strcpy(format_buffer,rhs.format_buffer);
116 // draw Draws a label anywhere in the HUD
120 draw( void ) // Required method in base class
122 // char format_buffer[80];
123 char label_buffer[80];
126 RECT scrn_rect = get_location();
128 if( data_available() ) {
129 sprintf( label_buffer, format_buffer, get_value() );
132 sprintf( label_buffer, format_buffer );
135 lenstr = getStringWidth( label_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" );
144 // lenstr = strlen( label_buffer );
146 if( justify == RIGHT_JUST ) {
147 posincr = scrn_rect.right - lenstr;
148 }else if( justify == CENTER_JUST ) {
149 posincr = get_span() - (lenstr/2); // -lenstr*4;
151 // justify == LEFT_JUST
155 if( fontSize == SMALL ) {
156 textString( scrn_rect.left + posincr, scrn_rect.top,
157 label_buffer, GLUT_BITMAP_8_BY_13);
160 if( fontSize == LARGE ) {
161 textString( scrn_rect.left + posincr, scrn_rect.top,
162 label_buffer, GLUT_BITMAP_9_BY_15);