2002-08-17 06:47:03 +00:00
|
|
|
#include "Object.h"
|
|
|
|
#include "Point.h"
|
|
|
|
#include "Size.h"
|
|
|
|
#include "Rect.h"
|
|
|
|
|
|
|
|
@implementation Rect
|
|
|
|
|
|
|
|
- (id) initWithComponents: (integer)x : (integer)y : (integer)w : (integer)h
|
|
|
|
{
|
2002-11-01 01:31:37 +00:00
|
|
|
self = [super init];
|
|
|
|
origin = [[Size alloc] initWithComponents: x : y];
|
|
|
|
size = [[Size alloc] initWithComponents: w : h];
|
2002-08-17 06:47:03 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithOrigin: (Point)anOrigin size: (Size)aSize
|
|
|
|
{
|
2002-11-01 01:31:37 +00:00
|
|
|
self = [super init];
|
2002-08-17 06:47:03 +00:00
|
|
|
|
|
|
|
if (!self || !anOrigin || !aSize)
|
|
|
|
return NIL;
|
|
|
|
|
2003-07-29 18:02:03 +00:00
|
|
|
origin = [anOrigin retain];
|
|
|
|
size = [aSize retain];
|
2002-08-17 06:47:03 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithRect: (Rect)aRect
|
|
|
|
{
|
2002-11-01 01:31:37 +00:00
|
|
|
self = [super init];
|
2002-08-17 06:47:03 +00:00
|
|
|
|
|
|
|
if (!self || !aRect)
|
|
|
|
return NIL;
|
|
|
|
|
|
|
|
[self setRect: aRect];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) copy
|
|
|
|
{
|
|
|
|
local id myCopy = [super copy];
|
|
|
|
|
|
|
|
if (!myCopy)
|
|
|
|
myCopy = [[self class] alloc];
|
|
|
|
|
|
|
|
return [myCopy initWithOrigin: origin size: size];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (Point) origin
|
|
|
|
{
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (Size) size
|
|
|
|
{
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setOrigin: (Point)aPoint
|
|
|
|
{
|
|
|
|
if (!aPoint)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (origin)
|
2003-07-29 18:02:03 +00:00
|
|
|
[origin release];
|
2002-08-17 06:47:03 +00:00
|
|
|
|
2003-07-29 18:02:03 +00:00
|
|
|
origin = [aPoint retain];
|
2002-08-17 06:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSize: (Size)aSize
|
|
|
|
{
|
|
|
|
if (!aSize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (size)
|
2003-07-29 18:02:03 +00:00
|
|
|
[size release];
|
2002-08-17 06:47:03 +00:00
|
|
|
|
2003-07-29 18:02:03 +00:00
|
|
|
size = [aSize retain];
|
2002-08-17 06:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setRect: (Rect)aRect
|
|
|
|
{
|
|
|
|
[self setOrigin: [aRect origin]];
|
|
|
|
[self setSize: [aRect size]];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|