/***************************************************************************
                            KComboBox.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_KComboBox.h>
#include <kdec/kde_KCompletionBase.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KComboBox.h>
#include <kdeobjc/KCompletion.h>

#include <kdeobjc/KURL.h>
#include <qtobjc/QPixmap.h>


@implementation  KComboBox


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

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

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

- initWithBOOL: (BOOL)rw 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KComboBox1((int)rw, 0, 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_KComboBox((kde_KComboBox *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- setEditURL: (KURL*)url
{
	kde_KComboBox_setEditURL((kde_KComboBox *)[self qt], (kde_KURL*) [url qt]);
	return self;
}

- insertURL: (KURL*)url index: (int)index
{
	kde_KComboBox_insertURL((kde_KComboBox *)[self qt], (kde_KURL*) [url qt], (int)index);
	return self;
}

- insertURL: (KURL*)url 
{
	kde_KComboBox_insertURL((kde_KComboBox *)[self qt], (kde_KURL*) [url qt], -1);
	return self;
}

- insertURL: (QPixmap *)pixmap url: (KURL*)url index: (int)index
{
	kde_KComboBox_insertURL1((kde_KComboBox *)[self qt], (qt_QPixmap *) [pixmap qt], (kde_KURL*) [url qt], (int)index);
	return self;
}

- insertURL: (QPixmap *)pixmap url: (KURL*)url 
{
	kde_KComboBox_insertURL1((kde_KComboBox *)[self qt], (qt_QPixmap *) [pixmap qt], (kde_KURL*) [url qt], -1);
	return self;
}

- changeURL: (KURL*)url index: (int)index
{
	kde_KComboBox_changeURL((kde_KComboBox *)[self qt], (kde_KURL*) [url qt], (int)index);
	return self;
}

- changeURL: (QPixmap *)pixmap url: (KURL*)url index: (int)index
{
	kde_KComboBox_changeURL1((kde_KComboBox *)[self qt], (qt_QPixmap *) [pixmap qt], (kde_KURL*) [url qt], (int)index);
	return self;
}

- (int) cursorPosition
{
	return (int) kde_KComboBox_cursorPosition((kde_KComboBox *)[self qt]);
}

- setAutoCompletion: (BOOL)autocomplete
{
	kde_KComboBox_setAutoCompletion((kde_KComboBox *)[self qt], (int)autocomplete);
	return self;
}

- (BOOL) autoCompletion
{
	return (BOOL) kde_KComboBox_autoCompletion((kde_KComboBox *)[self qt]);
}

- setContextMenuEnabled: (BOOL)showMenu
{
	kde_KComboBox_setContextMenuEnabled((kde_KComboBox *)[self qt], (int)showMenu);
	return self;
}

- (BOOL) isContextMenuEnabled
{
	return (BOOL) kde_KComboBox_isContextMenuEnabled((kde_KComboBox *)[self qt]);
}

- setURLDropsEnabled: (BOOL)enable
{
	kde_KComboBox_setURLDropsEnabled((kde_KComboBox *)[self qt], (int)enable);
	return self;
}

- (BOOL) isURLDropsEnabled
{
	return (BOOL) kde_KComboBox_isURLDropsEnabled((kde_KComboBox *)[self qt]);
}

- (BOOL) contains: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	return (BOOL) kde_KComboBox_contains((kde_KComboBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
}

- setTrapReturnKey: (BOOL)trap
{
	kde_KComboBox_setTrapReturnKey((kde_KComboBox *)[self qt], (int)trap);
	return self;
}

- (BOOL) trapReturnKey
{
	return (BOOL) kde_KComboBox_trapReturnKey((kde_KComboBox *)[self qt]);
}

- (KCompletionBox*) completionBox: (BOOL)create
{
	return (KCompletionBox*) [QtSupport objectForQtKey: kde_KComboBox_completionBox((kde_KComboBox *)[self qt], (int)create) withClass: [KCompletionBox class] allocatedInObjcWorld: YES];
}

- (KCompletionBox*) completionBox
{
	return (KCompletionBox*) [QtSupport objectForQtKey: kde_KComboBox_completionBox((kde_KComboBox *)[self qt], 1) withClass: [KCompletionBox class] allocatedInObjcWorld: YES];
}

- setLineEdit: (QLineEdit*)arg1
{
	kde_KComboBox_setLineEdit((kde_KComboBox *)[self qt], (qt_QLineEdit*) [arg1 qt]);
	return self;
}

//- rotateText: (KCompletionBase_KeyBindingType*)arg1
//{
//	kde_KComboBox_rotateText((kde_KComboBox *)[self qt], (kde_KCompletionBase_KeyBindingType*) [arg1 qt]);
//	return self;
//}

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

- setCompletedItems: (NSArray *)items
{
static qt_QStringList * _qlist_items = 0L;
	kde_KComboBox_setCompletedItems((kde_KComboBox *)[self qt], (qt_QStringList*) [items toQStringList: (void *)&_qlist_items]);
	return self;
}

- setCurrentItem: (NSString *)item insert: (BOOL)insert index: (int)index
{
static qt_QString * _qstring_item = 0L;
	kde_KComboBox_setCurrentItem((kde_KComboBox *)[self qt], (qt_QString *) [item toQString: &_qstring_item], (int)insert, (int)index);
	return self;
}

- setCurrentItem: (NSString *)item 
{
static qt_QString * _qstring_item = 0L;
	kde_KComboBox_setCurrentItem((kde_KComboBox *)[self qt], (qt_QString *) [item toQString: &_qstring_item], 0, -1);
	return self;
}

- setCurrentItemId: (int)index
{
	kde_KComboBox_setCurrentItem1((kde_KComboBox *)[self qt], (int)index);
	return self;
}

- setCompletedText: (NSString *)arg1 bool: (BOOL)arg2
{
static qt_QString * _qstring_arg1 = 0L;
	kde_KComboBox_setCompletedText1((kde_KComboBox *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)arg2);
	return self;
}

- create: (unsigned int)arg1 initializeWindow: (BOOL)initializeWindow destroyOldWindow: (BOOL)destroyOldWindow
{
	kde_KComboBox_create((kde_KComboBox *)[self qt], (unsigned int)arg1, (int)initializeWindow, (int)destroyOldWindow);
	return self;
}

- create
{
	kde_KComboBox_create((kde_KComboBox *)[self qt], 0, 1, 1);
	return self;
}

- itemSelected: (QListBoxItem *)arg1
{
	kde_KComboBox_itemSelected((kde_KComboBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
	return self;
}

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

@end

@implementation KComboBox (KCompletionBaseImplementation)

- (KCompletion*) completionObject: (BOOL)hsig
{
	return (KCompletion*) [QtSupport objectForQtKey: kde_KCompletionBase_completionObject(kde_KComboBox_KCompletionBase([self qt]), (int)hsig) withClass: [KCompletion class] allocatedInObjcWorld: YES];
}

- (KCompletion*) completionObject
{
	return (KCompletion*) [QtSupport objectForQtKey: kde_KCompletionBase_completionObject(kde_KComboBox_KCompletionBase([self qt]), 1) withClass: [KCompletion class] allocatedInObjcWorld: YES];
}

- setCompletionObject: (KCompletion*)arg1 hsig: (BOOL)hsig
{
	kde_KCompletionBase_setCompletionObject(kde_KComboBox_KCompletionBase([self qt]), (kde_KCompletion*) [arg1 qt], (int)hsig);
	return self;
}

- setCompletionObject: (KCompletion*)arg1
{
	kde_KCompletionBase_setCompletionObject(kde_KComboBox_KCompletionBase([self qt]), (kde_KCompletion*) [arg1 qt], 1);
	return self;
}

- setHandleSignals: (BOOL)arg1
{
	kde_KCompletionBase_setHandleSignals(kde_KComboBox_KCompletionBase([self qt]), (int)arg1);
	return self;
}

- (BOOL) isCompletionObjectAutoDeleted
{
	return (BOOL) kde_KCompletionBase_isCompletionObjectAutoDeleted(kde_KComboBox_KCompletionBase([self qt]));
}

- setAutoDeleteCompletionObject: (BOOL)autoDelete
{
	kde_KCompletionBase_setAutoDeleteCompletionObject(kde_KComboBox_KCompletionBase([self qt]), (int)autoDelete);
	return self;
}

- setEnableSignals: (BOOL)enable
{
	kde_KCompletionBase_setEnableSignals(kde_KComboBox_KCompletionBase([self qt]), (int)enable);
	return self;
}

- (BOOL) handleSignals
{
	return (BOOL) kde_KCompletionBase_handleSignals(kde_KComboBox_KCompletionBase([self qt]));
}

- (BOOL) emitSignals
{
	return (BOOL) kde_KCompletionBase_emitSignals(kde_KComboBox_KCompletionBase([self qt]));
}

- setCompletionMode: (int)mode
{
	kde_KCompletionBase_setCompletionMode(kde_KComboBox_KCompletionBase([self qt]), (int)mode);
	return self;
}

- (int) completionMode
{
	return (int) kde_KCompletionBase_completionMode(kde_KComboBox_KCompletionBase([self qt]));
}

- (BOOL) setKeyBinding: (int)arg1 key: (int)key
{
	return (BOOL) kde_KCompletionBase_setKeyBinding(kde_KComboBox_KCompletionBase([self qt]), (int)arg1, (int)key);
}

- (BOOL) setKeyBinding: (int)arg1
{
	return (BOOL) kde_KCompletionBase_setKeyBinding(kde_KComboBox_KCompletionBase([self qt]), (int)arg1, 0);
}

- (int) getKeyBinding: (int)item
{
	return (int) kde_KCompletionBase_getKeyBinding(kde_KComboBox_KCompletionBase([self qt]), (int)item);
}

- useGlobalKeyBindings
{
	kde_KCompletionBase_useGlobalKeyBindings(kde_KComboBox_KCompletionBase([self qt]));
	return self;
}

- setCompletedText: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	kde_KCompletionBase_setCompletedText(kde_KComboBox_KCompletionBase([self qt]), (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- setCompletedItems: (NSArray *)items
{
static qt_QStringList * _qlist_items = 0L;
	kde_KCompletionBase_setCompletedItems(kde_KComboBox_KCompletionBase([self qt]), (qt_QStringList*) [items toQStringList: (void *)&_qlist_items]);
	return self;
}

- (KCompletion*) compObj
{
	return (KCompletion*) [QtSupport objectForQtKey: kde_KCompletionBase_compObj(kde_KComboBox_KCompletionBase([self qt])) withClass: [KCompletion class] allocatedInObjcWorld: YES];
}

@end
