/***************************************************************************
                            KPalette.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_KPalette.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KPalette.h>
#include <qtobjc/QColor.h>


@implementation  KPalette

- (void *) qt
{
	return _qt;
}

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

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

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


- initWithText: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KPalette((qt_QString *) [name toQString: &_qstring_name])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

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

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

- (BOOL) save
{
	return (BOOL) kde_KPalette_save((kde_KPalette *)[self qt]);
}

- (NSString *) description
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KPalette_description((kde_KPalette *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setDescription: (NSString *)desc
{
static qt_QString * _qstring_desc = 0L;
	kde_KPalette_setDescription((kde_KPalette *)[self qt], (qt_QString *) [desc toQString: &_qstring_desc]);
	return self;
}

- (NSString *) name
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KPalette_name((kde_KPalette *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setName: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	kde_KPalette_setName((kde_KPalette *)[self qt], (qt_QString *) [name toQString: &_qstring_name]);
	return self;
}

- (int) editable
{
	return (int) kde_KPalette_editable((kde_KPalette *)[self qt]);
}

- setEditable: (int)editable
{
	kde_KPalette_setEditable((kde_KPalette *)[self qt], (int)editable);
	return self;
}

- (int) nrColors
{
	return (int) kde_KPalette_nrColors((kde_KPalette *)[self qt]);
}

- (QColor*) color: (int)index
{
	return (QColor*) [QtSupport objectForQtKey: kde_KPalette_color((kde_KPalette *)[self qt], (int)index) withClass: [QColor class] allocatedInObjcWorld: YES];
}

- (int) findColor: (QColor *)color
{
	return (int) kde_KPalette_findColor((kde_KPalette *)[self qt], (qt_QColor *) [color qt]);
}

- (NSString *) colorNameAtId: (int)index
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KPalette_colorName((kde_KPalette *)[self qt], (int)index);
	return [NSString fromQString: _qstring];
}

- (NSString *) colorName: (QColor *)color
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KPalette_colorName1((kde_KPalette *)[self qt], (qt_QColor *) [color qt]);
	return [NSString fromQString: _qstring];
}

- (int) addColor: (QColor *)newColor newColorName: (NSString *)newColorName
{
static qt_QString * _qstring_newColorName = 0L;
	return (int) kde_KPalette_addColor((kde_KPalette *)[self qt], (qt_QColor *) [newColor qt], (qt_QString *) [newColorName toQString: &_qstring_newColorName]);
}

- (int) addColor: (QColor *)newColor 
{
	return (int) kde_KPalette_addColor((kde_KPalette *)[self qt], (qt_QColor *) [newColor qt], qt_QString_null());
}

- (int) changeColorAtId: (int)index newColor: (QColor *)newColor newColorName: (NSString *)newColorName
{
static qt_QString * _qstring_newColorName = 0L;
	return (int) kde_KPalette_changeColor((kde_KPalette *)[self qt], (int)index, (qt_QColor *) [newColor qt], (qt_QString *) [newColorName toQString: &_qstring_newColorName]);
}

- (int) changeColorAtId: (int)index newColor: (QColor *)newColor
{
	return (int) kde_KPalette_changeColor((kde_KPalette *)[self qt], (int)index, (qt_QColor *) [newColor qt], qt_QString_null());
}

- (int) changeColor: (QColor *)oldColor newColor: (QColor *)newColor newColorName: (NSString *)newColorName
{
static qt_QString * _qstring_newColorName = 0L;
	return (int) kde_KPalette_changeColor1((kde_KPalette *)[self qt], (qt_QColor *) [oldColor qt], (qt_QColor *) [newColor qt], (qt_QString *) [newColorName toQString: &_qstring_newColorName]);
}

- (int) changeColor: (QColor *)oldColor newColor: (QColor *)newColor 
{
	return (int) kde_KPalette_changeColor1((kde_KPalette *)[self qt], (qt_QColor *) [oldColor qt], (qt_QColor *) [newColor qt], qt_QString_null());
}

+ (NSArray *) getPaletteList
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KPalette_getPaletteList();
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (int) Yes
{
	return (int) KPALETTE_Yes;
}

+ (int) No
{
	return (int) KPALETTE_No;
}

+ (int) Ask
{
	return (int) KPALETTE_Ask;
}

@end
