home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / povsrc.sit / MACHINE / MAC.SIT / Components.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-24  |  8.3 KB  |  276 lines  |  [TEXT/KAHL]

  1.  
  2. /************************************************************
  3.  
  4. Created: Wednesday, August 14, 1991 at 12:09 PM
  5.  Components.h
  6.  C Interface to the Macintosh Libraries
  7.  
  8.  
  9.  Copyright Apple Computer, Inc. 1990 - 1991
  10.  All rights reserved
  11.  
  12. ************************************************************/
  13.  
  14.  
  15. #ifndef __COMPONENTS__
  16. #define __COMPONENTS__
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22.  
  23. #define    gestaltComponentMgr 'cpnt'
  24.  
  25. #define    kAnyComponentType            0
  26. #define    kAnyComponentSubType        0
  27. #define    kAnyComponentManufacturer    0
  28. #define    kAnyComponentFlagsMask        0
  29.  
  30. enum {
  31.     cmpWantsRegisterMessage = 1L<<31
  32. };
  33.  
  34. struct ComponentDescription {
  35.  OSType componentType;                    /* A unique 4-byte code indentifying the command set */
  36.  OSType componentSubType;                /* Particular flavor of this instance */
  37.  OSType componentManufacturer;            /* Vendor indentification */
  38.  unsigned long componentFlags;            /* 8 each for Component,Type,SubType,Manuf/revision */
  39.  unsigned long componentFlagsMask;        /* Mask for specifying which flags to consider in search, zero during registration */
  40. };
  41.  
  42. typedef struct ComponentDescription ComponentDescription;
  43.  
  44. struct ResourceSpec {
  45.  OSType resType;                        /* 4-byte code  */
  46.  short resId;                            /*    */
  47. };
  48.  
  49. typedef struct ResourceSpec ResourceSpec;
  50.  
  51. struct ComponentResource {
  52.  ComponentDescription cd;                /* Registration parameters */
  53.  ResourceSpec component;                /* resource where Component code is found */
  54.  ResourceSpec componentName;            /* name string resource */
  55.  ResourceSpec componentInfo;            /* info string resource */
  56.  ResourceSpec componentIcon;            /* icon resource */
  57. };
  58.  
  59. typedef struct ComponentResource ComponentResource;
  60. typedef ComponentResource *ComponentResourcePtr, **ComponentResourceHandle;
  61.  
  62. /* Structure received by Component:  */
  63. struct ComponentParameters {
  64.  unsigned char flags;                    /* call modifiers: sync/async, deferred, immed, etc */
  65.  unsigned char paramSize;                /* size in bytes of actual parameters passed to this call */
  66.  short what;                            /* routine selector, negative for Component management calls */
  67.  long params[1];                        /* actual parameters for the indicated routine */
  68. };
  69.  
  70. typedef struct ComponentParameters ComponentParameters;
  71.  
  72.  
  73. struct ComponentRecord {
  74.  long data[1];
  75. };
  76.  
  77. typedef struct ComponentRecord ComponentRecord;
  78. typedef ComponentRecord *Component;
  79.  
  80. struct ComponentInstanceRecord {
  81.  long data[1];
  82. };
  83.  
  84. typedef struct ComponentInstanceRecord ComponentInstanceRecord;
  85. typedef ComponentInstanceRecord *ComponentInstance;
  86.  
  87.  
  88.  
  89. typedef long ComponentResult;
  90.  
  91. typedef pascal ComponentResult (*ComponentRoutine)
  92.   (ComponentParameters *tp, Handle componentStorage );
  93.  
  94. typedef pascal ComponentResult (*ComponentFunction)();
  95.  
  96.  
  97.  
  98.  
  99.  
  100. #define ComponentCallNow( callNumber, paramSize ) \
  101.   {0x2F3C,paramSize,callNumber,0x7000,0xA82A}
  102.  
  103. #ifdef __cplusplus
  104. extern "C" {
  105. #endif
  106.  
  107. /* 
  108.  *******************************************************
  109.  *                                                     *
  110.  *              APPLICATION LEVEL CALLS                *
  111.  *                                                     *
  112.  *******************************************************
  113.  * Component Database Add, Delete, and Query Routines 
  114.  *******************************************************
  115. */
  116.  
  117. pascal Component RegisterComponent(ComponentDescription *cd,ComponentRoutine componentEntryPoint,
  118.  short global,Handle componentName,Handle componentInfo,Handle componentIcon)
  119.  = {0x7001,0xA82A}; 
  120. pascal Component RegisterComponentResource(ComponentResourceHandle tr,short global)
  121.  = {0x7012,0xA82A}; 
  122. pascal OSErr UnregisterComponent(Component aComponent)
  123.  = {0x7002,0xA82A}; 
  124.  
  125. pascal Component FindNextComponent(Component aComponent,ComponentDescription *looking)
  126.  = {0x7004,0xA82A}; 
  127. pascal long CountComponents(ComponentDescription *looking)
  128.  = {0x7003,0xA82A}; 
  129.  
  130. pascal OSErr GetComponentInfo(Component aComponent,ComponentDescription *cd,
  131.  Handle componentName,Handle componentInfo,Handle componentIcon)
  132.  = {0x7005,0xA82A}; 
  133. pascal long GetComponentListModSeed(void)
  134.  = {0x7006,0xA82A}; 
  135.  
  136.  
  137. /* 
  138.  *******************************************************
  139.  * Component Instance Allocation and dispatch routines 
  140.  *******************************************************
  141. */
  142.  
  143. pascal ComponentInstance OpenComponent(Component aComponent)
  144.  = {0x7007,0xA82A}; 
  145. pascal OSErr CloseComponent(ComponentInstance aComponentInstance)
  146.  = {0x7008,0xA82A}; 
  147.  
  148. pascal OSErr GetComponentInstanceError(ComponentInstance aComponentInstance)
  149.  = {0x700A,0xA82A}; 
  150.  
  151. /*  direct calls to the Components  */
  152. pascal long ComponentFunctionImplemented(ComponentInstance ci,short ftnNumber)
  153.  = {0x2F3C,0x2,0xFFFD,0x7000,0xA82A}; 
  154. pascal long GetComponentVersion(ComponentInstance ci)
  155.  = {0x2F3C,0x0,0xFFFC,0x7000,0xA82A}; 
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159.  
  160.  
  161.  
  162. /*****************************************************
  163. *                                                    *
  164. *               CALLS MADE BY Components             *
  165. *                                                    *
  166. ******************************************************
  167. ******************************************************
  168. * Required Component routines
  169. *******************************************************/
  170.  
  171.  
  172. #define kComponentOpenSelect -1            /* ComponentInstance for this open */
  173. #define kComponentCloseSelect -2        /* ComponentInstance for this close */
  174. #define kComponentCanDoSelect -3        /* selector # being queried */
  175. #define kComponentVersionSelect -4        /* no params */
  176. #define kComponentRegisterSelect -5        /* no params */
  177. #define kComponentTargetSelect -6        /* ComponentInstance for top of call chain */
  178.  
  179. #ifdef __cplusplus
  180. extern "C" {
  181. #endif
  182.  
  183. /* 
  184.  *******************************************************
  185.  * Component Management routines
  186.  *******************************************************
  187. */
  188.  
  189. pascal void SetComponentInstanceError(ComponentInstance aComponentInstance,
  190.  OSErr theError)
  191.  = {0x700B,0xA82A}; 
  192.  
  193. pascal long GetComponentRefcon(Component aComponent)
  194.  = {0x7010,0xA82A}; 
  195. pascal void SetComponentRefcon(Component aComponent,long theRefcon)
  196.  = {0x7011,0xA82A}; 
  197.  
  198. pascal short OpenComponentResFile(Component aComponent)
  199.  = {0x7015,0xA82A}; 
  200. pascal OSErr CloseComponentResFile(short refnum)
  201.  = {0x7018,0xA82A}; 
  202.  
  203.  
  204. /* 
  205.  *******************************************************
  206.  * Component Instance Management routines
  207.  *******************************************************
  208. */
  209.  
  210. pascal Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance)
  211.  = {0x700C,0xA82A}; 
  212. pascal void SetComponentInstanceStorage(ComponentInstance aComponentInstance,
  213.  Handle theStorage)
  214.  = {0x700D,0xA82A}; 
  215.  
  216. pascal long GetComponentInstanceA5(ComponentInstance aComponentInstance)
  217.  = {0x700E,0xA82A}; 
  218. pascal void SetComponentInstanceA5(ComponentInstance aComponentInstance,
  219.  long theA5)
  220.  = {0x700F,0xA82A}; 
  221.  
  222. pascal long CountComponentInstances(Component aComponent)
  223.  = {0x7013,0xA82A}; 
  224.  
  225. /*  useful helper routines for convenient method dispatching  */
  226. pascal long CallComponentFunction(ComponentParameters *params,ComponentFunction func)
  227.  = {0x70FF,0xA82A}; 
  228. pascal long CallComponentFunctionWithStorage(Handle storage,ComponentParameters *params,
  229.  ComponentFunction func)
  230.  = {0x70FF,0xA82A}; 
  231. pascal long DelegateComponentCall(ComponentParameters *originalParams,ComponentInstance ci)
  232.  = {0x7024,0xA82A}; 
  233. #ifdef __cplusplus
  234. }
  235. #endif
  236. enum {
  237.  
  238.  
  239. /* Set Default Component flags */
  240.  defaultComponentIdentical = 0,
  241.  defaultComponentAnyFlags = 1,
  242.  defaultComponentAnyManufacturer = 2,
  243.  defaultComponentAnySubType = 4
  244.  
  245. #define defaultComponentAnyFlagsAnyManufacturer defaultComponentAnyFlags+defaultComponentAnyManufacturer
  246. #define defaultComponentAnyFlagsAnyManufacturerAnySubType defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType
  247. };
  248.  
  249. #ifdef __cplusplus
  250. extern "C" {
  251. #endif
  252. pascal OSErr SetDefaultComponent(Component aComponent,short flags)
  253.  = {0x701E,0xA82A}; 
  254. pascal ComponentInstance OpenDefaultComponent( OSType componentType, OSType componentSubType )
  255.  = {0x7021,0xA82A}; 
  256. pascal Component CaptureComponent(Component capturedComponent,Component capturingComponent)
  257.  = {0x701C,0xA82A}; 
  258. pascal OSErr UncaptureComponent(Component aComponent)
  259.  = {0x701D,0xA82A}; 
  260. #ifdef __cplusplus
  261. }
  262. #endif
  263.  
  264. typedef enum {                    /* errors from component manager & components  */
  265.     invalidComponentID = -3000,
  266.     validInstancesExist = -3001,
  267.     componentNotCaptured = -3002,
  268.     componentDontRegister = -3003
  269.     };
  270.  
  271. #define badComponentInstance    0x80008001
  272. #define badComponentSelector    0x80008002
  273.  
  274.  
  275. #endif
  276.