/***************************************************************************
                            KKey.m -  description
                             -------------------
    begin                : Thu Mar 21 01:01:29 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Thu Mar 21 01:01:29 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_KKey.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KKey.h>
#include <qtobjc/QKeyEvent.h>
#include <qtobjc/QKeySequence.h>


@implementation  KKey

- (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: kde_new_KKey()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- initWithKeySequence: (QKeySequence*)arg1
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKey2((qt_QKeySequence*) [arg1 qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithKeyEvent: (QKeyEvent*)arg1
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKey3((qt_QKeyEvent*) [arg1 qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

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

- initWithUnsigned: (unsigned int)key mod: (unsigned int)mod
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KKey6((unsigned int)key, (unsigned int)mod)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- clear
{
	kde_KKey_clear((kde_KKey *)[self qt]);
	return self;
}

- (BOOL) isInitWithInt: (int)keyQt
{
	return (BOOL) kde_KKey_init((kde_KKey *)[self qt], (int)keyQt);
}

- (BOOL) isInitWithKeySequence: (QKeySequence*)arg1
{
	return (BOOL) kde_KKey_init1((kde_KKey *)[self qt], (qt_QKeySequence*) [arg1 qt]);
}

- (BOOL) isInitWithKeyEvent: (QKeyEvent*)arg1
{
	return (BOOL) kde_KKey_init2((kde_KKey *)[self qt], (qt_QKeyEvent*) [arg1 qt]);
}

- (BOOL) isInitWithKey: (KKey*)arg1
{
	return (BOOL) kde_KKey_init3((kde_KKey *)[self qt], (kde_KKey*) [arg1 qt]);
}

- (BOOL) isInitWithText: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	return (BOOL) kde_KKey_init4((kde_KKey *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
}

- (BOOL) isInit: (unsigned int)key mod: (unsigned int)mod
{
	return (BOOL) kde_KKey_init5((kde_KKey *)[self qt], (unsigned int)key, (unsigned int)mod);
}

- (BOOL) isNull
{
	return (BOOL) kde_KKey_isNull((kde_KKey *)[self qt]);
}

//- (BOOL) isValidQt
//{
//	return (BOOL) kde_KKey_isValidQt((kde_KKey *)[self qt]);
//}

//- (BOOL) isValidNative
//{
//	return (BOOL) kde_KKey_isValidNative((kde_KKey *)[self qt]);
//}

- (unsigned int) sym
{
	return (unsigned int) kde_KKey_sym((kde_KKey *)[self qt]);
}

- (unsigned int) modFlags
{
	return (unsigned int) kde_KKey_modFlags((kde_KKey *)[self qt]);
}

- (int) compare: (KKey*)arg1
{
	return (int) kde_KKey_compare((kde_KKey *)[self qt], (kde_KKey*) [arg1 qt]);
}

- (int) keyCodeQt
{
	return (int) kde_KKey_keyCodeQt((kde_KKey *)[self qt]);
}

- (NSString *) toString
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KKey_toString((kde_KKey *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) toStringInternal
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KKey_toStringInternal((kde_KKey *)[self qt]);
	return [NSString fromQString: _qstring];
}

- simplify
{
	kde_KKey_simplify((kde_KKey *)[self qt]);
	return self;
}

+ (KKey*) null
{
	return (KKey*) [QtSupport objectForQtKey: kde_KKey_null() withClass: [KKey class] allocatedInObjcWorld: YES];
}

+ (NSString *) modFlagLabel: (int)arg1
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KKey_modFlagLabel((int)arg1);
	return [NSString fromQString: _qstring];
}

+ (int) MOD_FLAG_COUNT
{
	return (int) KKEY_MOD_FLAG_COUNT;
}

+ (int) QtWIN
{
	return (int) KKEY_QtWIN;
}

+ (int) SHIFT
{
	return (int) KKEY_SHIFT;
}

+ (int) CTRL
{
	return (int) KKEY_CTRL;
}

+ (int) ALT
{
	return (int) KKEY_ALT;
}

+ (int) WIN
{
	return (int) KKEY_WIN;
}

@end
