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

#include <qtjava/QtSupport.h>
#include <kdejava/Document.h>

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Document_createView__Lorg_kde_qt_QWidget_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KTextEditor::Document*) QtSupport::getQt(env, obj))->createView((QWidget*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)), "org.kde.koala.View");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Document_createView__Lorg_kde_qt_QWidget_2(JNIEnv *env, jobject obj, jobject parent)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KTextEditor::Document*) QtSupport::getQt(env, obj))->createView((QWidget*) QtSupport::getQt(env, parent), 0), "org.kde.koala.View");
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_Document_textLine(JNIEnv *env, jobject obj, jint line)
{
	QString  _qstring;
	_qstring = ((KTextEditor::Document*) QtSupport::getQt(env, obj))->textLine((int) line);
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_setSelection(JNIEnv *env, jobject obj, jint row_from, jint col_from, jint row_to, jint col_t)
{
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->setSelection((int) row_from, (int) col_from, (int) row_to, (int) col_t);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Document_hasSelection(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KTextEditor::Document*) QtSupport::getQt(env, obj))->hasSelection();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_Document_selection(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((KTextEditor::Document*) QtSupport::getQt(env, obj))->selection();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_Document_numLines(JNIEnv *env, jobject obj)
{
	return (jint) ((KTextEditor::Document*) QtSupport::getQt(env, obj))->numLines();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_insertLine__Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring s, jint line)
{
static QString * _qstring_s = 0;
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->insertLine((QString&) * (QString *) QtSupport::toQString(env, s, &_qstring_s), (int) line);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_insertLine__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring s)
{
static QString * _qstring_s = 0;
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->insertLine((QString&) * (QString *) QtSupport::toQString(env, s, &_qstring_s), -1);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_insertAt__Ljava_lang_String_2IIZ(JNIEnv *env, jobject obj, jstring s, jint line, jint col, jboolean mark)
{
static QString * _qstring_s = 0;
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->insertAt((QString&) * (QString *) QtSupport::toQString(env, s, &_qstring_s), (int) line, (int) col, (bool) mark);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_insertAt__Ljava_lang_String_2II(JNIEnv *env, jobject obj, jstring s, jint line, jint col)
{
static QString * _qstring_s = 0;
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->insertAt((QString&) * (QString *) QtSupport::toQString(env, s, &_qstring_s), (int) line, (int) col, FALSE);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_removeLine(JNIEnv *env, jobject obj, jint line)
{
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->removeLine((int) line);
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_Document_text(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((KTextEditor::Document*) QtSupport::getQt(env, obj))->text();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_Document_length(JNIEnv *env, jobject obj)
{
	return (jint) ((KTextEditor::Document*) QtSupport::getQt(env, obj))->length();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Document_setText(JNIEnv *env, jobject obj, jstring t)
{
static QString * _qstring_t = 0;
	((KTextEditor::Document*) QtSupport::getQt(env, obj))->setText((QString&) * (QString *) QtSupport::toQString(env, t, &_qstring_t));
	return;
}

