>
>    I imagine it would make a difference if you added a button,
>    and had the button's callback move the widgets around.

It doesn't seem to matter.  Here's the revised version.

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

class DBox : public Fl_Box {
public:
        DBox(int x, int y, int w, int h, char const* label = 0)
                : Fl_Box(x, y, w, h, label)
        {
                box(FL_DOWN_BOX);
        }
};

DBox* bx1;
DBox* bx2;
DBox* bx3;
DBox* bx4;

void btn_cb(Fl_Widget*, void* win)
{
        static bool closed = true;
        if(closed) {
                bx1->position(bx1->x() - 10, bx1->y() - 10);
                bx2->position(bx2->x() + 10, bx2->y() - 10);
                bx3->position(bx3->x() - 10, bx3->y() + 10);
                bx4->position(bx4->x() + 10, bx4->y() + 10);
                closed = false;
        }
        else {
                bx1->position(bx1->x() + 10, bx1->y() + 10);
                bx2->position(bx2->x() - 10, bx2->y() + 10);
                bx3->position(bx3->x() + 10, bx3->y() - 10);
                bx4->position(bx4->x() - 10, bx4->y() - 10);
                closed = true;
        }
        // static_cast<Fl_Double_Window*>(win)->init_sizes();
        static_cast<Fl_Double_Window*>(win)->redraw();
}

int main()
{
        Fl_Double_Window win(200, 200);

        bx1 = new DBox(50, 50, 50, 50);
        bx2 = new DBox(100, 50, 50, 50);
        bx3 = new DBox(50, 100, 50, 50);
        bx4 = new DBox(100, 100, 50, 50);

        Fl_Button* btn = new Fl_Button(170, 170, 30, 30);
        btn->callback(btn_cb, &win);

        win.end();
        win.resizable(&win);
        win.show();

        return Fl::run()
}




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

Reply via email to