/***************************************************************************
                            QValidator.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 <qvalidator.h>
#include <qstring.h>
#include <qcstring.h>

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

class QValidatorJBridge : public QValidator
{
public:
	QValidatorJBridge(QWidget * parent, const char * name) : QValidator(parent, name) {}
	~QValidatorJBridge() {QtSupport::qtKeyDeleted(this);}

    QValidator::State validate(QString & input, int & pos) const
    {
    	return (QValidator::State) QtSupport::validateDelegate((QValidator *) this, input, pos);
    };

    void fixup(QString & input) const
    {
    	QtSupport::fixupDelegate((QValidator *) this, input);
    	return;
    };
};

JNIEXPORT void JNICALL
Java_org_kde_qt_QValidator_newQValidator(JNIEnv *env, jobject obj, jobject parent, jstring name)
{
static QCString * _qcstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QValidatorJBridge((QWidget*) QtSupport::getQt(env, parent), QtSupport::toCharString(env, name, &_qcstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QValidator_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj) && ((QValidator*)QtSupport::getQt(env, obj))->parent() == (QObject *) 0) {
		delete (QValidator*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QValidator_validate(JNIEnv *env, jobject obj, jobject arg1, jintArray pos)
{
	/* DO NOTHING - should never be called */
	return 0;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QValidator_fixup(JNIEnv *env, jobject obj, jobject arg1)
{
	/* DO NOTHING - should never be called */
	return;
}