/***************************************************************************
                            QMovie.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_QMovie.h>
#include <qtobjc/QMovie.h>
#include <qtobjc/QByteArray.h>

@implementation  QMovie

- (void *) qt
{
	return _qt;
}

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

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

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


- init
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithInt: (int)bufsize
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie1((int)bufsize)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDataSource: (QDataSource*)arg1 bufsize: (int)bufsize
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie2((qt_QDataSource*) [arg1 qt], (int)bufsize)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDataSource: (QDataSource*)arg1 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie2((qt_QDataSource*) [arg1 qt], 1024)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)fileName bufsize: (int)bufsize
{
static qt_QString * _qstring_fileName = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie3((qt_QString *) [fileName toQString: &_qstring_fileName], (int)bufsize)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)fileName 
{
static qt_QString * _qstring_fileName = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie3((qt_QString *) [fileName toQString: &_qstring_fileName], 1024)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithByteArray: (QByteArray*)data bufsize: (int)bufsize
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie4((qt_QByteArray*) [data qt], (int)bufsize)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithByteArray: (QByteArray*)data 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMovie4((qt_QByteArray*) [data qt], 1024)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- copyWithZone: (NSZone *) zone
{
	QMovie * aCopy;
	aCopy = [[(QMovie *)[[self class] allocWithZone: zone] setQt: qt_new_QMovie5([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

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

- (int) pushSpace
{
	return (int) qt_QMovie_pushSpace((qt_QMovie *)[self qt]);
}

- pushData: (unsigned char*)data length: (int)length
{
	qt_QMovie_pushData((qt_QMovie *)[self qt], (unsigned char*)data, (int)length);
	return self;
}

- (QColor*) backgroundColor
{
	return (QColor*) [QtSupport objectForQtKey: qt_QMovie_backgroundColor((qt_QMovie *)[self qt]) withClass: [QColor class] allocatedInObjcWorld: YES];
}

- setBackgroundColor: (QColor *)arg1
{
	qt_QMovie_setBackgroundColor((qt_QMovie *)[self qt], (qt_QColor *) [arg1 qt]);
	return self;
}

- (QRect*) getValidRect
{
	return (QRect*) [QtSupport objectForQtKey: qt_QMovie_getValidRect((qt_QMovie *)[self qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (QPixmap*) framePixmap
{
	return (QPixmap*) [QtSupport objectForQtKey: qt_QMovie_framePixmap((qt_QMovie *)[self qt]) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (QImage*) frameImage
{
	return (QImage*) [QtSupport objectForQtKey: qt_QMovie_frameImage((qt_QMovie *)[self qt]) withClass: [QImage class] allocatedInObjcWorld: YES];
}

- (BOOL) isNull
{
	return (BOOL) qt_QMovie_isNull((qt_QMovie *)[self qt]);
}

- (int) frameNumber
{
	return (int) qt_QMovie_frameNumber((qt_QMovie *)[self qt]);
}

- (int) steps
{
	return (int) qt_QMovie_steps((qt_QMovie *)[self qt]);
}

- (BOOL) paused
{
	return (BOOL) qt_QMovie_paused((qt_QMovie *)[self qt]);
}

- (BOOL) finished
{
	return (BOOL) qt_QMovie_finished((qt_QMovie *)[self qt]);
}

- (BOOL) running
{
	return (BOOL) qt_QMovie_running((qt_QMovie *)[self qt]);
}

- unpause
{
	qt_QMovie_unpause((qt_QMovie *)[self qt]);
	return self;
}

- pause
{
	qt_QMovie_pause((qt_QMovie *)[self qt]);
	return self;
}

- step
{
	qt_QMovie_step((qt_QMovie *)[self qt]);
	return self;
}

- step: (int)arg1
{
	qt_QMovie_step1((qt_QMovie *)[self qt], (int)arg1);
	return self;
}

- restart
{
	qt_QMovie_restart((qt_QMovie *)[self qt]);
	return self;
}

- (int) speed
{
	return (int) qt_QMovie_speed((qt_QMovie *)[self qt]);
}

- setSpeed: (int)arg1
{
	qt_QMovie_setSpeed((qt_QMovie *)[self qt], (int)arg1);
	return self;
}

- connectResize: (QObject *)receiver slot: (NSString *)member
{
	qt_QMovie_connectResize((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], (char*) [member cString]);
	return self;
}

- disconnectResize: (QObject *)receiver slot: (NSString *)member
{
	qt_QMovie_disconnectResize((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], (char*) [member cString]);
	return self;
}

- disconnectResize: (QObject *)receiver 
{
	qt_QMovie_disconnectResize((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], 0);
	return self;
}

- connectUpdate: (QObject *)receiver slot: (NSString *)member
{
	qt_QMovie_connectUpdate((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], (char*) [member cString]);
	return self;
}

- disconnectUpdate: (QObject *)receiver slot: (NSString *)member
{
	qt_QMovie_disconnectUpdate((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], (char*) [member cString]);
	return self;
}

- disconnectUpdate: (QObject *)receiver 
{
	qt_QMovie_disconnectUpdate((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], 0);
	return self;
}

//- setDisplayWidget: (QWidget *)w
//{
//	qt_QMovie_setDisplayWidget((qt_QMovie *)[self qt], (qt_QWidget *) [w qt]);
//	return self;
//}

- connectStatus: (QObject *)receiver slot: (NSString *)member
{
	qt_QMovie_connectStatus((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], (char*) [member cString]);
	return self;
}

- disconnectStatus: (QObject *)receiver slot: (NSString *)member
{
	qt_QMovie_disconnectStatus((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], (char*) [member cString]);
	return self;
}

- disconnectStatus: (QObject *)receiver 
{
	qt_QMovie_disconnectStatus((qt_QMovie *)[self qt], (qt_QObject *) [receiver qt], 0);
	return self;
}

+ (int) SourceEmpty
{
	return (int) QMOVIE_SourceEmpty;
}

+ (int) UnrecognizedFormat
{
	return (int) QMOVIE_UnrecognizedFormat;
}

+ (int) Paused
{
	return (int) QMOVIE_Paused;
}

+ (int) EndOfFrame
{
	return (int) QMOVIE_EndOfFrame;
}

+ (int) EndOfLoop
{
	return (int) QMOVIE_EndOfLoop;
}

+ (int) EndOfMovie
{
	return (int) QMOVIE_EndOfMovie;
}

+ (int) SpeedChanged
{
	return (int) QMOVIE_SpeedChanged;
}

@end
