/*
 * Scan 'C' Header File
 * Written by Thomas Krehbiel
 *
 * Ged GUI system.
 *
 */

#ifndef SCAN_GED_H


#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif


#define INTERNATIONAL

/*
 * ID's for gadget Styles:
 */

#define Button_ID       0           /* Standard button */
#define Toggle_ID       1           /* Toggling button - not recommended */
#define String_ID       2           /* String gadget */
#define Integer_ID      3           /* Integer gadget */
#define HSlider_ID      4           /* Horizontal slider */
#define VSlider_ID      5           /* Vertical slider */
#define Cycle_ID        6           /* 2.0-style cycler */
#define Check_ID        7           /* 2.0-style checkbox */
#define MX_ID           8           /* 2.0-style MX */

#define Border_ID       10          /* Bevel box border */
#define Text_ID         11          /* Text */
#define Image_ID        12          /* struct Image */

#define Up_ID           13          /* Up button */
#define Down_ID         14          /* Down button */

#define QButton_ID      20          /* Button with no image */
#define QToggle_ID      21          /* Toggler with no image */
#define QString_ID      22          /* String with no image */
#define QInteger_ID     23          /* Integer with no image */
#define QHSlider_ID     24          /* HSlider with no image */
#define QVSlider_ID     25          /* VSlider with no image */
#define QCycle_ID       26          /* Cycler with no image */
#define QCheck_ID       27          /* Checkbox with no image */
#define QMX_ID          28          /* MX with no image */

#define Ignore_ID       100         /* Ignore this item - not implemented */

#define Font_ID         252         /* internal use only */
#define Offset_ID       253         /* internal use only */
#define Scale_ID        254         /* internal use only */

#define End_ID          255

/*
 * GedGadget - Internal use by the gadget maintenance routines.
 *             All fields should be considered READ ONLY and
 *             are subject to change without notice.
 *
 *             About the only thing you might be interested in
 *             is the "CycleArray" field; it allows you to
 *             change the list of labels for a cycle gadget
 *             at will by simply changing pointers.  You get
 *             a pointer to the GedGadget structure by
 *             casting the Gadget pointers returned by Ged_Create().
 *             Eg:
 *                   gedgad = (struct GedGadget *)gad;
 *
 */

struct GedGadget {
   struct Gadget  Gadget;           /* Regular Gadget */
   struct Border *PropBorder;       /* Prop border */
   long           Lowest, Highest;  /* Range of slider or integer */
   int          (*Code)(struct Window *, struct Gadget *, ULONG, ...);
                                    /* User code */
   ULONG          UserData;         /* User data */
   short          Style;            /* Gadget style */
   char           Shortcut;         /* Keyboard shortcut (no qualifier) */
   char           Selected;         /* Checkbox selected? */
   char         **CycleText;        /* Complete language text array */
   long          *CycleArray;       /* Array of text indexes... */
   short          CycleIndex;       /* Index into cycle array */
   ULONG         *Pointer;          /* Gadget state storage */
   struct NewGad *NewGad;           /* NewGad from which we came */
   short          NextActive;       /* GadgetID to activate next */
   short          ReturnCode;       /* Button return code */
   short         *MXArray;          /* Mutual exclusion array - unused for now */
   char           RightAmiga;       /* RightAmiga key shortcut */
};

/*
 * NewGad - You fill in an array of these to define what gadgets,
 *          text, borders, and images that you want for your window.
 *          End the list with an element of style End_ID.
 */

struct NewGad {
   short          Style;            /* Style - What this array element
                                     *    actually is.  Can be a gadget,
                                     *    text, border, or image.  See
                                     *    style defines above. */
   short          ID;               /* ID - For gadget styles, this is
                                     *    used to reference the gadget
                                     *    in most of the maintenance
                                     *    functions. */
   short          LE, TE, W, H;     /* Position - This defines the
                                     *    absolute location of the item.
                                     *    For text and images, only the
                                     *    LE and TE fields are actually
                                     *    used. */
   long           Label;            /* Indicates the index into a char **
                                     *    array to use as the text label
                                     *    for this item.  The text array
                                     *    is passed to the Ged_Create()
                                     *    function.  Used this way to
                                     *    make internationalizing easier.
                                     *    Alternately, if the text array
                                     *    passed to Ged_Create() is NULL,
                                     *    then this field is taken to be
                                     *    a simple pointer to a string.
                                     */
   int          (*Code)();          /* Code - for gadgets, this defines
                                     *    the function to call whenever
                                     *    this gadget is "played" with.
                                     *    The function will be passed
                                     *    the current value of the gadget
                                     *    (for string, integer, props, etc.)
                                     *    See below for the function
                                     *    prototypes for each of the styles
                                     *    of gadgets.  Use NULL if no
                                     *    function is needed.
                                     */
   ULONG          UserData;         /* UserData - passed to the function
                                     *    above unchanged; you can use
                                     *    this for whatever you want.
                                     */
   ULONG         *Pointer;          /* Points to a place to store the
                                     *    current "value" of this gadget
                                     *    (if the item *is* a gadget).
                                     *    For example, the current value
                                     *    of a slider could be stored here
                                     *    so you only need to reference a
                                     *    single global variable instead
                                     *    of retreiving the value from
                                     *    the gadget all the time.
                                     */
   /* Following entires vary from style to style: */
   long           Data1;            /* These represent various parameters */
   long           Data2;            /*    for the various styles. */
   long           Data3;            /*    They are detailed below. */
   long           Data4;
   long           Data5;
   long           Data6;
   long           Data7;
   long           Data8;
};

/*
 * Data#? Descriptions:
 *
 *
 * Button_ID:
 *
 *    Data1    (long) Value to return to caller of GedWindow.  Use
 *             non-zero to exit a GedWindow.
 *    Data2    (char) Keyboard shortcut character, NUL for none.
 *    Data3    (struct Image *) Image to use for this gadget instead
 *             of the standard bevel button imagery.
 *
 * Toggle_ID:
 *
 *    Data1    (long) Select state; non-zero to initially select.
 *    Data2    (char) Keyboard shortcut character, NUL for none.
 *    Data3    (struct Image *) Image to use for this gadget instead
 *             of the standard bevel button imagery.
 *
 * Integer_ID:
 *
 *    Data1    (long) Highest value for gadget (currently ignored).
 *    Data2    (long) Initial value.
 *    Data3    (long) Lowest value for gadget (current ignored).
 *    Data4    (long) ID of next gadget to activate.
 *    Data5    (long) 0 == left, 1 == right, 2 == center
 *
 * String_ID:
 *
 *    Data1    (long) Maximum characters in string buffer.
 *    Data2    (char *) Initial string for the gadget.
 *    Data4    (long) ID of next gadget to activate.
 *    Data5    (long) 0 == left, 1 == right, 2 == center
 *
 * Slider_ID:
 *
 *    Data1    (long) Highest value of slider.
 *    Data2    (long) Initial value of the slider.
 *    Data3    (long) Lowest value of slider.
 *    Data6    (struct Image *) Image to use for slider knob.
 *
 * Cycle_ID:
 *
 *    Data1    (long *) Array of gadget labels, each entry is an
 *             index into the char ** text array given to
 *             Ged_Create().
 *    Data2    (char) Keyboard shortcut character, NUL for none.
 *    Data4    (long) Initial element of cycle array to be shown.
 *    Data7    (char **) Text array to override the array passed
 *             to the Ged_Create() function.
 *
 * Check_ID:
 *
 *    Data1    (long) Select state; non-zero to initially select.
 *    Data2    (char) Keyboard shortcut character, NUL for none.
 *
 * MX_ID:
 *
 *    Data1    (long) Select state; non-zero to initially select.
 *    Data2    (char) Keyboard shortcut character, NUL for none.
 *
 * Border_ID:
 *
 *    Data1    (long) Non-zero for recessed border, otherwise raised.
 *    Data2    (long) Non-zero for double-thick border.
 *
 * Text_ID:
 *
 *    Data1    (long) Pen number to draw text with.
 *    Data3    (long) 0 = newgad->LE is the left edge of text;
 *                    1 = newgad->LE indicates the RIGHT edge of the text;
 *                    2 = newgad->LE indicates the CENTER of the text.
 *
 */

/*
 *  These are to allow easy creation of gadget function prototypes:
 *
 *  For example:
 *
 *  int SaveCode (GedButtonProto)
 *  {
 *     return(0);
 *  }
 */

#define GedButtonProto  struct Window *w, struct Gadget *g, ULONG ud
#define GedToggleProto  struct Window *w, struct Gadget *g, ULONG ud, long val
#define GedStringProto  struct Window *w, struct Gadget *g, ULONG ud, char *text
#define GedIntegerProto struct Window *w, struct Gadget *g, ULONG ud, long val
#define GedSliderProto  struct Window *w, struct Gadget *g, ULONG ud, long val, BOOL moving
#define GedCycleProto   struct Window *w, struct Gadget *g, ULONG ud, long idx
#define GedCheckProto   struct Window *w, struct Gadget *g, ULONG ud, long val
#define GedMXProto      struct Window *w, struct Gadget *g, ULONG ud, long val

/* Ancient compatibility - do not use: */
#define Reserved1    Data5
#define Reserved2    Data6
#define Reserved3    Data7
#define Reserved4    Data8

/* So we don't have to refer to `Data1', etc. */
#define ng_RC        Data1
#define ng_Key       Data2
#define ng_Image     Data3
#define ng_Select    Data1
#define ng_Highest   Data1
#define ng_Integer   Data2
#define ng_Lowest    Data3
#define ng_Next      Data4
#define ng_MaxChars  Data1
#define ng_String    Data2
#define ng_Initial   Data2
#define ng_Labels    Data1
#define ng_Index     Data4
#define ng_Exclude   Data3

/*
 * GedContext - used to keep context information about a list of
 *              NewGad's after they're created.  Should be considered
 *              READ ONLY, and is subject to change without notice.
 */

struct GedContext {
   struct Gadget    *GadList;       /* Gadget List */
   struct IntuiText *ITextList;     /* IntuiText List */
   struct Border    *BorderList;    /* Border List */
   struct Image     *ImageList;     /* Image List */
   char            **TextArray;     /* Text array */
   short             NumGads;       /* Number of gadgets */
   short             Reserved1;
   long              Reserved2[8];
};

#ifdef SCANPRIVATE
/*
 * Private, do not touch:
 */

extern int        (*GedPostGadHook)(struct Window *win);
extern int        (*GedPreGadHook)(struct Window *win);

extern UWORD      GedSourceWid, GedSourceHt,
                  GedDestWid, GedDestHt;
extern WORD       GedLeftOffset, GedTopOffset;
#endif


#define SCAN_GED_H
#endif
