Could you help me to fill the callback with the necessary functionality to 
print the squares to a gif/png/jpg file (whatever is easiest)?

#include <stdio.h>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Double_Window.H>

class Draw : public Fl_Widget {
  private:
    int color_;
  public:
    Draw(int x, int y, int w, int h, const char *l=0, int c=FL_BLACK) : 
Fl_Widget(x, y ,w ,h, l) {
      color_ = c;
    }
    void draw() {
      fl_color(color_);
      fl_rectf(x(), y(), w(), h());
    }
};

static void printimage_cb(Fl_Widget *w) {
  printf("Printing image...\n"); // print squares above to
                                 // .gif/.jpg/.pnm/.png file,
                                 // whatever is easiest
}

int main() {
  Fl_Double_Window win(200, 60, "draw");

  Draw* draw;

  draw = new Draw(10,10,10,10,NULL,FL_WHITE);
  draw = new Draw(30,10,10,10,NULL,FL_GREEN);
  draw = new Draw(50,10,10,10,NULL,FL_BLUE);
  draw = new Draw(70,10,10,10,NULL,FL_RED);

  Fl_Button printimage(10, 30, 100, 25, "Print Image!");
  printimage.callback(printimage_cb);

  win.show();
  return(Fl::run());
}

Regards,
Jens
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to