/***************************************************************************
                            QSimpleRichText.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 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 12:08:37 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <qtc/qt_QSimpleRichText.h>
#include <qtobjc/QSimpleRichText.h>
#include <qtobjc/QPoint.h>
#include <qtobjc/QRect.h>

#include <qtobjc/Qt.h>
#include <qtobjc/QFont.h>
#include <qtobjc/QStyleSheet.h>
#include <qtobjc/QMimeSourceFactory.h>
#include <qtobjc/QPainter.h>
#include <qtobjc/QRegion.h>
#include <qtobjc/QBrush.h>
#include <qtobjc/QPalette.h>
#include <qtobjc/QColorGroup.h>

@implementation  QSimpleRichText

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


- initWithText: (NSString *)text fnt: (QFont *)fnt context: (NSString *)context sheet: (QStyleSheet*)sheet
{
static qt_QString * _qstring_context = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QSimpleRichText((qt_QString *) [text toQString: &_qstring_text], (qt_QFont *) [fnt qt], (qt_QString *) [context toQString: &_qstring_context], (qt_QStyleSheet*) [sheet qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text fnt: (QFont *)fnt 
{
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QSimpleRichText((qt_QString *) [text toQString: &_qstring_text], (qt_QFont *) [fnt qt], qt_QString_null(), 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text fnt: (QFont *)fnt context: (NSString *)context sheet: (QStyleSheet*)sheet factory: (QMimeSourceFactory*)factory pageBreak: (int)pageBreak linkColor: (QColor *)linkColor linkUnderline: (BOOL)linkUnderline
{
static qt_QString * _qstring_context = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QSimpleRichText1((qt_QString *) [text toQString: &_qstring_text], (qt_QFont *) [fnt qt], (qt_QString *) [context toQString: &_qstring_context], (qt_QStyleSheet*) [sheet qt], (qt_QMimeSourceFactory*) [factory qt], (int)pageBreak, (qt_QColor *) [linkColor qt], (int)linkUnderline)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text fnt: (QFont *)fnt context: (NSString *)context sheet: (QStyleSheet*)sheet factory: (QMimeSourceFactory*)factory 
{
static qt_QString * _qstring_context = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QSimpleRichText1((qt_QString *) [text toQString: &_qstring_text], (qt_QFont *) [fnt qt], (qt_QString *) [context toQString: &_qstring_context], (qt_QStyleSheet*) [sheet qt], (qt_QMimeSourceFactory*) [factory qt], -1, (qt_QColor *) [(QColor *) [Qt blue] qt], 1)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			qt_del_QSimpleRichText((qt_QSimpleRichText *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- setWidth: (int)arg1
{
	qt_QSimpleRichText_setWidth((qt_QSimpleRichText *)[self qt], (int)arg1);
	return self;
}

- setWidth: (QPainter *)arg1 int: (int)arg2
{
	qt_QSimpleRichText_setWidth1((qt_QSimpleRichText *)[self qt], (qt_QPainter *) [arg1 qt], (int)arg2);
	return self;
}

- setDefaultFont: (QFont *)f
{
	qt_QSimpleRichText_setDefaultFont((qt_QSimpleRichText *)[self qt], (qt_QFont *) [f qt]);
	return self;
}

- (int) width
{
	return (int) qt_QSimpleRichText_width((qt_QSimpleRichText *)[self qt]);
}

- (int) widthUsed
{
	return (int) qt_QSimpleRichText_widthUsed((qt_QSimpleRichText *)[self qt]);
}

- (int) height
{
	return (int) qt_QSimpleRichText_height((qt_QSimpleRichText *)[self qt]);
}

- adjustSize
{
	qt_QSimpleRichText_adjustSize((qt_QSimpleRichText *)[self qt]);
	return self;
}

- draw: (QPainter *)p x: (int)x y: (int)y clipRect: (QRect*)clipRect cg: (QColorGroup *)cg paper: (QBrush*)paper
{
	qt_QSimpleRichText_draw((qt_QSimpleRichText *)[self qt], (qt_QPainter *) [p qt], (int)x, (int)y, (qt_QRect*) [clipRect qt], (qt_QColorGroup *) [cg qt], (qt_QBrush*) [paper qt]);
	return self;
}

- draw: (QPainter *)p x: (int)x y: (int)y clipRect: (QRect*)clipRect cg: (QColorGroup *)cg 
{
	qt_QSimpleRichText_draw((qt_QSimpleRichText *)[self qt], (qt_QPainter *) [p qt], (int)x, (int)y, (qt_QRect*) [clipRect qt], (qt_QColorGroup *) [cg qt], 0);
	return self;
}

- draw: (QPainter *)p x: (int)x y: (int)y clipRegion: (QRegion *)clipRegion cg: (QColorGroup *)cg paper: (QBrush*)paper
{
	qt_QSimpleRichText_draw1((qt_QSimpleRichText *)[self qt], (qt_QPainter *) [p qt], (int)x, (int)y, (qt_QRegion *) [clipRegion qt], (qt_QColorGroup *) [cg qt], (qt_QBrush*) [paper qt]);
	return self;
}

- draw: (QPainter *)p x: (int)x y: (int)y clipRegion: (QRegion *)clipRegion cg: (QColorGroup *)cg 
{
	qt_QSimpleRichText_draw1((qt_QSimpleRichText *)[self qt], (qt_QPainter *) [p qt], (int)x, (int)y, (qt_QRegion *) [clipRegion qt], (qt_QColorGroup *) [cg qt], 0);
	return self;
}

- (NSString *) context
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSimpleRichText_context((qt_QSimpleRichText *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) anchorAt: (QPoint*)pos
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSimpleRichText_anchorAt((qt_QSimpleRichText *)[self qt], (qt_QPoint*) [pos qt]);
	return [NSString fromQString: _qstring];
}

- (BOOL) inText: (QPoint*)pos
{
	return (BOOL) qt_QSimpleRichText_inText((qt_QSimpleRichText *)[self qt], (qt_QPoint*) [pos qt]);
}

@end
