/***************************************************************************
                            QFontMetrics.cpp -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 17:05:56 2001, 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 <qfontmetrics.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <qtjava/QFontMetrics.h>

class QFontMetricsJBridge : public QFontMetrics
{
public:
	QFontMetricsJBridge(const QFont& arg1) : QFontMetrics(arg1) {}
	QFontMetricsJBridge(const QFontMetrics& arg1) : QFontMetrics(arg1) {}
	~QFontMetricsJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_qt_QFontMetrics_newQFontMetrics__Lorg_kde_qt_QFont_2(JNIEnv *env, jobject obj, jobject arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QFontMetricsJBridge((QFont&) *(QFont *) QtSupport::getQt(env, arg1)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QFontMetrics_newQFontMetrics__Lorg_kde_qt_QFontMetrics_2(JNIEnv *env, jobject obj, jobject arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QFontMetricsJBridge((QFontMetrics&) *(QFontMetrics *) QtSupport::getQt(env, arg1)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_ascent(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->ascent();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_descent(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->descent();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_height(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->height();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_leading(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->leading();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_lineSpacing(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->lineSpacing();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_minLeftBearing(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->minLeftBearing();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_minRightBearing(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->minRightBearing();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_maxWidth(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->maxWidth();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QFontMetrics_inFont(JNIEnv *env, jobject obj, jchar arg1)
{
static QChar * _qchar_arg1 = 0;
	return (jboolean) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->inFont((QChar) * (QChar *) QtSupport::toQChar(env, arg1, &_qchar_arg1));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_leftBearing(JNIEnv *env, jobject obj, jchar arg1)
{
static QChar * _qchar_arg1 = 0;
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->leftBearing((QChar) * (QChar *) QtSupport::toQChar(env, arg1, &_qchar_arg1));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_rightBearing(JNIEnv *env, jobject obj, jchar arg1)
{
static QChar * _qchar_arg1 = 0;
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->rightBearing((QChar) * (QChar *) QtSupport::toQChar(env, arg1, &_qchar_arg1));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_width__Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring arg1, jint len)
{
static QString * _qstring_arg1 = 0;
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->width((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1), (int) len);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_width__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring arg1)
{
static QString * _qstring_arg1 = 0;
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->width((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1), -1);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_width__C(JNIEnv *env, jobject obj, jchar arg1)
{
static QChar * _qchar_arg1 = 0;
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->width((QChar) * (QChar *) QtSupport::toQChar(env, arg1, &_qchar_arg1));
}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QFontMetrics_width__C(JNIEnv *env, jobject obj, jchar c)
//{
//	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->width((char) c);
//}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_charWidth(JNIEnv *env, jobject obj, jstring str, jint pos)
{
static QString * _qstring_str = 0;
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->charWidth((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), (int) pos);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QFontMetrics_boundingRect__Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring arg1, jint len)
{
static QString * _qstring_arg1 = 0;
	QRect _r= ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->boundingRect((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1), (int) len);
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QRect(_r.left(),_r.top(),_r.width(),_r.height()), "org.kde.qt.QRect", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QFontMetrics_boundingRect__C(JNIEnv *env, jobject obj, jchar arg1)
{
static QChar * _qchar_arg1 = 0;
	QRect _r= ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->boundingRect((QChar) * (QChar *) QtSupport::toQChar(env, arg1, &_qchar_arg1));
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QRect(_r.left(),_r.top(),_r.width(),_r.height()), "org.kde.qt.QRect", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QFontMetrics_boundingRect__IIIIILjava_lang_String_2II_3ILorg_kde_qt_QTextParag_2(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jint flags, jstring str, jint len, jint tabstops, jintArray tabarray, jobject intern)
{
static QString * _qstring_str = 0;
	QRect _r= ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->boundingRect((int) x, (int) y, (int) w, (int) h, (int) flags, (QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), (int) len, (int) tabstops,  (int*) QtSupport::toIntPtr(env, tabarray), (QTextParag**) QtSupport::getQt(env, intern));
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QRect(_r.left(),_r.top(),_r.width(),_r.height()), "org.kde.qt.QRect", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QFontMetrics_size__ILjava_lang_String_2II_3ILorg_kde_qt_QTextParag_2(JNIEnv *env, jobject obj, jint flags, jstring str, jint len, jint tabstops, jintArray tabarray, jobject intern)
{
static QString * _qstring_str = 0;
	QSize _s= ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->size((int) flags, (QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), (int) len, (int) tabstops,  (int*) QtSupport::toIntPtr(env, tabarray), (QTextParag**) QtSupport::getQt(env, intern));
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSize(_s.width(),_s.height()), "org.kde.qt.QSize", TRUE);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_underlinePos(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->underlinePos();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_strikeOutPos(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->strikeOutPos();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QFontMetrics_lineWidth(JNIEnv *env, jobject obj)
{
	return (jint) ((QFontMetricsJBridge*) QtSupport::getQt(env, obj))->lineWidth();
}

