ColorPicker.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:14k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       ColorPicker.h
  3.  
  4.      Contains:   Color Picker package Interfaces.
  5.  
  6.      Version:    Technology: System 7.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1987-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __COLORPICKER__
  18. #define __COLORPICKER__
  19. #ifndef __MIXEDMODE__
  20. #include "MixedMode.h"
  21. #endif
  22. #ifndef __QUICKDRAW__
  23. #include "Quickdraw.h"
  24. #endif
  25. #ifndef __CMAPPLICATION__
  26. #include "CMApplication.h"
  27. #endif
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37. #if PRAGMA_STRUCT_ALIGN
  38.     #pragma options align=mac68k
  39. #elif PRAGMA_STRUCT_PACKPUSH
  40.     #pragma pack(push, 2)
  41. #elif PRAGMA_STRUCT_PACK
  42.     #pragma pack(2)
  43. #endif
  44. enum {
  45.                                                                 /*Maximum small fract value, as long*/
  46.     kMaximumSmallFract          = 0x0000FFFF
  47. };
  48. enum {
  49.     kDefaultColorPickerWidth    = 383,
  50.     kDefaultColorPickerHeight   = 238
  51. };
  52. typedef SInt16 DialogPlacementSpec;
  53. enum {
  54.     kAtSpecifiedOrigin          = 0,
  55.     kDeepestColorScreen         = 1,
  56.     kCenterOnMainScreen         = 2
  57. };
  58. /* These are for the flags field in the structs below (for example ColorPickerInfo). */
  59. enum {
  60.     kColorPickerDialogIsMoveable = 1,
  61.     kColorPickerDialogIsModal   = 2,
  62.     kColorPickerCanModifyPalette = 4,
  63.     kColorPickerCanAnimatePalette = 8,
  64.     kColorPickerAppIsColorSyncAware = 16,
  65.     kColorPickerInSystemDialog  = 32,
  66.     kColorPickerInApplicationDialog = 64,
  67.     kColorPickerInPickerDialog  = 128,
  68.     kColorPickerDetachedFromChoices = 256,
  69.     kColorPickerCallColorProcLive = 512
  70. };
  71. #if OLDROUTINENAMES
  72. enum {
  73.                                                                 /*Maximum small fract value, as long*/
  74.     MaxSmallFract               = 0x0000FFFF
  75. };
  76. enum {
  77.     kDefaultWidth               = 383,
  78.     kDefaultHeight              = 238
  79. };
  80. /* These are for the flags field in the structs below (for example ColorPickerInfo). */
  81. enum {
  82.     DialogIsMoveable            = 1,
  83.     DialogIsModal               = 2,
  84.     CanModifyPalette            = 4,
  85.     CanAnimatePalette           = 8,
  86.     AppIsColorSyncAware         = 16,
  87.     InSystemDialog              = 32,
  88.     InApplicationDialog         = 64,
  89.     InPickerDialog              = 128,
  90.     DetachedFromChoices         = 256,
  91.     CallColorProcLive           = 512
  92. };
  93. #endif  /* OLDROUTINENAMES */
  94. /* A SmallFract value is just the fractional part of a Fixed number,
  95. which is the low order word.  SmallFracts are used to save room,
  96. and to be compatible with Quickdraw's RGBColor.  They can be
  97. assigned directly to and from INTEGERs. */
  98. /* Unsigned fraction between 0 and 1 */
  99. typedef unsigned short                  SmallFract;
  100. /* For developmental simplicity in switching between the HLS and HSV
  101. models, HLS is reordered into HSL. Thus both models start with
  102. hue and saturation values; value/lightness/brightness is last. */
  103. struct HSVColor {
  104.     SmallFract                      hue;                        /*Fraction of circle, red at 0*/
  105.     SmallFract                      saturation;                 /*0-1, 0 for gray, 1 for pure color*/
  106.     SmallFract                      value;                      /*0-1, 0 for black, 1 for max intensity*/
  107. };
  108. typedef struct HSVColor                 HSVColor;
  109. struct HSLColor {
  110.     SmallFract                      hue;                        /*Fraction of circle, red at 0*/
  111.     SmallFract                      saturation;                 /*0-1, 0 for gray, 1 for pure color*/
  112.     SmallFract                      lightness;                  /*0-1, 0 for black, 1 for white*/
  113. };
  114. typedef struct HSLColor                 HSLColor;
  115. struct CMYColor {
  116.     SmallFract                      cyan;
  117.     SmallFract                      magenta;
  118.     SmallFract                      yellow;
  119. };
  120. typedef struct CMYColor                 CMYColor;
  121. struct PMColor {
  122.     CMProfileHandle                 profile;
  123.     CMColor                         color;
  124. };
  125. typedef struct PMColor                  PMColor;
  126. typedef PMColor *                       PMColorPtr;
  127. struct NPMColor {
  128.     CMProfileRef                    profile;
  129.     CMColor                         color;
  130. };
  131. typedef struct NPMColor                 NPMColor;
  132. typedef NPMColor *                      NPMColorPtr;
  133. typedef struct OpaquePicker*            Picker;
  134. typedef Picker picker;
  135. struct PickerMenuItemInfo {
  136.     short                           editMenuID;
  137.     short                           cutItem;
  138.     short                           copyItem;
  139.     short                           pasteItem;
  140.     short                           clearItem;
  141.     short                           undoItem;
  142. };
  143. typedef struct PickerMenuItemInfo       PickerMenuItemInfo;
  144. /* Structs related to deprecated API's have been pulled from this file. */
  145. /* Those structs necessary for developers writing their own color pickers... */
  146. /* have been moved to ColorPickerComponents.h. */
  147. typedef CALLBACK_API( void , ColorChangedProcPtr )(long userData, PMColor *newColor);
  148. typedef CALLBACK_API( void , NColorChangedProcPtr )(long userData, NPMColor *newColor);
  149. typedef CALLBACK_API( Boolean , UserEventProcPtr )(EventRecord *event);
  150. typedef STACK_UPP_TYPE(ColorChangedProcPtr)                     ColorChangedUPP;
  151. typedef STACK_UPP_TYPE(NColorChangedProcPtr)                    NColorChangedUPP;
  152. typedef STACK_UPP_TYPE(UserEventProcPtr)                        UserEventUPP;
  153. struct ColorPickerInfo {
  154.     PMColor                         theColor;
  155.     CMProfileHandle                 dstProfile;
  156.     UInt32                          flags;
  157.     DialogPlacementSpec             placeWhere;
  158.     Point                           dialogOrigin;
  159.     OSType                          pickerType;
  160.     UserEventUPP                    eventProc;
  161.     ColorChangedUPP                 colorProc;
  162.     UInt32                          colorProcData;
  163.     Str255                          prompt;
  164.     PickerMenuItemInfo              mInfo;
  165.     Boolean                         newColorChosen;
  166.     SInt8                           filler;
  167. };
  168. typedef struct ColorPickerInfo          ColorPickerInfo;
  169. struct NColorPickerInfo {
  170.     NPMColor                        theColor;
  171.     CMProfileRef                    dstProfile;
  172.     UInt32                          flags;
  173.     DialogPlacementSpec             placeWhere;
  174.     Point                           dialogOrigin;
  175.     OSType                          pickerType;
  176.     UserEventUPP                    eventProc;
  177.     NColorChangedUPP                colorProc;
  178.     UInt32                          colorProcData;
  179.     Str255                          prompt;
  180.     PickerMenuItemInfo              mInfo;
  181.     Boolean                         newColorChosen;
  182.     UInt8                           reserved;                   /*Must be 0*/
  183. };
  184. typedef struct NColorPickerInfo         NColorPickerInfo;
  185. /*  Below are the color conversion routines.*/
  186. EXTERN_API( SmallFract )
  187. Fix2SmallFract                  (Fixed                  f)                                  THREEWORDINLINE(0x3F3C, 0x0001, 0xA82E);
  188. EXTERN_API( Fixed )
  189. SmallFract2Fix                  (SmallFract             s)                                  THREEWORDINLINE(0x3F3C, 0x0002, 0xA82E);
  190. EXTERN_API( void )
  191. CMY2RGB                         (const CMYColor *       cColor,
  192.                                  RGBColor *             rColor)                             THREEWORDINLINE(0x3F3C, 0x0003, 0xA82E);
  193. EXTERN_API( void )
  194. RGB2CMY                         (const RGBColor *       rColor,
  195.                                  CMYColor *             cColor)                             THREEWORDINLINE(0x3F3C, 0x0004, 0xA82E);
  196. EXTERN_API( void )
  197. HSL2RGB                         (const HSLColor *       hColor,
  198.                                  RGBColor *             rColor)                             THREEWORDINLINE(0x3F3C, 0x0005, 0xA82E);
  199. EXTERN_API( void )
  200. RGB2HSL                         (const RGBColor *       rColor,
  201.                                  HSLColor *             hColor)                             THREEWORDINLINE(0x3F3C, 0x0006, 0xA82E);
  202. EXTERN_API( void )
  203. HSV2RGB                         (const HSVColor *       hColor,
  204.                                  RGBColor *             rColor)                             THREEWORDINLINE(0x3F3C, 0x0007, 0xA82E);
  205. EXTERN_API( void )
  206. RGB2HSV                         (const RGBColor *       rColor,
  207.                                  HSVColor *             hColor)                             THREEWORDINLINE(0x3F3C, 0x0008, 0xA82E);
  208. /*  GetColor() works with or without the Color Picker extension.*/
  209. EXTERN_API( Boolean )
  210. GetColor                        (Point                  where,
  211.                                  ConstStr255Param       prompt,
  212.                                  const RGBColor *       inColor,
  213.                                  RGBColor *             outColor)                           THREEWORDINLINE(0x3F3C, 0x0009, 0xA82E);
  214. /*  PickColor() requires the Color Picker extension (version 2.0 or greater).*/
  215. EXTERN_API( OSErr )
  216. PickColor                       (ColorPickerInfo *      theColorInfo)                       THREEWORDINLINE(0x3F3C, 0x0213, 0xA82E);
  217. /*  NPickColor() requires the Color Picker extension (version 2.1 or greater).*/
  218. EXTERN_API( OSErr )
  219. NPickColor                      (NColorPickerInfo *     theColorInfo)                       THREEWORDINLINE(0x3F3C, 0x0227, 0xA82E);
  220. /* A suite of mid-level API calls have been deprecated.  Likely you never...  */
  221. /* used them anyway.  They were removed from this file and should not be... */
  222. /* used in the future as they are not gauranteed to be supported. */
  223. #if OPAQUE_UPP_TYPES
  224.     EXTERN_API(ColorChangedUPP)
  225.     NewColorChangedUPP             (ColorChangedProcPtr     userRoutine);
  226.     EXTERN_API(NColorChangedUPP)
  227.     NewNColorChangedUPP            (NColorChangedProcPtr    userRoutine);
  228.     EXTERN_API(UserEventUPP)
  229.     NewUserEventUPP                (UserEventProcPtr        userRoutine);
  230.     EXTERN_API(void)
  231.     DisposeColorChangedUPP         (ColorChangedUPP         userUPP);
  232.     EXTERN_API(void)
  233.     DisposeNColorChangedUPP        (NColorChangedUPP        userUPP);
  234.     EXTERN_API(void)
  235.     DisposeUserEventUPP            (UserEventUPP            userUPP);
  236.     EXTERN_API(void)
  237.     InvokeColorChangedUPP          (long                    userData,
  238.                                     PMColor *               newColor,
  239.                                     ColorChangedUPP         userUPP);
  240.     EXTERN_API(void)
  241.     InvokeNColorChangedUPP         (long                    userData,
  242.                                     NPMColor *              newColor,
  243.                                     NColorChangedUPP        userUPP);
  244.     EXTERN_API(Boolean)
  245.     InvokeUserEventUPP             (EventRecord *           event,
  246.                                     UserEventUPP            userUPP);
  247. #else
  248.     enum { uppColorChangedProcInfo = 0x000003C0 };                  /* pascal no_return_value Func(4_bytes, 4_bytes) */
  249.     enum { uppNColorChangedProcInfo = 0x000003C0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes) */
  250.     enum { uppUserEventProcInfo = 0x000000D0 };                     /* pascal 1_byte Func(4_bytes) */
  251.     #define NewColorChangedUPP(userRoutine)                         (ColorChangedUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppColorChangedProcInfo, GetCurrentArchitecture())
  252.     #define NewNColorChangedUPP(userRoutine)                        (NColorChangedUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNColorChangedProcInfo, GetCurrentArchitecture())
  253.     #define NewUserEventUPP(userRoutine)                            (UserEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppUserEventProcInfo, GetCurrentArchitecture())
  254.     #define DisposeColorChangedUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  255.     #define DisposeNColorChangedUPP(userUPP)                        DisposeRoutineDescriptor(userUPP)
  256.     #define DisposeUserEventUPP(userUPP)                            DisposeRoutineDescriptor(userUPP)
  257.     #define InvokeColorChangedUPP(userData, newColor, userUPP)      CALL_TWO_PARAMETER_UPP((userUPP), uppColorChangedProcInfo, (userData), (newColor))
  258.     #define InvokeNColorChangedUPP(userData, newColor, userUPP)     CALL_TWO_PARAMETER_UPP((userUPP), uppNColorChangedProcInfo, (userData), (newColor))
  259.     #define InvokeUserEventUPP(event, userUPP)                      (Boolean)CALL_ONE_PARAMETER_UPP((userUPP), uppUserEventProcInfo, (event))
  260. #endif
  261. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  262. #define NewColorChangedProc(userRoutine)                        NewColorChangedUPP(userRoutine)
  263. #define NewNColorChangedProc(userRoutine)                       NewNColorChangedUPP(userRoutine)
  264. #define NewUserEventProc(userRoutine)                           NewUserEventUPP(userRoutine)
  265. #define CallColorChangedProc(userRoutine, userData, newColor)   InvokeColorChangedUPP(userData, newColor, userRoutine)
  266. #define CallNColorChangedProc(userRoutine, userData, newColor)  InvokeNColorChangedUPP(userData, newColor, userRoutine)
  267. #define CallUserEventProc(userRoutine, event)                   InvokeUserEventUPP(event, userRoutine)
  268. #if PRAGMA_STRUCT_ALIGN
  269.     #pragma options align=reset
  270. #elif PRAGMA_STRUCT_PACKPUSH
  271.     #pragma pack(pop)
  272. #elif PRAGMA_STRUCT_PACK
  273.     #pragma pack()
  274. #endif
  275. #ifdef PRAGMA_IMPORT_OFF
  276. #pragma import off
  277. #elif PRAGMA_IMPORT
  278. #pragma import reset
  279. #endif
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283. #endif /* __COLORPICKER__ */