5 #ifdef USE_HUD_TextList
6 #define textString(x, y, text, digit) TextString(text, x , y ,digit)
8 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
11 //======================= Top of instr_label class =========================
12 instr_label::instr_label(
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),
33 pformat ( label_format ),
34 pre_str ( pre_label_string ),
35 post_str ( post_label_string ),
36 justify ( justification ),
37 fontSize ( font_size ),
43 if (pre_str != NULL) {
44 if (post_str != NULL )
45 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
47 sprintf( format_buffer, "%s%s", pre_str, pformat );
49 } else if (post_str != NULL) {
50 sprintf( format_buffer, "%s%s", pformat, post_str );
51 } // else do nothing if both pre and post strings are nulls. Interesting.
56 instr_label::~instr_label()
62 instr_label::instr_label(const instr_label & image) :
63 instr_item((const instr_item &)image),
64 pformat ( image.pformat ),
65 pre_str ( image.pre_str ),
66 post_str ( image.post_str ),
67 blink ( image.blink ),
73 if (pre_str != NULL) {
75 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
77 sprintf( format_buffer, "%s%s", pre_str, pformat );
79 } else if (post_str != NULL) {
80 sprintf( format_buffer, "%s%s", pformat, post_str );
81 } // else do nothing if both pre and post strings are nulls. Interesting.
87 // draw Draws a label anywhere in the HUD
90 void instr_label::draw( void )
92 char label_buffer[80];
95 RECT scrn_rect = get_location();
97 if (data_available()) {
99 sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) );
101 sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
103 if (lbox) {// Box for label
104 float x = scrn_rect.left;
105 float y = scrn_rect.top;
106 float w = scrn_rect.right;
107 float h = HUD_TextSize;
113 glVertex2f( x - 2.0, y - 2.0);
114 glVertex2f( x + w + 2.0, y - 2.0);
115 glVertex2f( x + w + 2.0, y + h + 2.0);
116 glVertex2f( x - 2.0, y + h + 2.0);
119 glEnable(GL_LINE_STIPPLE);
120 glLineStipple( 1, 0xAAAA );
123 glVertex2f( x + w + 2.0, y - 2.0);
124 glVertex2f( x + w + 2.0, y + h + 2.0);
125 glVertex2f( x - 2.0, y + h + 2.0);
126 glVertex2f( x - 2.0, y - 2.0);
129 glDisable(GL_LINE_STIPPLE);
132 sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
136 // sprintf( label_buffer, format_buffer );
139 lenstr = getStringWidth( label_buffer );
143 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
144 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
145 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
146 fgPrintf( SG_COCKPIT, SG_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 == HUD_FONT_SMALL) {
160 textString( scrn_rect.left + posincr, scrn_rect.top,
161 label_buffer, get_digits());
163 } else if (fontSize == HUD_FONT_LARGE) {
164 textString( scrn_rect.left + posincr, scrn_rect.top,
165 label_buffer, get_digits());