On 5/31/21 7:04 AM, Fady Megally wrote:
I apologize if I am missing something obvious here but does Fl_Value_Output allow for changing the justification of the value out of the box ? trying to right justify the 7-seg oil temp number here. will have other value below and want the decimals to be aligned.
..and make sure the Fl_Value_Output is large enough to show
that many digits.
Complete example below:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Output.H>
Fl_Window *G_win = 0;
Fl_Output *G_out = 0;
void Timer_CB(void*)
{
// Running floating point number that changes each
timer tick
static float f = 0;
f += 10.3;
if ( f > 500 ) f = 0;
// Right padded 6 digit
char s[80]; sprintf(s, "%6.1f",
f);
G_out->value(s);
Fl::repeat_timeout(0.5, Timer_CB);
}
int main()
{
// Window
G_win = new Fl_Window(640,480);
G_win->color(0xa0a0a000); // bg
// Digit Display
G_out = new Fl_Output(10,10,120,40,"Oil Temp");
G_out->align(FL_ALIGN_CENTER|FL_ALIGN_BOTTOM);
G_out->labelcolor(FL_WHITE);
G_out->color(FL_BLACK);
G_out->textcolor(FL_GREEN);
G_out->textfont(FL_COURIER);
G_out->textsize(24);
G_win->show(); // ADDED
Fl::add_timeout(0.5, Timer_CB);
return Fl::run(); // ADDED
}