/* $Revision Header *** Header built automatically - do not edit! ***********
 *
 *	(C) Copyright 1991 by Torsten Jürgeleit
 *
 *	Name .....: edit1.c
 *	Created ..: Sunday 22-Dec-91 21:22:18
 *	Revision .: 0
 *
 *	Date        Author                 Comment
 *	=========   ====================   ====================
 *	22-Dec-91   Torsten Jürgeleit      Created this file!
 *
 ****************************************************************************
 *
 *	Edit ISUP objects - part 1
 *
 * $Revision Header ********************************************************/

	/* Includes */

#include "includes.h"
#include "defines.h"
#include "imports.h"
#include "protos.h"

	/* Defines for edit gadgets */

#define EDIT_GADGET_XOFFSET	(EDIT_GADGET4_LEFT_EDGE - EDIT_GADGET1_LEFT_EDGE - 3 * EDIT_GADGET1_WIDTH) / 3

#define EDIT_GADGET1_TYPE		GADGET_DATA_TYPE_BUTTON
#define EDIT_GADGET1_FLAGS		GADGET_DATA_FLAG_HOTKEY
#define EDIT_GADGET1_LEFT_EDGE		10
#define EDIT_GADGET1_TOP_EDGE		(EDITOR_WINDOW_HEIGHT - EDIT_GADGET1_HEIGHT - 5)
#define EDIT_GADGET1_WIDTH		((7 + 2) * 8)
#define EDIT_GADGET1_HEIGHT		15
#define EDIT_GADGET1_TEXT		"_Ok"
#define EDIT_GADGET1_TEXT_ATTR		&topaz80_attr

#define EDIT_GADGET2_TYPE		GADGET_DATA_TYPE_BUTTON
#define EDIT_GADGET2_FLAGS		GADGET_DATA_FLAG_HOTKEY
#define EDIT_GADGET2_LEFT_EDGE		(EDIT_GADGET1_LEFT_EDGE + EDIT_GADGET1_WIDTH + EDIT_GADGET_XOFFSET)
#define EDIT_GADGET2_TOP_EDGE		(EDITOR_WINDOW_HEIGHT - EDIT_GADGET2_HEIGHT - 5)
#define EDIT_GADGET2_WIDTH		EDIT_GADGET1_WIDTH
#define EDIT_GADGET2_HEIGHT		EDIT_GADGET1_HEIGHT
#define EDIT_GADGET2_TEXT		"_Default"
#define EDIT_GADGET2_TEXT_ATTR		&topaz80_attr

#define EDIT_GADGET3_TYPE		GADGET_DATA_TYPE_BUTTON
#define EDIT_GADGET3_FLAGS		GADGET_DATA_FLAG_HOTKEY
#define EDIT_GADGET3_LEFT_EDGE		(EDIT_GADGET4_LEFT_EDGE - EDIT_GADGET3_WIDTH - EDIT_GADGET_XOFFSET)
#define EDIT_GADGET3_TOP_EDGE		(EDITOR_WINDOW_HEIGHT - EDIT_GADGET3_HEIGHT - 5)
#define EDIT_GADGET3_WIDTH		EDIT_GADGET1_WIDTH
#define EDIT_GADGET3_HEIGHT		EDIT_GADGET1_HEIGHT
#define EDIT_GADGET3_TEXT		"S_witch"
#define EDIT_GADGET3_TEXT_ATTR		&topaz80_attr

#define EDIT_GADGET4_TYPE		GADGET_DATA_TYPE_BUTTON
#define EDIT_GADGET4_FLAGS		GADGET_DATA_FLAG_HOTKEY
#define EDIT_GADGET4_LEFT_EDGE		(EDITOR_WINDOW_WIDTH - EDIT_GADGET4_WIDTH - 10)
#define EDIT_GADGET4_TOP_EDGE		(EDITOR_WINDOW_HEIGHT - EDIT_GADGET4_HEIGHT - 5)
#define EDIT_GADGET4_WIDTH		EDIT_GADGET1_WIDTH
#define EDIT_GADGET4_HEIGHT		EDIT_GADGET1_HEIGHT
#define EDIT_GADGET4_TEXT		"_Cancel"
#define EDIT_GADGET4_TEXT_ATTR		&topaz80_attr

	/* Statics for edit gadgets */

STATIC struct GadgetData  edit_gadget_data[] = {
   {
	EDIT_GADGET1_TYPE,		/* gd_Type */
	EDIT_GADGET1_FLAGS,		/* gd_Flags */
	EDIT_GADGET1_LEFT_EDGE,		/* gd_LeftEdge */
	EDIT_GADGET1_TOP_EDGE,		/* gd_TopEdge */
	EDIT_GADGET1_WIDTH,		/* gd_Width */
	EDIT_GADGET1_HEIGHT,		/* gd_Height */
	EDIT_GADGET1_TEXT,		/* *gd_Text */
	EDIT_GADGET1_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	EDIT_GADGET2_TYPE,		/* gd_Type */
	EDIT_GADGET2_FLAGS,		/* gd_Flags */
	EDIT_GADGET2_LEFT_EDGE,		/* gd_LeftEdge */
	EDIT_GADGET2_TOP_EDGE,		/* gd_TopEdge */
	EDIT_GADGET2_WIDTH,		/* gd_Width */
	EDIT_GADGET2_HEIGHT,		/* gd_Height */
	EDIT_GADGET2_TEXT,		/* *gd_Text */
	EDIT_GADGET2_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	EDIT_GADGET3_TYPE,		/* gd_Type */
	EDIT_GADGET3_FLAGS,		/* gd_Flags */
	EDIT_GADGET3_LEFT_EDGE,		/* gd_LeftEdge */
	EDIT_GADGET3_TOP_EDGE,		/* gd_TopEdge */
	EDIT_GADGET3_WIDTH,		/* gd_Width */
	EDIT_GADGET3_HEIGHT,		/* gd_Height */
	EDIT_GADGET3_TEXT,		/* *gd_Text */
	EDIT_GADGET3_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	EDIT_GADGET4_TYPE,		/* gd_Type */
	EDIT_GADGET4_FLAGS,		/* gd_Flags */
	EDIT_GADGET4_LEFT_EDGE,		/* gd_LeftEdge */
	EDIT_GADGET4_TOP_EDGE,		/* gd_TopEdge */
	EDIT_GADGET4_WIDTH,		/* gd_Width */
	EDIT_GADGET4_HEIGHT,		/* gd_Height */
	EDIT_GADGET4_TEXT,		/* *gd_Text */
	EDIT_GADGET4_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	INTUISUP_DATA_END		/* mark end of gadget data array */
   }
};
	/* Defines for border data */

#define BORDER_GADGET1_TYPE		GADGET_DATA_TYPE_STRING
#define BORDER_GADGET1_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define BORDER_GADGET1_LEFT_EDGE	(180 + (4 + 1) * 8)
#define BORDER_GADGET1_TOP_EDGE		30
#define BORDER_GADGET1_WIDTH		100
#define BORDER_GADGET1_HEIGHT		12
#define BORDER_GADGET1_TEXT		"_Name"
#define BORDER_GADGET1_TEXT_ATTR	&topaz80_attr
#define BORDER_GADGET1_INPUT_LEN	MAX_TEMPLATE_NAME_LEN
#define BORDER_GADGET1_INPUT_ACTIVATE	((ULONG)BORDER_GADGET_NAME << 16 | BORDER_GADGET_NAME)
#define BORDER_GADGET1_INPUT_DEFAULT	NULL

#define BORDER_GADGET2_TYPE		GADGET_DATA_TYPE_CYCLE
#define BORDER_GADGET2_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT)
#define BORDER_GADGET2_TEXT		"_Type"
#define BORDER_GADGET2_LEFT_EDGE	BORDER_GADGET1_LEFT_EDGE
#define BORDER_GADGET2_TOP_EDGE		(BORDER_GADGET1_TOP_EDGE + BORDER_GADGET1_HEIGHT + 10)
#define BORDER_GADGET2_WIDTH		(20 + (11 + 2) * 8)
#define BORDER_GADGET2_HEIGHT		15
#define BORDER_GADGET2_TEXT_ATTR	&topaz80_attr
#define BORDER_GADGET2_ACTIVE		0
#define BORDER_GADGET2_TEXT_ARRAY	&border_type_text_array[0]

	/* Statics for edit gadgets */

STATIC BYTE *border_type_text_array[] = {
   "Box 1 - Out", "Box 1 - In", "Box 2 - Out", "Box 2 - In", NULL
};
STATIC struct GadgetData  border_gadget_data[] = {
   {
	BORDER_GADGET1_TYPE,		/* gd_Type */
	BORDER_GADGET1_FLAGS,		/* gd_Flags */
	BORDER_GADGET1_LEFT_EDGE,	/* gd_LeftEdge */
	BORDER_GADGET1_TOP_EDGE,	/* gd_TopEdge */
	BORDER_GADGET1_WIDTH,		/* gd_Width */
	BORDER_GADGET1_HEIGHT,		/* gd_Height */
	BORDER_GADGET1_TEXT,		/* *gd_Text */
	BORDER_GADGET1_TEXT_ATTR,	/* *gd_TextAttr */
	{
	BORDER_GADGET1_INPUT_LEN,	/* gd_InputLen */
	BORDER_GADGET1_INPUT_ACTIVATE,	/* gd_InputActivate */
	BORDER_GADGET1_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	BORDER_GADGET2_TYPE,		/* gd_Type */
	BORDER_GADGET2_FLAGS,		/* gd_Flags */
	BORDER_GADGET2_LEFT_EDGE,	/* gd_LeftEdge */
	BORDER_GADGET2_TOP_EDGE,	/* gd_TopEdge */
	BORDER_GADGET2_WIDTH,		/* gd_Width */
	BORDER_GADGET2_HEIGHT,		/* gd_Height */
	BORDER_GADGET2_TEXT,		/* *gd_Text */
	BORDER_GADGET2_TEXT_ATTR,	/* *gd_TextAttr */
	{
	0,				/* gd_CyclePad */
	BORDER_GADGET2_ACTIVE,		/* gd_CycleActive */
	BORDER_GADGET2_TEXT_ARRAY	/* *gd_CycleTextArray */
	}
   }, {
	INTUISUP_DATA_END		/* mark end of gadget data array */
   }
};
	/* Defines for text data */

#define TEXT_GADGET1_TYPE		GADGET_DATA_TYPE_STRING
#define TEXT_GADGET1_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define TEXT_GADGET1_LEFT_EDGE		(50 + (4 + 1) * 8)
#define TEXT_GADGET1_TOP_EDGE		20
#define TEXT_GADGET1_WIDTH		100
#define TEXT_GADGET1_HEIGHT		12
#define TEXT_GADGET1_TEXT		"_Name"
#define TEXT_GADGET1_TEXT_ATTR		&topaz80_attr
#define TEXT_GADGET1_INPUT_LEN		MAX_TEMPLATE_NAME_LEN
#define TEXT_GADGET1_INPUT_ACTIVATE	((ULONG)TEXT_GADGET_TEXT << 16 | TEXT_GADGET_FONT)
#define TEXT_GADGET1_INPUT_DEFAULT	NULL

#define TEXT_GADGET2_TYPE		GADGET_DATA_TYPE_STRING
#define TEXT_GADGET2_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define TEXT_GADGET2_LEFT_EDGE		TEXT_GADGET1_LEFT_EDGE
#define TEXT_GADGET2_TOP_EDGE		(TEXT_GADGET1_TOP_EDGE + TEXT_GADGET1_HEIGHT + 4)
#define TEXT_GADGET2_WIDTH		TEXT_GADGET1_WIDTH
#define TEXT_GADGET2_HEIGHT		TEXT_GADGET1_HEIGHT
#define TEXT_GADGET2_TEXT		"Te_xt"
#define TEXT_GADGET2_TEXT_ATTR		&topaz80_attr
#define TEXT_GADGET2_INPUT_LEN		MAX_TEXT_LEN
#define TEXT_GADGET2_INPUT_ACTIVATE	((ULONG)TEXT_GADGET_FONT << 16 | TEXT_GADGET_NAME)
#define TEXT_GADGET2_INPUT_DEFAULT	NULL

#define TEXT_GADGET3_TYPE		GADGET_DATA_TYPE_STRING
#define TEXT_GADGET3_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define TEXT_GADGET3_LEFT_EDGE		TEXT_GADGET1_LEFT_EDGE
#define TEXT_GADGET3_TOP_EDGE		(TEXT_GADGET2_TOP_EDGE + TEXT_GADGET2_HEIGHT + 4)
#define TEXT_GADGET3_WIDTH		TEXT_GADGET1_WIDTH
#define TEXT_GADGET3_HEIGHT		TEXT_GADGET1_HEIGHT
#define TEXT_GADGET3_TEXT		"_Font"
#define TEXT_GADGET3_TEXT_ATTR		&topaz80_attr
#define TEXT_GADGET3_INPUT_LEN		MAX_TEXT_LEN
#define TEXT_GADGET3_INPUT_ACTIVATE	((ULONG)TEXT_GADGET_NAME << 16 | TEXT_GADGET_TEXT)
#define TEXT_GADGET3_INPUT_DEFAULT	NULL

#define TEXT_GADGET4_TYPE		GADGET_DATA_TYPE_COUNT
#define TEXT_GADGET4_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT)
#define TEXT_GADGET4_LEFT_EDGE		(TEXT_GADGET5_LEFT_EDGE + TEXT_GADGET5_WIDTH - TEXT_GADGET4_WIDTH)
#define TEXT_GADGET4_TOP_EDGE		TEXT_GADGET3_TOP_EDGE
#define TEXT_GADGET4_WIDTH		60
#define TEXT_GADGET4_HEIGHT		12
#define TEXT_GADGET4_TEXT		"_Size"
#define TEXT_GADGET4_TEXT_ATTR		&topaz80_attr
#define TEXT_GADGET4_COUNT_MIN		5
#define TEXT_GADGET4_COUNT_MAX		200
#define TEXT_GADGET4_COUNT_VALUE	NULL

#define TEXT_GADGET5_TYPE		GADGET_DATA_TYPE_CYCLE
#define TEXT_GADGET5_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT)
#define TEXT_GADGET5_TEXT		"_Type"
#define TEXT_GADGET5_LEFT_EDGE		TEXT_GADGET1_LEFT_EDGE
#define TEXT_GADGET5_TOP_EDGE		(TEXT_GADGET3_TOP_EDGE + TEXT_GADGET3_HEIGHT + 4)
#define TEXT_GADGET5_WIDTH		(20 + (23 + 2) * 8)
#define TEXT_GADGET5_HEIGHT		15
#define TEXT_GADGET5_TEXT_ATTR		&topaz80_attr
#define TEXT_GADGET5_ACTIVE		0
#define TEXT_GADGET5_TEXT_ARRAY		&text_type_text_array[0]

#define TEXT_GADGET6_TYPE		GADGET_DATA_TYPE_CHECK
#define TEXT_GADGET6_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define TEXT_GADGET6_TEXT		"_Bold"
#define TEXT_GADGET6_LEFT_EDGE		(TEXT_GADGET5_LEFT_EDGE + TEXT_GADGET5_WIDTH + 50)
#define TEXT_GADGET6_TOP_EDGE		TEXT_GADGET1_TOP_EDGE
#define TEXT_GADGET6_WIDTH		0
#define TEXT_GADGET6_HEIGHT		0
#define TEXT_GADGET6_TEXT_ATTR		&topaz80_attr

#define TEXT_GADGET7_TYPE		GADGET_DATA_TYPE_CHECK
#define TEXT_GADGET7_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define TEXT_GADGET7_TEXT		"_Italic"
#define TEXT_GADGET7_LEFT_EDGE		TEXT_GADGET6_LEFT_EDGE
#define TEXT_GADGET7_TOP_EDGE		(TEXT_GADGET6_TOP_EDGE + 13)
#define TEXT_GADGET7_WIDTH		0
#define TEXT_GADGET7_HEIGHT		0
#define TEXT_GADGET7_TEXT_ATTR		&topaz80_attr

#define TEXT_GADGET8_TYPE		GADGET_DATA_TYPE_CHECK
#define TEXT_GADGET8_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define TEXT_GADGET8_TEXT		"_Underline"
#define TEXT_GADGET8_LEFT_EDGE		TEXT_GADGET6_LEFT_EDGE
#define TEXT_GADGET8_TOP_EDGE		(TEXT_GADGET7_TOP_EDGE + 13)
#define TEXT_GADGET8_WIDTH		0
#define TEXT_GADGET8_HEIGHT		0
#define TEXT_GADGET8_TEXT_ATTR		&topaz80_attr

#define TEXT_GADGET9_TYPE		GADGET_DATA_TYPE_CHECK
#define TEXT_GADGET9_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define TEXT_GADGET9_TEXT		"Color_2"
#define TEXT_GADGET9_LEFT_EDGE		TEXT_GADGET6_LEFT_EDGE
#define TEXT_GADGET9_TOP_EDGE		(TEXT_GADGET8_TOP_EDGE + 13)
#define TEXT_GADGET9_WIDTH		0
#define TEXT_GADGET9_HEIGHT		0
#define TEXT_GADGET9_TEXT_ATTR		&topaz80_attr

#define TEXT_GADGET10_TYPE		GADGET_DATA_TYPE_CHECK
#define TEXT_GADGET10_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define TEXT_GADGET10_TEXT		"Co_mplement"
#define TEXT_GADGET10_LEFT_EDGE		TEXT_GADGET6_LEFT_EDGE
#define TEXT_GADGET10_TOP_EDGE		(TEXT_GADGET9_TOP_EDGE + 13)
#define TEXT_GADGET10_WIDTH		0
#define TEXT_GADGET10_HEIGHT		0
#define TEXT_GADGET10_TEXT_ATTR		&topaz80_attr

	/* Statics for edit gadgets */

STATIC BYTE *text_type_text_array[] = {
   "Text", "Unsigned decimal number", "Signed decimal number", "Hex number",
   "Binary number", NULL
};
struct GadgetData  text_gadget_data[] = {
   {
	TEXT_GADGET1_TYPE,		/* gd_Type */
	TEXT_GADGET1_FLAGS,		/* gd_Flags */
	TEXT_GADGET1_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET1_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET1_WIDTH,		/* gd_Width */
	TEXT_GADGET1_HEIGHT,		/* gd_Height */
	TEXT_GADGET1_TEXT,		/* *gd_Text */
	TEXT_GADGET1_TEXT_ATTR,		/* *gd_TextAttr */
	{
	TEXT_GADGET1_INPUT_LEN,		/* gd_InputLen */
	TEXT_GADGET1_INPUT_ACTIVATE,	/* gd_InputActivate */
	TEXT_GADGET1_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	TEXT_GADGET2_TYPE,		/* gd_Type */
	TEXT_GADGET2_FLAGS,		/* gd_Flags */
	TEXT_GADGET2_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET2_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET2_WIDTH,		/* gd_Width */
	TEXT_GADGET2_HEIGHT,		/* gd_Height */
	TEXT_GADGET2_TEXT,		/* *gd_Text */
	TEXT_GADGET2_TEXT_ATTR,		/* *gd_TextAttr */
	{
	TEXT_GADGET2_INPUT_LEN,		/* gd_InputLen */
	TEXT_GADGET2_INPUT_ACTIVATE,	/* gd_InputActivate */
	TEXT_GADGET2_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	TEXT_GADGET3_TYPE,		/* gd_Type */
	TEXT_GADGET3_FLAGS,		/* gd_Flags */
	TEXT_GADGET3_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET3_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET3_WIDTH,		/* gd_Width */
	TEXT_GADGET3_HEIGHT,		/* gd_Height */
	TEXT_GADGET3_TEXT,		/* *gd_Text */
	TEXT_GADGET3_TEXT_ATTR,		/* *gd_TextAttr */
	{
	TEXT_GADGET3_INPUT_LEN,		/* gd_InputLen */
	TEXT_GADGET3_INPUT_ACTIVATE,	/* gd_InputActivate */
	TEXT_GADGET3_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	TEXT_GADGET4_TYPE,		/* gd_Type */
	TEXT_GADGET4_FLAGS,		/* gd_Flags */
	TEXT_GADGET4_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET4_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET4_WIDTH,		/* gd_Width */
	TEXT_GADGET4_HEIGHT,		/* gd_Height */
	TEXT_GADGET4_TEXT,		/* *gd_Text */
	TEXT_GADGET4_TEXT_ATTR,		/* *gd_TextAttr */
	{
	TEXT_GADGET4_COUNT_MIN,		/* gd_CountMin */
	TEXT_GADGET4_COUNT_MAX,		/* gd_CountMax */
	TEXT_GADGET4_COUNT_VALUE	/* gd_CountValue */
	}
   }, {
	TEXT_GADGET5_TYPE,		/* gd_Type */
	TEXT_GADGET5_FLAGS,		/* gd_Flags */
	TEXT_GADGET5_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET5_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET5_WIDTH,		/* gd_Width */
	TEXT_GADGET5_HEIGHT,		/* gd_Height */
	TEXT_GADGET5_TEXT,		/* *gd_Text */
	TEXT_GADGET5_TEXT_ATTR,		/* *gd_TextAttr */
	{
	0,				/* gd_CyclePad */
	TEXT_GADGET5_ACTIVE,		/* gd_CycleActive */
	TEXT_GADGET5_TEXT_ARRAY		/* *gd_CycleTextArray */
	}
   }, {
	TEXT_GADGET6_TYPE,		/* gd_Type */
	TEXT_GADGET6_FLAGS,		/* gd_Flags */
	TEXT_GADGET6_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET6_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET6_WIDTH,		/* gd_Width */
	TEXT_GADGET6_HEIGHT,		/* gd_Height */
	TEXT_GADGET6_TEXT,		/* *gd_Text */
	TEXT_GADGET6_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	TEXT_GADGET7_TYPE,		/* gd_Type */
	TEXT_GADGET7_FLAGS,		/* gd_Flags */
	TEXT_GADGET7_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET7_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET7_WIDTH,		/* gd_Width */
	TEXT_GADGET7_HEIGHT,		/* gd_Height */
	TEXT_GADGET7_TEXT,		/* *gd_Text */
	TEXT_GADGET7_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	TEXT_GADGET8_TYPE,		/* gd_Type */
	TEXT_GADGET8_FLAGS,		/* gd_Flags */
	TEXT_GADGET8_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET8_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET8_WIDTH,		/* gd_Width */
	TEXT_GADGET8_HEIGHT,		/* gd_Height */
	TEXT_GADGET8_TEXT,		/* *gd_Text */
	TEXT_GADGET8_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	TEXT_GADGET9_TYPE,		/* gd_Type */
	TEXT_GADGET9_FLAGS,		/* gd_Flags */
	TEXT_GADGET9_LEFT_EDGE,		/* gd_LeftEdge */
	TEXT_GADGET9_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET9_WIDTH,		/* gd_Width */
	TEXT_GADGET9_HEIGHT,		/* gd_Height */
	TEXT_GADGET9_TEXT,		/* *gd_Text */
	TEXT_GADGET9_TEXT_ATTR,		/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	TEXT_GADGET10_TYPE,		/* gd_Type */
	TEXT_GADGET10_FLAGS,		/* gd_Flags */
	TEXT_GADGET10_LEFT_EDGE,	/* gd_LeftEdge */
	TEXT_GADGET10_TOP_EDGE,		/* gd_TopEdge */
	TEXT_GADGET10_WIDTH,		/* gd_Width */
	TEXT_GADGET10_HEIGHT,		/* gd_Height */
	TEXT_GADGET10_TEXT,		/* *gd_Text */
	TEXT_GADGET10_TEXT_ATTR,	/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	INTUISUP_DATA_END		/* mark end of gadget data array */
   }
};
	/* Defines for normal gadget data */

#define NORMAL_GADGET1_TYPE		GADGET_DATA_TYPE_STRING
#define NORMAL_GADGET1_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define NORMAL_GADGET1_LEFT_EDGE	(50 + (4 + 1) * 8)
#define NORMAL_GADGET1_TOP_EDGE		20
#define NORMAL_GADGET1_WIDTH		100
#define NORMAL_GADGET1_HEIGHT		12
#define NORMAL_GADGET1_TEXT		"_Name"
#define NORMAL_GADGET1_TEXT_ATTR	&topaz80_attr
#define NORMAL_GADGET1_INPUT_LEN	MAX_TEMPLATE_NAME_LEN
#define NORMAL_GADGET1_INPUT_ACTIVATE	((ULONG)NORMAL_GADGET_TEXT << 16 | NORMAL_GADGET_FONT)
#define NORMAL_GADGET1_INPUT_DEFAULT	NULL

#define NORMAL_GADGET2_TYPE		GADGET_DATA_TYPE_STRING
#define NORMAL_GADGET2_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define NORMAL_GADGET2_LEFT_EDGE	NORMAL_GADGET1_LEFT_EDGE
#define NORMAL_GADGET2_TOP_EDGE		(NORMAL_GADGET1_TOP_EDGE + NORMAL_GADGET1_HEIGHT + 4)
#define NORMAL_GADGET2_WIDTH		NORMAL_GADGET1_WIDTH
#define NORMAL_GADGET2_HEIGHT		NORMAL_GADGET1_HEIGHT
#define NORMAL_GADGET2_TEXT		"Te_xt"
#define NORMAL_GADGET2_TEXT_ATTR	&topaz80_attr
#define NORMAL_GADGET2_INPUT_LEN	MAX_TEXT_LEN
#define NORMAL_GADGET2_INPUT_ACTIVATE	((ULONG)NORMAL_GADGET_FONT << 16 | NORMAL_GADGET_NAME)
#define NORMAL_GADGET2_INPUT_DEFAULT	NULL

#define NORMAL_GADGET3_TYPE		GADGET_DATA_TYPE_STRING
#define NORMAL_GADGET3_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT | GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE)
#define NORMAL_GADGET3_LEFT_EDGE	NORMAL_GADGET1_LEFT_EDGE
#define NORMAL_GADGET3_TOP_EDGE		(NORMAL_GADGET2_TOP_EDGE + NORMAL_GADGET2_HEIGHT + 4)
#define NORMAL_GADGET3_WIDTH		NORMAL_GADGET1_WIDTH
#define NORMAL_GADGET3_HEIGHT		NORMAL_GADGET1_HEIGHT
#define NORMAL_GADGET3_TEXT		"_Font"
#define NORMAL_GADGET3_TEXT_ATTR	&topaz80_attr
#define NORMAL_GADGET3_INPUT_LEN	MAX_TEXT_LEN
#define NORMAL_GADGET3_INPUT_ACTIVATE	((ULONG)NORMAL_GADGET_NAME << 16 | NORMAL_GADGET_TEXT)
#define NORMAL_GADGET3_INPUT_DEFAULT	NULL

#define NORMAL_GADGET4_TYPE		GADGET_DATA_TYPE_COUNT
#define NORMAL_GADGET4_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT)
#define NORMAL_GADGET4_LEFT_EDGE	(NORMAL_GADGET5_LEFT_EDGE + NORMAL_GADGET5_WIDTH - NORMAL_GADGET4_WIDTH)
#define NORMAL_GADGET4_TOP_EDGE		NORMAL_GADGET3_TOP_EDGE
#define NORMAL_GADGET4_WIDTH		60
#define NORMAL_GADGET4_HEIGHT		12
#define NORMAL_GADGET4_TEXT		"_Size"
#define NORMAL_GADGET4_TEXT_ATTR	&topaz80_attr
#define NORMAL_GADGET4_COUNT_MIN	5
#define NORMAL_GADGET4_COUNT_MAX	200
#define NORMAL_GADGET4_COUNT_VALUE	NULL

#define NORMAL_GADGET5_TYPE		GADGET_DATA_TYPE_CYCLE
#define NORMAL_GADGET5_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_LEFT)
#define NORMAL_GADGET5_TEXT		"_Pos"
#define NORMAL_GADGET5_LEFT_EDGE	NORMAL_GADGET1_LEFT_EDGE
#define NORMAL_GADGET5_TOP_EDGE		(NORMAL_GADGET3_TOP_EDGE + NORMAL_GADGET3_HEIGHT + 4)
#define NORMAL_GADGET5_WIDTH		(20 + (23 + 2) * 8)
#define NORMAL_GADGET5_HEIGHT		15
#define NORMAL_GADGET5_TEXT_ATTR	&topaz80_attr
#define NORMAL_GADGET5_ACTIVE		0
#define NORMAL_GADGET5_TEXT_ARRAY	&normal_text_pos_text_array[0]

#define NORMAL_GADGET6_TYPE		GADGET_DATA_TYPE_CHECK
#define NORMAL_GADGET6_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define NORMAL_GADGET6_TEXT		"Dis_abled"
#define NORMAL_GADGET6_LEFT_EDGE	(NORMAL_GADGET5_LEFT_EDGE + NORMAL_GADGET5_WIDTH + 50)
#define NORMAL_GADGET6_TOP_EDGE		NORMAL_GADGET1_TOP_EDGE
#define NORMAL_GADGET6_WIDTH		0
#define NORMAL_GADGET6_HEIGHT		0
#define NORMAL_GADGET6_TEXT_ATTR	&topaz80_attr

#define NORMAL_GADGET7_TYPE		GADGET_DATA_TYPE_CHECK
#define NORMAL_GADGET7_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define NORMAL_GADGET7_TEXT		"No _Border"
#define NORMAL_GADGET7_LEFT_EDGE	NORMAL_GADGET6_LEFT_EDGE
#define NORMAL_GADGET7_TOP_EDGE		(NORMAL_GADGET6_TOP_EDGE + 13)
#define NORMAL_GADGET7_WIDTH		0
#define NORMAL_GADGET7_HEIGHT		0
#define NORMAL_GADGET7_TEXT_ATTR	&topaz80_attr

#define NORMAL_GADGET8_TYPE		GADGET_DATA_TYPE_CHECK
#define NORMAL_GADGET8_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define NORMAL_GADGET8_TEXT		"_High Comp"
#define NORMAL_GADGET8_LEFT_EDGE	NORMAL_GADGET6_LEFT_EDGE
#define NORMAL_GADGET8_TOP_EDGE		(NORMAL_GADGET7_TOP_EDGE + 13)
#define NORMAL_GADGET8_WIDTH		0
#define NORMAL_GADGET8_HEIGHT		0
#define NORMAL_GADGET8_TEXT_ATTR	&topaz80_attr

#define NORMAL_GADGET9_TYPE		GADGET_DATA_TYPE_CHECK
#define NORMAL_GADGET9_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define NORMAL_GADGET9_TEXT		"Hot _Key"
#define NORMAL_GADGET9_LEFT_EDGE	NORMAL_GADGET6_LEFT_EDGE
#define NORMAL_GADGET9_TOP_EDGE		(NORMAL_GADGET8_TOP_EDGE + 13)
#define NORMAL_GADGET9_WIDTH		0
#define NORMAL_GADGET9_HEIGHT		0
#define NORMAL_GADGET9_TEXT_ATTR	&topaz80_attr

#define NORMAL_GADGET10_TYPE		GADGET_DATA_TYPE_CHECK
#define NORMAL_GADGET10_FLAGS		(GADGET_DATA_FLAG_HOTKEY | GADGET_DATA_FLAG_TEXT_RIGHT)
#define NORMAL_GADGET10_TEXT		"Color _2"
#define NORMAL_GADGET10_LEFT_EDGE	NORMAL_GADGET6_LEFT_EDGE
#define NORMAL_GADGET10_TOP_EDGE	(NORMAL_GADGET9_TOP_EDGE + 13)
#define NORMAL_GADGET10_WIDTH		0
#define NORMAL_GADGET10_HEIGHT		0
#define NORMAL_GADGET10_TEXT_ATTR	&topaz80_attr

	/* Statics for normal gadgets */

STATIC BYTE *normal_text_pos_text_array[] = {
   "Left of Select Box", "Right of Select Box", "Above the Select Box",
   "Below the Select Box", "Inside of Select Box", NULL
};
struct GadgetData  normal_gadget_data[] = {
   {
	NORMAL_GADGET1_TYPE,		/* gd_Type */
	NORMAL_GADGET1_FLAGS,		/* gd_Flags */
	NORMAL_GADGET1_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET1_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET1_WIDTH,		/* gd_Width */
	NORMAL_GADGET1_HEIGHT,		/* gd_Height */
	NORMAL_GADGET1_TEXT,		/* *gd_Text */
	NORMAL_GADGET1_TEXT_ATTR,	/* *gd_TextAttr */
	{
	NORMAL_GADGET1_INPUT_LEN,	/* gd_InputLen */
	NORMAL_GADGET1_INPUT_ACTIVATE,	/* gd_InputActivate */
	NORMAL_GADGET1_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	NORMAL_GADGET2_TYPE,		/* gd_Type */
	NORMAL_GADGET2_FLAGS,		/* gd_Flags */
	NORMAL_GADGET2_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET2_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET2_WIDTH,		/* gd_Width */
	NORMAL_GADGET2_HEIGHT,		/* gd_Height */
	NORMAL_GADGET2_TEXT,		/* *gd_Text */
	NORMAL_GADGET2_TEXT_ATTR,	/* *gd_TextAttr */
	{
	NORMAL_GADGET2_INPUT_LEN,	/* gd_InputLen */
	NORMAL_GADGET2_INPUT_ACTIVATE,	/* gd_InputActivate */
	NORMAL_GADGET2_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	NORMAL_GADGET3_TYPE,		/* gd_Type */
	NORMAL_GADGET3_FLAGS,		/* gd_Flags */
	NORMAL_GADGET3_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET3_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET3_WIDTH,		/* gd_Width */
	NORMAL_GADGET3_HEIGHT,		/* gd_Height */
	NORMAL_GADGET3_TEXT,		/* *gd_Text */
	NORMAL_GADGET3_TEXT_ATTR,	/* *gd_TextAttr */
	{
	NORMAL_GADGET3_INPUT_LEN,	/* gd_InputLen */
	NORMAL_GADGET3_INPUT_ACTIVATE,	/* gd_InputActivate */
	NORMAL_GADGET3_INPUT_DEFAULT	/* gd_InputDefault */
	}
   }, {
	NORMAL_GADGET4_TYPE,		/* gd_Type */
	NORMAL_GADGET4_FLAGS,		/* gd_Flags */
	NORMAL_GADGET4_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET4_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET4_WIDTH,		/* gd_Width */
	NORMAL_GADGET4_HEIGHT,		/* gd_Height */
	NORMAL_GADGET4_TEXT,		/* *gd_Text */
	NORMAL_GADGET4_TEXT_ATTR,	/* *gd_TextAttr */
	{
	NORMAL_GADGET4_COUNT_MIN,	/* gd_CountMin */
	NORMAL_GADGET4_COUNT_MAX,	/* gd_CountMax */
	NORMAL_GADGET4_COUNT_VALUE	/* gd_CountValue */
	}
   }, {
	NORMAL_GADGET5_TYPE,		/* gd_Type */
	NORMAL_GADGET5_FLAGS,		/* gd_Flags */
	NORMAL_GADGET5_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET5_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET5_WIDTH,		/* gd_Width */
	NORMAL_GADGET5_HEIGHT,		/* gd_Height */
	NORMAL_GADGET5_TEXT,		/* *gd_Text */
	NORMAL_GADGET5_TEXT_ATTR,	/* *gd_TextAttr */
	{
	0,				/* gd_CyclePad */
	NORMAL_GADGET5_ACTIVE,		/* gd_CycleActive */
	NORMAL_GADGET5_TEXT_ARRAY	/* *gd_CycleTextArray */
	}
   }, {
	NORMAL_GADGET6_TYPE,		/* gd_Type */
	NORMAL_GADGET6_FLAGS,		/* gd_Flags */
	NORMAL_GADGET6_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET6_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET6_WIDTH,		/* gd_Width */
	NORMAL_GADGET6_HEIGHT,		/* gd_Height */
	NORMAL_GADGET6_TEXT,		/* *gd_Text */
	NORMAL_GADGET6_TEXT_ATTR,	/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	NORMAL_GADGET7_TYPE,		/* gd_Type */
	NORMAL_GADGET7_FLAGS,		/* gd_Flags */
	NORMAL_GADGET7_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET7_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET7_WIDTH,		/* gd_Width */
	NORMAL_GADGET7_HEIGHT,		/* gd_Height */
	NORMAL_GADGET7_TEXT,		/* *gd_Text */
	NORMAL_GADGET7_TEXT_ATTR,	/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	NORMAL_GADGET8_TYPE,		/* gd_Type */
	NORMAL_GADGET8_FLAGS,		/* gd_Flags */
	NORMAL_GADGET8_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET8_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET8_WIDTH,		/* gd_Width */
	NORMAL_GADGET8_HEIGHT,		/* gd_Height */
	NORMAL_GADGET8_TEXT,		/* *gd_Text */
	NORMAL_GADGET8_TEXT_ATTR,	/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	NORMAL_GADGET9_TYPE,		/* gd_Type */
	NORMAL_GADGET9_FLAGS,		/* gd_Flags */
	NORMAL_GADGET9_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET9_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET9_WIDTH,		/* gd_Width */
	NORMAL_GADGET9_HEIGHT,		/* gd_Height */
	NORMAL_GADGET9_TEXT,		/* *gd_Text */
	NORMAL_GADGET9_TEXT_ATTR,	/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	NORMAL_GADGET10_TYPE,		/* gd_Type */
	NORMAL_GADGET10_FLAGS,		/* gd_Flags */
	NORMAL_GADGET10_LEFT_EDGE,	/* gd_LeftEdge */
	NORMAL_GADGET10_TOP_EDGE,	/* gd_TopEdge */
	NORMAL_GADGET10_WIDTH,		/* gd_Width */
	NORMAL_GADGET10_HEIGHT,		/* gd_Height */
	NORMAL_GADGET10_TEXT,		/* *gd_Text */
	NORMAL_GADGET10_TEXT_ATTR,	/* *gd_TextAttr */
	{ 0, 0, 0 }
   }, {
	INTUISUP_DATA_END		/* mark end of gadget data array */
   }
};
	/* Edit template data */

   SHORT
edit_template_data(VOID)
{
   struct Template    *tp = selected_template;
   struct BorderData  *bd;
   struct TextData    *td;
   struct GadgetData  *gd, *gd1, *gd2, *gd3;
   APTR  gl1, gl2, gl3, gl4;
   ULONG flags;
   SHORT status;

   /* Init normal and special gadget data */
   switch (TEMPLATE_GROUP(tp)) {
      case TEMPLATE_GROUP_BORDER :
	 bd  = &tp->tp_Data.tp_BorderData;
	 gd1 = &border_gadget_data[0];
	 gd2 = NULL;
	 gd3 = NULL;

	 /* Init normal gadget data */
	 (gd1 + BORDER_GADGET_NAME)->gd_SpecialData.gd_InputData.gd_InputDefault = &tp->tp_TemplateName[0];
	 (gd1 + BORDER_GADGET_TYPE)->gd_SpecialData.gd_CycleData.gd_CycleActive  = bd->bd_Type - 1;
	 break;

      case TEMPLATE_GROUP_TEXT :
	 td    = &tp->tp_Data.tp_TextData;
	 gd1   = &text_gadget_data[0];
	 gd2   = NULL;
	 gd3   = NULL;
	 flags = td->td_Flags;

	 /* Init normal gadget data */
	 (gd1 + TEXT_GADGET_NAME)->gd_SpecialData.gd_InputData.gd_InputDefault = &tp->tp_TemplateName[0];
	 (gd1 + TEXT_GADGET_TEXT)->gd_SpecialData.gd_InputData.gd_InputDefault = td->td_Text;
	 (gd1 + TEXT_GADGET_TEXT)->gd_Flags &= ~(GADGET_DATA_FLAG_STRING_UNSIGNED_DEC | GADGET_DATA_FLAG_STRING_SIGNED_DEC | GADGET_DATA_FLAG_STRING_HEX | GADGET_DATA_FLAG_STRING_BIN);
	 switch (td->td_Type) {
	    case TEXT_DATA_TYPE_NUM_UNSIGNED_DEC :
	       (gd1 + TEXT_GADGET_TEXT)->gd_Flags |= GADGET_DATA_FLAG_STRING_UNSIGNED_DEC;
	       break;

	    case TEXT_DATA_TYPE_NUM_SIGNED_DEC :
	       (gd1 + TEXT_GADGET_TEXT)->gd_Flags |= GADGET_DATA_FLAG_STRING_SIGNED_DEC;
	       break;

	    case TEXT_DATA_TYPE_NUM_HEX :
	       (gd1 + TEXT_GADGET_TEXT)->gd_Flags |= GADGET_DATA_FLAG_STRING_HEX;
	       break;

	    case TEXT_DATA_TYPE_NUM_BIN :
	       (gd1 + TEXT_GADGET_TEXT)->gd_Flags |= GADGET_DATA_FLAG_STRING_BIN;
	       break;
	 }
Printf("(gd + TEXT_GADGET_TEXT)=$%lx   flags=$%lx\n", (gd1 + TEXT_GADGET_TEXT), (gd1 + TEXT_GADGET_TEXT)->gd_Flags);
	 (gd1 + TEXT_GADGET_FONT)->gd_SpecialData.gd_InputData.gd_InputDefault        = (BYTE *)td->td_TextAttr->ta_Name;
	 (gd1 + TEXT_GADGET_SIZE)->gd_SpecialData.gd_CountData.gd_CountValue          = td->td_TextAttr->ta_YSize;
	 (gd1 + TEXT_GADGET_TYPE)->gd_SpecialData.gd_CycleData.gd_CycleActive         = td->td_Type - 1;
	 (gd1 + TEXT_GADGET_BOLD)->gd_SpecialData.gd_CheckData.gd_CheckSelected       = (flags & TEXT_DATA_FLAG_BOLD ? 1 : 0);
	 (gd1 + TEXT_GADGET_ITALIC)->gd_SpecialData.gd_CheckData.gd_CheckSelected     = (flags & TEXT_DATA_FLAG_ITALIC ? 1 : 0);
	 (gd1 + TEXT_GADGET_UNDERLINED)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (flags & TEXT_DATA_FLAG_UNDERLINED ? 1 : 0);
	 (gd1 + TEXT_GADGET_COLOR2)->gd_SpecialData.gd_CheckData.gd_CheckSelected     = (flags & TEXT_DATA_FLAG_COLOR2 ? 1 : 0);
	 (gd1 + TEXT_GADGET_COMPLEMENT)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (flags & TEXT_DATA_FLAG_COMPLEMENT ? 1 : 0);
	 break;

      case TEMPLATE_GROUP_GADGET :
	 gd    = &tp->tp_Data.tp_GadgetData;
	 gd1   = &normal_gadget_data[0];
	 flags = gd->gd_Flags;

	 /* Init normal gadget data */
	 (gd1 + NORMAL_GADGET_NAME)->gd_SpecialData.gd_InputData.gd_InputDefault = &tp->tp_TemplateName[0];
	 (gd1 + NORMAL_GADGET_TEXT)->gd_SpecialData.gd_InputData.gd_InputDefault = gd->gd_Text;
	 (gd1 + NORMAL_GADGET_FONT)->gd_SpecialData.gd_InputData.gd_InputDefault = (BYTE *)gd->gd_TextAttr->ta_Name;
	 (gd1 + NORMAL_GADGET_SIZE)->gd_SpecialData.gd_CountData.gd_CountValue   = gd->gd_TextAttr->ta_YSize;
	 switch (GADGET_TEXT_POS_MASK(gd->gd_Flags)) {
	    case GADGET_DATA_FLAG_TEXT_LEFT :
	       (gd1 + NORMAL_GADGET_POS)->gd_SpecialData.gd_CycleData.gd_CycleActive = TEXT_POS_LEFT;
	       break;

	    case GADGET_DATA_FLAG_TEXT_RIGHT :
	       (gd1 + NORMAL_GADGET_POS)->gd_SpecialData.gd_CycleData.gd_CycleActive = TEXT_POS_RIGHT;
	       break;

	    case GADGET_DATA_FLAG_TEXT_ABOVE :
	       (gd1 + NORMAL_GADGET_POS)->gd_SpecialData.gd_CycleData.gd_CycleActive = TEXT_POS_ABOVE;
	       break;

	    case GADGET_DATA_FLAG_TEXT_BELOW :
	       (gd1 + NORMAL_GADGET_POS)->gd_SpecialData.gd_CycleData.gd_CycleActive = TEXT_POS_BELOW;
	       break;

	    default :
	       (gd1 + NORMAL_GADGET_POS)->gd_SpecialData.gd_CycleData.gd_CycleActive = TEXT_POS_INSIDE;
	       break;
	 }
	 (gd1 + NORMAL_GADGET_DISABLED)->gd_SpecialData.gd_CheckData.gd_CheckSelected  = (flags & GADGET_DATA_FLAG_DISABLED ? 1 : 0);
	 (gd1 + NORMAL_GADGET_NO_BORDER)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (flags & GADGET_DATA_FLAG_NO_BORDER ? 1 : 0);
	 (gd1 + NORMAL_GADGET_HIGHCOMP)->gd_SpecialData.gd_CheckData.gd_CheckSelected  = (flags & GADGET_DATA_FLAG_HIGH_COMP ? 1 : 0);
	 (gd1 + NORMAL_GADGET_HOTKEY)->gd_SpecialData.gd_CheckData.gd_CheckSelected    = (flags & GADGET_DATA_FLAG_HOTKEY ? 1 : 0);
	 (gd1 + NORMAL_GADGET_COLOR2)->gd_SpecialData.gd_CheckData.gd_CheckSelected    = (flags & GADGET_DATA_FLAG_TEXT_COLOR2 ? 1 : 0);
	 
	 /* Init special gadget data */
	 switch (gd->gd_Type) {
	    case GADGET_DATA_TYPE_BUTTON :
	    case GADGET_DATA_TYPE_CHECK :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_MX :
	       gd2 = &list_gadget_data[0];
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_STRING :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_INTEGER :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_SLIDER :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_SCROLLER :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_CYCLE :
	       gd2 = &list_gadget_data[0];
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_COUNT :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_LISTVIEW :
	       gd2 = &list_gadget_data[0];
	       gd3 = NULL;
	       break;

	    case GADGET_DATA_TYPE_PALETTE :
	       gd2 = NULL;
	       gd3 = NULL;
	       break;
	 }
	 break;
   }

   /* If special gadget data needed then enable 'SWITCH' gadget */
   if (gd2 || gd3) {
      edit_gadget_data[EDIT_GADGET_SWITCH].gd_Flags &= ~GADGET_DATA_FLAG_DISABLED;
      gl2 = NULL;
      gl3 = NULL;
   } else {
      edit_gadget_data[EDIT_GADGET_SWITCH].gd_Flags |= GADGET_DATA_FLAG_DISABLED;
   }

   /* Create gadget lists */
   if (!(gl1 = ICreateGadgets(eri, gd1, 0, 0, NULL))) {
      status = EDITOR_ERROR_OUT_OF_MEM;
   } else {
      if (gd2 && !(gl2 = ICreateGadgets(eri, gd2, 0, 0, NULL))) {
	 status = EDITOR_ERROR_OUT_OF_MEM;
      } else {
	 if (gd3 && !(gl3 = ICreateGadgets(eri, gd3, 0, 0, NULL))) {
	    status = EDITOR_ERROR_OUT_OF_MEM;
	 } else {
	    if (!(gl4 = ICreateGadgets(eri, &edit_gadget_data[0], 0, 0,
								   NULL))) {
	       status = EDITOR_ERROR_OUT_OF_MEM;
	    } else {
	       status = edit_template_data_action(tp, gl1, gl2, gl3, gl4);
	       IFreeGadgets(gl4);
	    }
	    if (gd3) {
	       IFreeGadgets(gl3);
	    }
	 }
	 if (gd2) {
	    IFreeGadgets(gl2);
	 }
      }
      IFreeGadgets(gl1);
   }
   show_error(status);
   MWCheck();
   return(status);
}
