La compilazione e' estremamente semplice perche' nel pacchetto della libreria e' inserito uno script apposito e la compilazione avviene mediante il comando
fltk-config --compile main.cpp
Da notare che Debian 6 Stable include una versione piuttosto vecchia di Fltk (la 1.1)
--------------------------------------------------
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Progress.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Hor_Nice_Slider.H>
#include <iostream>
#include <stdio.h>
//fltk-config --compile main.cpp
using namespace std;
Fl_Text_Display *disp;
Fl_Text_Buffer *tbuff;
Fl_Progress *prog;
void slider_cb( Fl_Widget* o, void* ) {
char buffer [5];
Fl_Hor_Nice_Slider* b=(Fl_Hor_Nice_Slider*)o;
int valore = b->value();
prog->value(valore);
sprintf(buffer,"%d",valore);
tbuff->text(buffer);
}
int main() {
Fl_Window win(100,100,200,120,"Progress Bar" );
win.begin();
disp = new Fl_Text_Display(80, 40, 40, 21);
tbuff = new Fl_Text_Buffer(); // text buffer
disp->buffer(tbuff);
tbuff->text("0");
prog = new Fl_Progress( 10, 80, 180, 20,"");
prog->value(0);
Fl_Hor_Nice_Slider *slider = new Fl_Hor_Nice_Slider( 10, 10, 180, 20,"");
slider->minimum(0);
slider->maximum(100);
slider->step(1);
slider->callback(slider_cb);
win.end();
win.show();
return Fl::run();
}
--------------------------------------------------
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Progress.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Hor_Nice_Slider.H>
#include <iostream>
#include <stdio.h>
//fltk-config --compile main.cpp
using namespace std;
Fl_Text_Display *disp;
Fl_Text_Buffer *tbuff;
Fl_Progress *prog;
void slider_cb( Fl_Widget* o, void* ) {
char buffer [5];
Fl_Hor_Nice_Slider* b=(Fl_Hor_Nice_Slider*)o;
int valore = b->value();
prog->value(valore);
sprintf(buffer,"%d",valore);
tbuff->text(buffer);
}
int main() {
Fl_Window win(100,100,200,120,"Progress Bar" );
win.begin();
disp = new Fl_Text_Display(80, 40, 40, 21);
tbuff = new Fl_Text_Buffer(); // text buffer
disp->buffer(tbuff);
tbuff->text("0");
prog = new Fl_Progress( 10, 80, 180, 20,"");
prog->value(0);
Fl_Hor_Nice_Slider *slider = new Fl_Hor_Nice_Slider( 10, 10, 180, 20,"");
slider->minimum(0);
slider->maximum(100);
slider->step(1);
slider->callback(slider_cb);
win.end();
win.show();
return Fl::run();
}
Nessun commento:
Posta un commento