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.
96 instr_label & instr_label ::operator = (const instr_label & rhs )
98 if( !(this == &rhs)) {
99 instr_item::operator = (rhs);
100 pformat = rhs.pformat;
101 fontSize = rhs.fontSize;
103 justify = rhs.justify;
104 pre_str = rhs.pre_str;
105 post_str = rhs.post_str;
108 lbox = rhs.lbox; //hud
111 strcpy(format_buffer,rhs.format_buffer);
117 // draw Draws a label anywhere in the HUD
121 draw( void ) // Required method in base class
123 // char format_buffer[80];
124 char label_buffer[80];
127 RECT scrn_rect = get_location();
129 if( data_available() ) {
131 sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) );
134 sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
139 float x = scrn_rect.left;
140 float y = scrn_rect.top;
141 float w = scrn_rect.right;
142 float h = HUD_TextSize;
147 glVertex2f( x - 2.0, y - 2.0);
148 glVertex2f( x + w + 2.0, y - 2.0);
149 glVertex2f( x + w + 2.0, y + h + 2.0);
150 glVertex2f( x - 2.0, y + h + 2.0);
152 glEnable(GL_LINE_STIPPLE);
153 glLineStipple( 1, 0xAAAA );
155 glVertex2f( x + w + 2.0, y - 2.0);
156 glVertex2f( x + w + 2.0, y + h + 2.0);
157 glVertex2f( x - 2.0, y + h + 2.0);
158 glVertex2f( x - 2.0, y - 2.0);
160 glDisable(GL_LINE_STIPPLE);
163 sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
167 // sprintf( label_buffer, format_buffer );
170 lenstr = getStringWidth( label_buffer );
174 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
175 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
176 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
177 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
179 lenstr = strlen( label_buffer );
181 if( justify == RIGHT_JUST ) {
182 posincr = scrn_rect.right - lenstr;
183 }else if( justify == CENTER_JUST ) {
184 posincr = get_span() - (lenstr/2); // -lenstr*4;
186 // justify == LEFT_JUST
190 if( fontSize == HUD_FONT_SMALL ) {
191 textString( scrn_rect.left + posincr, scrn_rect.top,
192 label_buffer, get_digits()); //suma
195 if( fontSize == HUD_FONT_LARGE ) {
196 textString( scrn_rect.left + posincr, scrn_rect.top,
197 label_buffer, get_digits()); //suma