home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / GED403R.LZX / Install / Install.run / GOLDEDDATA / developer / api / include / api.h
Encoding:
C/C++ Source or Header  |  1996-07-11  |  9.8 KB  |  263 lines

  1. #ifndef API_H
  2. #define API_H
  3. /*
  4. **      $Filename: fd/api.h
  5. **      $Release: 6
  6. **
  7. **      API-2 definitions.
  8. **
  9. **      (C) Copyright 1996 Dietmar Eilert
  10. **          All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif
  16.  
  17. #ifndef EXEC_LISTS_H
  18. #include <exec/lists.h>
  19. #endif
  20.  
  21. #ifndef EXEC_LISTS_H
  22. #include <exec/lists.h>
  23. #endif
  24.  
  25. #ifndef INTUITION_INTUITION_H
  26. #include <intuition/intuition.h>
  27. #endif
  28.  
  29. #ifndef UTILITY_TAGITEM_H
  30. #include <utility/tagitem>
  31. #endif
  32.  
  33. #ifndef WORKBENCH_WORKBENCH_H
  34. #include <workbench/workbench.h>
  35. #endif
  36.  
  37. #ifndef MAKE_ID
  38. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  39. #endif
  40.  
  41. #define API_MAGIC  MAKE_ID('A','P','I','2')
  42.  
  43. /* library base */
  44.  
  45. struct APIBase {
  46.  
  47.     struct Library  Libary;                          /* standard library */
  48.     UWORD           pad;                             /* we are now longwod aligned */
  49.     ULONG           Magic;                           /* used to recognize API libraries */
  50. };
  51.  
  52.  
  53. /* -------------------------------- APIMessage ---------------------------------
  54.  
  55.  API messages are sent from a host (or an instance of the host)  to  clients.
  56.  API messages are linked (api_Next; may be NULL). The client has to check the
  57.  api_State field before processing the message  (must  be  API_STATE_NOTIFY).
  58.  Check  the  api_Class  field  to  determine  the  basic  message  type (e.g.
  59.  API_CLASS_SCREEN if the message is related to screen  handling).  Check  the
  60.  api_Action  field  to  determine the actual command (e.g. API_ACTION_HIDE if
  61.  the host wants you to close  your  windows).  A  client  should  update  the
  62.  api_Error field after having processed the message.
  63.  
  64. */
  65.  
  66. struct APIMessage {
  67.  
  68.     /* info slots (read-only) */
  69.  
  70.     ULONG                     api_State;             /* set by host: API message state (see below) */
  71.     struct APIMessage        *api_Next;              /* set by host: next APIMessage */
  72.     struct APIInstance       *api_Instance;          /* set by host: sender (instance of host) */
  73.  
  74.     /* command slots */
  75.  
  76.     ULONG                     api_Class;             /* set by host: notify class (see below) */
  77.     ULONG                     api_Action;            /* set by host: notify code  (see below) */
  78.     ULONG                     api_Qualifier;         /* set by host: intuition qualifier of last input event */
  79.     APTR                      api_Data;              /* set by host: all-purpose slot; usage depends on api_Class */
  80.     UBYTE                    *api_Command;           /* set by host: command string passed to client (read-only), command part uppercase */
  81.  
  82.     /* return code slots */
  83.  
  84.     LONG                      api_RC;                /* set by client: client's primary return code */
  85.     UBYTE                    *api_CommandResult;     /* set by client: command result string */
  86.     UBYTE                    *api_CommandError;      /* set by client: command error  string */
  87.     ULONG                     api_Error;             /* set by client: return code (see below) */
  88.     ULONG                     api_Refresh;           /* set by client: display refresh request */
  89.     struct APIOrder          *api_Order;             /* set by client: orders (depends on command set of host) */
  90. };
  91.  
  92.  
  93. /* supported api_State values */
  94.  
  95. #define API_STATE_IGNORE      0                      /* this messages should be ignored */
  96. #define API_STATE_NOTIFY      1                      /* this is a standard notify message */
  97. #define API_STATE_CONSUMED    2                      /* message consumed; won't be passed to other clients */
  98.  
  99.  
  100. /* api action classes */
  101.  
  102. #define API_CLASS_SCREEN      (1L<<1)                /* screen handling  */
  103. #define API_CLASS_KEY         (1L<<2)                /* keyboard event */
  104. #define API_CLASS_COMMAND     (1L<<3)                /* command event */
  105. #define API_CLASS_MOUSE       (1L<<4)                /* mouseclick event */
  106. #define API_CLASS_REFRESH     (1L<<5)                /* refresh request  */
  107. #define API_CLASS_SYSTEM      (1L<<6)                /* notifies */
  108.  
  109.  
  110. /* Supported api_Action values for API_CLASS_KEY */
  111.  
  112. #define API_ACTION_VANILLAKEY 1                      /* vanillakey event; key code passed in api_Data */
  113. #define API_ACTION_RAWKEY     2                      /* rawkey event; key code passed in api_Data */
  114.  
  115.  
  116. /* Supported api_Action values for API_CLASS_SCREEN */
  117.  
  118. #define API_ACTION_HIDE       1                      /* close your window(s) - host will close display */
  119. #define API_ACTION_SHOW       2                      /* open  your window(s) - host display available */
  120.  
  121.  
  122. /* Supported api_Action values for API_CLASS_COMMAND */
  123.  
  124. #define API_ACTION_COMMAND    1                      /* command passed to client (api_Command) */
  125.  
  126.  
  127. /* Supported api_Action values for API_CLASS_MOUSE */
  128.  
  129. #define API_ACTION_CLICK      1                      /* mouse click into client area (api_Data points to coordinates) */
  130.  
  131.  
  132. /* Supported api_Action values for API_CLASS_REFRESH */
  133.  
  134. #define API_ACTION_RESIZED    1                      /* client area has been resized */
  135.  
  136.  
  137. /* Supported api_Action values for API_CLASS_SYSTEM */
  138.  
  139. #define API_ACTION_WELCOME    1                      /* start client */
  140. #define API_ACTION_EXIT       2                      /* host requests client to quit */
  141.  
  142. /* Supported api_Error values - set by client */
  143.  
  144. #define API_ERROR_OK          0                      /* notify successfully processed */
  145. #define API_ERROR_FAIL        1                      /* processing of notify failed */
  146. #define API_ERROR_UNKNOWN     2                      /* unknown api_Code/api_Class detected */
  147.  
  148.  
  149. /* supported refresh types (api_Refresh) - requested by client */
  150.  
  151. #define API_REFRESH_DISPLAY   (1L<<1)                /* redraw display      */
  152. #define API_REFRESH_LINE      (1L<<2)                /* redraw current line */
  153. #define API_REFRESH_SYNC      (1L<<3)                /* sync view           */
  154. #define API_REFRESH_NOMARKER  (1L<<4)                /* hide selection      */
  155. #define API_REFRESH_MARKER    (1L<<8)                /* refresh marker      */
  156.  
  157.  
  158. /* ---------------------------------- APIHost ----------------------------------
  159.  
  160.  Host description (read-only): provided by host
  161.  
  162. */
  163.  
  164. struct APIHost {
  165.  
  166.     ULONG                     api_APIVersion;        /* interface standard supported by host */
  167.     ULONG                     api_Version;           /* release code */
  168.     ULONG                     api_Serial;            /* serial code of host */
  169.     UBYTE                    *api_Name;              /* application name */
  170.     UBYTE                    *api_Info;              /* application info */
  171.     APTR                      api_Environment;       /* configuration (host-specific) */
  172.  
  173.     /* private data may follow (depends on host) */
  174. };
  175.  
  176. #define API_INTERFACE_VERSION 2
  177.  
  178.  
  179. /* -------------------------------- APIInstance --------------------------------
  180.  
  181.  Instance description (read-only): provided by host.
  182.  
  183. */
  184.  
  185. struct APIInstance {
  186.  
  187.     struct APIHost           *api_Host;              /* host application */
  188.     UBYTE                    *api_Name;              /* instance name */
  189.     APTR                      api_Environment;       /* configuration (host-specific) */
  190.     struct Screen            *api_Screen;            /* screen used by instance */
  191.     struct Window            *api_Window;            /* window used by instance */
  192.     struct APIContainer      *api_Area;              /* reserved area provided by instance */
  193.  
  194.     /* private data may follow (depends on host) */
  195. };
  196.  
  197.  
  198. /* --------------------------------- APIClient ---------------------------------
  199.  
  200.  Client description (read-only): provided by client
  201.  
  202. */
  203.  
  204.  
  205. struct APIClient {
  206.  
  207.     ULONG                     api_APIVersion;        /* interface standard supported by client */
  208.     ULONG                     api_Version;           /* release code */
  209.     UBYTE                    *api_Name;              /* client name */
  210.     UBYTE                    *api_Info;              /* client info */
  211.     UBYTE                   **api_Commands;          /* command list (NULL-terminated) */
  212.     ULONG                     api_Serial;            /* serial code of client */
  213.     ULONG                     api_Classes;           /* class request */
  214.     struct APIContainer      *api_Area;              /* area request */
  215.  
  216.     /* private data may follow (depends on client) */
  217. };
  218.  
  219.  
  220. /* ------------------------------------ APIOrder -------------------------------
  221.  
  222.  Orders (host-specific) are created by clients and attached to APIMessages
  223.  
  224. */
  225.  
  226.  
  227. struct APIOrder {
  228.  
  229.     struct APIOrder          *api_Next;              /* next order or NULL */
  230.     APTR                      api_Data;              /* host-specific data */
  231.  
  232.     /* more data may follow */
  233. };
  234.  
  235.  
  236. /* ------------------------------- APIContainer --------------------------------
  237.  
  238.  Reserved area provided by instance, controlled by client (numeric values are
  239.  overridden by alignment flags)
  240.  
  241. */
  242.  
  243. struct APIContainer {
  244.  
  245.     struct Window            *api_Window;            /* window   */
  246.     struct Screen            *api_Screen;            /* screen   */
  247.     struct RastPort          *api_Rast;              /* rastport */
  248.     UWORD                    *api_Align;             /* alignment flags */
  249.     UWORD                    *api_Left;              /* dimensions */
  250.     UWORD                    *api_Top;               /* dimensions */
  251.     UWORD                    *api_Width;             /* dimensions */
  252.     UWORD                    *api_Height;            /* dimensions */
  253. };
  254.  
  255. #define API_CONTAINER_ALIGN_TOP         0            /* alignment flag */
  256. #define API_CONTAINER_ALIGN_BOTTOM      1            /* alignment flag */
  257. #define API_CONTAINER_ALIGN_LEFT        2            /* alignment flag */
  258. #define API_CONTAINER_ALIGN_RIGHT       4            /* alignment flag */
  259. #define API_CONTAINER_ALIGN_RELWIDTH    8            /* alignment flag */
  260. #define API_CONTAINER_ALIGN_RELHEIGHT   16           /* alignment flag */
  261.  
  262. #endif
  263.