home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 488.lha / modengine_v1.0 / mod.h < prev    next >
C/C++ Source or Header  |  1991-03-07  |  6KB  |  208 lines

  1. /* mod.h
  2.  * Copyright (C) 1990 Commodore-Amiga, Inc.
  3.  * written by David N. Junod
  4.  *
  5.  * header file for modengine1
  6.  * event processing engine structures & definitions
  7.  *
  8.  */
  9.  
  10. #include <intuition/intuition.h>
  11. #include <rexx/storage.h>    /* off of ARexx disk */
  12. #include <rexx/rxslib.h>    /* off of ARexx disk */
  13. #include <exec/ports.h>
  14. #include <exec/memory.h>
  15. #include <libraries/dos.h>
  16. #include <libraries/dosextens.h>
  17. #include <devices/inputevent.h>
  18. #include <proto/all.h>
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22.  
  23. /* mod_funcs.c: application functions */
  24. VOID NewFunc    (struct AppInfo *, struct Message *, UBYTE *args );
  25. VOID OpenFunc   (struct AppInfo *, struct Message *, UBYTE *args );
  26. VOID SaveFunc   (struct AppInfo *, struct Message *, UBYTE *args );
  27. VOID SaveAsFunc (struct AppInfo *, struct Message *, UBYTE *args );
  28. VOID AboutFunc  (struct AppInfo *, struct Message *, UBYTE *args );
  29. VOID QuitFunc   (struct AppInfo *, struct Message *, UBYTE *args );
  30. VOID ChooseFunc (struct AppInfo *, struct Message *, UBYTE *args );
  31. VOID DefineFunc (struct AppInfo *, struct Message *, UBYTE *args );
  32. VOID UndoFunc   (struct AppInfo *, struct Message *, UBYTE *args );
  33. VOID HelpFunc   (struct AppInfo *, struct Message *, UBYTE *args );
  34. VOID ArrowFunc  (struct AppInfo *, struct Message *, UBYTE *args );
  35. VOID ShellFunc  (struct AppInfo *, struct Message *, UBYTE *args );
  36. VOID WindowFunc (struct AppInfo *, struct Message *, UBYTE *args );
  37. VOID AbortFunc  (struct AppInfo *, struct Message *, UBYTE *args );
  38.  
  39. #define APPNAME "Our Application"
  40.  
  41. /* modengine1.c: initialization & dispatching routines */
  42. VOID main ( void );
  43. struct AppInfo *OpenAll ( void );
  44. VOID CloseAll (struct AppInfo *, int value , UBYTE *fmsg );
  45. BOOL HandlerFunc (struct AppInfo *, UBYTE * name, WORD function);
  46. struct MsgHandler * HandlerData (struct AppInfo *, UBYTE * name);
  47. BOOL AddMsgHandler (struct AppInfo *, struct MsgHandler *, BOOL);
  48. BOOL PerfFunc (struct AppInfo *, struct Message *, UBYTE *);
  49.  
  50. /* mod_misc.c: misc. functions */
  51. BOOL NotifyUser (struct Window *, UBYTE *);
  52. BOOL CheckForChanges (struct AppInfo * ai);
  53.  
  54. /* message handler node */
  55. struct MsgHandler
  56. {
  57.     struct Node mh_Node;
  58.     ULONG mh_SigBits;        /* signal bits to watch for */
  59.     WORD mh_Status;        /* current status */
  60.  
  61.     /* interface functions */
  62.     BOOL (*mh_Func[4])(struct AppInfo *, struct MsgHandler *);
  63.     VOID *mh_Data;        /* handler context data */
  64. };
  65.  
  66. /*--- interface function array pointers ---*/
  67. /* make a handler active */
  68. #define    MH_OPEN        0
  69. /* handle messages */
  70. #define    MH_HANDLE    1
  71. /* make a handler inactive */
  72. #define    MH_CLOSE    2
  73. /* free resources and delete handler */
  74. #define    MH_SHUTDOWN    3
  75.  
  76. /*--- node types ---*/
  77. /* message handler node */
  78. #define    MH_HANDLER_T    100
  79. /* data node */
  80. #define    MH_DATA_T    101
  81.  
  82. /*--- node priorities ---*/
  83. /* message handler node default priority */
  84. #define    MH_HANDLER_P    10
  85. /* data node default priority */
  86. #define    MH_DATA_P    -10
  87.  
  88. /* component for our function table */
  89. struct Funcs
  90. {
  91.     UBYTE *name;
  92.     VOID (*func)(struct AppInfo *, struct Message *, UBYTE *);
  93. };
  94.  
  95. /* no internal function defined for event */
  96. #define    NO_FUNCTION    NULL
  97.  
  98. /* make active when opened? */
  99. #define    ACTIVE        TRUE
  100. #define    INACTIVE    FALSE
  101.  
  102. /* required for application to run? */
  103. #define    REQUIRED    TRUE
  104. #define    OPTIONAL    FALSE
  105.  
  106. /*--- AREXX RELATED ITEMS -------------------------------------------------*/
  107. /* mod_arexx.c: AREXX message handling routines */
  108. struct MsgHandler *setup_arexx (struct AppInfo *, UBYTE *, UBYTE *, BOOL);
  109.  
  110. /* ARexx status definitions */
  111. #define AR_EXECUTE 0
  112. #define    AR_SUSPEND 1
  113.  
  114. /*--- DOS SHELL RELATED ITEMS ---------------------------------------------*/
  115. /* mod_dos.c: DOS message handling routines */
  116. struct MsgHandler *setup_dos (struct AppInfo *,UBYTE *,UBYTE *,UBYTE *, BOOL);
  117.  
  118. /* DOS shell status definitions */
  119. #define AS_CLOSED 0
  120. #define AS_CLOSING 1
  121. #define AS_GOING 2
  122. #define AS_OPEN 3
  123.  
  124. #define BUFFLEN      100
  125.  
  126. /*--- IDCMP RELATED ITEMS -------------------------------------------------*/
  127. /* mod_idcmp.c: IDCMP message handling routines */
  128. struct MsgHandler * setup_idcmp ( struct AppInfo *,
  129.          struct NewWindow *,struct KeyboardCMD *,struct Menu *,BOOL);
  130.  
  131. /* qualifiers to watch for in gadget related functions */
  132. #define SHIFTED (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)
  133.  
  134. /*--- MENU RELATED ITEMS ---*/
  135.  
  136. /* Extended MenuItem structure */
  137. struct EMenuItem
  138. {
  139.     struct MenuItem emi_Item;    /* embedded MenuItem structure */
  140.     UWORD emi_MenuID;        /* ID used for function number to perform */
  141.     VOID *emi_UserData;        /* UserData (like other Intuition structs) */
  142. };
  143.  
  144. /*--- GADGET RELATED ITEMS ---*/
  145.  
  146. /* Extended Gadget structure */
  147. struct EGadget
  148. {
  149.     struct Gadget eg_Gadget;    /* embedded Gadget structure */
  150.     WORD eg_Funcs[5];        /* Function array */
  151. };
  152.  
  153. /* Extended Gadget function array pointers */
  154. #define    EG_DOWNPRESS    0
  155. #define    EG_HOLD        1
  156. #define    EG_RELEASE    2
  157. #define    EG_DBLCLICK    3
  158. #define    EG_ABORT    4
  159.  
  160. /*--- KEYBOARD RELATED ITEMS ---*/
  161. #define    MAXKEYS    512
  162. #define    SPECIAL 255
  163.  
  164. /* some useful defines */
  165. #define    ESC    27
  166. #define    DELETE    127
  167. #define    HELP    (SPECIAL + '?')
  168. #define    FUNC1    (SPECIAL + '0')
  169. #define    FUNC2    (SPECIAL + '1')
  170. #define    FUNC3    (SPECIAL + '2')
  171. #define    FUNC4    (SPECIAL + '3')
  172. #define    FUNC5    (SPECIAL + '4')
  173. #define    FUNC6    (SPECIAL + '5')
  174. #define    FUNC7    (SPECIAL + '6')
  175. #define    FUNC8    (SPECIAL + '7')
  176. #define    FUNC9    (SPECIAL + '8')
  177. #define    FUNC10    (SPECIAL + '9')
  178. #define    UP    (SPECIAL + 'A')
  179. #define    DOWN    (SPECIAL + 'B')
  180. #define    RIGHT    (SPECIAL + 'C')
  181. #define    LEFT    (SPECIAL + 'D')
  182.  
  183. /* component for our keyboard command array */
  184. struct KeyboardCMD
  185. {
  186.     WORD key;
  187.     WORD funcID;
  188. };
  189.  
  190. /*--- GLOBAL DATA -----------------------------------------------------------*/
  191. /* AppInfo structure that contains our global variables */
  192. struct AppInfo
  193. {
  194.     struct List MsgList;    /* List of message handlers */
  195.     ULONG sigbits;        /* Sum of all signals */
  196.     struct Funcs *FuncTable;    /* Pointer to the function table */
  197.     BOOL Done;            /* Done with main loop? */
  198.     WORD numcmds;        /* Outstanding commands */
  199.     LONG pri_ret;        /* Primary error return value */
  200.     LONG sec_ret;        /* Secondary error return value */
  201.     UBYTE *textrtn;        /* Text return string */
  202.  
  203.     /* Project information */
  204.     UBYTE ProjPath[255];    /* Path of project */
  205.     UBYTE ProjName[31];        /* Name of project */
  206.     BOOL Changed;        /* Changes made to project? */
  207. };
  208.