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

#include <qtobjc/QWidget.h>
#include <qtobjc/QIconDragItem.h>
#include <qtobjc/QRect.h>


@implementation  QIconDrag


- initWithWidget: (QWidget *)dragSource name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QIconDrag((qt_QWidget *) [dragSource qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithWidget: (QWidget *)dragSource 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QIconDrag((qt_QWidget *) [dragSource qt], 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parent] == nil) {
			qt_del_QIconDrag((qt_QIconDrag *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- append: (QIconDragItem*)item pr: (QRect*)pr tr: (QRect*)tr
{
	qt_QIconDrag_append((qt_QIconDrag *)[self qt], (qt_QIconDragItem*) [item qt], (qt_QRect*) [pr qt], (qt_QRect*) [tr qt]);
	return self;
}

- (NSString *) format: (int)i
{
	return (NSString *) [NSString stringWithCString: qt_QIconDrag_format((qt_QIconDrag *)[self qt], (int)i)];
}

- (QByteArray*) encodedData: (NSString *)mime
{
	return (QByteArray*) [QtSupport objectForQtKey: qt_QIconDrag_encodedData((qt_QIconDrag *)[self qt], (char*) [mime cString]) withClass: [QByteArray class] allocatedInObjcWorld: YES];
}

+ (BOOL) canDecode: (QMimeSource*)e
{
	return (BOOL) qt_QIconDrag_canDecode((qt_QMimeSource*) [e qt]);
}

@end
