/****************************** ITextDCL.c ************************************
 *
 *  ITextDCL() - IntuiText Editor Requester declarations for the Gadget editor
 *  
 *  By Ray R. Larson
 *
 *  Copyright (C) 1986. All rights reserved.
 *
 *  This program is freely distributable as long as this copyright notice
 *  is retained. It intended for personal, non-commercial use.  
 *
 *                      *         *          *
 *                    
 *  This module contains the myriad gadget, image, and intuitext declarations
 *  used in ITextEd.c
 ***************************************************************************/

 
#include <exec/types.h>
#include <graphics/gfxbase.h>
#include <graphics/text.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <ctype.h>
#include <stdio.h>
#include <workbench/workbench.h>

#define INTUITION_REV      1
#define GRAPHICS_REV      1

#define CHARACTER_WIDTH  8
#define CHARACTER_HEIGHT 8

/* ========================================================================*/
/* Intuitext requester gadget ids                                          */

#define CLASSBITS 8

#define UPDOWNCLASS 1
#define CHOICECLASS 2
#define CHANGECLASS 3
#define BUTTONCLASS 4

#define GADGETNUM 255

#define LOAD   0
#define CANCEL 1
#define ADDTXT 2

#define UP     0
#define DOWN   1
#define POT    2

#define ITXT0  0
#define ITXT1  1
#define ITXT2  2
#define ITXT3  3
#define ITXT4  4
#define ITXT5  5
#define ITXT6  6
#define ITXT7  7

#define PLAIN    0
#define UNDERLIN 1
#define BOLD     2
#define ITALIC   4
#define BACKGPEN 5
#define FGPEN    6
#define MODJAM1  7
#define MODJAM2  8
#define MODINV   9
#define STRGAD  10

#define LOADGADGET   BUTTONCLASS << CLASSBITS | LOAD
#define CANCELGADGET BUTTONCLASS << CLASSBITS | CANCEL
#define ADDTXTGADGET BUTTONCLASS << CLASSBITS | ADDTXT

#define UPGADGET     UPDOWNCLASS << CLASSBITS | UP
#define DOWNGADGET   UPDOWNCLASS << CLASSBITS | DOWN
#define POTGADGET    UPDOWNCLASS << CLASSBITS | POT

#define ITXT0GADGET  CHOICECLASS << CLASSBITS | ITXT0
#define ITXT1GADGET  CHOICECLASS << CLASSBITS | ITXT1
#define ITXT2GADGET  CHOICECLASS << CLASSBITS | ITXT2
#define ITXT3GADGET  CHOICECLASS << CLASSBITS | ITXT3
#define ITXT4GADGET  CHOICECLASS << CLASSBITS | ITXT4
#define ITXT5GADGET  CHOICECLASS << CLASSBITS | ITXT5
#define ITXT6GADGET  CHOICECLASS << CLASSBITS | ITXT6
#define ITXT7GADGET  CHOICECLASS << CLASSBITS | ITXT7

#define PLAINGAD  CHANGECLASS << CLASSBITS | PLAIN
#define UNDERLGAD  CHANGECLASS << CLASSBITS | UNDERLIN
#define BOLDGAD    CHANGECLASS << CLASSBITS | BOLD
#define ITALICGAD  CHANGECLASS << CLASSBITS | ITALIC
#define BGPENGAD   CHANGECLASS << CLASSBITS | BACKGPEN
#define FGPENGAD   CHANGECLASS << CLASSBITS | FGPEN
#define JAM1GAD    CHANGECLASS << CLASSBITS | MODJAM1
#define JAM2GAD    CHANGECLASS << CLASSBITS | MODJAM2
#define INVGAD    CHANGECLASS << CLASSBITS | MODINV
#define MODITGAD    CHANGECLASS << CLASSBITS | STRGAD

#define MAXITXTS 100


/****************************************************************************
* Fonts available for use in IntuiText created by the editor.
****************************************************************************/
char def_font[] = "topaz.font";

struct TextAttr TxtAt_Plain = {	(UBYTE *)def_font, 8, FS_NORMAL, FPF_ROMFONT};

struct TextAttr TxtAt_BIU = {(UBYTE *)def_font, 8, 
        FSF_BOLD | FSF_ITALIC | FSF_UNDERLINED, FPF_ROMFONT};

struct TextAttr TxtAt_BU = {(UBYTE *)def_font, 8, 
        FSF_BOLD | FSF_UNDERLINED, FPF_ROMFONT};

struct TextAttr TxtAt_BI = {(UBYTE *)def_font, 8, 
        FSF_BOLD | FSF_ITALIC, FPF_ROMFONT};

struct TextAttr TxtAt_B ={(UBYTE *)def_font, 8, 
        FSF_BOLD, FPF_ROMFONT};

struct TextAttr TxtAt_IU ={(UBYTE *)def_font, 8, 
        FSF_ITALIC | FSF_UNDERLINED, FPF_ROMFONT};

struct TextAttr TxtAt_I ={(UBYTE *)def_font, 8, 
        FSF_ITALIC, FPF_ROMFONT};

struct TextAttr TxtAt_U ={(UBYTE *)def_font, 8, 
        FSF_UNDERLINED, FPF_ROMFONT};

/* This array's subscripts are the ORed bit values of the text types */
struct TextAttr *TxtFonts[]=
    { &TxtAt_Plain, /* 0 */
      &TxtAt_U,     /* 1 */
      &TxtAt_B,     /* 2 */
      &TxtAt_BU,    /* 3 */
      &TxtAt_I,     /* 4 */
      &TxtAt_IU,    /* 5 */
      &TxtAt_BI,    /* 6 */
      &TxtAt_BIU    /* 7 */
     };


/****************************************
 * The ITxt list selection Gadget stuff *
 ***************************************/

struct IntuiText ITxtList[] =
  {
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,/* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    },
    {
    0,1, JAM2,              /* frontpen, backpen, drawmode */
    0,0,                    /* left,top */
    NULL,                   /* font */
    NULL,       /* text */
    NULL                    /* next */
    }
  };

struct Gadget ITxtListGadget[] =
  {
    { /* ITxt name selection 0 */
    &ITxtListGadget[1],      /* next gadget */
    5,14,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[0],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT0GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 1 */
    &ITxtListGadget[2],      /* next gadget */
    5,24,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[1],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT1GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 2 */
    &ITxtListGadget[3],      /* next gadget */
    5,34,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[2],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT2GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 3 */
    &ITxtListGadget[4],      /* next gadget */
    5,44,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[3],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT3GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 4 */
    &ITxtListGadget[5],      /* next gadget */
    5,54,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[4],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT4GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 5 */
    &ITxtListGadget[6],      /* next gadget */
    5,64,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[5],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT5GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 6 */
    &ITxtListGadget[7],      /* next gadget */
    5,74,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,           /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[6],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT6GADGET,             /* gadget id   */
    NULL                     /* special info*/
    },
    { /* ITxt name selection 7 */
    NULL,           /* next gadget */
    5,84,                    /* location    */
    244,8,
    GADGHCOMP,               /* flags       */
    RELVERIFY ,              /* activation  */
    BOOLGADGET|REQGADGET,    /* type        */
    NULL,                    /* rendering   */
    NULL,                    /* rendering   */
    &ITxtList[7],            /* text        */
    0,                       /* mutual exlcude */
    NULL,                    /* string info */
    ITXT7GADGET,             /* gadget id   */
    NULL                     /* special info*/
    }
  };
/********************************
 * The Load Button gadget stuff *
 *******************************/
SHORT ButtonPoints1[] =
  {
  -4, -4,
  66, -4,
  66, 12,
  -4, 12,
  -4, -4
  };
struct Border ButtonBorder1 =
  {
  0,0,
  2,1,JAM1,
  5,
  &ButtonPoints1[0],
  NULL
  };
SHORT ButtonPoints0[] =
  {
  -3, -2,
  65, -2,
  65, 10,
  -3, 10,
  -3, -2
  };
struct Border ButtonBorder0 =
  {
  0,0,
  1,0,JAM1,
  5,
  &ButtonPoints0[0],
  &ButtonBorder1
  };

struct IntuiText LoadText =
  {
  1,0, JAM2,              /* frontpen, backpen, drawmode */
  0,0,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)" Modify",                   /* text */
  NULL                    /* next */
  };

struct Gadget LoadGadget =
  { /* Load button */
  &ITxtListGadget[0],      /* next gadget */
  14,130,                  /* location    */
  64,8,
  GADGHCOMP,               /* flags       */
  GADGIMMEDIATE|ENDGADGET, /* activation  */
  BOOLGADGET|REQGADGET,    /* type        */
  (APTR) &ButtonBorder0,   /* rendering   */
  NULL,                    /* rendering   */
  &LoadText,               /* text        */
  0,                       /* mutual exlcude */
  NULL,                    /* string info */
  LOADGADGET,              /* gadget id   */
  NULL                     /* special info*/
  };

SHORT ATPoints1[] =
  {
  -4, -4,
  97, -4,
  97, 12,
  -4, 12,
  -4, -4
  };
struct Border ATBorder1 =
  {
  0,0,
  2,1,JAM1,
  5,
  &ATPoints1[0],
  NULL
  };
SHORT ATPoints0[] =
  {
  -3, -2,
  96, -2,
  96, 10,
  -3, 10,
  -3, -2
  };
struct Border ATBorder0 =
  {
  0,0,
  1,0,JAM1,
  5,
  &ATPoints0[0],
  &ATBorder1
  };
  
/* AddTxtGadget */
struct IntuiText AddText =
  {
  1,0, JAM2,              /* frontpen, backpen, drawmode */
  0,0,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"Add New Text",                   /* text */
  NULL                    /* next */
  };

struct Gadget AddTxtGadget =
  { /* Load button */
  &LoadGadget,      /* next gadget */
  80,105,                  /* location    */
  90,8,
  GADGHCOMP,               /* flags       */
  GADGIMMEDIATE|ENDGADGET, /* activation  */
  BOOLGADGET|REQGADGET,    /* type        */
  (APTR) &ATBorder0,   /* rendering   */
  NULL,                    /* rendering   */
  &AddText,               /* text        */
  0,                       /* mutual exlcude */
  NULL,                    /* string info */
  ADDTXTGADGET,              /* gadget id   */
  NULL                     /* special info*/
  };

/**********************************
 * The Cancel Button gadget stuff *
 *********************************/
struct IntuiText CancelText =
  {
  1,0, JAM2,              /* frontpen, backpen, drawmode */
  0,0,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)" Cancel",      /* text */
  NULL                    /* next */
  };

struct Gadget CancelGadget =
  { /* Cancel button */
  &AddTxtGadget,             /* next gadget */
  187,130,                 /* location    */
  64,8,
  GADGHCOMP,               /* flags       */
  GADGIMMEDIATE|ENDGADGET, /* activation  */
  BOOLGADGET|REQGADGET,    /* type        */
  (APTR) &ButtonBorder0,   /* rendering   */
  NULL,                    /* rendering   */
  &CancelText,             /* text        */
  0,                       /* mutual exlcude */
  NULL,                    /* string info */
  CANCELGADGET,            /* gadget id   */
  NULL                     /* special info*/
  };

/***********************************************
 * The Scroll Selection List up (arrow) gadget *
 **********************************************/
UWORD UpArrowData[15] = {
   0xfffc,
   0xfcfc,
   0xf87c,
   0xf03c,
   0xe01c,
   0xc00c,
   0x8004,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfffc
};

struct Image UpArrow = 
  {
   0,0,
   14,
   14,
   1,
   &UpArrowData[0],
   0x1, 0x0,
   NULL
   };

struct Gadget UpGadget =
  { /* Up a file gadget */
  &CancelGadget,           /* next gadget */
  247,13,                  /* location    */
  12,15,
  GADGIMAGE|GADGHNONE,     /* flags       */
  GADGIMMEDIATE,           /* activation  */
  BOOLGADGET|REQGADGET,    /* type        */
  (APTR) &UpArrow,         /* rendering   */
  NULL,                    /* rendering   */
  NULL,                    /* text        */
  0,                       /* mutual exlcude */
  NULL,                    /* string info */
  UPGADGET,                /* gadget id   */
  NULL                     /* special info*/
  };
/*************************************************
 * The Scroll Selection List down (arrow) gadget *
 ************************************************/
UWORD DownArrowData[15] = {
   0xfffc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0xfcfc,
   0x8004,
   0xc00c,
   0xe01c,
   0xf03c,
   0xf87c,
   0xfcfc,
   0xfffc
};

struct Image DownArrow = 
  {
   0,0,
   14,
   14,
   1,
   &DownArrowData[0],
   0x1, 0x0,
   NULL
   };

struct Gadget DownGadget =
  { /* Down a file gadget */
  &UpGadget,               /* next gadget */
  247,79,                  /* location    */
  12,15,
  GADGIMAGE|GADGHNONE,     /* flags       */
  GADGIMMEDIATE,           /* activation  */
  BOOLGADGET|REQGADGET,    /* type        */
  (APTR) &DownArrow,       /* rendering   */
  NULL,                    /* rendering   */
  NULL,                    /* text        */
  0,                       /* mutual exlcude */
  NULL,                    /* string info */
  DOWNGADGET,              /* gadget id   */
  NULL                     /* special info*/
  };

/***************************************************
 * The Scroll Selection list up down Potentiometer *
 **************************************************/
struct PropInfo KnobInfo =
  {
  AUTOKNOB | FREEVERT | PROPBORDERLESS,
  0,
  0, /* VertPot */
  0,
  0x7fff, /* VertBody */
  0,0,0,0,0,0
  };

struct Image KnobImage =
  {
  0,0,
  0,0,0,
  NULL,
  0,0,
  NULL
  };

struct Gadget PotGadget =
  { /* Potentiometer file gadget */
  &DownGadget,             /* next gadget */
  247,28,                  /* location    */
  14,50,
  GADGHNONE,               /* flags       */
  RELVERIFY,               /* activation  */
  PROPGADGET|REQGADGET,    /* type        */
  (APTR) &KnobImage,       /* rendering   */
  NULL,                    /* rendering   */
  NULL,                    /* text        */
  0,                       /* mutual exlcude */
  (APTR)&KnobInfo,         /* string info */
  POTGADGET,               /* gadget id   */
  NULL                     /* special info*/
  };
/***************************************************************************
*                  Other Requester structures                              *
***************************************************************************/
struct IntuiText HeadingText =
  {
  2,1, JAM2,              /* frontpen, backpen, drawmode */
  65,3,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"Select IntuiText",/* text */
  NULL                    /* next */
  };

SHORT Requester0Points[] = {
  2,1,
  261,1,
  261,144,
  2,144,
  2,1
  };
struct Border Requester0Border = {
  0,0,
  1,0,JAM1,
  5,
  &Requester0Points[0],
  NULL
  };

SHORT Requester1Points[] = {
  2,12,
  261,12
  };
struct Border Requester1Border = {
  0,0,
  1,0,JAM1,
  2,
  &Requester1Points[0],
  &Requester0Border
  };

SHORT Requester2Points[] = {
  2,93,
  261,93
  };
struct Border Requester2Border = {
  0,0,
  1,0,JAM1,
  2,
  &Requester2Points[0],
  &Requester1Border
  };

SHORT Requester3Points[] = {
  246,12,
  246,93,
  246,78,
  261,78,
  261,27,
  247,27
  };
struct Border Requester3Border = {
  0,0,
  1,0,JAM1,
  6,
  &Requester3Points[0],
  &Requester2Border
  };
/****************************************************************************
 *           Structures for the IntuiText Add and Modify Requester
 ***************************************************************************/
SHORT ITxtReqPairs []=
   { 0,0,	
     349,0,
     349,134,
     0,134,
     0,0
    };
    
struct Border ITxtReqBord =
   { 0,0,1,0,JAM1,5,&ITxtReqPairs[0],NULL};
   
struct IntuiText ModTxtText =
  {
  2,1, JAM2,              /* frontpen, backpen, drawmode */
  65,3,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)" Add or Modify IntuiText ",/* text */
  NULL                    /* next */
  };

struct IntuiText ITDispText =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  -5,0,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"This text shows the attributes selected", /* text */
  NULL                    /* next */
  };
  
struct Gadget DummyGad = {
  NULL, 25, 33,1,1,
  GADGHCOMP,
  GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  NULL,NULL,&ITDispText,
  0x0,
  0x0, 
  0, NULL
};

SHORT modtxtpairs_1[] = {
  0,     0,   
  90,     0,   
  90,     16,   
  0,     16,   
  0,     0    
};
struct Border modtxtbord_1 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_1,
  NULL
};

struct IntuiText OKIT =
  {
  0,1, JAM2,              /* frontpen, backpen, drawmode */
  4,3,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"    OK    ",   /* text */
  NULL                    /* next */
  };

struct Gadget OKtxtGad = {
  &DummyGad, 243, 106, 90, 16,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_1,  (APTR)&modtxtbord_1, &OKIT,
  0x0,
  0x0, 
  LOADGADGET, NULL
};

SHORT modtxtpairs_2[] = {
  0,     0,   
  90,     0,   
  90,     16,   
  0,     16,   
  0,     0    
};
struct Border modtxtbord_2 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_2,
  NULL
};

struct IntuiText CanIT =
  {
  0,1, JAM2,              /* frontpen, backpen, drawmode */
  4,3,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"  CANCEL  ",   /* text */
  NULL                    /* next */
  };


struct Gadget CantxtGad = {
 &OKtxtGad, 20, 106, 90, 16,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_2,  (APTR)&modtxtbord_2, &CanIT,
  0x0,
  0x0, CANCELGADGET, NULL
};


/****************************************************************/
/*  The following data structure contains the image data  used  */
/*  for the pen color palettes.                                 */
/****************************************************************/
USHORT Colors_dat[]=  {
  0xffff,
  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xfe01,  0x8000,  0x000f,
  0xffff,  0xfe00,  0x0001,  0xffff,  0xfe06,  0x8000,  0x000f,  0xffff,
  0xfe00,  0x0001,  0xffff,  0xfe00,  0x8000,  0x000f,  0xffff,  0xfe00,
  0x0001,  0xffff,  0xfe00,  0x8000,  0x000f,  0xffff,  0xfe00,  0x0001,
  0xffff,  0xffe0,  0x8000,  0x000f,  0xffff,  0xfe00,  0x0001,  0xffff,
  0xfec0,  0x8000,  0x000f,  0xffff,  0xfe00,  0x0001,  0xffff,  0xfec0,
  0x8000,  0x000f,  0xffff,  0xfe00,  0x0001,  0xffff,  0xfec6,  0x8000,
  0x000f,  0xffff,  0xfe00,  0x0001,  0xffff,  0xff81,  0x8000,  0x000f,
  0xffff,  0xfe00,  0x0001,  0xffff,  0xffc3,  0x8000,  0x000f,  0xffff,
  0xfe00,  0x0001,  0xffff,  0xfe00,  0x8000,  0x000f,  0xffff,  0xfe00,
  0x0001,  0xffff,  0xfe00,  0x8000,  0x000f,  0xffff,  0xfe00,  0x0001,
  0xffff,  0xfe03,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,
  0xfe00,  0x0000,  0x0000,  0x0000,  0x0000,  0x0000,  0x0000,  0x00b7,
  0x0000,  0x0000,  0x0000,  0x01ff,  0xffff,  0xffff,  0xfc00,  0x0000,
  0x0000,  0x0000,  0x01ff,  0xffff,  0xffff,  0xfc61,  0x0000,  0x0000,
  0x0000,  0x01ff,  0xffff,  0xffff,  0xfdc3,  0x0000,  0x0000,  0x0000,
  0x01ff,  0xffff,  0xffff,  0xfdc1,  0x0000,  0x0000,  0x0000,  0x01ff,
  0xffff,  0xffff,  0xfc00,  0x0000,  0x0000,  0x0000,  0x01ff,  0xffff,
  0xffff,  0xfdc0,  0x0000,  0x0000,  0x0000,  0x01ff,  0xffff,  0xffff,
  0xfdc0,  0x0000,  0x0000,  0x0000,  0x01ff,  0xffff,  0xffff,  0xfc06,
  0x0000,  0x0000,  0x0000,  0x01ff,  0xffff,  0xffff,  0xfc00,  0x0000,
  0x0000,  0x0000,  0x01ff,  0xffff,  0xffff,  0xfcc0,  0x0000,  0x0000,
  0x0000,  0x01ff,  0xffff,  0xffff,  0xfc61,  0x0000,  0x0000,  0x0000,
  0x01ff,  0xffff,  0xffff,  0xfd66,  0x0000,  0x0000,  0x0000,  0x0000,
  0x0000,  0x0000,  0x0186,  0x0003,
     };

/***************************************************************/
/*  The following data structure defines the image  */
/***************************************************************/

struct Image ColorsImage =  {
       0, 0, /* Left, Top */
       103, 14, /* Width, Height */
       2,     /* Depth */ 
       (USHORT *)&Colors_dat, /* ImageData */
       0x03,  /* PlanePick */
       0x00,  /* PlaneOnOff */
       NULL     /* Next Image */
      }; 

struct IntuiText BGPenIT =
  {
  0,1, JAM2,              /* frontpen, backpen, drawmode */
  1,-9,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"Background Pen",   /* text */
  NULL                    /* next */
  };


struct Gadget BackPenGad = {
 &CantxtGad, 220, 79, 103, 14,
  GADGIMAGE | GADGHNONE,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&ColorsImage, NULL, &BGPenIT,
  0x0,
  0x0, BGPENGAD, NULL
};

struct IntuiText FGPenIT=
  {
  0,1, JAM2,              /* frontpen, backpen, drawmode */
  1,-9,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"Text Pen Color",   /* text */
  NULL                    /* next */
  };


struct Gadget ForePenGad = {
 &BackPenGad, 220, 52 , 103, 14,
  GADGIMAGE | GADGHNONE,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&ColorsImage, NULL, &FGPenIT,
  0x0,
  0x0, FGPENGAD, NULL
};


SHORT modtxtpairs_5[] = {
  0,     0,   
  67,     0,   
  67,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_5 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_5,
  NULL
};

struct IntuiText InvIT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  1,1,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"   XOR  ",   /* text */
  NULL                    /* next */
  };


struct Gadget INVERSEGad = {
 &ForePenGad, 121, 69, 67, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_5,  (APTR)&modtxtbord_5, &InvIT,
  0x0,
  0x0, INVGAD, NULL
};

SHORT modtxtpairs_6[] = {
  0,     0,   
  67,     0,   
  67,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_6 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_6,
  NULL
};

struct IntuiText J2IT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  1,1,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"  JAM2  ",   /* text */
  NULL                    /* next */
  };


struct Gadget JAM2Gad = {
 &INVERSEGad, 121, 57, 67, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_6,  (APTR)&modtxtbord_6, &J2IT,
  0x0,
  0x0, JAM2GAD, NULL
};

SHORT modtxtpairs_7[] = {
  0,     0,   
  67,     0,   
  67,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_7 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_7,
  NULL
};

struct IntuiText J1IT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  1,1,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"  JAM1  ",   /* text */
  NULL                    /* next */
  };


struct Gadget JAM1Gad = {
 &JAM2Gad, 121, 45, 67, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_7,  (APTR)&modtxtbord_7, &J1IT,
  0x0,
  0x0, JAM1GAD, NULL
};

SHORT modtxtpairs_8[] = {
  0,     0,   
  72,     0,   
  72,     11,   
  0,     11,   
  0,     0    
};
struct Border modtxtbord_8 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_8,
  NULL
};

struct IntuiText ItalIT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  1,1,                    /* left,top */
  &TxtAt_I,                   /* font */
  (UBYTE *)" Italic ",   /* text */
  NULL                    /* next */
  };


struct Gadget ItaltxtGad = {
 &JAM1Gad, 16, 81, 72, 11,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_8,  (APTR)&modtxtbord_8, &ItalIT,
  0x0,
  0x0, ITALICGAD, NULL
};

SHORT modtxtpairs_9[] = {
  0,     0,   
  72,     0,   
  72,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_9 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_9,
  NULL
};

struct IntuiText BoldIT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  1,1,                    /* left,top */
  &TxtAt_B,                   /* font */
  (UBYTE *)"  Bold",   /* text */
  NULL                    /* next */
  };


struct Gadget BoldtxtGad = {
 &ItaltxtGad, 16, 69, 72, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_9,  (APTR)&modtxtbord_9, &BoldIT,
  0x0,
  0x0, BOLDGAD, NULL
};

SHORT modtxtpairs_10[] = {
  0,     0,   
  72,     0,   
  72,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_10 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_10,
  NULL
};

struct IntuiText ULineIT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  8,1,                    /* left,top */
  &TxtAt_U,                   /* font */
  (UBYTE *)"Underln",   /* text */
  NULL                    /* next */
  };


struct Gadget UlinetxtGad = {
 &BoldtxtGad, 16, 57, 72, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_10,  (APTR)&modtxtbord_10, &ULineIT,
  0x0,
  0x0, UNDERLGAD, NULL
};

SHORT modtxtpairs_11[] = {
  0,     0,   
  72,     0,   
  72,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_11 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_11,
  NULL
};

struct IntuiText PlainIT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  1,1,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"  Plain ",   /* text */
  NULL                    /* next */
  };


struct Gadget PlaintxtGad = {
 &UlinetxtGad, 16, 45, 72, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  BOOLGADGET | REQGADGET,
  (APTR)&modtxtbord_11,  (APTR)&modtxtbord_11, &PlainIT,
  0x0,
  0x0, PLAINGAD, NULL
};

SHORT modtxtpairs_12[] = {
  0,     0,   
  314,     0,   
  314,     10,   
  0,     10,   
  0,     0    
};
struct Border modtxtbord_12 = {
  -1,  -1,
  1,  3,  JAM2,
  5,
  (SHORT *)&modtxtpairs_12,
  NULL
};

UBYTE ModBuff[80];
UBYTE ModUBuff[80];

struct IntuiText ModIT =
  {
  1,0, JAM1,              /* frontpen, backpen, drawmode */
  0,-9,                    /* left,top */
  NULL,                   /* font */
  (UBYTE *)"Enter or Edit Text: ",   /* text */
  NULL                    /* next */
  };


struct StringInfo ModStrInfo = {
  ModBuff, /*buffer*/
  ModUBuff, /*undo buffer*/
  0,      /*Bufferpos*/
  80,     /*MaxChars*/
  0,      /*DispPos*/
  0,      /*UndoPos*/
  0,      /*NumChars*/
  39,     /*DispCount*/
  15,     /*CLeft*/
  22,     /*CTop*/
  NULL,   /*LayerPtr*/
  0L,     /*LongInt*/
  NULL   /*AltKeyMap*/
};

struct Gadget ModTxtGad = {
 &PlaintxtGad, 15, 22, 314, 10,
  GADGHCOMP,
  RELVERIFY | GADGIMMEDIATE,
  STRGADGET | REQGADGET,
  (APTR)&modtxtbord_12,  (APTR)&modtxtbord_12, &ModIT,
  0x0,
  (APTR)&ModStrInfo, MODITGAD, NULL
};

