/***************************************************************************
                            QTableItem.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_QTableItem.h>
#include <qtobjc/QTableItem.h>
#include <qtobjc/QRect.h>

#include <qtobjc/QTable.h>
#include <qtobjc/QPixmap.h>
#include <qtobjc/QSize.h>
#include <qtobjc/QPainter.h>
#include <qtobjc/QColorGroup.h>

@implementation  QTableItem


- initWithTable: (QTable*)table et: (int)et text: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTableItem((qt_QTable*) [table qt], (int)et, (qt_QString *) [text toQString: &_qstring_text])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithTable: (QTable*)table et: (int)et text: (NSString *)text p: (QPixmap *)p
{
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTableItem1((qt_QTable*) [table qt], (int)et, (qt_QString *) [text toQString: &_qstring_text], (qt_QPixmap *) [p qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (QPixmap*) pixmap
{
	return (QPixmap*) [QtSupport objectForQtKey: qt_QTableItem_pixmap((qt_QTableItem *)[self qt]) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (NSString *) text
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QTableItem_text((qt_QTableItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setPixmap: (QPixmap *)p
{
	qt_QTableItem_setPixmap((qt_QTableItem *)[self qt], (qt_QPixmap *) [p qt]);
	return self;
}

- setText: (NSString *)t
{
static qt_QString * _qstring_t = 0L;
	qt_QTableItem_setText((qt_QTableItem *)[self qt], (qt_QString *) [t toQString: &_qstring_t]);
	return self;
}

- (QTable*) table
{
	return (QTable*) [QtSupport objectForQtKey: qt_QTableItem_table((qt_QTableItem *)[self qt]) withClass: [QTable class] allocatedInObjcWorld: YES];
}

- (int) alignment
{
	return (int) qt_QTableItem_alignment((qt_QTableItem *)[self qt]);
}

- setWordWrap: (BOOL)b
{
	qt_QTableItem_setWordWrap((qt_QTableItem *)[self qt], (int)b);
	return self;
}

- (BOOL) wordWrap
{
	return (BOOL) qt_QTableItem_wordWrap((qt_QTableItem *)[self qt]);
}

- (int) editType
{
	return (int) qt_QTableItem_editType((qt_QTableItem *)[self qt]);
}

- (QWidget*) createEditor
{
	return (QWidget*) [QtSupport objectForQtKey: qt_QTableItem_createEditor((qt_QTableItem *)[self qt]) withClass: [QWidget class] allocatedInObjcWorld: YES];
}

- setContentFromEditor: (QWidget *)w
{
	qt_QTableItem_setContentFromEditor((qt_QTableItem *)[self qt], (qt_QWidget *) [w qt]);
	return self;
}

- setReplaceable: (BOOL)arg1
{
	qt_QTableItem_setReplaceable((qt_QTableItem *)[self qt], (int)arg1);
	return self;
}

- (BOOL) isReplaceable
{
	return (BOOL) qt_QTableItem_isReplaceable((qt_QTableItem *)[self qt]);
}

- (NSString *) key
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QTableItem_key((qt_QTableItem *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (QSize*) sizeHint
{
	return (QSize*) [QtSupport objectForQtKey: qt_QTableItem_sizeHint((qt_QTableItem *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

- setSpan: (int)rs cs: (int)cs
{
	qt_QTableItem_setSpan((qt_QTableItem *)[self qt], (int)rs, (int)cs);
	return self;
}

- (int) rowSpan
{
	return (int) qt_QTableItem_rowSpan((qt_QTableItem *)[self qt]);
}

- (int) colSpan
{
	return (int) qt_QTableItem_colSpan((qt_QTableItem *)[self qt]);
}

- setRow: (int)r
{
	qt_QTableItem_setRow((qt_QTableItem *)[self qt], (int)r);
	return self;
}

- setCol: (int)c
{
	qt_QTableItem_setCol((qt_QTableItem *)[self qt], (int)c);
	return self;
}

- (int) row
{
	return (int) qt_QTableItem_row((qt_QTableItem *)[self qt]);
}

- (int) col
{
	return (int) qt_QTableItem_col((qt_QTableItem *)[self qt]);
}

- paint: (QPainter *)p cg: (QColorGroup *)cg cr: (QRect*)cr selected: (BOOL)selected
{
	qt_QTableItem_paint((qt_QTableItem *)[self qt], (qt_QPainter *) [p qt], (qt_QColorGroup *) [cg qt], (qt_QRect*) [cr qt], (int)selected);
	return self;
}

- updateEditor: (int)oldRow oldCol: (int)oldCol
{
	qt_QTableItem_updateEditor((qt_QTableItem *)[self qt], (int)oldRow, (int)oldCol);
	return self;
}

- setEnabled: (BOOL)b
{
	qt_QTableItem_setEnabled((qt_QTableItem *)[self qt], (int)b);
	return self;
}

- (BOOL) isEnabled
{
	return (BOOL) qt_QTableItem_isEnabled((qt_QTableItem *)[self qt]);
}

- (int) rtti
{
	return (int) qt_QTableItem_rtti((qt_QTableItem *)[self qt]);
}

+ (int) Never
{
	return (int) QTABLEITEM_Never;
}

+ (int) OnTyping
{
	return (int) QTABLEITEM_OnTyping;
}

+ (int) WhenCurrent
{
	return (int) QTABLEITEM_WhenCurrent;
}

+ (int) Always
{
	return (int) QTABLEITEM_Always;
}

@end
