/***************************************************************************
                            KPixmapIO.cpp -  description
                             -------------------
    begin                : Sun Jan 27 16:22:17 2002
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Jan 27 16:22:17 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
***************************************************************************/

#define _BOOL_H_
#include <qimage.h>
#include <kpixmapio.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <kdejava/KDESupport.h>
#include <kdejava/KPixmapIO.h>

class KPixmapIOJBridge : public KPixmapIO
{
public:
	KPixmapIOJBridge() : KPixmapIO() {}
	~KPixmapIOJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_newKPixmapIO(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KPixmapIOJBridge());
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (KPixmapIO*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KPixmapIO_finalize(env, obj);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KPixmapIO_isDisposed(JNIEnv *env, jobject obj)
{
	return (QtSupport::getQt(env, obj) == 0);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KPixmapIO_convertToPixmap(JNIEnv *env, jobject obj, jobject image)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QPixmap (((KPixmapIO*) QtSupport::getQt(env, obj))->convertToPixmap((QImage&) *(QImage *) QtSupport::getQt(env, image))), "org.kde.qt.QPixmap", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KPixmapIO_convertToImage(JNIEnv *env, jobject obj, jobject pixmap)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QImage (((KPixmapIO*) QtSupport::getQt(env, obj))->convertToImage((QPixmap&) *(QPixmap *) QtSupport::getQt(env, pixmap))), "org.kde.qt.QImage", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_putImage__Lorg_kde_qt_QPixmap_2IILorg_kde_qt_QImage_2(JNIEnv *env, jobject obj, jobject dst, jint dx, jint dy, jobject src)
{
	((KPixmapIO*) QtSupport::getQt(env, obj))->putImage((QPixmap*) QtSupport::getQt(env, dst), (int) dx, (int) dy, (QImage*) QtSupport::getQt(env, src));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_putImage__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QPoint_2Lorg_kde_qt_QImage_2(JNIEnv *env, jobject obj, jobject dst, jobject offset, jobject src)
{
	((KPixmapIO*) QtSupport::getQt(env, obj))->putImage((QPixmap*) QtSupport::getQt(env, dst), (QPoint&) *(QPoint *) QtSupport::getQt(env, offset), (QImage*) QtSupport::getQt(env, src));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KPixmapIO_getImage__Lorg_kde_qt_QPixmap_2IIII(JNIEnv *env, jobject obj, jobject src, jint sx, jint sy, jint sw, jint sh)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QImage (((KPixmapIO*) QtSupport::getQt(env, obj))->getImage((QPixmap*) QtSupport::getQt(env, src), (int) sx, (int) sy, (int) sw, (int) sh)), "org.kde.qt.QImage", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KPixmapIO_getImage__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QRect_2(JNIEnv *env, jobject obj, jobject src, jobject rect)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QImage (((KPixmapIO*) QtSupport::getQt(env, obj))->getImage((QPixmap*) QtSupport::getQt(env, src), (QRect&) *(QRect *) QtSupport::getQt(env, rect))), "org.kde.qt.QImage", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_setShmPolicy(JNIEnv *env, jobject obj, jint policy)
{
	((KPixmapIO*) QtSupport::getQt(env, obj))->setShmPolicy((int) policy);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPixmapIO_preAllocShm(JNIEnv *env, jobject obj, jint size)
{
	((KPixmapIO*) QtSupport::getQt(env, obj))->preAllocShm((int) size);
	return;
}

