5 #ifdef USE_HUD_TextList
6 #define textString( x , y, text, digit ) TextString( text, x , y,digit ) //suma
8 #define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma
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,
31 instr_item( x, y, width, height,
32 data_source,scale_data,options, working, digit), //suma
33 pformat ( label_format ),
34 pre_str ( pre_label_string ),
35 post_str ( post_label_string ),
36 justify ( justification ),
37 fontSize ( font_size ),
41 lbox ( label_box ) //hud
44 if( pre_str != NULL) {
45 if( post_str != NULL ) {
46 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
49 sprintf( format_buffer, "%s%s", pre_str, pformat );
53 if( post_str != NULL ) {
54 sprintf( format_buffer, "%s%s", pformat, post_str );
56 } // else do nothing if both pre and post strings are nulls. Interesting.
60 // I put this in to make it easy to construct a class member using the current
64 instr_label :: ~instr_label()
69 instr_label :: instr_label( const instr_label & image) :
70 instr_item((const instr_item &)image),
71 pformat ( image.pformat ),
72 pre_str ( image.pre_str ),
73 post_str ( image.post_str ),
74 blink ( image.blink ),
77 lbox (image.lbox ) //hud
80 if( pre_str != NULL) {
81 if( post_str != NULL ) {
82 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
85 sprintf( format_buffer, "%s%s", pre_str, pformat );
89 if( post_str != NULL ) {
90 sprintf( format_buffer, "%s%s", pformat, post_str );
92 } // else do nothing if both pre and post strings are nulls. Interesting.
98 // draw Draws a label anywhere in the HUD
102 draw( void ) // Required method in base class
104 // char format_buffer[80];
105 char label_buffer[80];
108 RECT scrn_rect = get_location();
110 if( data_available() ) {
112 sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) );
115 sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
120 float x = scrn_rect.left;
121 float y = scrn_rect.top;
122 float w = scrn_rect.right;
123 float h = HUD_TextSize;
128 glVertex2f( x - 2.0, y - 2.0);
129 glVertex2f( x + w + 2.0, y - 2.0);
130 glVertex2f( x + w + 2.0, y + h + 2.0);
131 glVertex2f( x - 2.0, y + h + 2.0);
133 glEnable(GL_LINE_STIPPLE);
134 glLineStipple( 1, 0xAAAA );
136 glVertex2f( x + w + 2.0, y - 2.0);
137 glVertex2f( x + w + 2.0, y + h + 2.0);
138 glVertex2f( x - 2.0, y + h + 2.0);
139 glVertex2f( x - 2.0, y - 2.0);
141 glDisable(GL_LINE_STIPPLE);
144 sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
148 // sprintf( label_buffer, format_buffer );
151 lenstr = getStringWidth( label_buffer );
155 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
156 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
157 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
158 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
160 lenstr = strlen( label_buffer );
162 if( justify == RIGHT_JUST ) {
163 posincr = scrn_rect.right - lenstr;
164 }else if( justify == CENTER_JUST ) {
165 posincr = get_span() - (lenstr/2); // -lenstr*4;
167 // justify == LEFT_JUST
171 if( fontSize == HUD_FONT_SMALL ) {
172 textString( scrn_rect.left + posincr, scrn_rect.top,
173 label_buffer, get_digits()); //suma
176 if( fontSize == HUD_FONT_LARGE ) {
177 textString( scrn_rect.left + posincr, scrn_rect.top,
178 label_buffer, get_digits()); //suma