/***************************************************************************
                            KPixmap.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, 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 <kdec/kde_KPixmap.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KPixmap.h>
#include <qtobjc/QImage.h>


@implementation  KPixmap


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

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

- initWithPixmap: (QPixmap *)pix
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KPixmap1((qt_QPixmap *) [pix qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (BOOL) convertFromImage: (QImage *)img conversion_flags: (int)conversion_flags
{
	return (BOOL) kde_KPixmap_convertFromImage((kde_KPixmap *)[self qt], (qt_QImage *) [img qt], (int)conversion_flags);
}

- (BOOL) convertFromImage: (QImage *)img mode: (int)mode
{
	return (BOOL) kde_KPixmap_convertFromImage1((kde_KPixmap *)[self qt], (qt_QImage *) [img qt], (int)mode);
}

- (BOOL) convertFromImage: (QImage *)img 
{
	return (BOOL) kde_KPixmap_convertFromImage1((kde_KPixmap *)[self qt], (qt_QImage *) [img qt], [KPixmap WebColor]);
}

- (BOOL) load: (NSString *)fileName format: (NSString *)format conversion_flags: (int)conversion_flags
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) kde_KPixmap_load((kde_KPixmap *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], (char*) [format cString], (int)conversion_flags);
}

- (BOOL) load: (NSString *)fileName format: (NSString *)format mode: (int)mode
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) kde_KPixmap_load1((kde_KPixmap *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], (char*) [format cString], (int)mode);
}

- (BOOL) load: (NSString *)fileName 
{
static qt_QString * _qstring_fileName = 0L;
	return (BOOL) kde_KPixmap_load1((kde_KPixmap *)[self qt], (qt_QString *) [fileName toQString: &_qstring_fileName], 0, [KPixmap WebColor]);
}

- (BOOL) checkColorTable: (QImage *)image
{
	return (BOOL) kde_KPixmap_checkColorTable((kde_KPixmap *)[self qt], (qt_QImage *) [image qt]);
}

+ (int) Auto
{
	return (int) KPIXMAP_Auto;
}

+ (int) Color
{
	return (int) KPIXMAP_Color;
}

+ (int) Mono
{
	return (int) KPIXMAP_Mono;
}

+ (int) LowColor
{
	return (int) KPIXMAP_LowColor;
}

+ (int) WebColor
{
	return (int) KPIXMAP_WebColor;
}

+ (int) Horizontal
{
	return (int) KPIXMAP_Horizontal;
}

+ (int) Vertical
{
	return (int) KPIXMAP_Vertical;
}

+ (int) Diagonal
{
	return (int) KPIXMAP_Diagonal;
}

+ (int) CrossDiagonal
{
	return (int) KPIXMAP_CrossDiagonal;
}

@end
