home *** CD-ROM | disk | FTP | other *** search
/ Chip: Special Computer Graphics & Animation / Chip-Special-Computergrafik.bin / programs / povray / povsrc.sea / POVSRC / SOURCE / Components.h < prev    next >
Text File  |  1993-11-30  |  9KB  |  262 lines

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