home *** CD-ROM | disk | FTP | other *** search
/ Amiga Times / AmigaTimes.iso / programme / GoldED / developer / api / include / api.h
Encoding:
C/C++ Source or Header  |  1998-10-06  |  9.9 KB  |  264 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.h>
  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  Library;                         /* 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.     UBYTE                    *api_Status;            /* set by client: status message */
  91. };
  92.  
  93.  
  94. /* supported api_State values */
  95.  
  96. #define API_STATE_IGNORE      0                      /* this messages should be ignored */
  97. #define API_STATE_NOTIFY      1                      /* this is a standard notify message */
  98. #define API_STATE_CONSUMED    2                      /* message consumed; won't be passed to other clients */
  99.  
  100.  
  101. /* api action classes */
  102.  
  103. #define API_CLASS_SCREEN      (1L<<1)                /* screen handling  */
  104. #define API_CLASS_KEY         (1L<<2)                /* keyboard event */
  105. #define API_CLASS_COMMAND     (1L<<3)                /* command event */
  106. #define API_CLASS_MOUSE       (1L<<4)                /* mouseclick event */
  107. #define API_CLASS_REFRESH     (1L<<5)                /* refresh request  */
  108. #define API_CLASS_SYSTEM      (1L<<6)                /* notifies */
  109.  
  110.  
  111. /* Supported api_Action values for API_CLASS_KEY */
  112.  
  113. #define API_ACTION_VANILLAKEY 1                      /* vanillakey event; key code passed in api_Data */
  114. #define API_ACTION_RAWKEY     2                      /* rawkey event; key code passed in api_Data */
  115.  
  116.  
  117. /* Supported api_Action values for API_CLASS_SCREEN */
  118.  
  119. #define API_ACTION_HIDE       1                      /* close your window(s) - host will close display */
  120. #define API_ACTION_SHOW       2                      /* open  your window(s) - host display available */
  121.  
  122.  
  123. /* Supported api_Action values for API_CLASS_COMMAND */
  124.  
  125. #define API_ACTION_COMMAND    1                      /* command passed to client (api_Command) */
  126.  
  127.  
  128. /* Supported api_Action values for API_CLASS_MOUSE */
  129.  
  130. #define API_ACTION_CLICK      1                      /* mouse click into client area (api_Data points to coordinates) */
  131.  
  132.  
  133. /* Supported api_Action values for API_CLASS_REFRESH */
  134.  
  135. #define API_ACTION_RESIZED    1                      /* client area has been resized */
  136.  
  137.  
  138. /* Supported api_Action values for API_CLASS_SYSTEM */
  139.  
  140. #define API_ACTION_WELCOME    1                      /* start client */
  141. #define API_ACTION_EXIT       2                      /* host requests client to quit */
  142.  
  143. /* Supported api_Error values - set by client */
  144.  
  145. #define API_ERROR_OK          0                      /* notify successfully processed */
  146. #define API_ERROR_FAIL        1                      /* processing of notify failed */
  147. #define API_ERROR_UNKNOWN     2                      /* unknown api_Code/api_Class detected */
  148.  
  149.  
  150. /* supported refresh types (api_Refresh) - requested by client */
  151.  
  152. #define API_REFRESH_DISPLAY   (1L<<1)                /* redraw display         */
  153. #define API_REFRESH_LINE      (1L<<2)                /* redraw current line    */
  154. #define API_REFRESH_SYNC      (1L<<3)                /* sync view              */
  155. #define API_REFRESH_NOMARKER  (1L<<4)                /* hide selection         */
  156. #define API_REFRESH_MARKER    (1L<<8)                /* refresh marker         */
  157.  
  158.  
  159. /* ---------------------------------- APIHost ----------------------------------
  160.  
  161.  Host description (read-only): provided by host
  162.  
  163. */
  164.  
  165. struct APIHost {
  166.  
  167.     ULONG                     api_APIVersion;        /* interface standard supported by host */
  168.     ULONG                     api_Version;           /* release code */
  169.     ULONG                     api_Serial;            /* serial code of host */
  170.     UBYTE                    *api_Name;              /* application name */
  171.     UBYTE                    *api_Info;              /* application info */
  172.     APTR                      api_Environment;       /* configuration (host-specific) */
  173.  
  174.     /* private data may follow (depends on host) */
  175. };
  176.  
  177. #define API_INTERFACE_VERSION 3
  178.  
  179.  
  180. /* -------------------------------- APIInstance --------------------------------
  181.  
  182.  Instance description (read-only): provided by host.
  183.  
  184. */
  185.  
  186. struct APIInstance {
  187.  
  188.     struct APIHost           *api_Host;              /* host application */
  189.     UBYTE                    *api_Name;              /* instance name */
  190.     APTR                      api_Environment;       /* configuration (host-specific) */
  191.     struct Screen            *api_Screen;            /* screen used by instance */
  192.     struct Window            *api_Window;            /* window used by instance */
  193.     struct APIContainer      *api_Area;              /* reserved area provided by instance */
  194.  
  195.     /* private data may follow (depends on host) */
  196. };
  197.  
  198.  
  199. /* --------------------------------- APIClient ---------------------------------
  200.  
  201.  Client description (read-only): provided by client
  202.  
  203. */
  204.  
  205.  
  206. struct APIClient {
  207.  
  208.     ULONG                     api_APIVersion;        /* interface standard supported by client */
  209.     ULONG                     api_Version;           /* release code */
  210.     UBYTE                    *api_Name;              /* client name */
  211.     UBYTE                    *api_Info;              /* client info */
  212.     UBYTE                   **api_Commands;          /* command list (NULL-terminated) */
  213.     ULONG                     api_Serial;            /* serial code of client */
  214.     ULONG                     api_Classes;           /* class request */
  215.     struct APIContainer      *api_Area;              /* area request */
  216.  
  217.     /* private data may follow (depends on client) */
  218. };
  219.  
  220.  
  221. /* ------------------------------------ APIOrder -------------------------------
  222.  
  223.  Orders (host-specific) are created by clients and attached to APIMessages
  224.  
  225. */
  226.  
  227.  
  228. struct APIOrder {
  229.  
  230.     struct APIOrder          *api_Next;              /* next order or NULL */
  231.     APTR                      api_Data;              /* host-specific data */
  232.  
  233.     /* more data may follow */
  234. };
  235.  
  236.  
  237. /* ------------------------------- APIContainer --------------------------------
  238.  
  239.  Reserved area provided by instance, controlled by client (numeric values are
  240.  overridden by alignment flags)
  241.  
  242. */
  243.  
  244. struct APIContainer {
  245.  
  246.     struct Window            *api_Window;            /* window   */
  247.     struct Screen            *api_Screen;            /* screen   */
  248.     struct RastPort          *api_Rast;              /* rastport */
  249.     UWORD                    *api_Align;             /* alignment flags */
  250.     UWORD                    *api_Left;              /* dimensions */
  251.     UWORD                    *api_Top;               /* dimensions */
  252.     UWORD                    *api_Width;             /* dimensions */
  253.     UWORD                    *api_Height;            /* dimensions */
  254. };
  255.  
  256. #define API_CONTAINER_ALIGN_TOP         0            /* alignment flag */
  257. #define API_CONTAINER_ALIGN_BOTTOM      1            /* alignment flag */
  258. #define API_CONTAINER_ALIGN_LEFT        2            /* alignment flag */
  259. #define API_CONTAINER_ALIGN_RIGHT       4            /* alignment flag */
  260. #define API_CONTAINER_ALIGN_RELWIDTH    8            /* alignment flag */
  261. #define API_CONTAINER_ALIGN_RELHEIGHT   16           /* alignment flag */
  262.  
  263. #endif
  264.