On 04/21/15 13:46, Ian MacArthur wrote:
> On Tue Apr 21 2015 03:10:22,
jorgem...@gmail.com wrote:
>> Hello,
>>
>> I am totally new to fltk and I am trying to run a very simple code that I include below. I am running FLTK for Windows in Visual Studio 2013 and my goal is to draw a box. When I run the code I can see a window and a button but the box is not shown. I will very much appreciate your feedback.
>
> You want to start of taking a look at the docs,
Yes, specifically the section entitled "Drawing things in FLTK".
To find the docs, go to the
fltk.org main page, click "Documentation",
and find the version you're running (hopefully FLTK 1.3.3), click
the HTML link, and look for the above section.
In particular, read those first few paragraphs, as they pertain
to your use of fl_draw_box() outside of a derived class's draw() method.
To draw shapes, you'll need to derive your own class (in your case,
you probably want to derive from Fl_Window if you want to draw anywhere
in the window) and create a draw() method for your class, and put
your fl_draw_box() code there, e.g.
class YourWindow : public Fl_Window {
public:
YourWindow(int W,int H,const char *L=0) : Fl_Window(W,H,L) { }
void draw() { // class's draw() method -- the only place where drawing can be done
Fl_Window::draw(); // First: let window draw itself (the bg, child widgets, buttons..)
fl_draw_box(FL_FLAT_BOX, 10, 10, 500, 30, fl_rgb_color(255, 0, 0)); // ..second, draw your box
}
};
..
int main() {
YourWindow win(600,400,"Flip Flaps"); // use "YourWindow" instead of "Fl_Window"
..
}