for example, this is from Erco's FLTK cheat page and is similar to examples in
the test folders in its implementation:
// DEMONSTRATE HOW TO DRAW AN 'X' IN FLTK
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Double_Window.H>
// SIMPLE BOX WIDGET THAT DRAWS AN 'X'
class DrawX : public Fl_Widget {
public:
DrawX(int X, int Y, int W, int H, const char*L=0) : Fl_Widget(X,Y,W,H,L) {
}
void draw() {
// DRAW BLACK 'X'
fl_color(FL_BLACK);
fl_line(x(), y(), x()+w()-1, y()+h()-1);
fl_line(x(), y()+h()-1, x()+w()-1, y());
}
};
int main() {
Fl_Double_Window win(200,200);
DrawX draw_x(0, 0, win.w(), win.h());
win.resizable(draw_x);
win.show();
return(Fl::run());
}
I replaced this line:
fl_line(x(), y(), x()+w()-1, y()+h()-1);
with fl_rectf(20,20,20,20);
And its duly drew me a black rectangle instead of the other line.
So how come you can't just write a stand alone function, providing the
headers are there:
void draw() {
fl_color(FL_BLACK);
fl_rectf(20,20,20,20);
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk