home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / include / scan / ged.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-30  |  21.3 KB  |  512 lines

  1. /*
  2.  * ImageFX Development Header File
  3.  * Copyright © 1991-1995 Nova Design, Inc.
  4.  * Written by Thomas Krehbiel
  5.  *
  6.  * The ImageFX "GED" gadget system.
  7.  *
  8.  */
  9.  
  10. #ifndef SCAN_GED_H
  11.  
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif
  16.  
  17. #ifndef INTUITION_INTUITION_H
  18. #include <intuition/intuition.h>
  19. #endif
  20.  
  21.  
  22. #define INTERNATIONAL
  23.  
  24. /*
  25.  * ID's for gadget Styles:
  26.  */
  27.  
  28. #define Button_ID       0           /* Standard button */
  29. #define Toggle_ID       1           /* Toggling button - not recommended */
  30. #define String_ID       2           /* String gadget */
  31. #define Integer_ID      3           /* Integer gadget */
  32. #define HSlider_ID      4           /* Horizontal slider */
  33. #define VSlider_ID      5           /* Vertical slider */
  34. #define Cycle_ID        6           /* 2.0-style cycler */
  35. #define Check_ID        7           /* 2.0-style checkbox */
  36. #define MX_ID           8           /* 2.0-style MX */
  37.  
  38. #define Border_ID       10          /* Bevel box border */
  39. #define Text_ID         11          /* Text */
  40. #define Image_ID        12          /* struct Image */
  41.  
  42. #define Up_ID           13          /* Up button */
  43. #define Down_ID         14          /* Down button */
  44.  
  45. #define QButton_ID      20          /* Button with no image */
  46. #define QToggle_ID      21          /* Toggler with no image */
  47. #define QString_ID      22          /* String with no image */
  48. #define QInteger_ID     23          /* Integer with no image */
  49. #define QHSlider_ID     24          /* HSlider with no image */
  50. #define QVSlider_ID     25          /* VSlider with no image */
  51. #define QCycle_ID       26          /* Cycler with no image */
  52. #define QCheck_ID       27          /* Checkbox with no image */
  53. #define QMX_ID          28          /* MX with no image */
  54.  
  55. #define List_ID         43          /* a listview-style gadget */
  56.  
  57. #define Ignore_ID       100         /* Ignore this item - not implemented */
  58.  
  59. #define Font_ID         252         /* internal use only */
  60. #define Offset_ID       253         /* internal use only */
  61. #define Scale_ID        254         /* internal use only */
  62.  
  63. #define End_ID          255
  64.  
  65.  
  66. /*
  67.  * These are used as gadget ID's for internal stuff.  Avoid
  68.  * using these ID values for your own gadgets.
  69.  */
  70. #define ELIST_LIST      (0xFFF0)
  71. #define ELIST_UP        (0xFFF1)
  72. #define ELIST_DOWN      (0xFFF2)
  73. #define ELIST_PROP      (0xFFF3)
  74.  
  75.  
  76. /*
  77.  * GedGadget - Internal use by the gadget maintenance routines.
  78.  *             All fields should be considered READ ONLY and
  79.  *             are subject to change without notice.
  80.  *
  81.  *             About the only thing you might be interested in
  82.  *             is the "CycleArray" field; it allows you to
  83.  *             change the list of labels for a cycle gadget
  84.  *             at will by simply changing pointers.  You get
  85.  *             a pointer to the GedGadget structure by
  86.  *             casting the Gadget pointers returned by Ged_Create().
  87.  *             Eg:
  88.  *                   gedgad = (struct GedGadget *)gad;
  89.  *
  90.  */
  91.  
  92. struct GedGadget
  93. {
  94.    struct Gadget  Gadget;           /* Regular Gadget */
  95.    struct Border *PropBorder;       /* Prop border */
  96.    long           Lowest, Highest;  /* Range of slider or integer */
  97.    int          (*Code)(struct Window *, struct Gadget *, ULONG, ...);
  98.                                     /* User code */
  99.    ULONG          UserData;         /* User data */
  100.    short          Style;            /* Gadget style */
  101.    char           Shortcut;         /* Keyboard shortcut (no qualifier) */
  102.    char           Selected;         /* Checkbox selected? */
  103.    char         **CycleText;        /* Complete language text array */
  104.    long          *CycleArray;       /* Array of text indexes... */
  105.    short          CycleIndex;       /* Index into cycle array */
  106.    ULONG         *Pointer;          /* Gadget state storage */
  107.    struct NewGad *NewGad;           /* NewGad from which we came */
  108.    short          NextActive;       /* GadgetID to activate next */
  109.    short          ReturnCode;       /* Button return code */
  110.    short         *MXArray;          /* Mutual exclusion array - unused for now */
  111.    char           RightAmiga;       /* RightAmiga key shortcut */
  112.    UBYTE          GedFlags;         /* Private */
  113.    struct EListView *LV;
  114.    short          LE, TE, W, H;
  115.    struct IntuiText *CycleLabel;    /* Private */
  116.    struct Image  *ButtonImage;      /* Private too */
  117.    char         **GTCycleArray;     /* Private too */
  118.    struct Gadget *BoopsiGadget;     /* Private too */
  119.    struct Image  *BoopsiFrame;      /* Private too */
  120.    char           CurLvlStr[80];    /* Private too */
  121.    WORD           CurLvlX,
  122.                   CurLvlY;
  123.    WORD           CurLvlN;
  124.    WORD           SkipTicks;        /* Private */
  125.    LONG           reserved[32];
  126. };
  127.  
  128. #define GGF_RENDERED    0x01        /* slider level has been rendered */
  129.  
  130.  
  131. /*
  132.  * NewGad - You fill in an array of these to define what gadgets,
  133.  *          text, borders, and images that you want for your window.
  134.  *          End the list with an element of style End_ID.
  135.  *
  136.  * THIS STRUCTURE MUST REMAIN INTACT THROUGHOUT THE LIFE OF THE GADGET!!
  137.  *
  138.  */
  139.  
  140. struct NewGad
  141. {
  142.    short          Style;            /* Style - What this array element
  143.                                      *    actually is.  Can be a gadget,
  144.                                      *    text, border, or image.  See
  145.                                      *    style defines above. */
  146.    short          ID;               /* ID - For gadget styles, this is
  147.                                      *    used to reference the gadget
  148.                                      *    in most of the maintenance
  149.                                      *    functions. */
  150.    short          LE, TE, W, H;     /* Position - This defines the
  151.                                      *    absolute location of the item.
  152.                                      *    For text and images, only the
  153.                                      *    LE and TE fields are actually
  154.                                      *    used. */
  155.    long           Label;            /* Indicates the index into a char **
  156.                                      *    array to use as the text label
  157.                                      *    for this item.  The text array
  158.                                      *    is passed to the Ged_Create()
  159.                                      *    function.  Used this way to
  160.                                      *    make internationalizing easier.
  161.                                      *    Alternately, if the text array
  162.                                      *    passed to Ged_Create() is NULL,
  163.                                      *    then this field is taken to be
  164.                                      *    a simple pointer to a string.
  165.                                      */
  166.    int          (*Code)();          /* Code - for gadgets, this defines
  167.                                      *    the function to call whenever
  168.                                      *    this gadget is "played" with.
  169.                                      *    The function will be passed
  170.                                      *    the current value of the gadget
  171.                                      *    (for string, integer, props, etc.)
  172.                                      *    See below for the function
  173.                                      *    prototypes for each of the styles
  174.                                      *    of gadgets.  Use NULL if no
  175.                                      *    function is needed.
  176.                                      */
  177.    ULONG          UserData;         /* UserData - passed to the function
  178.                                      *    above unchanged; you can use
  179.                                      *    this for whatever you want.
  180.                                      */
  181.    ULONG         *Pointer;          /* Points to a place to store the
  182.                                      *    current "value" of this gadget
  183.                                      *    (if the item *is* a gadget).
  184.                                      *    For example, the current value
  185.                                      *    of a slider could be stored here
  186.                                      *    so you only need to reference a
  187.                                      *    single global variable instead
  188.                                      *    of retreiving the value from
  189.                                      *    the gadget all the time.
  190.                                      */
  191.    /* Following entries vary from style to style: */
  192.    long           Data1;            /* These represent various parameters */
  193.    long           Data2;            /*    for the various styles. */
  194.    long           Data3;            /*    They are detailed below. */
  195.    long           Data4;
  196.    long           Data5;
  197.    long           Data6;
  198.    long           Data7;
  199.    long           Data8;
  200. };
  201.  
  202. /*
  203.  * Data#? Descriptions:
  204.  *
  205.  *
  206.  * Button_ID/Up_ID/Down_ID:
  207.  *
  208.  *    Data1    (long) Value to return to caller of GedWindow.  Use
  209.  *             non-zero to exit a GedWindow.
  210.  *    Data2    (char) Keyboard shortcut character, NUL for none.
  211.  *    Data3    (struct Image *) Image to use for this gadget instead
  212.  *             of the standard bevel button imagery.
  213.  *    Data4    (struct Image *) Image to use in addition to the
  214.  *             standard bevel button imagery.  The image is centered
  215.  *             inside the button.
  216.  *
  217.  * Toggle_ID:
  218.  *
  219.  *    Data1    (long) Select state; non-zero to initially select.
  220.  *    Data2    (char) Keyboard shortcut character, NUL for none.
  221.  *    Data3    (struct Image *) Image to use for this gadget instead
  222.  *             of the standard bevel button imagery.
  223.  *
  224.  * Integer_ID:
  225.  *
  226.  *    Data1    (long) Highest value for gadget (currently ignored).
  227.  *    Data2    (long) Initial value.
  228.  *    Data3    (long) Lowest value for gadget (current ignored).
  229.  *    Data4    (long) ID of next gadget to activate.
  230.  *    Data5    (long) 0 == left, 1 == right, 2 == center
  231.  *
  232.  * String_ID:
  233.  *
  234.  *    Data1    (long) Maximum characters in string buffer.
  235.  *    Data2    (char *) Initial string for the gadget.
  236.  *    Data4    (long) ID of next gadget to activate.
  237.  *    Data5    (long) 0 == left, 1 == right, 2 == center
  238.  *
  239.  * Slider_ID:
  240.  *
  241.  *    Data1    (long) Highest value of slider.
  242.  *    Data2    (long) Initial value of the slider.
  243.  *    Data3    (long) Lowest value of slider.
  244.  *    Data5    (long) Level positioning (see LEVEL_#? flags)      (2.0)
  245.  *    Data6    (struct Image *) Image to use for slider knob.
  246.  *    Data7    (char *) Level format (sprintf-style string) or    (2.0)
  247.  *                callback if (Data5 & LEVELF_CALLBACK).
  248.  *                Callback is used to fill in a string buffer
  249.  *                that Ged renders.
  250.  *    Data8    (long) If non-zero, specifies the maximum length   (2.0)
  251.  *                of the level indication, in characters.  Only
  252.  *                this many characters are rendered, in other
  253.  *                words.  If zero, all characters are rendered.
  254.  *
  255.  * Cycle_ID:
  256.  *
  257.  *    Data1    (long *) Array of gadget labels, each entry is an
  258.  *             index into the char ** text array given to
  259.  *             Ged_Create().
  260.  *    Data2    (char) Keyboard shortcut character, NUL for none.
  261.  *    Data4    (long) Initial element of cycle array to be shown.
  262.  *    Data6    (int (*)()) Function to call when cycler is double-clicked.
  263.  *    Data7    (char **) Text array to override the array passed
  264.  *             to the Ged_Create() function.
  265.  *
  266.  * Check_ID:
  267.  *
  268.  *    Data1    (long) Select state; non-zero to initially select.
  269.  *    Data2    (char) Keyboard shortcut character, NUL for none.
  270.  *
  271.  * MX_ID:
  272.  *
  273.  *    Data1    (long) Select state; non-zero to initially select.
  274.  *    Data2    (char) Keyboard shortcut character, NUL for none.
  275.  *
  276.  * Border_ID:
  277.  *
  278.  *    Data1    (long) Non-zero for recessed border, otherwise raised.
  279.  *    Data2    (long) Non-zero for double-thick border.
  280.  *
  281.  * Text_ID:
  282.  *
  283.  *    Data1    (long) Pen number to draw text with.
  284.  *    Data3    (long) 0 = newgad->LE is the left edge of text;
  285.  *                    1 = newgad->LE indicates the RIGHT edge of the text;
  286.  *                    2 = newgad->LE indicates the CENTER of the text.
  287.  *
  288.  * List_ID (2.0):
  289.  *
  290.  *    Data1    (struct EListView *) EListView structure, which must
  291.  *                be initialized with the following:
  292.  *
  293.  *                   Spacing - spacing between elements
  294.  *                   Active - initially active element
  295.  *                   List - the list of items
  296.  *                   Top - initial top element
  297.  *                   Count - total elements in the list
  298.  *                   cb_* - callbacks for drawing the list (optional)
  299.  *
  300.  *    Data2    (long) Return code when listview is double-clicked.
  301.  *
  302.  */
  303.  
  304. #define LEVEL_RIGHT     (0x0001)    /* Level placed to right of slider */
  305. #define LEVEL_ABOVE     (0x0002)    /* Level centered above slider */
  306. #define LEVEL_BELOW     (0x0003)    /* Level centered below slider */
  307.  
  308. #define LEVEL_CALLBACK  (0x8000)    /* Data7 is really a callback function */
  309.  
  310. /*
  311.  * EListView (2.0):
  312.  *
  313.  * Controls List_ID gadget styles.  Caller fills in appropriate
  314.  * fields when creating the gadget, Ged maintains the structure
  315.  * throughout its life.
  316.  *
  317.  */
  318.  
  319. struct EListView
  320. {
  321.  
  322.    void             *List;          /* Pointer to the list of "things"
  323.                                      * to maintain in the listview.
  324.                                      * This need not be an Exec List,
  325.                                      * but by default it is assumed
  326.                                      * to be.  You can use other kinds
  327.                                      * of lists by supplying your own
  328.                                      * callbacks for GetNode, NextNode,
  329.                                      * and PrevNode (see below).
  330.                                      */
  331.    unsigned short    Flags;         /* Various flag bits (see below) */
  332.    short             Count;         /* Total number of elements in the
  333.                                      * list.  Max 32K
  334.                                      */
  335.    short             Top;           /* Index of topmost element in the
  336.                                      * the list
  337.                                      */
  338.    short             Spacing;       /* Number of vertical pixels required
  339.                                      * for each element of the list.  Ie.
  340.                                      * Each element is this many pixels
  341.                                      * tall.  (Generally this would be
  342.                                      * the height of the font you're
  343.                                      * using.)
  344.                                      */
  345.    short             Active;        /* The element number that is "active".
  346.                                      * -1 means no element is active.
  347.                                      * The active element is the last one
  348.                                      * that was selected.  For a SHOWSELECTED
  349.                                      * list, it will be the one shown below
  350.                                      * the list.
  351.                                      */
  352.    short             Visible;       /* The number of elements that are
  353.                                      * visible per "page".  The GED
  354.                                      * system will figure this for you
  355.                                      * based on the height of your gadget.
  356.                                      */
  357.  
  358.                                     /* If not provided (ie. left NULL), the
  359.                                      * following callbacks default to
  360.                                      * assuming an Exec List style list.
  361.                                      */
  362.  
  363.    void           *(*cb_GetNode)(void *, short);
  364.                                     /* Callback function to retreive an
  365.                                      * element from the list
  366.                                      */
  367.    void           *(*cb_NextNode)(void *);
  368.                                     /* Callback function to advance to
  369.                                      * the next element in the list
  370.                                      */
  371.    void           *(*cb_PrevNode)(void *);
  372.                                     /* Callback function to back up to
  373.                                      * the previous element in the list
  374.                                      */
  375.  
  376.    /*
  377.     * One of cb_DrawNode or cb_NodeLabel must be provided, depending
  378.     * on how much control you want to have over the element drawing.
  379.     *
  380.     */
  381.    void            (*cb_DrawNode)(APTR, APTR, void *, short, short, short, short);
  382.                                     /*
  383.                                      * Callback to draw an element in
  384.                                      * the position indicated.  You are
  385.                                      * given a pointer to the element
  386.                                      * node and are required to do all
  387.                                      * the work of drawing yourself.
  388.                                      *
  389.                                      * Prototype:
  390.                                      *
  391.                                      *    DrawNode(window,
  392.                                      *             rastport,
  393.                                      *             node,
  394.                                      *             leftedge,
  395.                                      *             topedge,
  396.                                      *             width,
  397.                                      *             height);
  398.                                      *
  399.                                      * If not provided, cb_NodeName is
  400.                                      * used instead.
  401.                                      *
  402.                                      */
  403.    void            (*cb_NodeName)(void *, char *, short);
  404.                                     /* Callback to get the "name" of
  405.                                      * of a node.  This name is then
  406.                                      * rendered onscreen by GED.
  407.                                      *
  408.                                      * Prototype:
  409.                                      *
  410.                                      *    NodeName(node,
  411.                                      *             buffer,
  412.                                      *             maxlen);
  413.                                      *
  414.                                      * If not provided (ie. NULL), then
  415.                                      * it defaults to a callback that
  416.                                      * would work for an Exec List
  417.                                      * where each Node->ln_Name is
  418.                                      * used as the element label.
  419.                                      */
  420.  
  421.    long              reserved0[8];
  422.  
  423.    /* BEYOND THIS POINT IS PRIVATE! */
  424.  
  425.    APTR              Window;
  426.    APTR              RPort;
  427.    short             LeftEdge, TopEdge, Width, Height;
  428.    void             *TopNode;
  429.    short             SliderID, UpID, DownID, pad1;
  430.    ULONG             Secs, Micros;
  431.  
  432.    struct Gadget    *LVGad0, *LVGad1, *LVGad2, *LVGad3;
  433.  
  434.    long              reserved1[2];
  435.  
  436. };
  437.  
  438. /* EListView Flags: */
  439. #define ELVF_SHOWSELECTED  0x01     /* show selected item in area below
  440.                                        the list */
  441. #define ELVF_HIGHLIGHT     0x02     /* leave selected items highlighted */
  442.  
  443.  
  444. /*
  445.  *  These are to allow easy creation of gadget function prototypes:
  446.  *
  447.  *  For example:
  448.  *
  449.  *  int SaveCode (GedButtonProto)
  450.  *  {
  451.  *     return(0);
  452.  *  }
  453.  */
  454.  
  455. #define GedButtonProto  struct Window *w, struct Gadget *g, ULONG ud
  456. #define GedToggleProto  struct Window *w, struct Gadget *g, ULONG ud, long val
  457. #define GedStringProto  struct Window *w, struct Gadget *g, ULONG ud, char *text
  458. #define GedIntegerProto struct Window *w, struct Gadget *g, ULONG ud, long val
  459. #define GedSliderProto  struct Window *w, struct Gadget *g, ULONG ud, long val, BOOL moving
  460. #define GedCycleProto   struct Window *w, struct Gadget *g, ULONG ud, long idx
  461. #define GedCheckProto   struct Window *w, struct Gadget *g, ULONG ud, long val
  462. #define GedMXProto      struct Window *w, struct Gadget *g, ULONG ud, long val
  463. #define GedListProto    struct Window *w, struct Gadget *g, ULONG ud, long idx, struct EListView *lv
  464.  
  465. /* proto for callback for slider level: */
  466. #define GedSliderCBProto   struct Window *w, struct Gadget *g, ULONG ud, long val, char *stringbuf, int maxlen
  467.  
  468. /* Ancient compatibility - do not use: */
  469. #define Reserved1    Data5
  470. #define Reserved2    Data6
  471. #define Reserved3    Data7
  472. #define Reserved4    Data8
  473.  
  474. /* So we don't have to refer to `Data1', etc. */
  475. #define ng_RC        Data1
  476. #define ng_Key       Data2
  477. #define ng_Image     Data3
  478. #define ng_Select    Data1
  479. #define ng_Highest   Data1
  480. #define ng_Integer   Data2
  481. #define ng_Lowest    Data3
  482. #define ng_Next      Data4
  483. #define ng_MaxChars  Data1
  484. #define ng_String    Data2
  485. #define ng_Initial   Data2
  486. #define ng_Labels    Data1
  487. #define ng_Index     Data4
  488. #define ng_Exclude   Data3
  489.  
  490. /*
  491.  * GedContext - used to keep context information about a list of
  492.  *              NewGad's after they're created.  Should be considered
  493.  *              PRIVATE, and is subject to change without notice.
  494.  */
  495.  
  496. struct GedContext
  497. {
  498.    struct Gadget    *GadList;       /* Gadget List */
  499.    struct IntuiText *ITextList;     /* IntuiText List */
  500.    struct Border    *BorderList;    /* Border List */
  501.    struct Image     *ImageList;     /* Image List */
  502.    char            **TextArray;     /* Text array */
  503.    short             NumGads;       /* Number of gadgets */
  504.    short             NumGTGads;
  505.    struct Gadget    *GTList;        /* private */
  506.    long              Reserved2[7];
  507. };
  508.  
  509.  
  510. #define SCAN_GED_H
  511. #endif
  512.