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

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

class QGLContextJBridge : public QGLContext
{
public:
	QGLContextJBridge(const QGLFormat& format, QPaintDevice* device) : QGLContext(format, device) {}
	~QGLContextJBridge() {QtSupport::qtKeyDeleted(this);}
	 bool  protected_chooseContext(const QGLContext* shareContext) {
		return ( bool ) QGLContext::chooseContext(shareContext);
	}
	void protected_doneCurrent() {
		QGLContext::doneCurrent();
		return;
	}
//	 int  protected_choosePixelFormat(void* pfd, HDC pdc) {
//		return ( int ) QGLContext::choosePixelFormat(pfd, pdc);
//	}
	void protected_tryVisual(const QGLFormat& f, int bufDepth) {
		QGLContext::tryVisual(f, bufDepth);
		return;
	}
	void protected_chooseVisual() {
		QGLContext::chooseVisual();
		return;
	}
//	void protected_chooseMacVisual(GDHandle arg1) {
//		QGLContext::chooseMacVisual(arg1);
//		return;
//	}
	bool  protected_deviceIsPixmap() {
		return (bool ) QGLContext::deviceIsPixmap();
	}
	bool  protected_windowCreated() {
		return (bool ) QGLContext::windowCreated();
	}
	void protected_setWindowCreated(bool on) {
		QGLContext::setWindowCreated(on);
		return;
	}
	bool  protected_initialized() {
		return (bool ) QGLContext::initialized();
	}
	void protected_setInitialized(bool on) {
		QGLContext::setInitialized(on);
		return;
	}
	uint  protected_colorIndex(const QColor& c) {
		return (uint ) QGLContext::colorIndex(c);
	}
};


JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_newQGLContext(JNIEnv *env, jobject obj, jobject format, jobject device)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QGLContextJBridge((QGLFormat&) *(QGLFormat *) QtSupport::getQt(env, format), (QPaintDevice*) QtSupport::paintDevice(env, device)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_create__Lorg_kde_qt_QGLContext_2(JNIEnv *env, jobject obj, jobject shareContext)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->create((QGLContext*) QtSupport::getQt(env, shareContext));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_create__(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->create(0);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_isValid(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->isValid();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_isSharing(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->isSharing();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_reset(JNIEnv *env, jobject obj)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->reset();
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QGLContext_format(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QGLFormat (((QGLContextJBridge*) QtSupport::getQt(env, obj))->format()), "org.kde.qt.QGLFormat", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QGLContext_requestedFormat(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QGLFormat (((QGLContextJBridge*) QtSupport::getQt(env, obj))->requestedFormat()), "org.kde.qt.QGLFormat", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_setFormat(JNIEnv *env, jobject obj, jobject format)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->setFormat((QGLFormat&) *(QGLFormat *) QtSupport::getQt(env, format));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_makeCurrent(JNIEnv *env, jobject obj)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->makeCurrent();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_swapBuffers(JNIEnv *env, jobject obj)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->swapBuffers();
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QGLContext_device(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((QGLContextJBridge*) QtSupport::getQt(env, obj))->device(), "org.kde.qt.QPaintDeviceInterface");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QGLContext_overlayTransparentColor(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QColor (((QGLContextJBridge*) QtSupport::getQt(env, obj))->overlayTransparentColor()), "org.kde.qt.QColor", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QGLContext_currentContext(JNIEnv *env, jclass obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)QGLContextJBridge::currentContext(), "org.kde.qt.QGLContext");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_chooseContext__Lorg_kde_qt_QGLContext_2(JNIEnv *env, jobject obj, jobject shareContext)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_chooseContext((QGLContext*) QtSupport::getQt(env, shareContext));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_chooseContext__(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_chooseContext(0);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_doneCurrent(JNIEnv *env, jobject obj)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_doneCurrent();
	return;
}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QGLContext_choosePixelFormat(JNIEnv *env, jobject obj, jint pfd, jint pdc)
//{
//	return (jint) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_choosePixelFormat((void*) pfd, (HDC) pdc);
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QGLContext_tryVisual__Lorg_kde_qt_QGLFormat_2I(JNIEnv *env, jobject obj, jobject f, jint bufDepth)
//{
//	return (jint) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_tryVisual((QGLFormat&) *(QGLFormat *) QtSupport::getQt(env, f), (int) bufDepth);
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QGLContext_tryVisual__Lorg_kde_qt_QGLFormat_2(JNIEnv *env, jobject obj, jobject f)
//{
//	return (jint) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_tryVisual((QGLFormat&) *(QGLFormat *) QtSupport::getQt(env, f), 1);
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QGLContext_chooseVisual(JNIEnv *env, jobject obj)
//{
//	return (jint) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_chooseVisual();
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QGLContext_chooseMacVisual(JNIEnv *env, jobject obj, j arg1)
//{
//	return (jint) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_chooseMacVisual((GDHandle) arg1);
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_deviceIsPixmap(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_deviceIsPixmap();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_windowCreated(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_windowCreated();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_setWindowCreated(JNIEnv *env, jobject obj, jboolean on)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_setWindowCreated((bool) on);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QGLContext_initialized(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_initialized();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QGLContext_setInitialized(JNIEnv *env, jobject obj, jboolean on)
{
	((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_setInitialized((bool) on);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QGLContext_colorIndex(JNIEnv *env, jobject obj, jobject c)
{
	return (jint) ((QGLContextJBridge*) QtSupport::getQt(env, obj))->protected_colorIndex((QColor&) *(QColor *) QtSupport::getQt(env, c));
}

