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 lat_label::lat_label(int x,
17 const char *label_format,
18 const char *pre_label_string,
19 const char *post_label_string,
22 fgLabelJust justification,
27 instr_item( x, y, width, height,
28 data_source, scale_data,options, working,digit),
29 pformat ( label_format ),
30 pre_str ( pre_label_string ),
31 post_str ( post_label_string ),
32 justify ( justification ),
33 fontSize ( font_size ),
36 if (pre_str != NULL) {
38 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
40 sprintf( format_buffer, "%s%s", pre_str, pformat );
42 } else if (post_str != NULL) {
43 sprintf( format_buffer, "%s%s", pformat, post_str );
44 } // else do nothing if both pre and post strings are nulls. Interesting.
48 // I put this in to make it easy to construct a class member using the current
52 lat_label::~lat_label()
58 lat_label::lat_label( const lat_label & image) :
59 instr_item((const instr_item &)image),
60 pformat ( image.pformat ),
61 pre_str ( image.pre_str ),
62 post_str ( image.post_str ),
65 if (pre_str != NULL) {
67 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
69 sprintf( format_buffer, "%s%s", pre_str, pformat );
71 } else if (post_str != NULL) {
72 sprintf( format_buffer, "%s%s", pformat, post_str );
73 } // else do nothing if both pre and post strings are nulls. Interesting.
78 lat_label& lat_label::operator=(const lat_label & rhs)
80 if (!(this == &rhs)) {
81 instr_item::operator = (rhs);
82 pformat = rhs.pformat;
83 fontSize = rhs.fontSize;
85 justify = rhs.justify;
86 pre_str = rhs.pre_str;
87 post_str = rhs.post_str;
88 strcpy(format_buffer,rhs.format_buffer);
95 // draw Draws a label anywhere in the HUD
98 void lat_label::draw( void ) // Required method in base class
100 char label_buffer[80];
103 RECT scrn_rect = get_location();
104 // float lat = get_value();
106 if (data_available()) {
107 // // sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
108 sprintf( label_buffer, format_buffer,
109 coord_format_lat( get_value()) );
112 sprintf( label_buffer, format_buffer );
116 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
117 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
118 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
119 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
122 lenstr = getStringWidth(label_buffer);
124 if (justify == RIGHT_JUST)
125 posincr = scrn_rect.right - lenstr;
126 else if (justify == CENTER_JUST)
127 posincr = get_span() - (lenstr/2);
128 else // justify == LEFT_JUST
131 if (fontSize == HUD_FONT_SMALL) {
132 textString( scrn_rect.left + posincr, scrn_rect.top,
133 label_buffer, get_digits());
135 } else if (fontSize == HUD_FONT_LARGE) {
136 textString( scrn_rect.left + posincr, scrn_rect.top,
137 label_buffer, get_digits());