Added coding methods.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8276 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2000-12-08 01:17:22 +00:00
parent 181976dcb5
commit c3b0028f40

View file

@ -34,6 +34,7 @@
#include <AppKit/config.h> #include <AppKit/config.h>
#include <AppKit/NSAffineTransform.h> #include <AppKit/NSAffineTransform.h>
#include <AppKit/NSBezierPath.h>
#include <AppKit/PSOperators.h> #include <AppKit/PSOperators.h>
/* Private definitions */ /* Private definitions */
@ -67,7 +68,7 @@ static NSAffineTransformStruct identityTransform = {
t = (NSAffineTransform*)NSAllocateObject(self, 0, NSDefaultMallocZone()); t = (NSAffineTransform*)NSAllocateObject(self, 0, NSDefaultMallocZone());
t->matrix = identityTransform; t->matrix = identityTransform;
t->rotationAngle = 0.0; t->rotationAngle = 0.0;
return [t autorelease]; return AUTORELEASE(t);
} }
+ (id) new + (id) new
@ -312,24 +313,9 @@ static NSAffineTransformStruct identityTransform = {
TY += tranY; TY += tranY;
} }
+ matrixFrom: (const float[6])_matrix
{
NSAffineTransform *m = [[self alloc] autorelease];
[m setMatrix: _matrix];
return m;
}
- (id) copyWithZone: (NSZone*)zone - (id) copyWithZone: (NSZone*)zone
{ {
NSAffineTransform *new; return NSCopyObject(self, 0, zone);
new = (NSAffineTransform*)NSAllocateObject(isa, 0, zone);
new->matrix = matrix;
new->rotationAngle = rotationAngle;
return new;
} }
- (BOOL) isEqual: (id)anObject - (BOOL) isEqual: (id)anObject
@ -345,6 +331,41 @@ static NSAffineTransformStruct identityTransform = {
return NO; return NO;
} }
- (id) initWithCoder: (NSCoder*)aCoder
{
float replace[6];
[aCoder decodeArrayOfObjCType: @encode(float)
count: 6
at: replace];
[self setMatrix: replace];
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
float replace[6];
[self getMatrix: replace];
[aCoder encodeArrayOfObjCType: @encode(float)
count: 6
at: replace];
}
@end /* NSAffineTransform */
@implementation NSAffineTransform (GNUstep)
+ matrixFrom: (const float[6])_matrix
{
NSAffineTransform *m = AUTORELEASE([self alloc]);
[m setMatrix: _matrix];
return m;
}
- (void) scaleBy: (float)sx :(float)sy - (void) scaleBy: (float)sx :(float)sy
{ {
A *= sx; B *= sx; A *= sx; B *= sx;
@ -558,5 +579,5 @@ static NSAffineTransformStruct identityTransform = {
replace[5] = matrix.ty; replace[5] = matrix.ty;
} }
@end /* NSAffineTransform */ @end /* NSAffineTransform (GNUstep) */