home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSImageRep.h < prev    next >
Text File  |  1996-10-17  |  4KB  |  102 lines

  1. /*
  2.     NSImageRep.h
  3.     Application Kit
  4.     Copyright (c) 1994-1996, NeXT Software, Inc.
  5.     All rights reserved.
  6. */
  7.  
  8. #import <Foundation/NSObject.h>
  9. #import <AppKit/NSGraphics.h>
  10. #import <AppKit/AppKitDefines.h>
  11.  
  12. @class NSPasteboard;
  13.  
  14. /* NSImageRepMatchesDevice indicates the value is variable, depending on the output device. It can be passed in (or received back) as the value of bitsPerSample, pixelsWide, and pixelsHigh.
  15. */
  16. enum {
  17.     NSImageRepMatchesDevice = 0
  18. };
  19.  
  20. @interface NSImageRep : NSObject <NSCopying, NSCoding> {
  21.     struct __repFlags {
  22.     unsigned int hasAlpha:1;
  23.     unsigned int isOpaque:1;
  24.         unsigned int cacheParamsComputed:1;
  25.         unsigned int cacheAlphaComputed:1;
  26.         unsigned int reserved:4;
  27.         unsigned int bitsPerSample:8;
  28.     unsigned int gsaved:16;
  29.     } _repFlags;
  30.     NSString *_colorSpaceName;
  31.     NSSize _size;
  32.     int _pixelsWide;
  33.     int _pixelsHigh;
  34. }
  35.  
  36. /* Drawing methods. drawAtPoint: and drawInRect: go through draw after modifying the CTM.
  37. */
  38. - (BOOL)draw;
  39. - (BOOL)drawAtPoint:(NSPoint)point;
  40. - (BOOL)drawInRect:(NSRect)rect;
  41.  
  42. /* Methods to return info about the image. NSImageRep provides storage for all of these; however, it's illegal to set them in some subclasses.
  43. */
  44. - (void)setSize:(NSSize)aSize;
  45. - (NSSize)size;
  46. - (void)setAlpha:(BOOL)flag;
  47. - (BOOL)hasAlpha;
  48. - (void)setOpaque:(BOOL)flag;
  49. - (BOOL)isOpaque;
  50. - (void)setColorSpaceName:(NSString *)string;
  51. - (NSString *)colorSpaceName;
  52. - (void)setBitsPerSample:(int)anInt;
  53. - (int)bitsPerSample;
  54. - (void)setPixelsWide:(int)anInt;
  55. - (int)pixelsWide;
  56. - (void)setPixelsHigh:(int)anInt;
  57. - (int)pixelsHigh;
  58.  
  59. /* The rest of the methods all deal with subclassers which can read/write data in files or pasteboards. 
  60. */
  61.  
  62. /* Registry management: Subclasses which deal with file & pasteboard types should register themselves. These classes should also implement imageUnfilteredFileTypes, imageUnfilteredPasteboardTypes, initWithData:, canInitWithData:, imageRepWithData:, and, if they have the ability to read multiple images from a file, imageRepsWithData:. These last three should not do any filtering; all filtering is automatic.
  63. */
  64. + (void)registerImageRepClass:(Class)imageRepClass;
  65. + (void)unregisterImageRepClass:(Class)imageRepClass;
  66. + (NSArray *)registeredImageRepClasses;
  67. + (Class)imageRepClassForFileType:(NSString *)type;
  68. + (Class)imageRepClassForPasteboardType:(NSString *)type;
  69. + (Class)imageRepClassForData:(NSData *)data;
  70.     
  71. /* Should be overridden by subclassers to load an unfiltered image. 
  72. */
  73. + (BOOL)canInitWithData:(NSData *)data;
  74.  
  75. /* Implemented by subclassers to indicate what data types they can deal with.
  76. */
  77. + (NSArray *)imageUnfilteredFileTypes;
  78. + (NSArray *)imageUnfilteredPasteboardTypes;
  79.  
  80. /* These expand the unfiltered lists returned by imageUnfilteredFileTypes and imageUnfilteredPasteboardTypes.
  81. */
  82. + (NSArray *)imageFileTypes;
  83. + (NSArray *)imagePasteboardTypes;
  84.  
  85. /* Convenience method: Checks to see if any of the types on the pasteboard can be understood by a registered imagerep class after filtering or if the pasteboard contains a filename that can be understood by a registered imagerep class after filtering. If sent to a subclass, does this for just the types understood by the subclass.
  86. */
  87. + (BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard;
  88.  
  89. /* Convenience methods: Checks to see if the provided file or pasteboard types can be understood by a registered imagerep class after filtering; if so, calls imageRepsWithData: or imageRepWithData:. If sent to a subclass, does this just for the types understood by that subclass.
  90. */
  91. + (NSArray *)imageRepsWithContentsOfFile:(NSString *)filename;
  92. + (id)imageRepWithContentsOfFile:(NSString *)filename;
  93. + (NSArray *)imageRepsWithPasteboard:(NSPasteboard *)pasteboard;
  94. + (id)imageRepWithPasteboard:(NSPasteboard *)pasteboard;
  95.  
  96. @end
  97.  
  98. /* Notifications */
  99. #define NSImageRepRegistryChangedNotification NSImageRepRegistryDidChangeNotification /* obsolete name */
  100. APPKIT_EXTERN NSString *NSImageRepRegistryDidChangeNotification;
  101.  
  102.