home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Headers / misckit / MiscColor.h < prev    next >
Encoding:
Text File  |  1994-03-23  |  5.2 KB  |  142 lines

  1. //
  2. //    MiscColor.h -- a wrapper class around the NXColor functions
  3. //        Written by Don Yacktman Copyright (c) 1994 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. #import <appkit/appkit.h>
  15.  
  16. @interface MiscColor:Object <NXTransport>
  17. {
  18.     NXColor theColor;
  19.     id delegate;
  20. }
  21.  
  22. + (BOOL)canInitFromPasteboard:(Pasteboard *)pasteboard;
  23. + newFromPasteBoard:(Pasteboard *)pasteboard;
  24. + newColor:(NXColor)color;
  25.  
  26. - init;
  27. - initColor:(NXColor)color; // designated initializer!
  28. - initFromPasteBoard:(Pasteboard *)pasteboard;
  29. - initColorFromPixel:(NXPoint *)location;
  30.  
  31. // putting the color on a pasteboard
  32. // Note that we can put both an NXColor and/or our whole object
  33. // on the pasteboard, so that a subclass that is drag/dropped can
  34. // retain it's full richness, while still being compatabile with
  35. // NEXTSTEP drag and drop into other applications and NEXTSTEP objects.
  36. - writeToPasteBoard:(Pasteboard *)pasteboard;
  37. - readFromPasteBoard:(Pasteboard *)pasteboard;
  38. - setFromPasteBoard:(Pasteboard *)pasteboard;
  39.  
  40. // change a color component:  should be in range 0.0 to 1.0
  41. - setRedComponent:(float)red;
  42. - setGreenComponent:(float)green;
  43. - setBlueComponent:(float)blue;
  44. - setCyanComponent:(float)cyan;
  45. - setMagentaComponent:(float)magenta;
  46. - setYellowComponent:(float)yellow;
  47. - setBlackComponent:(float)black;
  48. - setHueComponent:(float)hue;
  49. - setSaturationComponent:(float)saturation;
  50. - setBrightnessComponent:(float)brightness;
  51. - setGrayComponent:(float)gray;
  52. - setAlphaComponent:(float)alpha; // NX_NOALPHA to remove alpha
  53.  
  54. // change/access color directly
  55. - setColor:(NXColor)color;
  56. - setColorFromObject:object;
  57. - setColorFromPixel:(NXPoint *)location;
  58. - (NXColor)color; // our displayable color (passed thru filter)
  59. - (NXColor)actualColor; // the color before filtering
  60. - (NXColor)filterColor:(NXColor)input; // subclasses can filter color for printing
  61.  
  62. - display;    // sends color to PS interpreter via -setColor below.
  63. - (BOOL)setColor;    // send color to postscript interpreter, NO returned if not set
  64.  
  65. // getting values for a particular colorspace, will return 0.0 to 1.0
  66. //        (or, on alpha methods, NO_ALPHA if no alpha)
  67. - getGray:(float *)gray;
  68. - getGray:(float *)gray alpha:(float *)alpha;
  69. - getRed:(float *)red green:(float *)green blue:(float *)blue;
  70. - getRed:(float *)red green:(float *)green blue:(float *)blue
  71.         alpha:(float *)alpha;
  72. - getHue:(float *)hue saturation:(float *)saturation
  73.         brightness:(float *)brightness;
  74. - getHue:(float *)hue saturation:(float *)saturation
  75.         brightness:(float *)brightness alpha:(float *)alpha;
  76. - getCyan:(float *)cyan magenta:(float *)magenta yellow:(float *)yellow
  77.         black:(float *)black;
  78. - getCyan:(float *)cyan magenta:(float *)magenta yellow:(float *)yellow
  79.         black:(float *)black alpha:(float *)alpha;
  80.  
  81. // keep args in 0.0 to 1.0 range, or NX_NOALPHA for alpha value
  82. - setGray:(float)gray;
  83. - setGray:(float)gray alpha:(float)alpha;
  84. - setRed:(float)red green:(float)green blue:(float)blue;
  85. - setRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha;
  86. - setHue:(float)hue saturation:(float)saturation
  87.         brightness:(float)brightness;
  88. - setHue:(float)hue saturation:(float)saturation
  89.         brightness:(float)brightness alpha:(float)alpha;
  90. - setCyan:(float)cyan magenta:(float)magenta yellow:(float)yellow
  91.         black:(float)black;
  92. - setCyan:(float)cyan magenta:(float)magenta yellow:(float)yellow
  93.         black:(float)black alpha:(float)alpha;
  94.  
  95. - (BOOL)isEqualColor:anObject;    // checks only -color method's return
  96. - (BOOL)isEqualToColor:(NXColor)color;    // if same color...
  97. - (BOOL)isEqual:anObject;        // must be of same class
  98.  
  99. - read:(NXTypedStream *)stream;
  100. - write:(NXTypedStream *)stream;
  101.  
  102. // Interface Builder support
  103. - (const char *)getInspectorClassName;
  104. - (NXImage *)getIBImage;
  105.  
  106. // getting individual color components
  107. - (float)redComponent;
  108. - (float)greenComponent;
  109. - (float)blueComponent;
  110. - (float)cyanComponent;
  111. - (float)magentaComponent;
  112. - (float)yellowComponent;
  113. - (float)blackComponent;
  114. - (float)hueComponent;
  115. - (float)saturationComponent;
  116. - (float)brightnessComponent;
  117. - (float)grayComponent;
  118. - (float)alphaComponent;
  119.  
  120. // dealing with persistently named colors
  121. + findColorNamed:(const char *)aName inList:(const char *)aListName;
  122. - (const char *)colorName; // different than the object's name
  123. - (const char *)colorListName; // name of originating color list, if there is one
  124.  
  125. - delegate;
  126. - setDelegate:anObject;
  127.  
  128. // delegate methods:  (allows delegate to change the color, so that, say
  129. //        you intercept color setting in your app to handle color separations...)
  130. //- (NXColor)willSendColorToPS:(NXColor)color shouldPrint:(BOOL *)printOK;
  131.         // returns color you should set, set printOK to NO if you don't want any
  132.         // color sent to the PS interpreter.
  133. //- didSendColorToPS:(NXColor)color;
  134.  
  135. @end
  136.  
  137. // The method prototypes allow us to compile without warnings
  138. @interface MiscColor(delegate)
  139. - (NXColor)willSendColorToPS:(NXColor)color shouldPrint:(BOOL *)printOK;
  140. - didSendColorToPS:(NXColor)color;
  141. @end
  142.