home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / appkit / graphics.h < prev    next >
Text File  |  1992-02-03  |  6KB  |  170 lines

  1. /*
  2.     graphics.h
  3.     Application Kit, Release 2.0
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #import "color.h"
  8.  
  9. /* This file defines the most primitive client graphic structures. */
  10.  
  11. #ifndef GRAPHICS_H
  12. #define GRAPHICS_H
  13.  
  14. #ifndef EVENT_H
  15. #import <dpsclient/dpsfriends.h>
  16. #import <dpsclient/event.h>
  17. #endif EVENT_H
  18.  
  19. #ifndef OBJC_INCL
  20. #import <objc/objc.h>
  21. #endif OBJC_INCL
  22.  
  23. #import <objc/typedstream.h>
  24.  
  25. #define    NX_WHITE    (1.0)
  26. #define    NX_LTGRAY    (2.0/3.0)
  27. #define    NX_DKGRAY    (1.0/3.0)
  28. #define    NX_BLACK    (0.0)
  29.  
  30. typedef struct _NXRect {    /* rectangle */
  31.     NXPoint         origin;
  32.     NXSize          size;
  33. } NXRect;
  34.  
  35. #define    NX_X(aRect)    ((aRect)->origin.x)
  36. #define    NX_Y(aRect)    ((aRect)->origin.y)
  37. #define    NX_WIDTH(aRect)    ((aRect)->size.width)
  38. #define    NX_HEIGHT(aRect)    ((aRect)->size.height)
  39. #define    NX_MAXX(aRect)    ((aRect)->origin.x + (aRect)->size.width)
  40. #define    NX_MAXY(aRect)    ((aRect)->origin.y + (aRect)->size.height)
  41. #define    NX_MIDX(aRect)    (NX_X(aRect)+NX_WIDTH(aRect)/2.0)
  42. #define    NX_MIDY(aRect)    (NX_Y(aRect)+NX_HEIGHT(aRect)/2.0)
  43.  
  44. /* The sides of a rectangle */
  45. #define NX_XMIN    0
  46. #define NX_YMIN    1
  47. #define NX_XMAX    2
  48. #define NX_YMAX    3
  49.  
  50. /*
  51.  * The following values should be used in describing color space of bitmaps.
  52.  */
  53. typedef enum _NXColorSpace { 
  54.     NX_CustomColorSpace = -1,        /* color space from graphics state */
  55.     NX_OneIsBlackColorSpace = 0,    /* monochrome, 1 is black */
  56.     NX_OneIsWhiteColorSpace = 1,    /* monochrome, 1 is white */
  57.     NX_RGBColorSpace = 2,            
  58.     NX_CMYKColorSpace = 5
  59. } NXColorSpace;
  60.  
  61. /*
  62.  * NXWindowDepth defines the values used in setting window depth limits.
  63.  * Use the functions NXBPSFroUFth() and NXColorSpaceFromDepth()
  64.  * to extract colorspace/bps info from an NXWindowDepth.
  65.  */
  66. typedef enum _NXWindowDepth { 
  67.     NX_DefaultDepth = 0,
  68.     NX_TwoBitGrayDepth = 258,
  69.     NX_EightBitGrayDepth = 264,            
  70.     NX_TwelveBitRGBDepth = 516,
  71.     NX_TwentyFourBitRGBDepth = 520
  72. } NXWindowDepth;
  73.  
  74.  
  75. extern NXColor NXReadPixel(const NXPoint *p);
  76. extern void NXCopyBits(int sgnum, const NXRect *sRect, const NXPoint *dPoint);
  77. extern void NXDrawButton(const NXRect *aRect, const NXRect *clipRect);
  78. extern void NXDrawGrayBezel(const NXRect *aRect, const NXRect *clipRect);
  79. extern void NXDrawGroove(const NXRect *aRect, const NXRect *clipRect);
  80. extern NXRect *NXDrawTiledRects(NXRect *boundsRect, const NXRect *clipRect,
  81.         const int *sides, const float *grays, int count);
  82. extern void NXDrawWhiteBezel(const NXRect *aRect, const NXRect *clipRect);
  83. extern void NXEraseRect(const NXRect *aRect);
  84. extern void NXFrameRect(const NXRect *aRect);
  85. extern void NXFrameRectWithWidth(const NXRect *aRect, NXCoord frameWidth);
  86. extern void NXRectClip(const NXRect *aRect);
  87. extern void NXRectClipList(const NXRect *rects, int count);
  88. extern void NXRectFill(const NXRect *aRect);
  89. extern void NXRectFillList(const NXRect *rects, int count);
  90. extern void NXHighlightRect(const NXRect *aRect);
  91. extern void NXRectFillListWithGrays(const NXRect *rects, const float *grays, int count);
  92.  
  93. extern BOOL NXContainsRect(const NXRect *a, const NXRect *b);
  94. extern NXRect *NXDivideRect(NXRect *aRect, NXRect *bRect, NXCoord slice, int edge);
  95. extern BOOL NXEmptyRect(const NXRect *aRect);
  96. extern BOOL NXEqualRect(const NXRect *aRect, const NXRect *bRect);
  97. extern void NXInsetRect(NXRect *aRect, NXCoord dX, NXCoord dY);
  98. extern void NXIntegralRect(NXRect *aRect);
  99. extern NXRect *NXIntersectionRect(const NXRect *aRect, NXRect *bRect);
  100. extern BOOL NXIntersectsRect(const NXRect *aRect, const NXRect *bRect);
  101. extern void NXOffsetRect(NXRect *aRect, NXCoord dX, NXCoord dY);
  102. extern BOOL NXPointInRect(const NXPoint *aPoint, const NXRect *aRect);
  103. extern BOOL NXMouseInRect(const NXPoint *aPoint, const NXRect *aRect, BOOL flipped);
  104. extern void NXSetRect(NXRect *aRect, NXCoord x, NXCoord y, NXCoord w, NXCoord h);
  105. extern NXRect *NXUnionRect(const NXRect *aRect, NXRect *bRect);
  106.  
  107. extern NXColorSpace NXColorSpaceFromDepth (NXWindowDepth depth);
  108. extern int NXBPSFromDepth (NXWindowDepth depUF
  109. extern int NXNumberOfColorComponents (NXColorSpace colorSpace);
  110. extern BOOL NXGetBestDepth (NXWindowDepth *depth, int numColors, int bps);
  111.  
  112. extern void NXPing(void);
  113.  
  114. /* Obsolete, do not use */
  115. extern int NXContainRect(NXRect *aRect, const NXRect *bRect);
  116.  
  117. extern void NXDrawBitmap(const NXRect *rect, int width, int height,
  118.             int bps, int spp, int bpp, int bpr, 
  119.             BOOL isPlanar, BOOL hasAlpha, NXColorSpace colorSpace,
  120.             const unsigned char *const data[5]);
  121.  
  122. extern void NXReadBitmap(const NXRect *rect, int w, int h, int bps, int spp, 
  123.                 int planarConfig, int photoInt,
  124.                 void *data1, void *data2, void *data3,
  125.                 void *data4, void *data5 );
  126.  
  127. extern void NXSizeBitmap(const NXRect *rect, int *size, int *width, 
  128.     int *height, int *bps, int *spp, int *planarConfig, int *photoInt );
  129.  
  130. extern void NXCopyBitmapFromGState (int srcGState,
  131.                     const NXRect *srcRect,
  132.                     const NXRect *destRect);
  133.  
  134. extern void NXWritePoint (NXTypedStream *s, const NXPoint *aPoint);
  135.     /* Equivalent to NXWriteTypes (s, "ff", &aPoint.x, &aPoint.y) */
  136. extern void NXReadPoint (NXTypedStream *s, NXPoint *aPoint);
  137.  
  138. extern void NXWriteSize (NXTypedStream *s, const NXSize *aSize);
  139.     /* Equivalent to NXWriteTypes (s, "ff", &aSize.width, &aSize.height) */
  140. extern void NXReadSize (NXTypedStream *s, NXSize *aSize);
  141.  
  142. extern void NXWriteRect (NXTypedStream *s, const NXRect *aRect);
  143.     /* Equivalent to NXWriteArray (s, "f", 4, &aRect) */
  144. extern void NXReadRect (NXTypedStream *s, NXRect *aRect);
  145.  
  146. /*
  147.  * The following four constants are obsolete and used in the 1.0 API. 
  148.  * Use NXColorSpace instead.
  149.  */
  150. #define NX_MONOTONICMASK    1
  151. #define NX_COLORMASK        2
  152. #define NX_ALPHAMASK        4
  153. #define NX_PALETTEMASK        8
  154.  
  155. /*
  156.  * The following two constants are obsolete and used in the 1.0 API to
  157.  * describe planar configuration of bitmaps. 2.0 API uses a boolean (isPlanar) 
  158.  * instead.
  159.  */
  160. #define NX_MESHED        1
  161. #define NX_PLANAR        2    
  162.  
  163. /*
  164.  * #defines for historical reasons; don't use these in new applications.
  165.  */
  166. #define NXWindowDepthType    NXWindowDepth
  167. #define NXColorSpaceType    NXColorSpace
  168.  
  169. #endif GRAPHICS_H
  170.