8 #ifdef USE_HUD_TextList
9 #define textString(x, y, text, digit) TextString(text, x , y ,digit)
11 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
14 FLTFNPTR get_func(const char *name); // FIXME
16 instr_label::instr_label(const SGPropertyNode *node) :
18 node->getIntValue("x"),
19 node->getIntValue("y"),
20 node->getIntValue("width"),
21 node->getIntValue("height"),
22 NULL /* node->getStringValue("data_source") */, // FIXME
23 node->getFloatValue("scale_data"),
24 node->getIntValue("options"),
25 node->getBoolValue("working", true),
26 node->getIntValue("digits")),
27 pformat(node->getStringValue("label_format")),
28 fontSize(fgGetInt("/sim/startup/xsize") > 1000 ? HUD_FONT_LARGE : HUD_FONT_SMALL), // FIXME
29 blink(node->getIntValue("blinking")),
30 lat(node->getBoolValue("latitude", false)),
31 lon(node->getBoolValue("longitude", false)),
32 lbox(node->getBoolValue("label_box", false)),
33 lon_node(fgGetNode("/position/longitude-string", true)),
34 lat_node(fgGetNode("/position/latitude-string", true))
36 SG_LOG(SG_INPUT, SG_INFO, "Done reading instr_label instrument "
37 << node->getStringValue("name", "[unnamed]"));
39 set_data_source(get_func(node->getStringValue("data_source")));
41 int just = node->getIntValue("justification");
45 justify = CENTER_JUST;
49 string pre_str(node->getStringValue("pre_label_string"));
52 else if (pre_str == "blank")
55 const char *units = strcmp(fgGetString("/sim/startup/units"), "feet") ? " m" : " ft"; // FIXME
57 string post_str(node->getStringValue("post_label_string"));
58 if (post_str== "NULL")
60 else if (post_str == "blank")
62 else if (post_str == "units")
65 format_buffer = pre_str + pformat;
66 format_buffer += post_str;
70 void instr_label::draw(void)
72 char label_buffer[80];
75 RECT scrn_rect = get_location();
77 memset( label_buffer, 0, sizeof( label_buffer));
78 if (data_available()) {
80 snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), lat_node->getStringValue());
82 snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), lon_node->getStringValue());
84 if (lbox) {// Box for label
85 float x = scrn_rect.left;
86 float y = scrn_rect.top;
87 float w = scrn_rect.right;
88 float h = HUD_TextSize;
94 glVertex2f(x - 2.0, y - 2.0);
95 glVertex2f(x + w + 2.0, y - 2.0);
96 glVertex2f(x + w + 2.0, y + h + 2.0);
97 glVertex2f(x - 2.0, y + h + 2.0);
100 glEnable(GL_LINE_STIPPLE);
101 glLineStipple(1, 0xAAAA);
104 glVertex2f(x + w + 2.0, y - 2.0);
105 glVertex2f(x + w + 2.0, y + h + 2.0);
106 glVertex2f(x - 2.0, y + h + 2.0);
107 glVertex2f(x - 2.0, y - 2.0);
110 glDisable(GL_LINE_STIPPLE);
113 snprintf(label_buffer, sizeof(label_buffer)-1, format_buffer.c_str(), get_value() * data_scaling());
117 snprintf(label_buffer, sizeof( label_buffer) -1, format_buffer.c_str());
120 lenstr = getStringWidth(label_buffer);
123 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer);
124 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
125 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer);
126 fgPrintf( SG_COCKPIT, SG_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;
134 else // justify == LEFT_JUST
137 if (fontSize == HUD_FONT_SMALL) {
138 textString(scrn_rect.left + posincr, scrn_rect.top,
139 label_buffer, get_digits());
141 } else if (fontSize == HUD_FONT_LARGE) {
142 textString(scrn_rect.left + posincr, scrn_rect.top,
143 label_buffer, get_digits());