home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / os-include / intuition / sghooks.h < prev    next >
C/C++ Source or Header  |  1993-10-15  |  7KB  |  190 lines

  1. #ifndef INTUITION_SGHOOKS_H
  2. #define INTUITION_SGHOOKS_H TRUE
  3. /*
  4. **  $VER: sghooks.h 38.1 (11.11.91)
  5. **  Includes Release 40.15
  6. **
  7. **  string gadget extensions and hooks
  8. **
  9. **  (C) Copyright 1988-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif
  16.  
  17. struct StringExtend {
  18.     /* display specifications    */
  19.     struct TextFont *Font;    /* must be an open Font (not TextAttr)    */
  20.     UBYTE    Pens[2];    /* color of text/backgroun        */
  21.     UBYTE    ActivePens[2];    /* colors when gadget is active        */
  22.  
  23.     /* edit specifications    */
  24.     ULONG    InitialModes;    /* initial mode flags, below        */
  25.     struct Hook *EditHook;    /* if non-NULL, must supply WorkBuffer    */
  26.     UBYTE    *WorkBuffer;    /* must be as large as StringInfo.Buffer*/
  27.  
  28.     ULONG    Reserved[4];    /* set to 0                */
  29. };
  30.  
  31. struct SGWork    {
  32.     /* set up when gadget is first activated    */
  33.     struct Gadget    *Gadget;    /* the contestant itself    */
  34.     struct StringInfo    *StringInfo;    /* easy access to sinfo        */
  35.     UBYTE        *WorkBuffer;    /* intuition's planned result    */
  36.     UBYTE        *PrevBuffer;    /* what was there before    */
  37.     ULONG        Modes;        /* current mode            */
  38.  
  39.     /* modified for each input event    */
  40.     struct InputEvent    *IEvent;    /* actual event: do not change    */
  41.     UWORD        Code;        /* character code, if one byte    */
  42.     WORD        BufferPos;    /* cursor position        */
  43.     WORD        NumChars;
  44.     ULONG        Actions;    /* what Intuition will do    */
  45.     LONG        LongInt;    /* temp storage for longint    */
  46.  
  47.     struct GadgetInfo    *GadgetInfo;    /* see cghooks.h        */
  48.     UWORD        EditOp;        /* from constants below        */
  49. };
  50.  
  51. /* SGWork.EditOp -
  52.  * These values indicate what basic type of operation the global
  53.  * editing hook has performed on the string before your gadget's custom
  54.  * editing hook gets called.  You do not have to be concerned with the
  55.  * value your custom hook leaves in the EditOp field, only if you
  56.  * write a global editing hook.
  57.  *
  58.  * For most of these general edit operations, you'll want to compare
  59.  * the BufferPos and NumChars of the StringInfo (before global editing)
  60.  * and SGWork (after global editing).
  61.  */
  62.  
  63. #define EO_NOOP        (0x0001)
  64.     /* did nothing                            */
  65. #define EO_DELBACKWARD    (0x0002)
  66.     /* deleted some chars (maybe 0).                */
  67. #define EO_DELFORWARD    (0x0003)
  68.     /* deleted some characters under and in front of the cursor    */
  69. #define EO_MOVECURSOR    (0x0004)
  70.     /* moved the cursor                        */
  71. #define EO_ENTER    (0x0005)
  72.     /* "enter" or "return" key, terminate                */
  73. #define EO_RESET    (0x0006)
  74.     /* current Intuition-style undo                    */
  75. #define EO_REPLACECHAR    (0x0007)
  76.     /* replaced one character and (maybe) advanced cursor        */
  77. #define EO_INSERTCHAR    (0x0008)
  78.     /* inserted one char into string or added one at end        */
  79. #define EO_BADFORMAT    (0x0009)
  80.     /* didn't like the text data, e.g., Bad LONGINT            */
  81. #define EO_BIGCHANGE    (0x000A)    /* unused by Intuition    */
  82.     /* complete or major change to the text, e.g. new string    */
  83. #define EO_UNDO        (0x000B)    /* unused by Intuition    */
  84.     /* some other style of undo                    */
  85. #define EO_CLEAR    (0x000C)
  86.     /* clear the string                        */
  87. #define EO_SPECIAL    (0x000D)    /* unused by Intuition    */
  88.     /* some operation that doesn't fit into the categories here    */
  89.  
  90.  
  91. /* Mode Flags definitions (ONLY first group allowed as InitialModes)    */
  92. #define SGM_REPLACE    (1L << 0)    /* replace mode            */
  93. /* please initialize StringInfo with in-range value of BufferPos
  94.  * if you are using SGM_REPLACE mode.
  95.  */
  96.  
  97. #define SGM_FIXEDFIELD    (1L << 1)    /* fixed length buffer        */
  98.                     /* always set SGM_REPLACE, too    */
  99. #define SGM_NOFILTER    (1L << 2)    /* don't filter control chars    */
  100.  
  101. /* SGM_EXITHELP is new for V37, and ignored by V36: */
  102. #define SGM_EXITHELP    (1L << 7)    /* exit with code = 0x5F if HELP hit */
  103.  
  104.  
  105. /* These Mode Flags are for internal use only                */
  106. #define SGM_NOCHANGE    (1L << 3)    /* no edit changes yet        */
  107. #define SGM_NOWORKB    (1L << 4)    /* Buffer == PrevBuffer        */
  108. #define SGM_CONTROL    (1L << 5)    /* control char escape mode    */
  109. #define SGM_LONGINT    (1L << 6)    /* an intuition longint gadget    */
  110.  
  111. /* String Gadget Action Flags (put in SGWork.Actions by EditHook)    */
  112. #define SGA_USE        (0x1L)    /* use contents of SGWork        */
  113. #define SGA_END        (0x2L)    /* terminate gadget, code in Code field    */
  114. #define SGA_BEEP    (0x4L)    /* flash the screen for the user    */
  115. #define SGA_REUSE    (0x8L)    /* reuse input event            */
  116. #define SGA_REDISPLAY    (0x10L)    /* gadget visuals changed        */
  117.  
  118. /* New for V37: */
  119. #define SGA_NEXTACTIVE    (0x20L)    /* Make next possible gadget active.    */
  120. #define SGA_PREVACTIVE    (0x40L)    /* Make previous possible gadget active.*/
  121.  
  122. /* function id for only existing custom string gadget edit hook    */
  123.  
  124. #define SGH_KEY        (1L)    /* process editing keystroke        */
  125. #define SGH_CLICK    (2L)    /* process mouse click cursor position    */
  126.  
  127. /* Here's a brief summary of how the custom string gadget edit hook works:
  128.  *    You provide a hook in StringInfo.Extension.EditHook.
  129.  *    The hook is called in the standard way with the 'object'
  130.  *    a pointer to SGWork, and the 'message' a pointer to a command
  131.  *    block, starting either with (longword) SGH_KEY, SGH_CLICK,
  132.  *    or something new.
  133.  *
  134.  *    You return 0 if you don't understand the command (SGH_KEY is
  135.  *    required and assumed).    Return non-zero if you implement the
  136.  *    command.
  137.  *
  138.  *   SGH_KEY:
  139.  *    There are no parameters following the command longword.
  140.  *
  141.  *    Intuition will put its idea of proper values in the SGWork
  142.  *    before calling you, and if you leave SGA_USE set in the
  143.  *    SGWork.Actions field, Intuition will use the values
  144.  *    found in SGWork fields WorkBuffer, NumChars, BufferPos,
  145.  *    and LongInt, copying the WorkBuffer back to the StringInfo
  146.  *    Buffer.
  147.  *
  148.  *    NOTE WELL: You may NOT change other SGWork fields.
  149.  *
  150.  *    If you clear SGA_USE, the string gadget will be unchanged.
  151.  *
  152.  *    If you set SGA_END, Intuition will terminate the activation
  153.  *    of the string gadget.  If you also set SGA_REUSE, Intuition
  154.  *    will reuse the input event after it deactivates your gadget.
  155.  *
  156.  *    In this case, Intuition will put the value found in SGWork.Code
  157.  *    into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
  158.  *    sends to the application.
  159.  *
  160.  *    If you set SGA_BEEP, Intuition will call DisplayBeep(); use
  161.  *    this if the user has typed in error, or buffer is full.
  162.  *
  163.  *    Set SGA_REDISPLAY if the changes to the gadget warrant a
  164.  *    gadget redisplay.  Note: cursor movement requires a redisplay.
  165.  *
  166.  *    Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
  167.  *    when you set SGA_END.  This tells Intuition that you want
  168.  *    the next or previous gadget with GFLG_TABCYCLE to be activated.
  169.  *
  170.  *   SGH_CLICK:
  171.  *    This hook command is called when Intuition wants to position
  172.  *    the cursor in response to a mouse click in the string gadget.
  173.  *
  174.  *    Again, here are no parameters following the command longword.
  175.  *
  176.  *    This time, Intuition has already calculated the mouse position
  177.  *    character cell and put it in SGWork.BufferPos.    The previous
  178.  *    BufferPos value remains in the SGWork.StringInfo.BufferPos.
  179.  *
  180.  *    Intuition will again use the SGWork fields listed above for
  181.  *    SGH_KEY.  One restriction is that you are NOT allowed to set
  182.  *    SGA_END or SGA_REUSE for this command.    Intuition will not
  183.  *    stand for a gadget which goes inactive when you click in it.
  184.  *
  185.  *    You should always leave the SGA_REDISPLAY flag set, since Intuition
  186.  *    uses this processing when activating a string gadget.
  187.  */
  188.  
  189. #endif
  190.