/***************************************************************************
                            QCanvasView.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_QCanvasView.h>
#include <qtobjc/QCanvasView.h>
#include <qtobjc/QWMatrix.h>

#include <qtobjc/QCanvas.h>
#include <qtobjc/QPainter.h>

@implementation  QCanvasView


- initWithWidget: (QWidget *)parent name: (NSString *)name f: (int)f
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QCanvasView((qt_QWidget *) [parent qt], (char*) [name cString], (int)f)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- initWithCanvas: (QCanvas*)viewing parent: (QWidget *)parent name: (NSString *)name f: (int)f
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QCanvasView1((qt_QCanvas*) [viewing qt], (qt_QWidget *) [parent qt], (char*) [name cString], (int)f)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithCanvas: (QCanvas*)viewing 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QCanvasView1((qt_QCanvas*) [viewing qt], 0, 0, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parentWidget: YES] == nil) {
			qt_del_QCanvasView((qt_QCanvasView *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (QCanvas*) canvas
{
	return (QCanvas*) [QtSupport objectForQtKey: qt_QCanvasView_canvas((qt_QCanvasView *)[self qt]) withClass: [QCanvas class] allocatedInObjcWorld: YES];
}

- setCanvas: (QCanvas*)v
{
	qt_QCanvasView_setCanvas((qt_QCanvasView *)[self qt], (qt_QCanvas*) [v qt]);
	return self;
}

- (QWMatrix*) worldMatrix
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QCanvasView_worldMatrix((qt_QCanvasView *)[self qt]) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (QWMatrix*) inverseWorldMatrix
{
	return (QWMatrix*) [QtSupport objectForQtKey: qt_QCanvasView_inverseWorldMatrix((qt_QCanvasView *)[self qt]) withClass: [QWMatrix class] allocatedInObjcWorld: YES];
}

- (BOOL) setWorldMatrix: (QWMatrix *)arg1
{
	return (BOOL) qt_QCanvasView_setWorldMatrix((qt_QCanvasView *)[self qt], (qt_QWMatrix *) [arg1 qt]);
}

- drawContents: (QPainter *)arg1 cx: (int)cx cy: (int)cy cw: (int)cw ch: (int)ch
{
	qt_QCanvasView_drawContents((qt_QCanvasView *)[self qt], (qt_QPainter *) [arg1 qt], (int)cx, (int)cy, (int)cw, (int)ch);
	return self;
}

- (QSize*) sizeHint
{
	return (QSize*) [QtSupport objectForQtKey: qt_QCanvasView_sizeHint((qt_QCanvasView *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

@end
