/***************************************************************************
                            KPixmapIO.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, 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 <kdec/kde_KPixmapIO.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KPixmapIO.h>
#include <qtobjc/QImage.h>
#include <qtobjc/QPixmap.h>
#include <qtobjc/QPoint.h>
#include <qtobjc/QRect.h>


@implementation  KPixmapIO

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

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

- (QPixmap*) convertToPixmap: (QImage *)image
{
	return (QPixmap*) [QtSupport objectForQtKey: kde_KPixmapIO_convertToPixmap((kde_KPixmapIO *)[self qt], (qt_QImage *) [image qt]) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (QImage*) convertToImage: (QPixmap *)pixmap
{
	return (QImage*) [QtSupport objectForQtKey: kde_KPixmapIO_convertToImage((kde_KPixmapIO *)[self qt], (qt_QPixmap *) [pixmap qt]) withClass: [QImage class] allocatedInObjcWorld: YES];
}

- putImage: (QPixmap *)dst dx: (int)dx dy: (int)dy src: (QImage*)src
{
	kde_KPixmapIO_putImage((kde_KPixmapIO *)[self qt], (qt_QPixmap *) [dst qt], (int)dx, (int)dy, (qt_QImage*) [src qt]);
	return self;
}

- putImage: (QPixmap *)dst offset: (QPoint*)offset src: (QImage*)src
{
	kde_KPixmapIO_putImage1((kde_KPixmapIO *)[self qt], (qt_QPixmap *) [dst qt], (qt_QPoint*) [offset qt], (qt_QImage*) [src qt]);
	return self;
}

- (QImage*) getImage: (QPixmap *)src sx: (int)sx sy: (int)sy sw: (int)sw sh: (int)sh
{
	return (QImage*) [QtSupport objectForQtKey: kde_KPixmapIO_getImage((kde_KPixmapIO *)[self qt], (qt_QPixmap *) [src qt], (int)sx, (int)sy, (int)sw, (int)sh) withClass: [QImage class] allocatedInObjcWorld: YES];
}

- (QImage*) getImage: (QPixmap *)src rect: (QRect*)rect
{
	return (QImage*) [QtSupport objectForQtKey: kde_KPixmapIO_getImage1((kde_KPixmapIO *)[self qt], (qt_QPixmap *) [src qt], (qt_QRect*) [rect qt]) withClass: [QImage class] allocatedInObjcWorld: YES];
}

- setShmPolicy: (int)policy
{
	kde_KPixmapIO_setShmPolicy((kde_KPixmapIO *)[self qt], (int)policy);
	return self;
}

- preAllocShm: (int)size
{
	kde_KPixmapIO_preAllocShm((kde_KPixmapIO *)[self qt], (int)size);
	return self;
}

+ (int) ShmDontKeep
{
	return (int) KPIXMAPIO_ShmDontKeep;
}

+ (int) ShmKeepAndGrow
{
	return (int) KPIXMAPIO_ShmKeepAndGrow;
}

@end
