// generated by Fast Light User Interface Designer (fluid) version 2.1000

#include "resize.h"
#include <fltk/events.h>

void warp(int dx, int dy) {
  fltk::warp_mouse(fltk::event_x_root()+dx, fltk::event_y_root()+dy);
}

static void cb_8(fltk::Button* o, void*) {
  fltk::Window* w = o->window();
  w->position(w->x(),w->y()-50);
  warp(0,-50);
}

static void cb_(fltk::Button* o, void*) {
  fltk::Window* w = o->window();
  w->position(w->x()-50,w->y());
  warp(-50,0);
}

static void cb_1(fltk::Button* o, void*) {
  fltk::Window* w = o->window();
  w->position(w->x()+50,w->y());
  warp(+50,0);
}

static void cb_2(fltk::Button* o, void*) {
  fltk::Window* w = o->window();
  w->position(w->x(),w->y()+50);
  warp(0,+50);
}

static void cb_grow(fltk::Button* o, void*) {
  fltk::Window* w = o->window();
  int mx = fltk::event_x_root()-w->x();
  int my = fltk::event_y_root()-w->y();
  warp(mx*20/w->w(), my*20/w->h());
  w->resize(w->w()+20, w->h()+20);
}

static void cb_shrink(fltk::Button* o, void*) {
  fltk::Window* w = o->window();
  int mx = fltk::event_x_root()-w->x();
  int my = fltk::event_y_root()-w->y();
  warp(-mx*20/w->w(), -my*20/w->h());
  w->resize(w->w()-20, w->h()-20);
}

#include <fltk/run.h>

int main (int argc, char **argv) {

  fltk::Window* w;
   {fltk::Window* o = new fltk::Window(320, 240);
    w = o;
    o->shortcut(0xff1b);
    o->begin();
     {fltk::Button* o = new fltk::Button(60, 0, 39, 40, "@8->");
      o->set_vertical();
      o->callback((fltk::Callback*)cb_8);
    }
     {fltk::InvisibleBox* o = new fltk::InvisibleBox(148, 10, 157, 218, "This is a test of program-generated resize() of a window.  The window should \
move or resize once when each button is clicked.  The program and window manag\
er should not go into fits echoing resizes back and forth!");
      o->set_vertical();
      o->box(fltk::BORDER_BOX);
      o->align(fltk::ALIGN_LEFT|fltk::ALIGN_CENTER|fltk::ALIGN_INSIDE|fltk::ALIGN_WRAP);
      fltk::Group::current()->resizable(o);
    }
     {fltk::Button* o = new fltk::Button(20, 40, 40, 40, "@<-");
      o->set_vertical();
      o->callback((fltk::Callback*)cb_);
    }
     {fltk::Button* o = new fltk::Button(99, 40, 39, 40, "@->");
      o->set_vertical();
      o->callback((fltk::Callback*)cb_1);
    }
     {fltk::Button* o = new fltk::Button(60, 80, 39, 39, "@2->");
      o->set_vertical();
      o->callback((fltk::Callback*)cb_2);
    }
     {fltk::Button* o = new fltk::Button(30, 129, 108, 40, "grow");
      o->labelfont(fltk::HELVETICA_BOLD);
      o->labelsize(18);
      o->callback((fltk::Callback*)cb_grow);
    }
     {fltk::Button* o = new fltk::Button(30, 188, 108, 40, "shrink");
      o->labelfont(fltk::HELVETICA_BOLD);
      o->labelsize(18);
      o->callback((fltk::Callback*)cb_shrink);
    }
    o->end();
  }
  w->show(argc, argv);
  return  fltk::run();
}
