/***************************************************************************
                            Node.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/dom_string.h>
#include <dom/dom_doc.h>
#include <dom/dom_node.h>
#include <qstring.h>
#include <qcstring.h>

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

class NodeJBridge : public DOM::Node
{
public:
	NodeJBridge() : Node() {}
	NodeJBridge(const Node& other) : Node(other) {}
	~NodeJBridge() {QtSupport::qtKeyDeleted(this);}
};


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

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_DOMNode_finalize(env, obj);
	return;
}

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

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMNode_nodeName(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((DOM::Node*) QtSupport::getQt(env, obj))->nodeName();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMNode_nodeValue(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((DOM::Node*) QtSupport::getQt(env, obj))->nodeValue();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_setNodeValue(JNIEnv *env, jobject obj, jstring arg1)
{
static DOM::DOMString * _domstring_arg1 = 0;
	((DOM::Node*) QtSupport::getQt(env, obj))->setNodeValue((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, arg1, &_domstring_arg1));
	return;
}

JNIEXPORT jshort JNICALL
Java_org_kde_koala_DOMNode_nodeType(JNIEnv *env, jobject obj)
{
	return (jshort) ((DOM::Node*) QtSupport::getQt(env, obj))->nodeType();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_parentNode(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->parentNode()), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_childNodes(JNIEnv *env, jobject obj)
{
	DOM::NodeList  _qlist;
	_qlist = ((DOM::Node*) QtSupport::getQt(env, obj))->childNodes();
	return (jobject) KDESupport::arrayWithNodeList(env, (DOM::NodeList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_firstChild(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->firstChild()), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_lastChild(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->lastChild()), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_previousSibling(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->previousSibling()), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_nextSibling(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->nextSibling()), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_attributes(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::NamedNodeMap (((DOM::Node*) QtSupport::getQt(env, obj))->attributes()), "org.kde.koala.NamedNodeMap", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_ownerDocument(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Document (((DOM::Node*) QtSupport::getQt(env, obj))->ownerDocument()), "org.kde.koala.Document", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_insertBefore(JNIEnv *env, jobject obj, jobject newChild, jobject refChild)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->insertBefore((DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, newChild), (DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, refChild))), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_replaceChild(JNIEnv *env, jobject obj, jobject newChild, jobject oldChild)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->replaceChild((DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, newChild), (DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, oldChild))), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_removeChild(JNIEnv *env, jobject obj, jobject oldChild)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->removeChild((DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, oldChild))), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_appendChild(JNIEnv *env, jobject obj, jobject newChild)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->appendChild((DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, newChild))), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMNode_hasChildNodes(JNIEnv *env, jobject obj)
{
	return (jboolean) ((DOM::Node*) QtSupport::getQt(env, obj))->hasChildNodes();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_cloneNode(JNIEnv *env, jobject obj, jboolean deep)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Node*) QtSupport::getQt(env, obj))->cloneNode((bool) deep)), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_normalize(JNIEnv *env, jobject obj)
{
	((DOM::Node*) QtSupport::getQt(env, obj))->normalize();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMNode_isSupported(JNIEnv *env, jobject obj, jstring feature, jstring version)
{
static DOM::DOMString * _domstring_version = 0;
static DOM::DOMString * _domstring_feature = 0;
	return (jboolean) ((DOM::Node*) QtSupport::getQt(env, obj))->isSupported((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, feature, &_domstring_feature), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, version, &_domstring_version));
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMNode_namespaceURI(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((DOM::Node*) QtSupport::getQt(env, obj))->namespaceURI();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMNode_prefix(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((DOM::Node*) QtSupport::getQt(env, obj))->prefix();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_setPrefix(JNIEnv *env, jobject obj, jstring prefix)
{
static DOM::DOMString * _domstring_prefix = 0;
	((DOM::Node*) QtSupport::getQt(env, obj))->setPrefix((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, prefix, &_domstring_prefix));
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMNode_localName(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((DOM::Node*) QtSupport::getQt(env, obj))->localName();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMNode_hasAttributes(JNIEnv *env, jobject obj)
{
	return (jboolean) ((DOM::Node*) QtSupport::getQt(env, obj))->hasAttributes();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_addEventListener(JNIEnv *env, jobject obj, jstring type, jobject listener, jboolean useCapture)
{
static DOM::DOMString * _domstring_type = 0;
	((DOM::Node*) QtSupport::getQt(env, obj))->addEventListener((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, type, &_domstring_type), (DOM::EventListener*) QtSupport::getQt(env, listener), (bool) useCapture);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_removeEventListener(JNIEnv *env, jobject obj, jstring type, jobject listener, jboolean useCapture)
{
static DOM::DOMString * _domstring_type = 0;
	((DOM::Node*) QtSupport::getQt(env, obj))->removeEventListener((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, type, &_domstring_type), (DOM::EventListener*) QtSupport::getQt(env, listener), (bool) useCapture);
	return;
}

//JNIEXPORT jboolean JNICALL
//Java_org_kde_koala_DOMNode_dispatchEvent(JNIEnv *env, jobject obj, j evt)
//{
//	return (jboolean) ((DOM::Node*) QtSupport::getQt(env, obj))->dispatchEvent((Event) evt);
//}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DOMNode_elementId(JNIEnv *env, jobject obj)
{
	return (jint) ((DOM::Node*) QtSupport::getQt(env, obj))->elementId();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMNode_isNull(JNIEnv *env, jobject obj)
{
	return (jboolean) ((DOM::Node*) QtSupport::getQt(env, obj))->isNull();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_handle(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((DOM::Node*) QtSupport::getQt(env, obj))->handle(), "org.kde.koala.NodeImpl");
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_DOMNode_index(JNIEnv *env, jobject obj)
{
	return (jlong) ((DOM::Node*) QtSupport::getQt(env, obj))->index();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMNode_toHTML(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((DOM::Node*) QtSupport::getQt(env, obj))->toHTML();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_applyChanges(JNIEnv *env, jobject obj)
{
	((DOM::Node*) QtSupport::getQt(env, obj))->applyChanges();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_getCursor(JNIEnv *env, jobject obj, jint offset, jint _x, jint _y, jint height)
{
	((DOM::Node*) QtSupport::getQt(env, obj))->getCursor((int) offset, (int&) * (int *) _x, (int&) * (int *) _y, (int&) * (int *) height);
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMNode_getRect(JNIEnv *env, jobject obj)
{
	QRect _r= ((DOM::Node*) QtSupport::getQt(env, obj))->getRect();
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QRect(_r.left(),_r.top(),_r.width(),_r.height()), "org.kde.qt.QRect", TRUE);
}

