/***************************************************************************
                            CSSStyleSheet.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 <dom/css_stylesheet.h>
#include <dom/css_rule.h>
#include <qstring.h>
#include <qcstring.h>

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

class CSSStyleSheetJBridge : public DOM::CSSStyleSheet
{
public:
	CSSStyleSheetJBridge() : CSSStyleSheet() {}
	CSSStyleSheetJBridge(const CSSStyleSheet& other) : CSSStyleSheet(other) {}
	CSSStyleSheetJBridge(const StyleSheet& other) : CSSStyleSheet(other) {}
	~CSSStyleSheetJBridge() {QtSupport::qtKeyDeleted(this);}
};


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

JNIEXPORT void JNICALL
Java_org_kde_koala_CSSStyleSheet_newCSSStyleSheet__Lorg_kde_koala_CSSStyleSheet_2(JNIEnv *env, jobject obj, jobject other)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new CSSStyleSheetJBridge((DOM::CSSStyleSheet&) *(DOM::CSSStyleSheet *) QtSupport::getQt(env, other)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_CSSStyleSheet_newCSSStyleSheet__Lorg_kde_koala_StyleSheet_2(JNIEnv *env, jobject obj, jobject other)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new CSSStyleSheetJBridge((DOM::StyleSheet&) *(DOM::StyleSheet *) QtSupport::getQt(env, other)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_CSSStyleSheet_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_CSSStyleSheet_finalize(env, obj);
	return;
}

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_CSSStyleSheet_ownerRule(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::CSSRule (((DOM::CSSStyleSheet*) QtSupport::getQt(env, obj))->ownerRule()), "org.kde.koala.CSSRule", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_CSSStyleSheet_cssRules(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::CSSRuleList (((DOM::CSSStyleSheet*) QtSupport::getQt(env, obj))->cssRules()), "org.kde.koala.CSSRuleList", TRUE);
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_CSSStyleSheet_insertRule(JNIEnv *env, jobject obj, jstring rule, jlong index)
{
static DOM::DOMString * _domstring_rule = 0;
	return (jlong) ((DOM::CSSStyleSheet*) QtSupport::getQt(env, obj))->insertRule((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, rule, &_domstring_rule), (unsigned long) index);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_CSSStyleSheet_deleteRule(JNIEnv *env, jobject obj, jlong index)
{
	((DOM::CSSStyleSheet*) QtSupport::getQt(env, obj))->deleteRule((unsigned long) index);
	return;
}

