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
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1996-05-30 20:03:15 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2011-03-04 11:33:22 +00:00
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSCoder.h>
|
|
|
|
#import <Foundation/NSData.h>
|
|
|
|
#import "AppKit/NSPasteboard.h"
|
|
|
|
#import "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
|
|
|
{
|
2011-03-10 23:03:01 +00:00
|
|
|
return AUTORELEASE([[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];
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
if ([aCoder allowsKeyedCoding])
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[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
|
|
|
{
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
NSData *data = nil;
|
2001-06-07 21:54:51 +00:00
|
|
|
|
|
|
|
self = [super initWithCoder: aDecoder];
|
* Source/NSEvent.m,
* Source/NSParagraphStyle.m: Use NSInteger instead of enumerator
type name for decoding and encoding.
* Header/AppKit/NSFontPanel.h,
* Header/AppKit/NSOpenPanel.h,
* Header/AppKit/NSDataLinkPanel.h,
* Source/NSDataLinkPanel.m,
* Header/AppKit/NSForm.h,
* Source/NSForm.m,
* Header/AppKit/NSHelpPanel.h,
* Source/NSHelpPanel.m,
* Source/NSColorPanel.m: Remove unused encoding/decoding
* methods.
* Source/NSCustomImageRep.m,
* Source/NSEPSImageRep.m,
* Source/NSMovie.m,
* Source/NSRulerMarker.m,
* Source/NSColorList.m: Flag missing keyed encoding/decoding.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36377 72102866-910b-0410-8b05-ffd578937521
2013-03-17 19:53:50 +00:00
|
|
|
if ([aDecoder allowsKeyedCoding])
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data = [aDecoder decodeObject];
|
|
|
|
}
|
2001-06-07 21:54:51 +00:00
|
|
|
return [self initWithData: data];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|