#include "EZ.h"

static int  exit_program();   /* 'Quit' button call back */    
static int  hide_dialogue();  /* 'No' button call back   */
static int  test();
extern void exit();           /* 'Yes' button call back  */

main(argc, argv)
     int argc; char **argv;
{
  EZ_Widget *f, *quit, *tmp;

  EZ_Initialize(argc,argv,1);              /* initialize the EZWGL */

  f = EZ_CreateFrame(NULL,NULL);
  quit = EZ_CreateButton(f, "Quit", 0); /* create a button      */
  EZ_SetWidgetCallBack(quit,exit_program, NULL); /* register a call back */
  tmp = EZ_CreateButton(f, "Test", 0); /* create a button      */
  EZ_SetWidgetCallBack(tmp,test, NULL); /* register a call back */
  EZ_DisplayWidget(f);                  /* display the button   */
  EZ_EventMainLoop();                      /* enter the event loop */
}

static EZ_Widget *dialogue = (EZ_Widget *)NULL;

static int exit_program(widget)
     EZ_Widget *widget;
{
  if(dialogue == (EZ_Widget *)NULL)
    {
      EZ_Widget *tmp;
      dialogue = EZ_CreateFrame(NULL,          /* a frame to hold 2 items, a   */
				"Quit ?");     /* label and another frame.     */
      EZ_ConfigureWidget(dialogue,EZ_TRANSIENT,1,0);
      tmp = EZ_CreateButton(dialogue,"Yes", 0);/* Yes button on a              */
      EZ_SetWidgetCallBack(tmp,exit, NULL);         
      tmp = EZ_CreateButton(dialogue,"No", 0); /* No button on frame           */
      EZ_ConfigureWidget(tmp,EZ_CALLBACK,hide_dialogue, NULL,0);      
    }
  EZ_SetGrab(dialogue);
  EZ_DisplayWidget(dialogue);
}

static int hide_dialogue(widget)
     EZ_Widget *widget;
{
  EZ_HideWidget(dialogue);
}

static int test(widget)
     EZ_Widget *widget;
{
  printf("You pressed the Test button\n");
}
