/***************************************************************************
                            CSSStyleSheet.cpp -  description
                             -------------------
    begin                : Sun Aug 26 09:45:02 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Aug 26 09:45:02 2001, using kdoc parser/custom Java conversion backend.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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(CSSStyleSheetImpl* impl) : CSSStyleSheet(impl) {}
	~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_newCSSStyleSheet__Lorg_kde_koala_CSSStyleSheetImpl_2(JNIEnv *env, jobject obj, jobject impl)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new CSSStyleSheetJBridge((CSSStyleSheetImpl*) QtSupport::getQt(env, impl)));
//		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 jobject JNICALL
Java_org_kde_koala_CSSStyleSheet_ownerRule(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::CSSRule (((CSSStyleSheetJBridge*) 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 (((CSSStyleSheetJBridge*) 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) ((CSSStyleSheetJBridge*) 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)
{
	((CSSStyleSheetJBridge*) QtSupport::getQt(env, obj))->deleteRule((unsigned long) index);
	return;
}

