> It doesn't work.
> I don't know what's wrong with my code but I'm lost.
> I spend 2 days on it and I don't see any solution to that pb.

Ok, may be I gave you a bad explanation of my pb
wich led you on wrong ways. I'm sorry.
So let's try to fixe problems one by one.
First, the setting clip region to avoid the
child widget drawing outside its parent.
Here's a simple and compilable example to show my pb:


#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>


class MyWidget : public Fl_Group
{

  Fl_Box *childWdg;

  void draw()
  {
    Fl_Group::draw();

    fl_push_clip(x(), y(), w(), h());

    fl_pop_clip();
  }

    public:

  MyWidget(int x, int y, int w, int h, const char *l = 0)
    : Fl_Group(x, y, w, h, l)
  {
    box(FL_DOWN_BOX);
    color((Fl_Color) FL_WHITE);

    begin();
    childWdg = new Fl_Box(x + 120, y + 20, 200, 60);
    childWdg->box(FL_UP_BOX);
    childWdg->color((Fl_Color) FL_RED);
    end();
  }

};


class Application : public Fl_Double_Window
{
  MyWidget *myWdg;

    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);
  color((Fl_Color) FL_INACTIVE_COLOR);

  begin();
  myWdg = new MyWidget(20, 20, 200, 250);
  end();

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

int main (int argc, char ** argv)
{
  Application myApp(500, 300, "Widget", argc, argv);

  return(Fl::run());
}

What do I have to do to avoid the
child widget drawing outside its parent ?


Thanks

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

Reply via email to