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 // DBLFNPTR data_source,
19 const char *label_format,
20 const char *pre_label_string,
21 const char *post_label_string,
25 fgLabelJust justification,
29 instr_item( x, y, width, height,
30 data_source, scale_data,options, working ),
31 pformat ( label_format ),
32 pre_str ( pre_label_string ),
33 post_str ( post_label_string ),
34 justify ( justification ),
35 fontSize ( font_size ),
38 if( pre_str != NULL) {
39 if( post_str != NULL ) {
40 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
43 sprintf( format_buffer, "%s%s", pre_str, pformat );
47 if( post_str != NULL ) {
48 sprintf( format_buffer, "%s%s", pformat, post_str );
50 } // else do nothing if both pre and post strings are nulls. Interesting.
54 // I put this in to make it easy to construct a class member using the current
58 lon_label :: ~lon_label()
63 lon_label :: lon_label( const lon_label & image) :
64 instr_item((const instr_item &)image),
65 pformat ( image.pformat ),
66 pre_str ( image.pre_str ),
67 post_str ( image.post_str ),
70 if( pre_str != NULL) {
71 if( post_str != NULL ) {
72 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
75 sprintf( format_buffer, "%s%s", pre_str, pformat );
79 if( post_str != NULL ) {
80 sprintf( format_buffer, "%s%s", pformat, post_str );
82 } // else do nothing if both pre and post strings are nulls. Interesting.
86 lon_label & lon_label ::operator = (const lon_label & rhs )
88 if( !(this == &rhs)) {
89 instr_item::operator = (rhs);
90 pformat = rhs.pformat;
91 fontSize = rhs.fontSize;
93 justify = rhs.justify;
94 pre_str = rhs.pre_str;
95 post_str = rhs.post_str;
96 strcpy(format_buffer,rhs.format_buffer);
102 // draw Draws a label anywhere in the HUD
106 draw( void ) // Required method in base class
108 // char format_buffer[80];
109 char label_buffer[80];
112 RECT scrn_rect = get_location();
113 float lon = get_value();
114 // double lon = get_value();
115 if( data_available() ) {
116 // char *lonstring = coord_format_lon(lon);
117 lenstr = sprintf( label_buffer, format_buffer, coord_format_lon(lon) );
120 lenstr = sprintf( label_buffer, format_buffer );
124 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
125 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
126 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
127 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
130 lenstr = getStringWidth(label_buffer);
132 if( justify == RIGHT_JUST ) {
133 posincr = scrn_rect.right - lenstr;
134 }else if( justify == CENTER_JUST ) {
135 posincr = get_span() - (lenstr/2);
137 // justify == LEFT_JUST
141 if( fontSize == SMALL ) {
142 textString( scrn_rect.left + posincr, scrn_rect.top,
143 label_buffer, GLUT_BITMAP_8_BY_13);
146 if( fontSize == LARGE ) {
147 textString( scrn_rect.left + posincr, scrn_rect.top,
148 label_buffer, GLUT_BITMAP_9_BY_15);