/***************************************************************************
                            MouseEvent.cpp -  description
                             -------------------
    begin                : Fri Mar 15 15:14:30 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar 15 15:14:30 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 <khtml_events.h>
#include <qstring.h>
#include <qcstring.h>

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

class MouseEventJBridge : public khtml::MouseEvent
{
public:
	MouseEventJBridge(const char* name, QMouseEvent* qmouseEvent, int x, int y, const DOM::DOMString& url, const DOM::DOMString& target, const DOM::Node& innerNode) : MouseEvent(name, qmouseEvent, x, y, url, target, innerNode) {}
	~MouseEventJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_MouseEvent_newMouseEvent(JNIEnv *env, jobject obj, jstring name, jobject qmouseEvent, jint x, jint y, jstring url, jstring target, jobject innerNode)
{
static DOM::DOMString * _domstring_target = 0;
static DOM::DOMString * _domstring_url = 0;
static QCString * _qstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new MouseEventJBridge((char*) QtSupport::toCharString(env, name, &_qstring_name), (QMouseEvent*) QtSupport::getQt(env, qmouseEvent), (int) x, (int) y, (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, url, &_domstring_url), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, target, &_domstring_target), (DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, innerNode)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MouseEvent_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (khtml::MouseEvent*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MouseEvent_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_MouseEvent_finalize(env, obj);
	return;
}

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_MouseEvent_qmouseEvent(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((khtml::MouseEvent*) QtSupport::getQt(env, obj))->qmouseEvent(), "org.kde.qt.QMouseEvent");
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_MouseEvent_x(JNIEnv *env, jobject obj)
{
	return (jint) ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->x();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_MouseEvent_y(JNIEnv *env, jobject obj)
{
	return (jint) ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->y();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_MouseEvent_absX(JNIEnv *env, jobject obj)
{
	return (jint) ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->absX();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_MouseEvent_absY(JNIEnv *env, jobject obj)
{
	return (jint) ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->absY();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_MouseEvent_url(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->url();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_MouseEvent_target(JNIEnv *env, jobject obj)
{
	DOM::DOMString _domstring;
	_domstring = ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->target();
	return KDESupport::fromDOMString(env, &_domstring);
}

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

JNIEXPORT jlong JNICALL
Java_org_kde_koala_MouseEvent_offset(JNIEnv *env, jobject obj)
{
	return (jlong) ((khtml::MouseEvent*) QtSupport::getQt(env, obj))->offset();
}

