/* $Revision Header *** Header built automatically - do not edit! ***********
 *
 *	(C) Copyright 1991 by Torsten Jürgeleit
 *
 *	Name .....: gadgets.h
 *	Created ..: Thursday 19-Dec-91 20:52:44
 *	Revision .: 10
 *
 *	Date        Author                 Comment
 *	=========   ====================   ====================
 *	08-Aug-92   Torsten Jürgeleit      new flags
 *					   GADGET_DATA_FLAG_INPUT_CENTER/RIGHT
 *	06-Aug-92   Torsten Jürgeleit      new flag
 *					   GADGET_DATA_FLAG_LISTVIEW_ENTRY_COLOR
 *	19-Jul-92   Torsten Jürgeleit      remove/display_visible_gadget_lists()
 *					   imported from requester/requester.c
 *	11-Jul-92   Torsten Jürgeleit      use RAWKEY instead of VANILLAKEY
 *					   for gadget hotkeys
 *	01-Jul-92   Torsten Jürgeleit      added support for custom slider
 *					   knob image
 *	14-Apr-92   Torsten Jürgeleit      new flag GADGET_DATA_FLAG_NO_CLEAR
 *	01-Apr-92   Torsten Jürgeleit      any references to gadget data
 *					   via gl_Data removed
 *	01-Apr-92   Torsten Jürgeleit      changed parameter size of
 *					   modify_gadget() for new value of
 *					   USE_CURRENT_VALUE (1L << 31)
 *	31-Mar-92   Torsten Jürgeleit      changed USE_CURRENT_VALUE from ~0L
 *					   to (1L << 31)
 *	21-Mar-92   Torsten Jürgeleit      flags for converting numbers with
 *					   string gadgets
 *	19-Dec-91   Torsten Jürgeleit      Created this file!
 *
 ****************************************************************************
 *
 *	Defines, structures, prototypes and pragmas for gadget functions
 *
 * $Revision Header ********************************************************/

#ifndef	ISUP_GADGETS_H
#define	ISUP_GADGETS_H

	/* Defines for gadgets */

#define GADGET_DATA_TYPE_BUTTON		1	/* button gadget */
#define GADGET_DATA_TYPE_CHECK		2	/* check mark gadget */
#define GADGET_DATA_TYPE_MX		3	/* mutual exclude gadget */
#define GADGET_DATA_TYPE_STRING		4	/* string input gadget */
#define GADGET_DATA_TYPE_INTEGER	5	/* integer input gadget */
#define GADGET_DATA_TYPE_SLIDER		6	/* slider gadget */
#define GADGET_DATA_TYPE_SCROLLER	7	/* scroller gadget */
#define GADGET_DATA_TYPE_CYCLE		8	/* cycle gadget */
#define GADGET_DATA_TYPE_COUNT		9	/* count gadget */
#define GADGET_DATA_TYPE_LISTVIEW	10	/* list view gadget */
#define GADGET_DATA_TYPE_PALETTE	11	/* palette gadget */

#define MAX_GADGET_DATA_TYPE		GADGET_DATA_TYPE_PALETTE

#define GADGET_DATA_FLAG_DISABLED		(1L << 0)	/* gadget disabled (ghosted) - default enabled */
#define GADGET_DATA_FLAG_NO_BORDER		(1L << 1)	/* no gadget border - default with border */
#define GADGET_DATA_FLAG_HIGH_COMP		(1L << 2)	/* highliting by complement - default by select border */
#define GADGET_DATA_FLAG_ORIENTATION_VERT	(1L << 3)	/* vertical orientation - default horizontal */
#define GADGET_DATA_FLAG_HOTKEY			(1L << 4)	/* hotkey given - default none */
#define GADGET_DATA_FLAG_NO_TEXT_OUTPUT		(1L << 5)	/* no text output, but scan gadget text for hotkey */
#define GADGET_DATA_FLAG_TEXT_LEFT		(1L << 6)	/* place text left of gadget */
#define GADGET_DATA_FLAG_TEXT_RIGHT		(1L << 7)	/* place text right of gadget */
#define GADGET_DATA_FLAG_TEXT_ABOVE		(1L << 8)	/* place text above of gadget */
#define GADGET_DATA_FLAG_TEXT_BELOW		(1L << 9)	/* place text below of gadget */
#define GADGET_DATA_FLAG_TEXT_COLOR2		(1L << 10)	/* use 2nd text render pen for gadget text */
#define GADGET_DATA_FLAG_BUTTON_TOGGLE		(1L << 11)	/* button gadgets: toggle button - default no toggle */
#define GADGET_DATA_FLAG_BUTTON_IMAGE		(1L << 12)	/* button gadgets: render image - default no image */
#define GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE	(1L << 13)	/* input gadgets: acivate after GADGETUP next or previous input gadget */
#define GADGET_DATA_FLAG_STRING_UNSIGNED_DEC    (1L << 14)	/* string gadgets: input default no pointer to string but an unsigned decimal number */
#define GADGET_DATA_FLAG_STRING_SIGNED_DEC	(1L << 15)	/* string gadgets: input default no pointer to string but an signed decimal number */
#define GADGET_DATA_FLAG_STRING_HEX		(1L << 16)	/* string gadgets: input default no pointer to string but an hex number */
#define GADGET_DATA_FLAG_STRING_BIN		(1L << 17)	/* string gadgets: input default no pointer to string but an binary number */
#define GADGET_DATA_FLAG_SCROLLER_NO_ARROWS	(1L << 18)	/* scroller gadget: no arrows - default with arrows */
#define GADGET_DATA_FLAG_COUNT_SIGNED_DEC	(1L << 19)	/* count gadget: signed dec - default unsigned dec */
#define GADGET_DATA_FLAG_LISTVIEW_READ_ONLY	(1L << 20)	/* list view gadget: read only - default selection enabled */
#define GADGET_DATA_FLAG_LISTVIEW_SHOW_SELECTED (1L << 21)	/* list view gadget: show last selected entry - default no */
#define GADGET_DATA_FLAG_PALETTE_NO_INDICATOR	(1L << 22)	/* palette gadget: no current color indicator - default with indicator */
#define GADGET_DATA_FLAG_PALETTE_INDICATOR_TOP	(1L << 23)	/* palette gadget: place indicator at top - default at left */
#define GADGET_DATA_FLAG_MOVE_POINTER		(1L << 24)	/* move mouse pointer to center of this gadget */
#define GADGET_DATA_FLAG_NO_CLEAR		(1L << 25)	/* don't clear area occupied by this gadget before drawing */
#define GADGET_DATA_FLAG_SLIDER_IMAGE		(1L << 26)	/* kludge to define image for knob of proportional gadget in gd_TextAttr (if text then default TextAttr used) */
#define GADGET_DATA_FLAG_LISTVIEW_ENTRY_COLOR	(1L << 27)	/* list view gadget: if first char of an entry text equals <Ctrl A> ($01) then this char will be skipped and the rest of this entry text will be printed in a different color */
#define GADGET_DATA_FLAG_INPUT_CENTER		(1L << 28)	/* input gadgets: center input string within gadget */
#define GADGET_DATA_FLAG_INPUT_RIGHT		(1L << 29)	/* input gadgets: right justify input string within gadget */

#define GADGET_IDCMP_FLAGS_BUTTON	(GADGETUP | RAWKEY)
#define GADGET_IDCMP_FLAGS_CHECK	(GADGETDOWN | RAWKEY)
#define GADGET_IDCMP_FLAGS_MX		(GADGETDOWN | RAWKEY)
#define GADGET_IDCMP_FLAGS_STRING	(GADGETUP | RAWKEY)
#define GADGET_IDCMP_FLAGS_INTEGER	(GADGETUP | RAWKEY)
#define GADGET_IDCMP_FLAGS_SLIDER	(GADGETUP | MOUSEMOVE | RAWKEY)
#define GADGET_IDCMP_FLAGS_SCROLLER	(GADGETDOWN | GADGETUP | MOUSEMOVE | INTUITICKS | RAWKEY)
#define GADGET_IDCMP_FLAGS_CYCLE	(GADGETUP | RAWKEY)
#define GADGET_IDCMP_FLAGS_COUNT	(GADGETDOWN | GADGETUP | MOUSEMOVE | RAWKEY)
#define GADGET_IDCMP_FLAGS_LISTVIEW	(GADGETDOWN | GADGETUP | MOUSEMOVE | INTUITICKS | RAWKEY)
#define GADGET_IDCMP_FLAGS_PALETTE	(GADGETUP | RAWKEY)
#define GADGET_IDCMP_FLAGS_ALL		(GADGETDOWN | GADGETUP | MOUSEMOVE | INTUITICKS | RAWKEY)

#define GADGET_LIST_FLAG_DISPLAYED	(1 << 0)	/* gadget list currently displayed */

#define EXTENDED_GADGET_TYPE_BUTTON		1
#define EXTENDED_GADGET_TYPE_CHECK		2
#define EXTENDED_GADGET_TYPE_MX			3
#define EXTENDED_GADGET_TYPE_STRING		4
#define EXTENDED_GADGET_TYPE_INTEGER		5
#define EXTENDED_GADGET_TYPE_SLIDER_PROP	6
#define EXTENDED_GADGET_TYPE_SCROLLER_PROP	7
#define EXTENDED_GADGET_TYPE_SCROLLER_LEFT	8
#define EXTENDED_GADGET_TYPE_SCROLLER_RIGHT	9
#define EXTENDED_GADGET_TYPE_SCROLLER_UP	10
#define EXTENDED_GADGET_TYPE_SCROLLER_DOWN	11
#define EXTENDED_GADGET_TYPE_CYCLE		12
#define EXTENDED_GADGET_TYPE_COUNT		13
#define EXTENDED_GADGET_TYPE_LISTVIEW_PROP	14
#define EXTENDED_GADGET_TYPE_LISTVIEW_UP	15
#define EXTENDED_GADGET_TYPE_LISTVIEW_DOWN	16
#define EXTENDED_GADGET_TYPE_LISTVIEW_ENTRY	17
#define EXTENDED_GADGET_TYPE_PALETTE_INDICATOR	18
#define EXTENDED_GADGET_TYPE_PALETTE_COLOR	19

#define EXTENDED_GADGET_FLAG_HOTKEY		(1 << 0)	/* hotkey exists -> eg_Hotkey and eg_HotkeyPos are valid */
#define EXTENDED_GADGET_FLAG_RENDER_BORDER	(1 << 1)	/* draw eg_Render as border */
#define EXTENDED_GADGET_FLAG_RENDER_IMAGE	(1 << 2)	/* draw eg_Render as image */
#define EXTENDED_GADGET_FLAG_KNOB_IMAGE		(1 << 3)	/* proportional gadget with custom knob image instead of AUTOKNOB */
#define EXTENDED_GADGET_FLAG_CLOSE_FONT		(1 << 4)	/* font defined in gd_TextAttr opened -> don't forget to close it */

#define USE_CURRENT_VALUE	(1L << 31)	/* used for set_gadget_attributes() to indicate data for which to use the current value */

	/* Defines for internal use only */

#define QUALIFIER_SHIFT		(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)
#define QUALIFIER_ALT		(IEQUALIFIER_LALT | IEQUALIFIER_RALT)

#define ARROW_AUTO_REPEAT_START_DELAY	3

#define MAX_CYCLE_DELAY		5

#define CYCLE_POP_XOFFSET	4
#define CYCLE_POP_YOFFSET	2

#define CYCLE_LIST_ENTRY_YPOS(num)	(yinc > 0 ? num * yinc : (cy->cy_TextEntries - num - 1) * -yinc);

#define MAX_COUNT_DELAY		5
#define MAX_COUNT_STEP_SIZE	20
#define MAX_COUNT_DISTANCE	(MAX_COUNT_DELAY * MAX_COUNT_STEP_SIZE)
#define MIN_COUNT_DELAY_MICROS	30000L

#define MAX_DATA_FLAG_BITS	32

#define DEC_NUM_CONVERT_FLAGS	0
#define HEX_NUM_CONVERT_FLAGS	(CONVERT_FLAG_IDENTIFIER | CONVERT_FLAG_C_STYLE)
#define BIN_NUM_CONVERT_FLAGS	CONVERT_FLAG_IDENTIFIER

	/* Structures */

struct VisibleGadgetLists {
	struct SignalSemaphore  vg_Semaphore;
	struct MinList          vg_MinList;
	USHORT	vg_Count;
};
struct GadgetList {
	struct MinNode     gl_MinNode; 	/* node to insert GadgetList into VisibleGadgetLists list */
	struct RenderInfo  *gl_RenderInfo;
	struct Window      *gl_Window;
	LONG	gl_ID;			/* id = 'ISUP' */
	USHORT	gl_DataEntries;		/* number of entries in gadget data array */
	UBYTE	gl_Flags;
	UBYTE	gl_AutoRepeatDelay;	/* delay counter for start of auto repeat for active arrow gadget */
	BYTE	*gl_GadgetBuffer;
	ULONG	gl_GadgetBufferSize;
	BYTE	*gl_ImageBuffer;
	ULONG	gl_ImageBufferSize;
	BYTE	**gl_LanguageTextArray;
	struct RequesterList   *gl_RequesterList;
	struct ExtendedGadget  *gl_ActiveGadget;
	struct ExtendedGadget  *gl_Gadgets[1];	/* array with gl_DataEntries ptr to extended gadgets */
};
struct GadgetData {
	ULONG	gd_Type;
	ULONG	gd_Flags;
	USHORT	gd_LeftEdge;
	USHORT	gd_TopEdge;
	USHORT	gd_Width;
	USHORT	gd_Height;
	BYTE	*gd_Text;
	struct TextAttr  *gd_TextAttr;
	union	{
	    struct {	/* standard data struct */
		LONG	gd_Data1;
		LONG	gd_Data2;
		VOID	*gd_Data3;
	    } gd_Data;

	    struct {	/* for button gadgets */
		ULONG	gd_ButtonSelected;		/* selection state for toggle buttons - ZERO = unselected, non ZERO = selected */
		struct Image  *gd_ButtonNormalRender;	/* normal render image */
		struct Image  *gd_ButtonSelectRender;	/* select render image */
	    } gd_ButtonData;

	    struct {	/* for check gadgets */
		ULONG	gd_CheckSelected;	/* selection state - ZERO = unselected, non ZERO = selected */
		ULONG	gd_CheckPad1;
		ULONG	gd_CheckPad2;
	    } gd_CheckData;

	    struct {	/* for mutual exclude gadgets */
		ULONG	gd_MXSpacing;		/* pixel spacing between MX gadgets */
		ULONG	gd_MXActiveEntry;	/* num of active entry from text array */
		BYTE	**gd_MXTextArray;	/* ptr to MX text ptr array */
	    } gd_MXData;

	    struct {	/* for string and integer gadgets */
		ULONG	gd_InputLen;		/* len of input buffer */
		USHORT	gd_InputActivateNext;	/* num of next string/num gadget to activate */
		USHORT	gd_InputActivatePrev;	/* num of previous string/num gadget to activate */
		BYTE	*gd_InputDefault;	/* string: default text [syntax: "text"] */
						/* integer: default number [syntax: (VOID *)num] */
	    } gd_InputData;

	    struct {	/* for slider gadgets */
		LONG	gd_SliderMin;		/* min level */
		LONG	gd_SliderMax;		/* max level */
		LONG	gd_SliderLevel;		/* current slider level */
	    } gd_SliderData;

	    struct {	/* for scroller gadgets */
		ULONG	gd_ScrollerVisible;	/* visible entries */
		ULONG	gd_ScrollerTotal;	/* total entries */
		ULONG	gd_ScrollerTop;		/* current top entry */
	    } gd_ScrollerData;

	    struct {	/* for cycle gadget */
		ULONG	gd_CycleSpacing;	/* pixel spacing between pop up cycle list entries */
		ULONG	gd_CycleActive;		/* num of current cycle text ptr array entry */
		BYTE	**gd_CycleTextArray;	/* ptr to cycle text ptr array */
	    } gd_CycleData;

	    struct {	/* for count gadget */
		ULONG	gd_CountMin;		/* min value */
		ULONG	gd_CountMax;		/* max value */
		ULONG	gd_CountValue;	/* current count value */
	    } gd_CountData;

	    struct {	/* for list view gadget */
		ULONG	gd_ListViewSpacing;	/* pixel spacing between list view entries */
		ULONG	gd_ListViewTop;		/* current top entry */
		struct List  *gd_ListViewList;	/* current list ptr */
	    } gd_ListViewData;

	    struct {	/* for palette gadget */
		ULONG	gd_PaletteDepth;	/* num of bitplanes for palette */
		ULONG	gd_PaletteColorOffset;	/* first color of palette */
		ULONG	gd_PaletteActiveColor;	/* selected color */
	    } gd_PaletteData;
	} gd_SpecialData;
};
struct MXData {
	USHORT	mx_TextEntries;
	USHORT	mx_ActiveEntry;
};
struct InputData {
	USHORT	id_ActivateNext;
	USHORT	id_ActivatePrev;
};
struct SliderData {
	LONG	sl_Min;
	LONG	sl_Max;
	LONG	sl_Level;
};
struct ScrollerData {
	ULONG	sc_Visible;
	ULONG	sc_Total;
	ULONG	sc_Top;
};
struct CycleData {
	SHORT	cy_LeftEdge;
	SHORT	cy_TopEdge;
	USHORT	cy_Width;
	USHORT	cy_Height;
	USHORT	cy_EntryHeight;
	BYTE	**cy_TextArray;
	BYTE	*cy_ActiveText;
	USHORT	cy_TextEntries;
	USHORT	cy_ActiveEntry;
};
struct CountData {
	SHORT	co_LeftEdge;
	SHORT	co_TopEdge;
	USHORT	co_Width;
	USHORT	co_Height;
	ULONG	co_Min;
	ULONG	co_Max;
	ULONG	co_Value;
};
struct ListViewData {
	SHORT	lv_LeftEdge;
	SHORT	lv_TopEdge;
	USHORT	lv_Width;
	USHORT	lv_Height;
	USHORT	lv_VisibleEntries;
	USHORT	lv_EntryHeight;
	struct List  *lv_List;
	struct Node  *lv_TopNode;
	USHORT	lv_ListEntries;
	USHORT	lv_TopEntry;
	USHORT	lv_SelectedEntry;
};
struct PaletteData {
	USHORT	pd_MaxColors;
	USHORT	pd_ColorOffset;
	ULONG	pd_ActiveColor;
};
struct ExtendedGadget {
	struct Gadget  eg_Gadget;
	USHORT	eg_BorderWidth;		/* needed by editor - DIRECT behind gadget structure !!! */
	USHORT	eg_BorderHeight;	/* needed by editor - DIRECT behind gadget structure !!! */
	SHORT	eg_BorderLeftEdge;	/* needed by modify_gadget() */
	SHORT	eg_BorderTopEdge;	/* needed by modify_gadget() */
	USHORT	eg_Type;		/* internal gadget type */
	USHORT	eg_Flags;		/* special flags, e.g render object type */
	USHORT	eg_DataType;		/* copy of gd_Data */
	USHORT	eg_DataEntry;		/* ordinal number of entry in gl_Data array */
	ULONG	eg_DataFlags;		/* copy of gd_Flags */
	struct GadgetList  *eg_GadgetList;
	struct TextAttr    *eg_TextAttr;
	struct TextFont    *eg_TextFont;
	BYTE	*eg_Text;
	SHORT	eg_TextLeftEdge;
	SHORT	eg_TextTopEdge;
	USHORT	eg_TextWidth;		/* needed by modify_gadget() */
	UBYTE	eg_Hotkey;		/* ASCII value of gadget hotkey */
	UBYTE	eg_HotkeyPos;		/* pos of as hotkey marked (underscore) char in gadget text */
	APTR	eg_Render;		/* ptr to image or border - determined by eg_Flags */
	struct ExtendedGadget  *eg_NextGadget;
};
	/* Global prototypes */

struct GadgetList  *create_gadgets(struct RenderInfo  *ri,
		       struct GadgetData  *gd, SHORT hoffset, SHORT voffset,
						BYTE **language_text_array);
VOID  free_gadgets(struct GadgetList  *gl);
VOID  display_gadgets(struct Window  *win, struct GadgetList  *gl);
VOID  refresh_gadgets(struct GadgetList  *gl);
VOID  modify_gadget(struct GadgetList  *gl, USHORT data_entry,
		  LONG left_edge, LONG top_edge, ULONG width, ULONG height);
ULONG set_gadget_attributes(struct GadgetList  *gl, USHORT data_entry,
		 ULONG flag_mask, ULONG flag_bits, ULONG data1, ULONG data2,
							       VOID *data3);
VOID  activate_input_gadget(struct GadgetList  *gl, USHORT data_entry);
struct Gadget  *gadget_address(struct GadgetList  *gl, USHORT data_entry);
struct Window  *remove_gadgets(struct GadgetList  *gl);
struct IntuiMessage  *get_msg(struct MsgPort  *uport);
VOID  reply_msg(struct IntuiMessage  *imsg);
UBYTE convert_rawkey_to_ascii(struct IntuiMessage  *im);

	/* Global pragmas */

#pragma intfunc(create_gadgets(a0,a1,d0,d1,a2))
#pragma intfunc(free_gadgets(a0))
#pragma intfunc(display_gadgets(a0,a1))
#pragma intfunc(refresh_gadgets(a0))
#pragma intfunc(modify_gadget(a0,d0,d1,d2,d3,d4))
#pragma intfunc(set_gadget_attributes(a0,d0,d1,d2,d3,d4,a1))
#pragma intfunc(activate_input_gadget(a0,d0))
#pragma intfunc(gadget_address(a0,d0))
#pragma intfunc(remove_gadgets(a0))
#pragma intfunc(get_msg(a0))
#pragma intfunc(reply_msg(a0))
#pragma intfunc(convert_rawkey_to_ascii(a0))

#endif   /* ISUP_GADGETS_H */
