imm wrote:
> Please post a short example that is complete enough to compile.
> What you have posted doesn't show enough of how you are using your
> widget to allow meaningful advice to be given.

Sorry, here's the complete example:

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


class MyGroup : public Fl_Group
{
  Fl_Box *box1;

  public:

   MyGroup(int x, int y, int w, int h, const char *l=0)
   : Fl_Group(x, y, w, h, l)
   {
     box(FL_FLAT_BOX);//main widget
     color((Fl_Color) FL_GRAY);
     begin();
     box1 = new Fl_Box(5,5,100, 100);//child widget
     box1->box(FL_FLAT_BOX);
     box1->color((Fl_Color) FL_RED);
     end();
   }

   //called by the parent widget (the main window)
   //when it resized
   void myResize(int x, int y)
   {
     resize(x+5, y+5, 100, 100);//resize the main widget
     box1->resize(x+5, y+5, 100, 100);//resize the child widget
   }
};

class Application : public Fl_Double_Window
{
    MyGroup *grp;
    int offset;

    void resize(int x, int y, int w, int h)
    {
      Fl_Double_Window::resize(x, y, w, h);
      grp->myResize(offset,offset);
    }

    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_WHITE);
  offset = Fl::box_dx(this->box());
  begin();
  grp = new MyGroup(offset, offset,10,10);
  end();

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

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

  return(Fl::run());
}

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

Reply via email to