imm wrote:
> You possibly want to put a group inside your window, sized as Paolo
> indicated, then add your widgets to that group. I think that would
> maybe clip the children (I haven't tried that, though.)
>
> Failing that, you make your own subclass of DFl_Group and in the
> draw:: method you use fl_clip() to enforce the clipping region you need.

I tried this :

class MyGroup : public Fl_Group //Create a Fl_Group derived class
{
  void MyGroup::draw()
  {
    Fl_Group::draw();

    fl_push_clip(x(), y(), w() - Fl::box_dw(box()),
                                 h() - Fl::box_dh(box()));

    fl_pop_clip();
   }
  public:

   MyGroup(int x, int y, int w, int h, const char *l=0)
   : Fl_Group(x, y, w, h, l){}
};

class Application : public Fl_Double_Window
{
    Fl_Box *bx; //Child box widget
    MyGroup *grp;
    public:
     Application(int w, int h, const char *l, int argc, char *argv[]);
};

Application::Application(int w, int h, const char *l, int argc, char *argv[])
: Fl_Double_Window(w, h, l)
{
  box(FL_DOWN_BOX); //Add 2 pixels borders all around the main window
  color((Fl_Color) FL_WHITE);

  begin();
  grp = new MyGroup(Fl::box_dx(box()), Fl::box_dy(box()),
               w - Fl::box_dw(box()), h - Fl::box_dh(box()));
  bx = new Fl_Box(0,0,100, 400);
  bx->box(FL_FLAT_BOX);
  bx->color((Fl_Color) FL_RED);
  grp->add(bx);

  end();

  resizable(this);
  show(argc, argv);
}

int main (int argc, char ** argv)
{
  Application myApp(500, 300, "My App", argc, argv);
  return(Fl::run());
}


But infortunately pb remains the same.
May be a tip in the virtual draw function ?
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to