/***************************************************************************
                            QPicture.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_QPicture.h>
#include <qtobjc/QPicture.h>
#include <qtobjc/QIODevice.h>

#include <qtobjc/QPainter.h>

@implementation  QPicture


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

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

- copyWithZone: (NSZone *) zone
{
	QPicture * aCopy;
	aCopy = [[(QPicture *)[[self class] allocWithZone: zone] setQt: qt_new_QPicture1([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

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

- (BOOL) isNull
{
	return (BOOL) qt_QPicture_isNull((qt_QPicture *)[self qt]);
}

- (unsigned int) size
{
	return (unsigned int) qt_QPicture_size((qt_QPicture *)[self qt]);
}

- (NSString *) data
{
	return (NSString *) [NSString stringWithCString: qt_QPicture_data((qt_QPicture *)[self qt])];
}

- setData: (NSString *)data size: (unsigned int)size
{
	qt_QPicture_setData((qt_QPicture *)[self qt], (char*) [data cString], (unsigned int)size);
	return self;
}

- (BOOL) play: (QPainter *)arg1
{
	return (BOOL) qt_QPicture_play((qt_QPicture *)[self qt], (qt_QPainter *) [arg1 qt]);
}

- (BOOL) load: (QIODevice *)dev format: (NSString *)format
{
	return (BOOL) qt_QPicture_load((qt_QPicture *)[self qt], (qt_QIODevice *) [dev qt], (char*) [format cString]);
}

- (BOOL) load: (QIODevice *)dev 
{
	return (BOOL) qt_QPicture_load((qt_QPicture *)[self qt], (qt_QIODevice *) [dev qt], 0);
}

- (BOOL) loadFromFile: (NSString *)fileName format: (NSString *)format
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) qt_QPicture_load1((qt_QPicture *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], (char*) [format cString]);
}

- (BOOL) loadFromFile: (NSString *)fileName
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) qt_QPicture_load1((qt_QPicture *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], 0);
}

- (BOOL) save: (QIODevice *)dev format: (NSString *)format
{
	return (BOOL) qt_QPicture_save((qt_QPicture *)[self qt], (qt_QIODevice *) [dev qt], (char*) [format cString]);
}

- (BOOL) save: (QIODevice *)dev 
{
	return (BOOL) qt_QPicture_save((qt_QPicture *)[self qt], (qt_QIODevice *) [dev qt], 0);
}

- (BOOL) saveToFile: (NSString *)fileName format: (NSString *)format
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) qt_QPicture_save1((qt_QPicture *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], (char*) [format cString]);
}

- (BOOL) saveToFile: (NSString *)fileName
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) qt_QPicture_save1((qt_QPicture *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], 0);
}

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

//- (BOOL) cmd: (int)arg1 painter: (QPainter *)arg2 pdevcmdparam: (QPDevCmdParam*)arg3
//{
//	return (BOOL) qt_QPicture_cmd((qt_QPicture *)[self qt], (int)arg1, (qt_QPainter *) [arg2 qt], (qt_QPDevCmdParam*) [arg3 qt]);
//}

- (int) metric: (int)arg1
{
	return (int) qt_QPicture_metric((qt_QPicture *)[self qt], (int)arg1);
}

- detach
{
	qt_QPicture_detach((qt_QPicture *)[self qt]);
	return self;
}

//- (QPicture) copy
//{
//	return (QPicture) qt_QPicture_copy((qt_QPicture *)[self qt]);
//}

@end
