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 pre_str(node->getStringValue("pre_label_string")),
29 post_str(node->getStringValue("post_label_string")),
30 fontSize(fgGetInt("/sim/startup/xsize") > 1000 ? HUD_FONT_LARGE : HUD_FONT_SMALL), // FIXME
31 blink(node->getIntValue("blinking")),
32 lat(node->getBoolValue("latitude", false)),
33 lon(node->getBoolValue("longitude", false)),
34 lbox(node->getBoolValue("label_box", false)),
35 lon_node(fgGetNode("/position/longitude-string", true)),
36 lat_node(fgGetNode("/position/latitude-string", true))
38 SG_LOG(SG_INPUT, SG_INFO, "Done reading instr_label instrument "
39 << node->getStringValue("name", "[unnamed]"));
41 set_data_source(get_func(node->getStringValue("data_source")));
43 int just = node->getIntValue("justification");
47 justify = CENTER_JUST;
51 if (!strcmp(pre_str, "NULL"))
53 else if (!strcmp(pre_str, "blank"))
56 const char *units = strcmp(fgGetString("/sim/startup/units"), "feet") ? " m" : " ft"; // FIXME
58 if (!strcmp(post_str, "blank"))
60 else if (!strcmp(post_str, "NULL"))
62 else if (!strcmp(post_str, "units"))
66 if (pre_str != NULL) {
68 sprintf(format_buffer, "%s%s%s", pre_str, pformat, post_str);
70 sprintf(format_buffer, "%s%s", pre_str, pformat);
72 } else if (post_str != NULL) {
73 sprintf(format_buffer, "%s%s", pformat, post_str);
75 strcpy(format_buffer, pformat); // FIXME
80 void instr_label::draw(void)
82 char label_buffer[80];
85 RECT scrn_rect = get_location();
87 if (data_available()) {
89 snprintf(label_buffer, 80, format_buffer, lat_node->getStringValue());
91 snprintf(label_buffer, 80, format_buffer, lon_node->getStringValue());
93 if (lbox) {// Box for label
94 float x = scrn_rect.left;
95 float y = scrn_rect.top;
96 float w = scrn_rect.right;
97 float h = HUD_TextSize;
103 glVertex2f(x - 2.0, y - 2.0);
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);
109 glEnable(GL_LINE_STIPPLE);
110 glLineStipple(1, 0xAAAA);
113 glVertex2f(x + w + 2.0, y - 2.0);
114 glVertex2f(x + w + 2.0, y + h + 2.0);
115 glVertex2f(x - 2.0, y + h + 2.0);
116 glVertex2f(x - 2.0, y - 2.0);
119 glDisable(GL_LINE_STIPPLE);
122 sprintf(label_buffer, format_buffer, get_value() * data_scaling());
126 sprintf(label_buffer, format_buffer);
129 lenstr = getStringWidth(label_buffer);
132 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer);
133 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
134 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer);
135 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
137 lenstr = strlen(label_buffer);
139 if (justify == RIGHT_JUST)
140 posincr = scrn_rect.right - lenstr;
141 else if (justify == CENTER_JUST)
142 posincr = get_span() - (lenstr / 2); // -lenstr*4;
143 else // justify == LEFT_JUST
146 if (fontSize == HUD_FONT_SMALL) {
147 textString(scrn_rect.left + posincr, scrn_rect.top,
148 label_buffer, get_digits());
150 } else if (fontSize == HUD_FONT_LARGE) {
151 textString(scrn_rect.left + posincr, scrn_rect.top,
152 label_buffer, get_digits());