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,
27 instr_item( x, y, width, height,
28 data_source, scale_data,options, working ),
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) {
37 if( post_str != NULL ) {
38 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
41 sprintf( format_buffer, "%s%s", pre_str, pformat );
45 if( post_str != NULL ) {
46 sprintf( format_buffer, "%s%s", pformat, post_str );
48 } // else do nothing if both pre and post strings are nulls. Interesting.
52 // I put this in to make it easy to construct a class member using the current
56 lat_label :: ~lat_label()
61 lat_label :: lat_label( const lat_label & image) :
62 instr_item((const instr_item &)image),
63 pformat ( image.pformat ),
64 pre_str ( image.pre_str ),
65 post_str ( image.post_str ),
68 if( pre_str != NULL) {
69 if( post_str != NULL ) {
70 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
73 sprintf( format_buffer, "%s%s", pre_str, pformat );
77 if( post_str != NULL ) {
78 sprintf( format_buffer, "%s%s", pformat, post_str );
80 } // else do nothing if both pre and post strings are nulls. Interesting.
84 lat_label & lat_label ::operator = (const lat_label & rhs )
86 if( !(this == &rhs)) {
87 instr_item::operator = (rhs);
88 pformat = rhs.pformat;
89 fontSize = rhs.fontSize;
91 justify = rhs.justify;
92 pre_str = rhs.pre_str;
93 post_str = rhs.post_str;
94 strcpy(format_buffer,rhs.format_buffer);
100 // draw Draws a label anywhere in the HUD
104 draw( void ) // Required method in base class
106 char label_buffer[80];
109 RECT scrn_rect = get_location();
110 // float lat = get_value();
112 if( data_available() ) {
113 // sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
114 sprintf( label_buffer, format_buffer,
115 coord_format_lat( get_value()) );
118 sprintf( label_buffer, format_buffer );
122 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
123 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
124 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
125 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
128 lenstr = getStringWidth(label_buffer);
130 if( justify == RIGHT_JUST ) {
131 posincr = scrn_rect.right - lenstr;
132 }else if( justify == CENTER_JUST ) {
133 posincr = get_span() - (lenstr/2);
134 } else { // justify == LEFT_JUST
138 if( fontSize == SMALL ) {
139 textString( scrn_rect.left + posincr, scrn_rect.top,
140 label_buffer, GLUT_BITMAP_8_BY_13);
143 if( fontSize == LARGE ) {
144 textString( scrn_rect.left + posincr, scrn_rect.top,
145 label_buffer, GLUT_BITMAP_9_BY_15);