/***************************************************************************
                            QPointArray.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <qtc/qt_QPointArray.h>
#include <qtobjc/QPointArray.h>
#include <qtobjc/QPoint.h>
#include <qtobjc/QRect.h>
#include <qtobjc/QWMatrix.h>

@implementation  QPointArray


- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}

- init
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QPointArray()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			qt_del_QPointArray((qt_QPointArray *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- initWithRect: (QRect*)r closed: (BOOL)closed
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QPointArray3((qt_QRect*) [r qt], (int)closed)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithRect: (QRect*)r 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QPointArray3((qt_QRect*) [r qt], 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithInt: (int)nPoints points: (short *)points
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QPointArray4((int)nPoints, (short *)points)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	[NSMutableArray arrayWithQPointArray: [self qt]];
	return self;
}

- (QPointArray*) copy
{
	return (QPointArray*) [QtSupport objectForQtKey: qt_QPointArray_copy((qt_QPointArray *)[self qt]) withClass: [QPointArray class] allocatedInObjcWorld: YES];
}

- translate: (int)dx dy: (int)dy
{
	qt_QPointArray_translate((qt_QPointArray *)[self qt], (int)dx, (int)dy);
	return self;
}

- (QRect*) boundingRect
{
	return (QRect*) [QtSupport objectForQtKey: qt_QPointArray_boundingRect((qt_QPointArray *)[self qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- point: (unsigned int)i x: (int*)x y: (int*)y
{
	qt_QPointArray_point((qt_QPointArray *)[self qt], (unsigned int)i, (int*)x, (int*)y);
	return self;
}

- (QPoint*) point: (unsigned int)i
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QPointArray_point1((qt_QPointArray *)[self qt], (unsigned int)i) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

- setPoint: (unsigned int)i x: (int)x y: (int)y
{
	qt_QPointArray_setPoint((qt_QPointArray *)[self qt], (unsigned int)i, (int)x, (int)y);
	return self;
}

- setPoint: (unsigned int)i p: (QPoint*)p
{
	qt_QPointArray_setPoint1((qt_QPointArray *)[self qt], (unsigned int)i, (qt_QPoint*) [p qt]);
	return self;
}

- (BOOL) setPoints: (int)nPoints points: (short *)points
{
	return (BOOL) qt_QPointArray_setPoints((qt_QPointArray *)[self qt], (int)nPoints, (short *)points);
}

- (BOOL) putPoints: (int)index nPoints: (int)nPoints points: (short *)points
{
	return (BOOL) qt_QPointArray_putPoints((qt_QPointArray *)[self qt], (int)index, (int)nPoints, (short *)points);
}

- (BOOL) putPoints: (int)index nPoints: (int)nPoints from: (QPointArray*)from fromIndex: (int)fromIndex
{
	return (BOOL) qt_QPointArray_putPoints2((qt_QPointArray *)[self qt], (int)index, (int)nPoints, (qt_QPointArray*) [from qt], (int)fromIndex);
}

- (BOOL) putPoints: (int)index nPoints: (int)nPoints from: (QPointArray*)from 
{
	return (BOOL) qt_QPointArray_putPoints2((qt_QPointArray *)[self qt], (int)index, (int)nPoints, (qt_QPointArray*) [from qt], 0);
}

- makeArc: (int)x y: (int)y w: (int)w h: (int)h a1: (int)a1 a2: (int)a2
{
	qt_QPointArray_makeArc((qt_QPointArray *)[self qt], (int)x, (int)y, (int)w, (int)h, (int)a1, (int)a2);
	return self;
}

- makeEllipse: (int)x y: (int)y w: (int)w h: (int)h
{
	qt_QPointArray_makeEllipse((qt_QPointArray *)[self qt], (int)x, (int)y, (int)w, (int)h);
	return self;
}

- makeArc: (int)x y: (int)y w: (int)w h: (int)h a1: (int)a1 a2: (int)a2 wmatrix: (QWMatrix *)arg1
{
	qt_QPointArray_makeArc1((qt_QPointArray *)[self qt], (int)x, (int)y, (int)w, (int)h, (int)a1, (int)a2, (qt_QWMatrix *) [arg1 qt]);
	return self;
}

- (QPointArray*) cubicBezier
{
	return (QPointArray*) [QtSupport objectForQtKey: qt_QPointArray_cubicBezier((qt_QPointArray *)[self qt]) withClass: [QPointArray class] allocatedInObjcWorld: YES];
}

- (void*) shortPoints: (int)index nPoints: (int)nPoints
{
	return (void*) qt_QPointArray_shortPoints((qt_QPointArray *)[self qt], (int)index, (int)nPoints);
}

- (void*) shortPoints
{
	return (void*) qt_QPointArray_shortPoints((qt_QPointArray *)[self qt], 0, -1);
}

+ cleanBuffers
{
	qt_QPointArray_cleanBuffers();
	return self;
}

@end
