/**
Todo Description
*/ @implementation NSCachedImageRep /**Initializes and returns a new NSCachedImageRep with size and depth specified by aSize and aDepth recpectivly. If seperate is YES, the image will gets its own unique cache without sharing it with other images.
*/ - (id) initWithSize: (NSSize)aSize depth: (NSWindowDepth)aDepth separate: (BOOL)separate alpha: (BOOL)alpha { NSWindow *win; NSRect frame; // FIXME: Only create new window when separate is YES frame.origin = NSMakePoint(0,0); frame.size = aSize; win = [[GSCacheW alloc] initWithContentRect: frame styleMask: NSBorderlessWindowMask backing: NSBackingStoreRetained defer: NO]; self = [self initWithWindow: win rect: frame]; RELEASE(win); [self setAlpha: alpha]; [self setBitsPerSample: NSBitsPerSampleFromDepth(aDepth)]; return self; } /**Initializes and returns a new NSCachedImageRep into a NSWindow aWindow. The image will be draw into the rectange aRect of this window. aWindow is retained
*/ - (id) initWithWindow: (NSWindow *)aWindow rect: (NSRect)aRect { [super init]; _window = RETAIN(aWindow); _rect = aRect; /* Either win or rect must be non-NULL. If rect is empty, we get the frame info from the window. If win is nil we create it from the rect information. */ if (NSIsEmptyRect(_rect)) { if (!_window) { [NSException raise: NSInvalidArgumentException format: @"Must specify either window or rect when " @"creating NSCachedImageRep"]; } _rect = [_window frame]; } if (!_window) _window = [[GSCacheW alloc] initWithContentRect: _rect styleMask: NSBorderlessWindowMask backing: NSBackingStoreRetained defer: NO]; [self setSize: _rect.size]; [self setAlpha: NO]; [self setOpaque: YES]; [self setPixelsHigh: _rect.size.height]; [self setPixelsWide: _rect.size.width]; return self; } - (void) dealloc { RELEASE(_window); [super dealloc]; } /**Returns the rectangle where the image is cached
*/ - (NSRect) rect { return _rect; } /**Returns the NSWindow where the image is cached
*/ - (NSWindow *) window { return _window; } - (BOOL) draw { PScomposite(NSMinX(_rect), NSMinY(_rect), NSWidth(_rect), NSHeight(_rect), [_window gState], 0, 0, NSCompositeSourceOver); return YES; } // NSCoding protocol - (void) encodeWithCoder: (NSCoder*)aCoder { [super encodeWithCoder: aCoder]; [aCoder encodeObject: _window]; [aCoder encodeRect: _rect]; } - (id) initWithCoder: (NSCoder*)aDecoder { self = [super initWithCoder: aDecoder]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_window]; _rect = [aDecoder decodeRect]; return self; } // NSCopying protocol - (id) copyWithZone: (NSZone *)zone { // Cached images should not be copied return nil; } @end