Stan wrote:
>> 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.
I can see a difference, if I comment out or use the init_sizes()
call below. You can see it best, if you enable screen updates
while dragging in your Windows or Window manager environment.
With init_sizes(): Whenever you click the button and resize
the window thereafter, it behaves like expected (by a normal
user): the 4 squares start moving from the place where they
had moved when the button had been clicked.
Without init_sizes(): The squares "jump" to a previous
position and move from there, when the window gets resized
after a button click. You can also see a difference, if
you do click the button first, or resize the window first.
Albrecht
> #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