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

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

class KWinModuleJBridge : public KWinModule
{
public:
	KWinModuleJBridge(QObject* parent) : KWinModule(parent) {}
	~KWinModuleJBridge() {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_KWinModule_newKWinModule__Lorg_kde_qt_QObject_2(JNIEnv *env, jobject obj, jobject parent)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KWinModuleJBridge((QObject*) QtSupport::getQt(env, parent)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KWinModule_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KWinModule_finalize(env, obj);
	return;
}

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

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KWinModule_windows(JNIEnv *env, jobject obj)
//{
//	return () ((KWinModule*) QtSupport::getQt(env, obj))->windows();
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KWinModule_stackingOrder(JNIEnv *env, jobject obj)
//{
//	return () ((KWinModule*) QtSupport::getQt(env, obj))->stackingOrder();
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KWinModule_hasWId(JNIEnv *env, jobject obj, jint arg1)
{
	return (jboolean) ((KWinModule*) QtSupport::getQt(env, obj))->hasWId((WId) arg1);
}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KWinModule_systemTrayWindows(JNIEnv *env, jobject obj)
//{
//	return () ((KWinModule*) QtSupport::getQt(env, obj))->systemTrayWindows();
//}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KWinModule_currentDesktop(JNIEnv *env, jobject obj)
{
	return (jint) ((KWinModule*) QtSupport::getQt(env, obj))->currentDesktop();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KWinModule_numberOfDesktops(JNIEnv *env, jobject obj)
{
	return (jint) ((KWinModule*) QtSupport::getQt(env, obj))->numberOfDesktops();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KWinModule_activeWindow(JNIEnv *env, jobject obj)
{
	return (jint) ((KWinModule*) QtSupport::getQt(env, obj))->activeWindow();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KWinModule_workArea(JNIEnv *env, jobject obj, jint desktop)
{
	QRect _r= ((KWinModule*) QtSupport::getQt(env, obj))->workArea((int) desktop);
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QRect(_r.left(),_r.top(),_r.width(),_r.height()), "org.kde.qt.QRect", TRUE);
}

//JNIEXPORT jobject JNICALL
//Java_org_kde_koala_KWinModule_workArea__I(JNIEnv *env, jobject obj, j arg1, jint desktop)
//{
//	QRect _r= ((KWinModule*) QtSupport::getQt(env, obj))->workArea((QValueList<WId>) arg1, (int) desktop);
//	return (jobject) QtSupport::objectForQtKey(env, (void *)new QRect(_r.left(),_r.top(),_r.width(),_r.height()), "org.kde.qt.QRect", TRUE);
//}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KWinModule_desktopName(JNIEnv *env, jobject obj, jint desktop)
{
	QString  _qstring;
	_qstring = ((KWinModule*) QtSupport::getQt(env, obj))->desktopName((int) desktop);
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KWinModule_setDesktopName(JNIEnv *env, jobject obj, jint desktop, jstring name)
{
static QString * _qstring_name = 0;
	((KWinModule*) QtSupport::getQt(env, obj))->setDesktopName((int) desktop, (QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
	return;
}

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

