/*---------------------------------------------------------------------------
    file intui.c
       This file contains ALL the declarations of global intuition
    structs for the keymap editor.
*/

#define HEX_ID 100
#define QUIT_ID 200
#define STRING_ID 300
#define CANCEL_ID 400
#define FILE_ID 199
#define DIR_ID 299
#define GO_ID 399

#define ROW1 6
#define ROW2 27
#define ROW3 40

extern struct Image skl_img;

extern char name[90][11];
extern char qual_name[8][18];

struct Gadget gadget[90];

UBYTE filestring[48];
UBYTE dirstring[48] = {"DEVS:keymaps/"};

/***************************************************************************
 *            This stuff is all for the "modify key" requester
 */

/*-----------------------------------------------------*/
/*        The input string gadget definition           */

UBYTE instring[128];
UBYTE undostring[128];
UBYTE inmsg[] = {"Type in new string for this key:"};

struct IntuiText input_text = {
   1,0,JAM1,0,-10,NULL,(UBYTE *)&inmsg,NULL
   };

struct StringInfo stringinfo = {
   (UBYTE *)&instring,(UBYTE *)&undostring,0,128,0,
   NULL,NULL,NULL,NULL,NULL,NULL,NULL,&MyKeyMap};

struct Gadget input_gadget = {
   NULL,
   10,ROW2,600,11,GADGHCOMP,ALTKEYMAP | TOGGLESELECT | RELVERIFY,
   STRGADGET | REQGADGET,NULL,NULL,&input_text,NULL,
   (APTR)&stringinfo,STRING_ID,NULL
   };

/*-----------------------------------------------------*/
/*         The hex input string gadget definition      */

UBYTE hexinstring[10];
UBYTE hexundostring[10];

UBYTE hexval[4];
struct IntuiText hex_data_text = {
   1,2,JAM2,30,0,NULL,(UBYTE *)&hexval,NULL
   };

UBYTE hexmsg[] = {"<- Enter value in hex  (0d = return)"};
struct IntuiText hex_text = {
   1,0,JAM1,60,0,NULL,(UBYTE *)&hexmsg,&hex_data_text
   };

struct StringInfo hexstringinfo = {
   (UBYTE *)&hexinstring,(UBYTE *)&hexundostring,0,3,0,
   NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };

struct Gadget hex_gadget = {
   &input_gadget,
   10,ROW3,24,11,GADGHCOMP,GADGIMMEDIATE | RELVERIFY,STRGADGET | REQGADGET,
   NULL,NULL,&hex_text,NULL,(APTR)&hexstringinfo,HEX_ID,NULL
   };

/*-----------------------------------------------------*/
/*         The cancel gadget definition                */

UBYTE cancelmsg[] = {"Cancel"};
SHORT cancel1[] = { 0,0, 60,0, 60,11, 0,11, 0,0 };

struct Border cancel_border = {
   0,0,1,0,JAM1,5,(SHORT *)&cancel1,NULL 
   };

struct IntuiText cancel_text = {
   1,0,JAM1,8,2,NULL,(UBYTE *)&cancelmsg,NULL
   };

struct Gadget cancel_gadget = {
   &hex_gadget,
   540,ROW3,60,11,GADGHCOMP,RELVERIFY | ENDGADGET,BOOLGADGET | REQGADGET,
   (APTR)&cancel_border,NULL,&cancel_text,NULL,NULL,CANCEL_ID,NULL
   };

/*-----------------------------------------------------*/
/*         The modfiy keymap gadget definition                  */

UBYTE quitmsg[] = {"Modify Keymap"};
SHORT quit1[] = { 0,0, 110,0, 110,11, 0,11, 0,0 };

struct Border quit_border = {
   0,0,1,0,JAM1,5,(SHORT *)&quit1,NULL 
   };

struct IntuiText quit_text = {
   1,0,JAM1,5,2,NULL,(UBYTE *)&quitmsg,NULL
   };

struct Gadget quitgadget = {
   &cancel_gadget,
   400,ROW3,110,11,GADGHCOMP,RELVERIFY | ENDGADGET,BOOLGADGET | REQGADGET,
   (APTR)&quit_border,NULL,&quit_text,NULL,NULL,QUIT_ID,NULL
   };

/*-----------------------------------------------------*/
/*         The main requester definition               */

SHORT border1[] = { 0,0, 632,0, 632,58, 0,58, 0,0 };
SHORT border2[] = { 4,2, 630,2, 630,56, 4,56, 4,2 };

struct Border req_border[] = {
   {0,0,2,1,COMPLEMENT,5,(SHORT *)&border1,&req_border[1] },
   {0,0,2,1,COMPLEMENT,5,(SHORT *)&border2,NULL }
   };

UBYTE qualtxt[] = {"Qualifier: shift+alt+control"};
struct IntuiText qual_text = {
   1,0,JAM1,400,ROW1,NULL,(UBYTE *)&qualtxt,NULL
   };

UBYTE keyp[] = {"Key Selected:"};
struct IntuiText key_text = {
   1,0,JAM1,20,ROW1,NULL,(UBYTE *)&keyp,&qual_text
   };

UBYTE code_buff[] = {"Keycode:                 "};
struct IntuiText code_text = {
   1,0,JAM1,220,ROW1,NULL,(UBYTE *)&code_buff,&key_text
   };

struct IntuiText name_text = {
   1,0,JAM1,130,ROW1,NULL,NULL,&code_text
   };

struct Requester main_requester = {
   NULL,
   3,139,636,60,0,0,&quitgadget,&req_border[0],&name_text,NULL,
   2,NULL,NULL,NULL
   };

/***************************************************************************
 *   This is for various auto requesters
 */

/*-----------------------------------------------------*/
/*         The auto requester definitions              */

UBYTE cred_msg1[] = {"SetKey was made and produced with..."};
UBYTE cred_msg2[] = {"Keymap doctoring by            Charles J. Carter"};
UBYTE cred_msg3[] = {"Intuition User Interface by    *emmbee* MWBeutjer"};
UBYTE cred_msg4[] = {"ArtWork and Font by            Jim Watson"};
struct IntuiText cred3_txt = {
   0,1,JAM1,12,43,NULL,(UBYTE *)&cred_msg4[0],NULL
   };
struct IntuiText cred2_txt = {
   0,1,JAM1,12,32,NULL,(UBYTE *)&cred_msg3[0],&cred3_txt
   };
struct IntuiText cred1_txt = {
   0,1,JAM1,12,21,NULL,(UBYTE *)&cred_msg2[0],&cred2_txt
   };
struct IntuiText cred_txt = {
   0,1,JAM1,12,10,NULL,(UBYTE *)&cred_msg1[0],&cred1_txt
   };

struct IntuiText toolong_txt = {
   0,1,JAM1,12,10,NULL,(UBYTE *)
"Too many characters in Key; Please Shorten",NULL
   };

UBYTE nomsg[] = {"Cancel"};
struct IntuiText no_txt = {
   0,1,JAM1,AUTOLEFTEDGE,AUTOTOPEDGE,NULL,(UBYTE *)&nomsg[0],NULL
   };

UBYTE yesmsg[] = {"Exit"};
struct IntuiText yes_txt = {
   0,1,JAM1,AUTOLEFTEDGE,AUTOTOPEDGE,NULL,(UBYTE *)&yesmsg[0],NULL
   };

UBYTE exmsg[] = {"You are exiting without saving the keymap!!"};
struct IntuiText auto_txt = {
   0,1,JAM1,8,10,NULL,(UBYTE *)&exmsg[0],NULL
   };

UBYTE errmsg[] = {"File access error. Load/Save failed!"};
struct IntuiText err_txt = {
   0,1,JAM1,8,10,NULL,(UBYTE *)&errmsg[0],NULL
   };

UBYTE ayesmsg[] = {"Load"};
struct IntuiText ayes_txt = {
   0,1,JAM1,AUTOLEFTEDGE,AUTOTOPEDGE,NULL,(UBYTE *)&ayesmsg[0],NULL
   };

UBYTE ldmsg[] = {"You have not saved your changes!!"};
struct IntuiText ald_txt = {
   0,1,JAM1,8,10,NULL,(UBYTE *)&ldmsg[0],NULL
   };

UBYTE kstr[8][128];

struct IntuiText dstr_txt[8] = {
   {
   0,1,JAM1,8,12,NULL,(UBYTE *)&kstr[0][0],&dstr_txt[1]
   },

   {
   0,1,JAM1,8,23,NULL,(UBYTE *)&kstr[1][0],&dstr_txt[2]
   },

   {
   0,1,JAM1,8,34,NULL,(UBYTE *)&kstr[2][0],&dstr_txt[3]
   },

   {
   0,1,JAM1,8,45,NULL,(UBYTE *)&kstr[3][0],&dstr_txt[4]
   },

   {
   0,1,JAM1,8,56,NULL,(UBYTE *)&kstr[4][0],&dstr_txt[5]
   },

   {
   0,1,JAM1,8,67,NULL,(UBYTE *)&kstr[5][0],&dstr_txt[6]
   },

   {
   0,1,JAM1,8,78,NULL,(UBYTE *)&kstr[6][0],&dstr_txt[7]
   },

   {
   0,1,JAM1,8,89,NULL,(UBYTE *)&kstr[7][0],NULL
   }
};

UBYTE dstr_msg[] = {"Current definitions of             " };
struct IntuiText dstr = {
   0,1,JAM1,8,3,NULL,(UBYTE *)&dstr_msg[0],&dstr_txt[0] };

/***************************************************************************
 *  This is for the menu.
 */

#define CRED_IT 4

UBYTE crtxt[] = { "Hoopla Department!" };

struct IntuiText credit_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&crtxt,NULL
   };

struct MenuItem credit_item = {
   NULL,
   0,44,300,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   NULL,
   (APTR)&credit_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

/*-----------------------------------------------------*/
/*          Sub menu #2                                */

#define EXIT_NO 1

UBYTE exit_txt[] = { "Exit without setting the map " };

struct IntuiText exit_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&exit_txt,NULL
   };

struct MenuItem exit_item = {
   NULL,
   290,13,250,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   NULL,
   (APTR)&exit_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

#define EXIT_SET 0

UBYTE sv_st_txt[] = { "Exit & set this keymap " };

struct IntuiText sv_st_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&sv_st_txt,NULL
   };

struct MenuItem sv_st_item = {
   &exit_item,
   290,2,250,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   NULL,
   (APTR)&sv_st_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

#define EXIT_OPT 3

UBYTE qtxt[] = { "End keymap editing " };

struct IntuiText quit_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&qtxt,NULL
   };

struct MenuItem quit_item = {
   &credit_item,
   0,33,300,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   NULL,
   (APTR)&quit_item_text,
   NULL,
   NULL,
   &sv_st_item,
   NULL    };

#define SAVE_IT 2

UBYTE savetxt[] = { "Save a keymap to the disk " };

struct IntuiText save_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&savetxt,NULL
   };

struct MenuItem save_item = {
   &quit_item,
   0,22,300,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   NULL,
   (APTR)&save_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

#define LOAD_IT 1

UBYTE loadtxt[] = { "Load a keymap from the disk " };

struct IntuiText load_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&loadtxt,NULL
   };

struct MenuItem load_item = {
   &save_item,
   0,11,300,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   1L,
   (APTR)&load_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

#define CHANGE 1

UBYTE change_txt[] = { "   Change the keys in the map" };

struct IntuiText change_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&change_txt,NULL
   };

struct MenuItem change_item = {
   NULL,
   290,13,250,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | CHECKED,
   1L,
   (APTR)&change_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

#define VIEW_MODE 0

UBYTE view_txt[] = { "   View the keys in the keymap" };

struct IntuiText view_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&view_txt,NULL
   };

struct MenuItem view_item = {
   &change_item,
   290,2,250,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
   0xFFFEL,
   (APTR)&view_item_text,
   NULL,
   NULL,
   NULL,
   NULL    };

#define MODE_IT 0

UBYTE modetxt[] = { "Select View or Change Mode" };

struct IntuiText mode_item_text = {
   0,1,JAM1,3,2,NULL,(UBYTE *)&modetxt,NULL
   };

struct MenuItem mode_item = {
   &load_item,
   0,0,300,11,
   ITEMTEXT | ITEMENABLED | HIGHCOMP,
   NULL,
   (APTR)&mode_item_text,
   NULL,
   NULL,
   &view_item,
   NULL    };

UBYTE menuname[] = { "SetKey: Main Control" };

struct Menu menu = {
   NULL,
   10,NULL,300,NULL,
   MENUENABLED,
   (BYTE *)&menuname[0],
   (struct MenuItem *)&mode_item
   };

/***************************************************************************
          The new window definition
*/

struct NewWindow nw = {
   0,0,640,200, /* position */
   -1,-1,       /* pens     */
   CLOSEWINDOW | MENUPICK | GADGETDOWN | RAWKEY | REQSET | GADGETUP,
   WINDOWCLOSE | NOCAREREFRESH | ACTIVATE | WINDOWDEPTH,
   &gadget[0],           /* gadet pointer */
   NULL,        /* user check    */
   (unsigned char *)" SetKey V2.0 Keymap Editor Deluxe ",
   NULL,   /* screen */
   NULL,   /* superbitmap */
   10,10,640,200, /* minmax size */
   WBENCHSCREEN
   };

struct Window *w;
extern struct Window *OpenWindow();

/*   The "key" gadgets are:

     No.      Key associated.
    ====================================
    0        escape
    1-10     function keys (1-10)
    11       delete
    12       tilde
    13-22    1-0 keys
    23       minus
    24       equal
    25       backslash
    26       backspace
    27-29    top row keypad
    30       tab
    31-40    top row alphabet keys
    41       left bracket
    42       right bracket
    43       help key
    44-46    row 2 keypad
   *47       control
   *48       caps lock
    49-57    middle row alphabet keys
    58       semicolon
    59       quote key
    60       return
    61       up arrow
    62-64    row 3 keypad
   *65       left shift
    66-72    bottom row alphabet keys
    73       comma
    74       period
    75       slash
   *76       right shift
    77       left arrow
    78       right arrow
    79       keypad zero
    80       keypad period
   *81       left alt
    82       left Amiga
    83       spacebar
    84       right Amiga
   *85       right alt
    86       down arrow
    87       keypad minus
    88       enter
    ====================================
    * indicates qualifier key - 47,48,65,76,81,85

*/


SHORT l_edge[90] = {
   /* gadgets 0-11   */
   9,52,93,133,175,214,269,310,350,392,431,481,
   /* gadgets 12-29  */
   9,49,81,112,144,175,208,238,270,302,333,364,396,427,459,537,570,601,
   /* gadgets 30-46  */
   9,61,93,124,156,187,219,250,282,314,345,376,409,481,538,570,601,
   /* gadgets 47-64  */
   9,40,71,103,134,166,198,229,261,292,323,355,387,417,481,537,570,601,
   /* gadgets 65-80  */
   9,88,118,150,181,213,244,276,307,339,370,402,465,496,537,601,
   /* gadgets 81-93  */
   47,88,128,360,402,481,536,570,440 };

SHORT t_edge[90] = {
   0,0,0,0,0,0,0,0,0,0,0,0,
   12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
   24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
   36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,
   48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,
   60,60,60,60,60,60,60,60,24 };

SHORT width[90] = {
   30,40,39,41,38,38,40,39,41,38,38,30,
   39,31,30,31,30,32,29,31,30,30,30,31,30,31,52,32,30,29,
   51,31,29,31,30,31,30,31,31,30,30,32,29,30,32,30,29,
   30,30,31,30,31,31,30,31,30,30,31,31,29,63,30,32,30,29,
   78,29,31,30,31,30,31,30,31,30,31,62,30,29,63,29,
   40,39,231,40,39,30,33,60,40 };

SHORT g_to_key[90] = {
   0x45,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x46,
   0,1,2,3,4,5,6,7,8,9,10,11,12,13,0x41,0x3d,0x3e,0x3f,
   0x42,16,17,18,19,20,21,22,23,24,25,26,27,0x5f,0x2d,0x2e,0x2f,
   0x63,0x62,32,33,34,35,36,37,38,39,40,41,42,0x44,0x4c,0x1d,0x1e,0x1f,
   96,49,50,51,52,53,54,55,56,57,58,97,0x4f,0x4e,15,0x3c,
   0x64,0x66,64,0x67,0x65,0x4d,0x4a,0x43,0x44 };

SHORT key_to_g[] = {
   12,13,14,15,16,17,18,19,20,21,22,23,24,25,99,79,31,32,
   33,34,35,36,37,38,39,40,41,42,99,62,63,64,49,50,51,52,
   53,54,55,56,57,58,59,99,99,44,45,46,99,66,67,68,69,70,
   71,72,73,74,75,99,80,27,28,29,83,26,30,88,60,0,11,99,99,99,87,
   99,61,86,78,77,1,2,3,4,5,6,7,8,9,10,99,99,99,99,99,43,
   65,76,48,47,81,85,82,84
   };
