/***************************************************************************
                            KJavaApplet.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 <kjavaappletcontext.h>
#include <kjavaapplet.h>
#include <qstring.h>
#include <qcstring.h>

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

class KJavaAppletJBridge : public KJavaApplet
{
public:
	KJavaAppletJBridge(KJavaAppletWidget* _parent, KJavaAppletContext* _context) : KJavaApplet(_parent, _context) {}
	~KJavaAppletJBridge() {QtSupport::qtKeyDeleted(this);}
	void childEvent(QChildEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "childEvent", arg1, "org.kde.qt.QChildEvent")) {
			QObject::childEvent(arg1);
		}
		return;
	}
	void customEvent(QCustomEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "customEvent", arg1, "org.kde.qt.QCustomEvent")) {
			QObject::customEvent(arg1);
		}
		return;
	}
	void timerEvent(QTimerEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "timerEvent", arg1, "org.kde.qt.QTimerEvent")) {
			QObject::timerEvent(arg1);
		}
		return;
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_newKJavaApplet__Lorg_kde_koala_KJavaAppletWidget_2Lorg_kde_koala_KJavaAppletContext_2(JNIEnv *env, jobject obj, jobject _parent, jobject _context)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KJavaAppletJBridge((KJavaAppletWidget*) QtSupport::getQt(env, _parent), (KJavaAppletContext*) QtSupport::getQt(env, _context)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj) && ((KJavaApplet*)QtSupport::getQt(env, obj))->parent() == (QObject *) 0) {
		delete (KJavaApplet*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KJavaApplet_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setAppletClass(JNIEnv *env, jobject obj, jstring clazzName)
{
static QString * _qstring_clazzName = 0;
	((KJavaApplet*) QtSupport::getQt(env, obj))->setAppletClass((QString&) * (QString *) QtSupport::toQString(env, clazzName, &_qstring_clazzName));
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setBaseURL(JNIEnv *env, jobject obj, jstring base)
{
static QString * _qstring_base = 0;
	((KJavaApplet*) QtSupport::getQt(env, obj))->setBaseURL((QString&) * (QString *) QtSupport::toQString(env, base, &_qstring_base));
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setCodeBase(JNIEnv *env, jobject obj, jstring codeBase)
{
static QString * _qstring_codeBase = 0;
	((KJavaApplet*) QtSupport::getQt(env, obj))->setCodeBase((QString&) * (QString *) QtSupport::toQString(env, codeBase, &_qstring_codeBase));
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setArchives(JNIEnv *env, jobject obj, jstring _archives)
{
static QString * _qstring__archives = 0;
	((KJavaApplet*) QtSupport::getQt(env, obj))->setArchives((QString&) * (QString *) QtSupport::toQString(env, _archives, &_qstring__archives));
	return;
}

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

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setSize(JNIEnv *env, jobject obj, jobject size)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->setSize((QSize) *(QSize *) QtSupport::getQt(env, size));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KJavaApplet_size(JNIEnv *env, jobject obj)
{
	QSize _s= ((KJavaApplet*) QtSupport::getQt(env, obj))->size();
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSize(_s.width(),_s.height()), "org.kde.qt.QSize", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setParameter(JNIEnv *env, jobject obj, jstring name, jstring value)
{
static QString * _qstring_value = 0;
static QString * _qstring_name = 0;
	((KJavaApplet*) QtSupport::getQt(env, obj))->setParameter((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name), (QString&) * (QString *) QtSupport::toQString(env, value, &_qstring_value));
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KJavaApplet_parameter(JNIEnv *env, jobject obj, jstring name)
{
	QString  _qstring;
static QString * _qstring_name = 0;
	_qstring = ((KJavaApplet*) QtSupport::getQt(env, obj))->parameter((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
	return QtSupport::fromQString(env, &_qstring);
}

//JNIEXPORT jstring JNICALL
//Java_org_kde_koala_KJavaApplet_getParams(JNIEnv *env, jobject obj)
//{
//	QString  _qstring;
//	_qcstring = (const char *)((KJavaApplet*) QtSupport::getQt(env, obj))->getParams();
//	return QtSupport::fromCharString(env, (char *) _qcstring);
//}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setWindowName(JNIEnv *env, jobject obj, jstring title)
{
static QString * _qstring_title = 0;
	((KJavaApplet*) QtSupport::getQt(env, obj))->setWindowName((QString&) * (QString *) QtSupport::toQString(env, title, &_qstring_title));
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_resizeAppletWidget(JNIEnv *env, jobject obj, jint width, jint height)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->resizeAppletWidget((int) width, (int) height);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_create(JNIEnv *env, jobject obj)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->create();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_init(JNIEnv *env, jobject obj)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->init();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KJavaApplet_isCreated(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KJavaApplet*) QtSupport::getQt(env, obj))->isCreated();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_start(JNIEnv *env, jobject obj)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->start();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_stop(JNIEnv *env, jobject obj)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->stop();
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KJavaApplet_appletId(JNIEnv *env, jobject obj)
{
	return (jint) ((KJavaApplet*) QtSupport::getQt(env, obj))->appletId();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaApplet_setAppletId(JNIEnv *env, jobject obj, jint identifier)
{
	((KJavaApplet*) QtSupport::getQt(env, obj))->setAppletId((int) identifier);
	return;
}

