/***************************************************************************
                            KCompletionBox.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_KCompletionBox.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KCompletionBox.h>

@implementation  KCompletionBox


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

- initWithWidget: (QWidget *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KCompletionBox((qt_QWidget *) [parent 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 parentWidget: YES] == nil) {
			kde_del_KCompletionBox((kde_KCompletionBox *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (QSize*) sizeHint
{
	return (QSize*) [QtSupport objectForQtKey: kde_KCompletionBox_sizeHint((kde_KCompletionBox *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

- (NSArray *) items
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KCompletionBox_items((kde_KCompletionBox *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- insertItems: (NSArray *)items index: (int)index
{
static qt_QStringList * _qlist_items = 0L;
	kde_KCompletionBox_insertItems((kde_KCompletionBox *)[self qt], (qt_QStringList*) [items toQStringList: (void *)&_qlist_items], (int)index);
	return self;
}

- insertItems: (NSArray *)items 
{
static qt_QStringList * _qlist_items = 0L;
	kde_KCompletionBox_insertItems((kde_KCompletionBox *)[self qt], (qt_QStringList*) [items toQStringList: (void *)&_qlist_items], -1);
	return self;
}

- popup
{
	kde_KCompletionBox_popup((kde_KCompletionBox *)[self qt]);
	return self;
}

- setTabHandling: (BOOL)enable
{
	kde_KCompletionBox_setTabHandling((kde_KCompletionBox *)[self qt], (int)enable);
	return self;
}

- (BOOL) isTabHandling
{
	return (BOOL) kde_KCompletionBox_isTabHandling((kde_KCompletionBox *)[self qt]);
}

- setCancelledText: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	kde_KCompletionBox_setCancelledText((kde_KCompletionBox *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return self;
}

- (NSString *) cancelledText
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCompletionBox_cancelledText((kde_KCompletionBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- down
{
	kde_KCompletionBox_down((kde_KCompletionBox *)[self qt]);
	return self;
}

- up
{
	kde_KCompletionBox_up((kde_KCompletionBox *)[self qt]);
	return self;
}

- pageDown
{
	kde_KCompletionBox_pageDown((kde_KCompletionBox *)[self qt]);
	return self;
}

- pageUp
{
	kde_KCompletionBox_pageUp((kde_KCompletionBox *)[self qt]);
	return self;
}

- home
{
	kde_KCompletionBox_home((kde_KCompletionBox *)[self qt]);
	return self;
}

- end
{
	kde_KCompletionBox_end((kde_KCompletionBox *)[self qt]);
	return self;
}

- show
{
	kde_KCompletionBox_show((kde_KCompletionBox *)[self qt]);
	return self;
}

- hide
{
	kde_KCompletionBox_hide((kde_KCompletionBox *)[self qt]);
	return self;
}

- (BOOL) eventFilter: (QObject *)arg1 event: (QEvent *)arg2
{
	return (BOOL) kde_KCompletionBox_eventFilter((kde_KCompletionBox *)[self qt], (qt_QObject *) [arg1 qt], (qt_QEvent *) [arg2 qt]);
}

- slotActivated: (QListBoxItem *)arg1
{
	kde_KCompletionBox_slotActivated((kde_KCompletionBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
	return self;
}

@end
