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 instr_label :: ~instr_label()
61 instr_label :: instr_label( const instr_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 instr_label & instr_label ::operator = (const instr_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 format_buffer[80];
107 char label_buffer[80];
110 RECT scrn_rect = get_location();
112 if( data_available() ) {
113 sprintf( label_buffer, format_buffer, get_value() );
116 sprintf( label_buffer, format_buffer );
119 lenstr = getStringWidth( label_buffer );
123 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
124 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
125 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
126 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
128 // lenstr = strlen( 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); // -lenstr*4;
135 // justify == LEFT_JUST
139 if( fontSize == SMALL ) {
140 textString( scrn_rect.left + posincr, scrn_rect.top,
141 label_buffer, GLUT_BITMAP_8_BY_13);
144 if( fontSize == LARGE ) {
145 textString( scrn_rect.left + posincr, scrn_rect.top,
146 label_buffer, GLUT_BITMAP_9_BY_15);