/***************************************************************************
                            QWMatrix.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_QWMatrix.h>
#include <qtobjc/QWMatrix.h>
#include <qtobjc/QPoint.h>
#include <qtobjc/QPointArray.h>
#include <qtobjc/QRect.h>


@implementation  QWMatrix

- (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_QWMatrix()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDouble: (double)m11 m12: (double)m12 m21: (double)m21 m22: (double)m22 dx: (double)dx dy: (double)dy
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QWMatrix1((double)m11, (double)m12, (double)m21, (double)m22, (double)dx, (double)dy)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- setMatrix: (double)m11 m12: (double)m12 m21: (double)m21 m22: (double)m22 dx: (double)dx dy: (double)dy
{
	qt_QWMatrix_setMatrix((qt_QWMatrix *)[self qt], (double)m11, (double)m12, (double)m21, (double)m22, (double)dx, (double)dy);
	return self;
}

- (double) m11
{
	return (double) qt_QWMatrix_m11((qt_QWMatrix *)[self qt]);
}

- (double) m12
{
	return (double) qt_QWMatrix_m12((qt_QWMatrix *)[self qt]);
}

- (double) m21
{
	return (double) qt_QWMatrix_m21((qt_QWMatrix *)[self qt]);
}

- (double) m22
{
	return (double) qt_QWMatrix_m22((qt_QWMatrix *)[self qt]);
}

- (double) dx
{
	return (double) qt_QWMatrix_dx((qt_QWMatrix *)[self qt]);
}

- (double) dy
{
	return (double) qt_QWMatrix_dy((qt_QWMatrix *)[self qt]);
}

- mapInt: (int)x y: (int)y tx: (int*)tx ty: (int*)ty
{
	qt_QWMatrix_map((qt_QWMatrix *)[self qt], (int)x, (int)y, (int*)tx, (int*)ty);
	return self;
}

- mapDouble: (double)x y: (double)y tx: (double*)tx ty: (double*)ty
{
	qt_QWMatrix_map1((qt_QWMatrix *)[self qt], (double)x, (double)y, (double*)tx, (double*)ty);
	return self;
}

- (QRect*) mapRect: (QRect*)arg1
{
	return (QRect*) [QtSupport objectForQtKey: qt_QWMatrix_mapRect((qt_QWMatrix *)[self qt], (qt_QRect*) [arg1 qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (QPoint*) mapPoint: (QPoint*)p
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QWMatrix_map2((qt_QWMatrix *)[self qt], (qt_QPoint*) [p qt]) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

//- (QRect*) mapRect: (QRect*)r
//{
//	return (QRect*) [QtSupport objectForQtKey: qt_QWMatrix_map3((qt_QWMatrix *)[self qt], (qt_QRect*) [r qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
//}

- (QPointArray*) mapPointArray: (QPointArray*)a
{
	return (QPointArray*) [QtSupport objectForQtKey: qt_QWMatrix_map4((qt_QWMatrix *)[self qt], (qt_QPointArray*) [a qt]) withClass: [QPointArray class] allocatedInObjcWorld: YES];
}

- reset
{
	qt_QWMatrix_reset((qt_QWMatrix *)[self qt]);
	return self;
}

- (BOOL) isIdentity
{
	return (BOOL) qt_QWMatrix_isIdentity((qt_QWMatrix *)[self qt]);
}

- (QWMatrix*) translate: (double)dx dy: (double)dy
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QWMatrix_translate((qt_QWMatrix *)[self qt], (double)dx, (double)dy) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (QWMatrix*) scale: (double)sx sy: (double)sy
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QWMatrix_scale((qt_QWMatrix *)[self qt], (double)sx, (double)sy) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (QWMatrix*) shear: (double)sh sv: (double)sv
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QWMatrix_shear((qt_QWMatrix *)[self qt], (double)sh, (double)sv) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (QWMatrix*) rotate: (double)a
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QWMatrix_rotate((qt_QWMatrix *)[self qt], (double)a) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (BOOL) isInvertible
{
	return (BOOL) qt_QWMatrix_isInvertible((qt_QWMatrix *)[self qt]);
}

- (QWMatrix*) invert: (int*)arg1
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QWMatrix_invert((qt_QWMatrix *)[self qt], (int*)arg1) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (QWMatrix*) invert
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QWMatrix_invert((qt_QWMatrix *)[self qt], 0) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

@end
