/***************************************************************************
                            Node.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/dom_node.h>
#include <dom/dom_doc.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(NodeImpl* _impl) : Node(_impl) {}
	~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_newNode__Lorg_kde_koala_DOMNodeImpl_2(JNIEnv *env, jobject obj, jobject _impl)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new DOM::NodeJBridge((NodeImpl*) QtSupport::getQt(env, _impl)));
//		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 jstring JNICALL
Java_org_kde_koala_DOMNode_nodeName(JNIEnv *env, jobject obj)
{
	DOM::DOMString  _domstring;
	_domstring = ((NodeJBridge*) 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 = ((NodeJBridge*) 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;
	((NodeJBridge*) 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) ((NodeJBridge*) 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 (((NodeJBridge*) 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 = ((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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 (((NodeJBridge*) 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) ((NodeJBridge*) 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 (((NodeJBridge*) QtSupport::getQt(env, obj))->cloneNode((bool) deep)), "org.kde.koala.DOMNode", TRUE);
}

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;
	((NodeJBridge*) 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;
	((NodeJBridge*) 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, jobject evt)
//{
//	return (jboolean) ((NodeJBridge*) QtSupport::getQt(env, obj))->dispatchEvent((DOM::Event) evt);
//}

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

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

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

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMNode_applyChanges(JNIEnv *env, jobject obj)
{
	((NodeJBridge*) 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)
{
	((NodeJBridge*) 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= ((NodeJBridge*) 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);
}

