/***************************************************************************
                            QRect.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_QRect.h>
#include <qtobjc/QRect.h>
#include <qtobjc/QPoint.h>
#include <qtobjc/QSize.h>


@implementation  QRect

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

- initWithPoint: (QPoint*)topleft bottomright: (QPoint*)bottomright
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QRect1((qt_QPoint*) [topleft qt], (qt_QPoint*) [bottomright qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithPoint: (QPoint*)topleft size: (QSize *)size
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QRect2((qt_QPoint*) [topleft qt], (qt_QSize *) [size qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithInt: (int)left top: (int)top width: (int)width height: (int)height
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QRect3((int)left, (int)top, (int)width, (int)height)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (BOOL) isNull
{
	return (BOOL) qt_QRect_isNull((qt_QRect *)[self qt]);
}

- (BOOL) isEmpty
{
	return (BOOL) qt_QRect_isEmpty((qt_QRect *)[self qt]);
}

- (BOOL) isValid
{
	return (BOOL) qt_QRect_isValid((qt_QRect *)[self qt]);
}

- (QRect*) normalize
{
	return (QRect*) [QtSupport objectForQtKey: qt_QRect_normalize((qt_QRect *)[self qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (int) left
{
	return (int) qt_QRect_left((qt_QRect *)[self qt]);
}

- (int) top
{
	return (int) qt_QRect_top((qt_QRect *)[self qt]);
}

- (int) right
{
	return (int) qt_QRect_right((qt_QRect *)[self qt]);
}

- (int) bottom
{
	return (int) qt_QRect_bottom((qt_QRect *)[self qt]);
}

- (short) rLeft
{
	return (short) qt_QRect_rLeft((qt_QRect *)[self qt]);
}

- (short) rTop
{
	return (short) qt_QRect_rTop((qt_QRect *)[self qt]);
}

- (short) rRight
{
	return (short) qt_QRect_rRight((qt_QRect *)[self qt]);
}

- (short) rBottom
{
	return (short) qt_QRect_rBottom((qt_QRect *)[self qt]);
}

- (int) x
{
	return (int) qt_QRect_x((qt_QRect *)[self qt]);
}

- (int) y
{
	return (int) qt_QRect_y((qt_QRect *)[self qt]);
}

- setLeft: (int)pos
{
	qt_QRect_setLeft((qt_QRect *)[self qt], (int)pos);
	return self;
}

- setTop: (int)pos
{
	qt_QRect_setTop((qt_QRect *)[self qt], (int)pos);
	return self;
}

- setRight: (int)pos
{
	qt_QRect_setRight((qt_QRect *)[self qt], (int)pos);
	return self;
}

- setBottom: (int)pos
{
	qt_QRect_setBottom((qt_QRect *)[self qt], (int)pos);
	return self;
}

- setX: (int)x
{
	qt_QRect_setX((qt_QRect *)[self qt], (int)x);
	return self;
}

- setY: (int)y
{
	qt_QRect_setY((qt_QRect *)[self qt], (int)y);
	return self;
}

- (QPoint*) topLeft
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QRect_topLeft((qt_QRect *)[self qt]) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

- (QPoint*) bottomRight
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QRect_bottomRight((qt_QRect *)[self qt]) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

- (QPoint*) topRight
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QRect_topRight((qt_QRect *)[self qt]) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

- (QPoint*) bottomLeft
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QRect_bottomLeft((qt_QRect *)[self qt]) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

- (QPoint*) center
{
	return (QPoint*) [QtSupport objectForQtKey: qt_QRect_center((qt_QRect *)[self qt]) withClass: [QPoint class] allocatedInObjcWorld: YES];
}

- rect: (int*)x y: (int*)y w: (int*)w h: (int*)h
{
	qt_QRect_rect((qt_QRect *)[self qt], (int*)x, (int*)y, (int*)w, (int*)h);
	return self;
}

- coords: (int*)x1 y1: (int*)y1 x2: (int*)x2 y2: (int*)y2
{
	qt_QRect_coords((qt_QRect *)[self qt], (int*)x1, (int*)y1, (int*)x2, (int*)y2);
	return self;
}

- moveTopLeft: (QPoint*)p
{
	qt_QRect_moveTopLeft((qt_QRect *)[self qt], (qt_QPoint*) [p qt]);
	return self;
}

- moveBottomRight: (QPoint*)p
{
	qt_QRect_moveBottomRight((qt_QRect *)[self qt], (qt_QPoint*) [p qt]);
	return self;
}

- moveTopRight: (QPoint*)p
{
	qt_QRect_moveTopRight((qt_QRect *)[self qt], (qt_QPoint*) [p qt]);
	return self;
}

- moveBottomLeft: (QPoint*)p
{
	qt_QRect_moveBottomLeft((qt_QRect *)[self qt], (qt_QPoint*) [p qt]);
	return self;
}

- moveCenter: (QPoint*)p
{
	qt_QRect_moveCenter((qt_QRect *)[self qt], (qt_QPoint*) [p qt]);
	return self;
}

- moveBy: (int)dx dy: (int)dy
{
	qt_QRect_moveBy((qt_QRect *)[self qt], (int)dx, (int)dy);
	return self;
}

- setRect: (int)x y: (int)y w: (int)w h: (int)h
{
	qt_QRect_setRect((qt_QRect *)[self qt], (int)x, (int)y, (int)w, (int)h);
	return self;
}

- setCoords: (int)x1 y1: (int)y1 x2: (int)x2 y2: (int)y2
{
	qt_QRect_setCoords((qt_QRect *)[self qt], (int)x1, (int)y1, (int)x2, (int)y2);
	return self;
}

- addCoords: (int)x1 y1: (int)y1 x2: (int)x2 y2: (int)y2
{
	qt_QRect_addCoords((qt_QRect *)[self qt], (int)x1, (int)y1, (int)x2, (int)y2);
	return self;
}

- (QSize*) size
{
	return (QSize*) [QtSupport objectForQtKey: qt_QRect_size((qt_QRect *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

- (int) width
{
	return (int) qt_QRect_width((qt_QRect *)[self qt]);
}

- (int) height
{
	return (int) qt_QRect_height((qt_QRect *)[self qt]);
}

- setWidth: (int)w
{
	qt_QRect_setWidth((qt_QRect *)[self qt], (int)w);
	return self;
}

- setHeight: (int)h
{
	qt_QRect_setHeight((qt_QRect *)[self qt], (int)h);
	return self;
}

- setSize: (QSize *)s
{
	qt_QRect_setSize((qt_QRect *)[self qt], (qt_QSize *) [s qt]);
	return self;
}

- (BOOL) contains: (QPoint*)p proper: (BOOL)proper
{
	return (BOOL) qt_QRect_contains((qt_QRect *)[self qt], (qt_QPoint*) [p qt], (int)proper);
}

- (BOOL) contains: (QPoint*)p 
{
	return (BOOL) qt_QRect_contains((qt_QRect *)[self qt], (qt_QPoint*) [p qt], 0);
}

- (BOOL) contains: (int)x y: (int)y proper: (BOOL)proper
{
	return (BOOL) qt_QRect_contains1((qt_QRect *)[self qt], (int)x, (int)y, (int)proper);
}

- (BOOL) contains: (int)x y: (int)y 
{
	return (BOOL) qt_QRect_contains1((qt_QRect *)[self qt], (int)x, (int)y, 0);
}

- (BOOL) containsRect: (QRect*)r proper: (BOOL)proper
{
	return (BOOL) qt_QRect_contains2((qt_QRect *)[self qt], (qt_QRect*) [r qt], (int)proper);
}

- (BOOL) containsRect: (QRect*)r
{
	return (BOOL) qt_QRect_contains2((qt_QRect *)[self qt], (qt_QRect*) [r qt], 0);
}

- (QRect*) unite: (QRect*)r
{
	return (QRect*) [QtSupport objectForQtKey: qt_QRect_unite((qt_QRect *)[self qt], (qt_QRect*) [r qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (QRect*) intersect: (QRect*)r
{
	return (QRect*) [QtSupport objectForQtKey: qt_QRect_intersect((qt_QRect *)[self qt], (qt_QRect*) [r qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (BOOL) intersects: (QRect*)r
{
	return (BOOL) qt_QRect_intersects((qt_QRect *)[self qt], (qt_QRect*) [r qt]);
}

@end
