
/*
 * .tpl.c
 *
 * MACHINE GENERATED
 */

#include "defs.h"

Prototype __regargs struct Gadget *InitGads(struct Screen *);
Prototype void      FreeGads(void);

Prototype UBYTE         *Buf_storage_str;

Prototype struct Gadget *Gad_storage_str;
Prototype struct Gadget *Gad_storage_list;
Prototype struct Gadget *Gad_pagesize;
Prototype struct Gadget *Gad_linelength;
Prototype struct Gadget *Gad_split;
Prototype struct Gadget *Gad_title;
Prototype struct Gadget *Gad_filereq;
Prototype struct Gadget *Gad_print_it;
Prototype struct Gadget *Gad_automatic;
Prototype struct Gadget *Gad_quit;

Prototype struct NewGadget  NGAry[11];
Prototype struct MinList    List_storage_list;

#define xpos1   12
#define xpos2   (xpos1 +  33)
#define xpos3   (xpos1 + 180)
#define xpos4   (xpos1 + 302)

#define ypos1   29
#define ypos2   (ypos1 +  16)
#define ypos3   (ypos1 +  32)
#define ypos4   (ypos1 +  48)
#define ypos5   (ypos1 +  64)


/***********************  NGAry[11] **********************************/
const UBYTE linesstr[]  = "lines per page";
const UBYTE charsstr[]  = "chars per line";
const UBYTE splitstr[]  = "split pages";
const UBYTE addstr[]    = "add titlelines";
const UBYTE automstr[]  = "automatic";
const UBYTE loadstr[]   = "load files";
const UBYTE quitstr[]   = "Q U I T";
const UBYTE storagstr[] = "storage:";
const UBYTE printstr[]  = "print it";
const UBYTE forgetstr[] = "forget it";

struct NewGadget NGAry[11] =
{
  {xpos1, ypos1,59,  12, linesstr,  NULPTR, GAD_pagesize,     0x0002, NULPTR},
  {xpos1, ypos2,59,  12, charsstr,  NULPTR, GAD_linelength,   0x0002, NULPTR},
  {xpos2, ypos3, 0,   0, splitstr,  NULPTR, GAD_split,        0x0002, NULPTR},
  {xpos2, ypos4, 0,   0, addstr,    NULPTR, GAD_title,        0x0002, NULPTR},
  {xpos2, ypos5, 0,   0, automstr,  NULPTR, GAD_automatic,    0x0002, NULPTR},
  {xpos1, 114, 177,  17, loadstr,   NULPTR, GAD_filereq,      0x0010, NULPTR},
  {xpos1, 134, 177,  17, quitstr,   NULPTR, GAD_quit,         0x0010, NULPTR},
  {xpos3,  30, 241, 101, storagstr, NULPTR, GAD_storage_list, 0x0004, NULPTR},
  {xpos3, 110, 241,  17, NULPTR,    NULPTR, GAD_storage_str,  0x0004, NULPTR},
  {xpos3, 134, 119,  17, printstr,  NULPTR, GAD_print_it,     0x0000, NULPTR},
  {xpos4, 134, 119,  17, forgetstr, NULPTR, GAD_forget_it,    0x0000, NULPTR}
};

/***********************  Gad_pagesize ******************************/
struct Gadget *Gad_pagesize;

const UBYTE  *StatAry_pagesize[] =
{
  " 66",
  " 88",
  (void *) 0
};

UBYTE **Ary_pagesize   = StatAry_pagesize;

/***********************  Gad_linelength ****************************/
struct Gadget *Gad_linelength;

const UBYTE *StatAry_linelength[] =
{
  " 80",
  " 96",
  "132",
  (void *) 0
};

UBYTE **Ary_linelength  = StatAry_linelength;

/*****  Gad_split Gad_title Gad_filereq Gad_quit ********************/
struct Gadget *Gad_split;
struct Gadget *Gad_title;
struct Gadget *Gad_filereq;
struct Gadget *Gad_quit;

/***********************  Gad_storage_list **************************/
struct Gadget *Gad_storage_list;

struct MinList List_storage_list =
{
  (PE *) &List_storage_list.mlh_Tail,
  NULPTR,
  (PE *) &List_storage_list.mlh_Head
};

long   SelNo_storage_list  = 0;

/***********************  Gad_storage_str  **************************/
struct Gadget *Gad_storage_str;
UBYTE  *Buf_storage_str;
const UBYTE  *DefText_storage_str = "Welcome to the machine ...";

/*****  Gad_print_it Gad_automatic Gad_forget_it ********************/
struct Gadget *Gad_print_it;
struct Gadget *Gad_automatic;
struct Gadget *Gad_forget_it;

struct Gadget *GList;
struct VisualInfo *VisInfo;

/***********************  InitGads(scr)  **************************/
__regargs struct Gadget *
InitGads(struct Screen *scr)
{
  struct Gadget *gad;
  short  i;

  GList = (void *) 0;
  if ((VisInfo = GetVisualInfo(scr, TAG_END)) == NULL)
    return (NULPTR);

  struct NewGadget *ng;

  for ( i = 0, ng = NGAry;
        i < sizeof(NGAry) / sizeof(NGAry[0]);
        ++i, ++ng)
  {
    ng->ng_VisualInfo = VisInfo;
    ng->ng_TextAttr   = scr->Font;
  }

  if ((gad = CreateContext(&GList)) == NULL)
    return (NULPTR);

  Gad_pagesize      = gad = CreateGadget( CYCLE_KIND, gad, NG_pagesize,
                                          GTCY_Labels, Ary_pagesize,
                                          GTCY_Active, pagesize,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_linelength    = gad = CreateGadget( CYCLE_KIND, gad, NG_linelength,
                                          GTCY_Labels, Ary_linelength,
                                          GTCY_Active, linelength,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_split         = gad = CreateGadget( CHECKBOX_KIND, gad, NG_split,
                                          GTCB_Checked, split,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_title         = gad = CreateGadget( CHECKBOX_KIND, gad, NG_title,
                                          GTCB_Checked, title,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_automatic     = gad = CreateGadget( CHECKBOX_KIND, gad, NG_automatic,
                                          GTCB_Checked, autom,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_filereq       = gad = CreateGadget( BUTTON_KIND, gad, NG_filereq,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_quit          = gad = CreateGadget( BUTTON_KIND, gad, NG_quit,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_storage_str   = gad = CreateGadget( STRING_KIND, gad, NG_storage_str,
                                          GTST_MaxChars, MAXPATH,
                                          GTST_String,   DefText_storage_str,
                                          TAG_END );
  if (gad == NULL)
    return (NULL);

  Buf_storage_str   = ((struct StringInfo *)Gad_storage_str->SpecialInfo)->Buffer;

  Gad_storage_list  = gad = CreateGadget( LISTVIEW_KIND, gad, NG_storage_list,
                                          GTLV_Labels,        &List_storage_list,
                                          GTLV_Selected,      SelNo_storage_list,
                                          GTLV_ShowSelected,  Gad_storage_str,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  Gad_print_it      = gad = CreateGadget( BUTTON_KIND, gad, NG_print_it,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);


  Gad_forget_it     = gad = CreateGadget( BUTTON_KIND, gad, NG_forget_it,
                                          TAG_END);
  if (gad == NULL)
    return (NULL);

  return (GList);
}

/***********************  FreeGads(void)  ****************************/
void
FreeGads(void)
{
  FreeGadgets(GList);
  if (VisInfo)
    FreeVisualInfo(VisInfo);
  VisInfo = NULL;
  GList   = NULL;
}

