2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSEPSImageRep</title>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
<abstract>EPS image representation.</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
1996-10-18 17:14:13 +00:00
|
|
|
Author: Adam Fedor <fedor@colorado.edu>
|
1996-08-22 18:51:08 +00:00
|
|
|
Date: Feb 1996
|
|
|
|
|
|
|
|
This file is part of the GNUstep Application Kit Library.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
1996-08-22 18:51:08 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
2005-05-26 02:52:46 +00:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1996-08-22 18:51:08 +00:00
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-08 16:44:35 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
2002-04-02 11:13:36 +00:00
|
|
|
#include <Foundation/NSCoder.h>
|
2001-06-07 21:54:51 +00:00
|
|
|
#include <Foundation/NSData.h>
|
2003-06-13 15:01:12 +00:00
|
|
|
#include "AppKit/NSPasteboard.h"
|
|
|
|
#include "AppKit/NSEPSImageRep.h"
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-08-22 18:51:08 +00:00
|
|
|
@implementation NSEPSImageRep
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-08 16:44:35 +00:00
|
|
|
+ (BOOL) canInitWithData: (NSData *)data
|
|
|
|
{
|
|
|
|
char buffer[2];
|
|
|
|
|
|
|
|
[data getBytes: buffer length: 2];
|
|
|
|
|
|
|
|
// Simple check for Postscript
|
|
|
|
if (buffer[0] == '%' && buffer[1] == '!')
|
|
|
|
return YES;
|
|
|
|
else
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSArray *) imageUnfilteredFileTypes
|
|
|
|
{
|
|
|
|
static NSArray *types = nil;
|
|
|
|
|
|
|
|
if (types == nil)
|
|
|
|
{
|
|
|
|
types = [[NSArray alloc] initWithObjects: @"eps", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSArray *) imageUnfilteredPasteboardTypes
|
|
|
|
{
|
|
|
|
static NSArray *types = nil;
|
|
|
|
|
|
|
|
if (types == nil)
|
|
|
|
{
|
|
|
|
types = [[NSArray alloc] initWithObjects: NSPostScriptPboardType, nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Initializing a New Instance
|
1996-08-22 18:51:08 +00:00
|
|
|
+ (id) imageRepWithData: (NSData *)epsData
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-07 21:54:51 +00:00
|
|
|
return [[self alloc] initWithData: epsData];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
1997-01-31 13:40:15 +00:00
|
|
|
|
1996-08-22 18:51:08 +00:00
|
|
|
- (id) initWithData: (NSData *)epsData
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1996-08-22 18:51:08 +00:00
|
|
|
[self notImplemented: _cmd];
|
2001-06-07 21:54:51 +00:00
|
|
|
|
|
|
|
_epsData = epsData;
|
|
|
|
// Set bounds from parsed header
|
|
|
|
//_bounds = NSMakeRect();
|
1996-08-22 18:51:08 +00:00
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Getting Image Data
|
1996-08-22 18:51:08 +00:00
|
|
|
- (NSRect) boundingBox
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-07 21:54:51 +00:00
|
|
|
return _bounds;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-08-22 18:51:08 +00:00
|
|
|
- (NSData *) EPSRepresentation
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-07 21:54:51 +00:00
|
|
|
return _epsData;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-08-22 18:51:08 +00:00
|
|
|
- (void) prepareGState
|
2001-06-07 21:54:51 +00:00
|
|
|
{
|
|
|
|
// This is for subclasses only
|
|
|
|
}
|
|
|
|
|
|
|
|
// Drawing the Image
|
|
|
|
- (BOOL) draw
|
1996-08-22 18:51:08 +00:00
|
|
|
{
|
|
|
|
[self notImplemented: _cmd];
|
2001-06-07 21:54:51 +00:00
|
|
|
|
|
|
|
[self prepareGState];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NSCopying protocol
|
|
|
|
- (id) copyWithZone: (NSZone *)zone
|
|
|
|
{
|
|
|
|
NSEPSImageRep *copy = [super copyWithZone: zone];
|
|
|
|
|
|
|
|
copy->_epsData = [_epsData copyWithZone: zone];
|
|
|
|
|
|
|
|
return copy;
|
1996-08-22 18:51:08 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// NSCoding protocol
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-07 21:54:51 +00:00
|
|
|
NSData *data = [self EPSRepresentation];
|
|
|
|
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
[data encodeWithCoder: aCoder];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-07 21:54:51 +00:00
|
|
|
NSData *data;
|
|
|
|
|
|
|
|
self = [super initWithCoder: aDecoder];
|
|
|
|
data = [aDecoder decodeObject];
|
|
|
|
return [self initWithData: data];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|