home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / cbm / os-include.lha / os-include / intuition / sghooks.i < prev   
Text File  |  1993-10-15  |  7KB  |  215 lines

  1.     IFND INTUITION_SGHOOKS_I
  2. INTUITION_SGHOOKS_I SET 1
  3. **
  4. ** $VER: sghooks.i 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.     IFND EXEC_TYPES_I
  14.     INCLUDE "exec/types.i"
  15.     ENDC
  16.  
  17.  STRUCTURE StringExtend,0
  18.     ; display specifications
  19.     APTR    sex_Font    ; must be an open Font (not TextAttr)
  20.     STRUCT    sex_Pens,2    ; color of text/background
  21.     STRUCT    sex_ActivePens,2 ; colors when gadget is active
  22.  
  23.     ; edit specifications
  24.     ULONG    sex_InitialModes ; initial mode flags, below
  25.     APTR    sex_EditHook    ; if non-NULL, must supply WorkBuffer
  26.     APTR    sex_WorkBuffer    ; must be as large as StringInfo.Buffer
  27.  
  28.     STRUCT    sex_Reserved,16    ; set to 0
  29.  LABEL    sex_SIZEOF
  30.  
  31.  
  32.  STRUCTURE SGWork,0
  33.     ; set up when gadget is first activated
  34.     APTR        sgw_Gadget    ; the contestant itself
  35.     APTR        sgw_StringInfo    ; easy access to sinfo
  36.     APTR        sgw_WorkBuffer    ; intuition's planned result
  37.     APTR        sgw_PrevBuffer    ; what was there before
  38.     ULONG        sgw_Modes    ; current mode
  39.  
  40.     ; modified for each input event
  41.     APTR        sgw_IEvent    ; actual event: do not change
  42.     UWORD        sgw_Code    ; character code, if one byte
  43.     WORD        sgw_BufferPos    ; cursor position
  44.     WORD        sgw_NumChars
  45.     ULONG        sgw_Actions    ; what Intuition will do
  46.     LONG        sgw_LongInt    ; temp storage for longint
  47.  
  48.     APTR        sgw_GadgetInfo    ; see cghooks.h
  49.     UWORD        sgw_EditOp    ; from constants below
  50.  LABEL    sgw_SIZEOF    ; this may change as the structure is extended
  51.  
  52.  
  53. * SGWork.EditOp -
  54. * These values indicate what basic type of operation the global
  55. * editing hook has performed on the string before your gadget's custom
  56. * editing hook gets called.  You do not have to be concerned with the
  57. * value your custom hook leaves in the sgw_EditOp field, only if you
  58. * write a global editing hook.
  59. *
  60. * For most of these general edit operations, you'll want to compare
  61. * the BufferPos and NumChars of the StringInfo (before global editing)
  62. * and SGWork (after global editing).
  63.  
  64. EO_NOOP        EQU ($0001)
  65.     ; did nothing
  66. EO_DELBACKWARD    EQU ($0002)
  67.     ; deleted some chars (maybe 0).
  68. EO_DELFORWARD    EQU ($0003)
  69.     ; deleted some characters under and in front of the cursor
  70. EO_MOVECURSOR    EQU ($0004)
  71.     ; moved the cursor
  72. EO_ENTER    EQU ($0005)
  73.         ; "enter" or "return" key, terminate
  74. EO_RESET    EQU ($0006)
  75.     ; current Intuition-style undo    
  76. EO_REPLACECHAR    EQU ($0007)
  77.     ; replaced one character and (maybe) advanced cursor
  78. EO_INSERTCHAR    EQU ($0008)
  79.     ; inserted one char into string or added one at end
  80. EO_BADFORMAT    EQU ($0009)
  81.     ; didn't like the text data, e.g., Bad LONGINT
  82. EO_BIGCHANGE    EQU ($000A)    ; unused by Intuition
  83.     ; complete or major change to the text, e.g. new string
  84. EO_UNDO        EQU ($000B)    ; unused by Intuition
  85.     ; some other style of undo
  86. EO_CLEAR    EQU ($000C)
  87.     ; clear the string
  88. EO_SPECIAL    EQU ($000D)    ; unused by Intuition
  89.     ; some operation that doesn't fit into the categories here
  90.  
  91.  
  92. ; Mode Flags definitions (ONLY first group allowed as InitialModes)
  93.  
  94. SGM_REPLACE    EQU    1
  95. SGMB_REPLACE    EQU    0
  96. SGMF_REPLACE    EQU    1
  97. ; please initialize StringInfo with in-range value of BufferPos 
  98. ; if you are using SGM_REPLACE mode.
  99.  
  100. ; fixed length buffer, always set SGM_REPLACE, too.
  101. SGM_FIXEDFIELD    EQU $00000002
  102. SGMB_FIXEDFIELD    EQU 1
  103. SGMF_FIXEDFIELD    EQU 2
  104.  
  105. ; don't filter control chars
  106. SGM_NOFILTER    EQU $00000004
  107. SGMB_NOFILTER    EQU 2
  108. SGMF_NOFILTER    EQU 4
  109.  
  110. ; SGM_EXITHELP is new for V37, and ignored by V36:
  111. ; exit with code = 0x5F if HELP hit
  112. SGM_EXITHELP    EQU $00000080
  113. SGMB_EXITHELP    EQU 7
  114. SGMF_EXITHELP    EQU $80
  115.  
  116.  
  117. ; String Gadget Action Flags (put in SGWork.Actions by EditHook)
  118. SGA_USE        EQU $1        ; use contents of SGWork
  119. SGAB_USE    EQU 0
  120. SGAF_USE    EQU $1
  121.  
  122. SGA_END        EQU $2        ; terminate gadget, code in Code field
  123. SGAB_END    EQU 1
  124. SGAF_END    EQU $2
  125.  
  126. SGA_BEEP    EQU $4        ; flash the screen for the user
  127. SGAB_BEEP    EQU 2
  128. SGAF_BEEP    EQU $4
  129.  
  130. SGA_REUSE    EQU $8        ; reuse input event
  131. SGAB_REUSE    EQU 3
  132. SGAF_REUSE    EQU $8
  133.  
  134. SGA_REDISPLAY    EQU $10        ; gadget visuals changed
  135. SGAB_REDISPLAY        EQU 4
  136. SGAF_REDISPLAY        EQU $10
  137.  
  138. ; New for V37:
  139. SGA_NEXTACTIVE    EQU $20        ; Make next possible gadget active.
  140. SGAB_NEXTACTIVE    EQU 5
  141. SGAF_NEXTACTIVE    EQU $20
  142.  
  143. ; New for V37:
  144. SGA_PREVACTIVE    EQU $40        ; Make previous possible gadget active.
  145. SGAB_PREVACTIVE    EQU 6
  146. SGAF_PREVACTIVE    EQU $40
  147.  
  148.  
  149. ; function id for only existing custom string gadget edit hook
  150. SGH_KEY        EQU    1    ; process editing keystroke
  151. SGH_CLICK    EQU    2    ; process mouse click cursor position
  152.  
  153. * Here's a brief summary of how the custom string gadget edit hook works:
  154. *    You provide a hook in StringInfo.Extension.EditHook.
  155. *    The hook is called in the standard way with the 'object'
  156. *    a pointer to SGWork, and the 'message' a pointer to a command
  157. *    block, starting either with (longword) SGH_KEY, SGH_CLICK,
  158. *    or something new.
  159. *
  160. *    You return 0 if you don't understand the command (SGH_KEY is
  161. *    required and assumed).    Return non-zero if you implement the
  162. *    command.
  163. *
  164. *   SGH_KEY:
  165. *    There are no parameters following the command longword.
  166. *
  167. *    Intuition will put its idea of proper values in the SGWork
  168. *    before calling you, and if you leave SGA_USE set in the
  169. *    SGWork.Actions field, Intuition will use the values
  170. *    found in SGWork fields WorkBuffer, NumChars, BufferPos,
  171. *    and LongInt, copying the WorkBuffer back to the StringInfo
  172. *    Buffer.
  173. *
  174. *    NOTE WELL: You may NOT change other SGWork fields.
  175. *
  176. *    If you clear SGA_USE, the string gadget will be unchanged.
  177. *
  178. *    If you set SGA_END, Intuition will terminate the activation
  179. *    of the string gadget.  If you also set SGA_REUSE, Intuition
  180. *    will reuse the input event after it deactivates your gadget.
  181. *
  182. *    In this case, Intuition will put the value found in SGWork.Code
  183. *    into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
  184. *    sends to the application.
  185. *
  186. *    If you set SGA_BEEP, Intuition will call DisplayBeep(); use
  187. *    this if the user has typed in error, or buffer is full.
  188. *
  189. *    Set SGA_REDISPLAY if the changes to the gadget warrant a
  190. *    gadget redisplay.  Note: cursor movement requires a redisplay.
  191. *
  192. *    Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
  193. *    when you set SGA_END.  This tells Intuition that you want
  194. *    the next or previous gadget with GFLG_TABCYCLE to be activated.
  195. *
  196. *   SGH_CLICK:
  197. *    This hook command is called when Intuition wants to position
  198. *    the cursor in response to a mouse click in the string gadget.
  199. *
  200. *    Again, here are no parameters following the command longword.
  201. *
  202. *    This time, Intuition has already calculated the mouse position
  203. *    character cell and put it in SGWork.BufferPos.    The previous
  204. *    BufferPos value remains in the SGWork.StringInfo.BufferPos.
  205. *
  206. *    Intuition will again use the SGWork fields listed above for
  207. *    SGH_KEY.  One restriction is that you are NOT allowed to set
  208. *    SGA_END or SGA_REUSE for this command.    Intuition will not
  209. *    stand for a gadget which goes inactive when you click in it.
  210. *
  211. *    You should always leave the SGA_REDISPLAY flag set, since Intuition
  212. *    uses this processing when activating a string gadget.
  213.  
  214.     ENDC
  215.