2

I installed FLTK 1.3.X from fltk.org on my visual studio 2012 compiler and use PPP book for C++ programming (this). My problem is about filling a Shape in. For example please observe this code:

#include <Simple_window.h>

using namespace Graph_lib;
int main()
{
    Simple_window win(Point(100,100), 1000, 600, "Binary_tree");
    Graph_lib::Circle c(Point(200,200),50);
    c.set_color(Color::red);
    c.set_fill_color(Color::blue);
    Graph_lib::Ellipse e(Point(100,100),50,30);
    e.set_color(Color::blue);
    e.set_fill_color(Color::red);
    Graph_lib::Rectangle r(Point(250,200),Point(350,300));
    r.set_color(Color::green);
    r.set_fill_color(Color::red);
    win.attach(r);
    win.attach(e);
    win.attach(c);
    win.wait_for_button();
}

When I run the program, All three Shapes are drawn on window but only the Rectangle is filled in! Why? set_color works for the three and apparently the set_fill_color is defined for all Shapes and it too should work but why it doesn't for Circle and Ellipse?

This is the .CPP and .h files ( )

zhiar
  • 113
  • 9
  • There isn't any idea!? – zhiar Aug 30 '14 at 15:16
  • This isn't anything to do with fltk: it is to do with graph_lib which is written on top of fltk. Where did you get graph_lib from and which platform are you running on? – cup Sep 02 '14 at 05:21
  • My machine is Windows 7 and compiler is M Visual Studio 2012. I installed _FLTK_ version 1.3.2 and _Graph_lib_ has come from it I think. – zhiar Sep 03 '14 at 15:10
  • Took a while to find graph_lib - it comes from Stourstrup's site. Anyway, ran your program and it fills the circle and ellipse. It goes into fl_arci.cxx routine Fl_Graphics_Driver::pie which should fill up the circle. – cup Sep 03 '14 at 20:41
  • What version of FLTK you used please? The 1.3.2? – zhiar Sep 04 '14 at 08:31
  • Yes - 1.3.2. It is possible that your FLTK has not been built correctly. Did you build it from source or did you get it as a prebuilt library? If you didn't build it from source, get the source from the fltk site, go to the IDE directory, convert the VS10 solution to VS11 and rebuild. – cup Sep 04 '14 at 12:32
  • Excuse me, I'm not familiar with those phrases but to inform you how I installed FLTK please read [this](http://stackoverflow.com/questions/21063872/fltk-version-1-3-2-visual-studio-2012-and-the-first-example-of-stroustrups-ppp). I appreciate your further guidance. – zhiar Sep 04 '14 at 13:15
  • On step 3, instead of going into VC6 and using the dsw, you should be going into VC2010 and converting that solution. It is more compatible with VS11. – cup Sep 04 '14 at 19:46
  • OK, I do that on step 3 and go on the rest of steps as before. But what I should do is reinstalling FLTK on the existing one or I should uninstall (?) this version someway and install it again by that new way? – zhiar Sep 04 '14 at 20:55
  • Instead of installing/reinstalling you could do this - set an environment variable FLTK to the 1.3.2 diectory. Then in the include add $(FLTK) and libs add $(FLTK)/lib. – cup Sep 04 '14 at 21:03

1 Answers1

0

Probably, it was you who started the thread regarding this issue on another website where I found a solution, but in order to help others, who also struggles with this problem, I will make this post. Here you can download the working Stroustrup's library. If you don't want to rewrite all the files, just change the code in the function "Circle::draw_lines()" in Graph.cpp to this one and recompile the library:

if (fill_color().visibility()) {    // fill
    fl_color(fill_color().as_int());
    fl_pie(point(0).x,point(0).y,r+r-1,r+r-1,0,360);
    fl_color(color().as_int()); // reset color
}

if (color().visibility()) {
    fl_color(color().as_int());
    fl_arc(point(0).x,point(0).y,r+r,r+r,0,360);
}
Thelastpolaris
  • 341
  • 4
  • 12