/***************************************************************************
                            KPalette.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 <kpalette.h>
#include <qstring.h>
#include <qcstring.h>

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

class KPaletteJBridge : public KPalette
{
public:
	KPaletteJBridge(const QString& name) : KPalette(name) {}
	KPaletteJBridge(const KPalette& arg1) : KPalette(arg1) {}
	~KPaletteJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KPalette_newKPalette__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring name)
{
static QString * _qstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KPaletteJBridge((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KPalette_newKPalette__Lorg_kde_koala_KPalette_2(JNIEnv *env, jobject obj, jobject arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KPaletteJBridge((KPalette&) *(KPalette *) QtSupport::getQt(env, arg1)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KPalette_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KPalette_finalize(env, obj);
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KPalette_save(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KPalette*) QtSupport::getQt(env, obj))->save();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KPalette_description(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((KPalette*) QtSupport::getQt(env, obj))->description();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPalette_setDescription(JNIEnv *env, jobject obj, jstring desc)
{
static QString * _qstring_desc = 0;
	((KPalette*) QtSupport::getQt(env, obj))->setDescription((QString&) * (QString *) QtSupport::toQString(env, desc, &_qstring_desc));
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KPalette_name(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((KPalette*) QtSupport::getQt(env, obj))->name();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPalette_setName(JNIEnv *env, jobject obj, jstring name)
{
static QString * _qstring_name = 0;
	((KPalette*) QtSupport::getQt(env, obj))->setName((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_editable(JNIEnv *env, jobject obj)
{
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->editable();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KPalette_setEditable(JNIEnv *env, jobject obj, jint editable)
{
	((KPalette*) QtSupport::getQt(env, obj))->setEditable((KPalette::Editable) editable);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_nrColors(JNIEnv *env, jobject obj)
{
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->nrColors();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KPalette_color(JNIEnv *env, jobject obj, jint index)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QColor (((KPalette*) QtSupport::getQt(env, obj))->color((int) index)), "org.kde.qt.QColor", TRUE);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_findColor(JNIEnv *env, jobject obj, jobject color)
{
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->findColor((QColor&) *(QColor *) QtSupport::getQt(env, color));
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KPalette_colorName__I(JNIEnv *env, jobject obj, jint index)
{
	QString  _qstring;
	_qstring = ((KPalette*) QtSupport::getQt(env, obj))->colorName((int) index);
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KPalette_colorName__Lorg_kde_qt_QColor_2(JNIEnv *env, jobject obj, jobject color)
{
	QString  _qstring;
	_qstring = ((KPalette*) QtSupport::getQt(env, obj))->colorName((QColor&) *(QColor *) QtSupport::getQt(env, color));
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_addColor__Lorg_kde_qt_QColor_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject newColor, jstring newColorName)
{
static QString * _qstring_newColorName = 0;
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->addColor((QColor&) *(QColor *) QtSupport::getQt(env, newColor), (QString&) * (QString *) QtSupport::toQString(env, newColorName, &_qstring_newColorName));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_addColor__Lorg_kde_qt_QColor_2(JNIEnv *env, jobject obj, jobject newColor)
{
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->addColor((QColor&) *(QColor *) QtSupport::getQt(env, newColor), QString::null);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_changeColor__ILorg_kde_qt_QColor_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jint index, jobject newColor, jstring newColorName)
{
static QString * _qstring_newColorName = 0;
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->changeColor((int) index, (QColor&) *(QColor *) QtSupport::getQt(env, newColor), (QString&) * (QString *) QtSupport::toQString(env, newColorName, &_qstring_newColorName));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_changeColor__ILorg_kde_qt_QColor_2(JNIEnv *env, jobject obj, jint index, jobject newColor)
{
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->changeColor((int) index, (QColor&) *(QColor *) QtSupport::getQt(env, newColor), QString::null);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_changeColor__Lorg_kde_qt_QColor_2Lorg_kde_qt_QColor_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject oldColor, jobject newColor, jstring newColorName)
{
static QString * _qstring_newColorName = 0;
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->changeColor((QColor&) *(QColor *) QtSupport::getQt(env, oldColor), (QColor&) *(QColor *) QtSupport::getQt(env, newColor), (QString&) * (QString *) QtSupport::toQString(env, newColorName, &_qstring_newColorName));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KPalette_changeColor__Lorg_kde_qt_QColor_2Lorg_kde_qt_QColor_2(JNIEnv *env, jobject obj, jobject oldColor, jobject newColor)
{
	return (jint) ((KPalette*) QtSupport::getQt(env, obj))->changeColor((QColor&) *(QColor *) QtSupport::getQt(env, oldColor), (QColor&) *(QColor *) QtSupport::getQt(env, newColor), QString::null);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KPalette_getPaletteList(JNIEnv *env, jclass obj)
{
	QStringList  _qlist;
	_qlist = KPaletteJBridge::getPaletteList();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

