/* A demo showing the use of timer objects.  */

#include <stdlib.h>
#include "forms.h"

FL_FORM *form1, *form2;
FL_OBJECT *but, *tim, *tim2;

void makeforms(void)
{
  form1 = fl_bgn_form(FL_UP_BOX,400,400);
    but = fl_add_button(FL_NORMAL_BUTTON,140,160,120,80,"Push Me");
    tim = fl_add_timer(FL_VALUE_TIMER,200,310,90,50,"Time Left");
    fl_set_object_lcol(tim, FL_BLACK);
  fl_end_form();
  form2 = fl_bgn_form(FL_UP_BOX,320,120);
    fl_add_box(FL_NO_BOX,160,80,0,0,"You were too late");
    fl_add_button(FL_NORMAL_BUTTON,100,20,120,30,"Try Again");
    tim2 = fl_add_timer(FL_HIDDEN_TIMER,0,0,1,2,"");
  fl_end_form();
}

int
main(int argc, char *argv[])
{
  FL_OBJECT *ret;

  fl_initialize(argv[0], "FormDemo", 0, 0 ,&argc, argv);
  makeforms();

  fl_show_form(form1,FL_PLACE_CENTER,FL_NOBORDER,NULL);

  fl_set_timer(tim,10);
  ret = fl_do_forms();
  if (ret == but) exit(0);
  fl_deactivate_form(form1);
  fl_set_timer(tim2,10);
  fl_show_form(form2,FL_PLACE_MOUSE,0,NULL);
  fl_do_forms();
  fl_hide_form(form2);
  fl_activate_form(form1);
  fl_set_timer(tim,10);
  do ret = fl_do_forms(); while (ret != but);
  fl_hide_form(form1);
  return 0;
}

