5 #ifdef USE_HUD_TextList
6 #define textString( x , y, text, font ) TextString( text, x , y )
8 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
11 //======================= Top of instr_label class =========================
18 const char *label_format,
19 const char *pre_label_string,
20 const char *post_label_string,
23 fgLabelJust justification,
29 instr_item( x, y, width, height,
30 data_source,scale_data,options, working ),
31 pformat ( label_format ),
32 pre_str ( pre_label_string ),
33 post_str ( post_label_string ),
34 justify ( justification ),
35 fontSize ( font_size ),
41 if( pre_str != NULL) {
42 if( post_str != NULL ) {
43 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
46 sprintf( format_buffer, "%s%s", pre_str, pformat );
50 if( post_str != NULL ) {
51 sprintf( format_buffer, "%s%s", pformat, post_str );
53 } // else do nothing if both pre and post strings are nulls. Interesting.
57 // I put this in to make it easy to construct a class member using the current
61 instr_label :: ~instr_label()
66 instr_label :: instr_label( const instr_label & image) :
67 instr_item((const instr_item &)image),
68 pformat ( image.pformat ),
69 pre_str ( image.pre_str ),
70 post_str ( image.post_str ),
71 blink ( image.blink ),
76 if( pre_str != NULL) {
77 if( post_str != NULL ) {
78 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
81 sprintf( format_buffer, "%s%s", pre_str, pformat );
85 if( post_str != NULL ) {
86 sprintf( format_buffer, "%s%s", pformat, post_str );
88 } // else do nothing if both pre and post strings are nulls. Interesting.
92 instr_label & instr_label ::operator = (const instr_label & rhs )
94 if( !(this == &rhs)) {
95 instr_item::operator = (rhs);
96 pformat = rhs.pformat;
97 fontSize = rhs.fontSize;
99 justify = rhs.justify;
100 pre_str = rhs.pre_str;
101 post_str = rhs.post_str;
106 strcpy(format_buffer,rhs.format_buffer);
112 // draw Draws a label anywhere in the HUD
116 draw( void ) // Required method in base class
118 // char format_buffer[80];
119 char label_buffer[80];
122 RECT scrn_rect = get_location();
124 if( data_available() ) {
126 sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) );
129 sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
131 sprintf( label_buffer, format_buffer, get_value() );
134 sprintf( label_buffer, format_buffer );
137 lenstr = getStringWidth( label_buffer );
141 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
142 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
143 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
144 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
146 // lenstr = strlen( 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);