/***************************************************************************
                            QListBox.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, 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 <qtc/qt_QStrList.h>
#include <qtc/qt_QStringList.h>
#include <qtc/qt_QListBox.h>
#include <qtobjc/QListBox.h>
#include <qtobjc/QFont.h>
#include <qtobjc/QPoint.h>

#include <qtobjc/QPainter.h>
#include <qtobjc/QPixmap.h>

@implementation  QListBox


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

- init
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QListBox(0, 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) {
			qt_del_QListBox((qt_QListBox *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- setFont: (QFont *)arg1
{
	qt_QListBox_setFont((qt_QListBox *)[self qt], (qt_QFont *) [arg1 qt]);
	return self;
}

- (unsigned int) count
{
	return (unsigned int) qt_QListBox_count((qt_QListBox *)[self qt]);
}

- insertStringList: (NSArray *)arg1 index: (int)index
{
static qt_QStringList * _qlist_arg1 = 0L;
	qt_QListBox_insertStringList((qt_QListBox *)[self qt], (qt_QStringList*) [arg1 toQStringList: (void *)&_qlist_arg1], (int)index);
	return self;
}

- insertStringList: (NSArray *)arg1 
{
static qt_QStringList * _qlist_arg1 = 0L;
	qt_QListBox_insertStringList((qt_QListBox *)[self qt], (qt_QStringList*) [arg1 toQStringList: (void *)&_qlist_arg1], -1);
	return self;
}

- insertStrList: (NSArray *)arg1 index: (int)index
{
static qt_QStrList * _qlist_arg1 = 0L;
	qt_QListBox_insertStrList((qt_QListBox *)[self qt], (qt_QStrList *) [arg1 toQStrList: (void *)&_qlist_arg1], (int)index);
	return self;
}

- insertStrList: (NSArray *)arg1 
{
static qt_QStrList * _qlist_arg1 = 0L;
	qt_QListBox_insertStrList((qt_QListBox *)[self qt], (qt_QStrList *) [arg1 toQStrList: (void *)&_qlist_arg1], -1);
	return self;
}

//- insertStrList: (NSArray *)arg1 index: (int)index
//{
//static qt_QStrList * _qlist_arg1 = 0L;
//	qt_QListBox_insertStrList1((qt_QListBox *)[self qt], (qt_QStrList *) [arg1 toQStrList: (void *)&_qlist_arg1], (int)index);
//	return self;
//}

//- insertStrList: (NSArray *)arg1
//{
//static qt_QStrList * _qlist_arg1 = 0L;
//	qt_QListBox_insertStrList1((qt_QListBox *)[self qt], (qt_QStrList *) [arg1 toQStrList: (void *)&_qlist_arg1], -1);
//	return self;
//}

- insertStrList: (NSString *)arg1 numStrings: (int)numStrings index: (int)index
{
	qt_QListBox_insertStrList2((qt_QListBox *)[self qt], (char**) [arg1 cString], (int)numStrings, (int)index);
	return self;
}

- insertText: (NSString *)arg1
{
	qt_QListBox_insertStrList2((qt_QListBox *)[self qt], (char**) [arg1 cString], -1, -1);
	return self;
}

- insertListBoxItem: (QListBoxItem *)arg1 index: (int)index
{
	qt_QListBox_insertItem((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt], (int)index);
	return self;
}

- insertListBoxItem: (QListBoxItem *)arg1 
{
	qt_QListBox_insertItem((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt], -1);
	return self;
}

- insertListBoxItem: (QListBoxItem *)arg1 after: (QListBoxItem *)after
{
	qt_QListBox_insertItem1((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt], (qt_QListBoxItem *) [after qt]);
	return self;
}

- insertTextItem: (NSString *)text index: (int)index
{
static qt_QString * _qstring_text = 0L;
	qt_QListBox_insertItem2((qt_QListBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text], (int)index);
	return self;
}

- insertTextItem: (NSString *)text 
{
static qt_QString * _qstring_text = 0L;
	qt_QListBox_insertItem2((qt_QListBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text], -1);
	return self;
}

- insertPixmapItem: (QPixmap *)pixmap index: (int)index
{
	qt_QListBox_insertItem3((qt_QListBox *)[self qt], (qt_QPixmap *) [pixmap qt], (int)index);
	return self;
}

- insertPixmapItem: (QPixmap *)pixmap 
{
	qt_QListBox_insertItem3((qt_QListBox *)[self qt], (qt_QPixmap *) [pixmap qt], -1);
	return self;
}

- insertPixmapItem: (QPixmap *)pixmap text: (NSString *)text index: (int)index
{
static qt_QString * _qstring_text = 0L;
	qt_QListBox_insertItem4((qt_QListBox *)[self qt], (qt_QPixmap *) [pixmap qt], (qt_QString *) [text toQString: &_qstring_text], (int)index);
	return self;
}

- insertPixmapItem: (QPixmap *)pixmap text: (NSString *)text 
{
static qt_QString * _qstring_text = 0L;
	qt_QListBox_insertItem4((qt_QListBox *)[self qt], (qt_QPixmap *) [pixmap qt], (qt_QString *) [text toQString: &_qstring_text], -1);
	return self;
}

- removeIntItem: (int)index
{
	qt_QListBox_removeItem((qt_QListBox *)[self qt], (int)index);
	return self;
}

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

- (QPixmap*) pixmap: (int)index
{
	return (QPixmap*) [QtSupport objectForQtKey: qt_QListBox_pixmap((qt_QListBox *)[self qt], (int)index) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- changeListBoxItem: (QListBoxItem *)arg1 index: (int)index
{
	qt_QListBox_changeItem((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt], (int)index);
	return self;
}

- changeTextItem: (NSString *)text index: (int)index
{
static qt_QString * _qstring_text = 0L;
	qt_QListBox_changeItem1((qt_QListBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text], (int)index);
	return self;
}

- changePixmapItem: (QPixmap *)pixmap index: (int)index
{
	qt_QListBox_changeItem2((qt_QListBox *)[self qt], (qt_QPixmap *) [pixmap qt], (int)index);
	return self;
}

- changePixmapItem: (QPixmap *)pixmap text: (NSString *)text index: (int)index
{
static qt_QString * _qstring_text = 0L;
	qt_QListBox_changeItem3((qt_QListBox *)[self qt], (qt_QPixmap *) [pixmap qt], (qt_QString *) [text toQString: &_qstring_text], (int)index);
	return self;
}

- takeItem: (QListBoxItem *)arg1
{
	qt_QListBox_takeItem((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
	return self;
}

- (int) numItemsVisible
{
	return (int) qt_QListBox_numItemsVisible((qt_QListBox *)[self qt]);
}

- (int) currentItem
{
	return (int) qt_QListBox_currentItem((qt_QListBox *)[self qt]);
}

- (NSString *) currentText
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QListBox_currentText((qt_QListBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setCurrentItem: (int)index
{
	qt_QListBox_setCurrentItem((qt_QListBox *)[self qt], (int)index);
	return self;
}

- setCurrentListBoxItem: (QListBoxItem *)arg1
{
	qt_QListBox_setCurrentItem1((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
	return self;
}

- centerCurrentItem
{
	qt_QListBox_centerCurrentItem((qt_QListBox *)[self qt]);
	return self;
}

- (int) topItem
{
	return (int) qt_QListBox_topItem((qt_QListBox *)[self qt]);
}

- setTopItem: (int)index
{
	qt_QListBox_setTopItem((qt_QListBox *)[self qt], (int)index);
	return self;
}

- setBottomItem: (int)index
{
	qt_QListBox_setBottomItem((qt_QListBox *)[self qt], (int)index);
	return self;
}

- (long) maxItemWidth
{
	return (long) qt_QListBox_maxItemWidth((qt_QListBox *)[self qt]);
}

- setSelectionMode: (int)arg1
{
	qt_QListBox_setSelectionMode((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- (int) selectionMode
{
	return (int) qt_QListBox_selectionMode((qt_QListBox *)[self qt]);
}

- setMultiSelection: (BOOL)multi
{
	qt_QListBox_setMultiSelection((qt_QListBox *)[self qt], (int)multi);
	return self;
}

- (BOOL) isMultiSelection
{
	return (BOOL) qt_QListBox_isMultiSelection((qt_QListBox *)[self qt]);
}

- setListBoxItemSelected: (QListBoxItem *)arg1 bool: (BOOL)arg2
{
	qt_QListBox_setSelected((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt], (int)arg2);
	return self;
}

- setSelected: (int)arg1 bool: (BOOL)arg2
{
	qt_QListBox_setSelected1((qt_QListBox *)[self qt], (int)arg1, (int)arg2);
	return self;
}

- (BOOL) isSelected: (int)arg1
{
	return (BOOL) qt_QListBox_isSelected((qt_QListBox *)[self qt], (int)arg1);
}

- (BOOL) isListBoxItemSelected: (QListBoxItem *)arg1
{
	return (BOOL) qt_QListBox_isSelected1((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
}

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

- (QSize*) minimumSizeHint
{
	return (QSize*) [QtSupport objectForQtKey: qt_QListBox_minimumSizeHint((qt_QListBox *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

- (QListBoxItem*) item: (int)index
{
	return (QListBoxItem*) [QtSupport objectForQtKey: qt_QListBox_item((qt_QListBox *)[self qt], (int)index) withClass: [QListBoxItem class] allocatedInObjcWorld: YES];
}

- (int) index: (QListBoxItem *)arg1
{
	return (int) qt_QListBox_index((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
}

- (QListBoxItem*) findListBoxItem: (NSString *)text compare: (int)compare
{
static qt_QString * _qstring_text = 0L;
	return (QListBoxItem*) [QtSupport objectForQtKey: qt_QListBox_findItem((qt_QListBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text], (int)compare) withClass: [QListBoxItem class] allocatedInObjcWorld: YES];
}

- (QListBoxItem*) findListBoxItem: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	return (QListBoxItem*) [QtSupport objectForQtKey: qt_QListBox_findItem((qt_QListBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text], [QListBox BeginsWith]) withClass: [QListBoxItem class] allocatedInObjcWorld: YES];
}

- triggerUpdate: (BOOL)doLayout
{
	qt_QListBox_triggerUpdate((qt_QListBox *)[self qt], (int)doLayout);
	return self;
}

- (BOOL) itemVisible: (int)index
{
	return (BOOL) qt_QListBox_itemVisible((qt_QListBox *)[self qt], (int)index);
}

- (BOOL) listBoxItemVisible: (QListBoxItem *)arg1
{
	return (BOOL) qt_QListBox_itemVisible1((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
}

- setColumnMode: (int)arg1
{
	qt_QListBox_setColumnMode((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

//- setColumnMode: (int)arg1
//{
//	qt_QListBox_setColumnMode1((qt_QListBox *)[self qt], (int)arg1);
//	return self;
//}

- setRowMode: (int)arg1
{
	qt_QListBox_setRowMode((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

//- setRowMode: (int)arg1
//{
//	qt_QListBox_setRowMode1((qt_QListBox *)[self qt], (int)arg1);
//	return self;
//}

- (int) columnMode
{
	return (int) qt_QListBox_columnMode((qt_QListBox *)[self qt]);
}

- (int) rowMode
{
	return (int) qt_QListBox_rowMode((qt_QListBox *)[self qt]);
}

- (int) numColumns
{
	return (int) qt_QListBox_numColumns((qt_QListBox *)[self qt]);
}

- (int) numRows
{
	return (int) qt_QListBox_numRows((qt_QListBox *)[self qt]);
}

- (BOOL) variableWidth
{
	return (BOOL) qt_QListBox_variableWidth((qt_QListBox *)[self qt]);
}

- setVariableWidth: (BOOL)arg1
{
	qt_QListBox_setVariableWidth((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- (BOOL) variableHeight
{
	return (BOOL) qt_QListBox_variableHeight((qt_QListBox *)[self qt]);
}

- setVariableHeight: (BOOL)arg1
{
	qt_QListBox_setVariableHeight((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

//- viewportPaintEvent: (QPaintEvent*)arg1
//{
//	qt_QListBox_viewportPaintEvent((qt_QListBox *)[self qt], (qt_QPaintEvent*) [arg1 qt]);
//	return self;
//}

- (BOOL) dragSelect
{
	return (BOOL) qt_QListBox_dragSelect((qt_QListBox *)[self qt]);
}

- setDragSelect: (BOOL)arg1
{
	qt_QListBox_setDragSelect((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- (BOOL) autoScroll
{
	return (BOOL) qt_QListBox_autoScroll((qt_QListBox *)[self qt]);
}

- setAutoScroll: (BOOL)arg1
{
	qt_QListBox_setAutoScroll((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- (BOOL) autoScrollBar
{
	return (BOOL) qt_QListBox_autoScrollBar((qt_QListBox *)[self qt]);
}

- setAutoScrollBar: (BOOL)enable
{
	qt_QListBox_setAutoScrollBar((qt_QListBox *)[self qt], (int)enable);
	return self;
}

- (BOOL) scrollBar
{
	return (BOOL) qt_QListBox_scrollBar((qt_QListBox *)[self qt]);
}

- setScrollBar: (BOOL)enable
{
	qt_QListBox_setScrollBar((qt_QListBox *)[self qt], (int)enable);
	return self;
}

- (BOOL) autoBottomScrollBar
{
	return (BOOL) qt_QListBox_autoBottomScrollBar((qt_QListBox *)[self qt]);
}

- setAutoBottomScrollBar: (BOOL)enable
{
	qt_QListBox_setAutoBottomScrollBar((qt_QListBox *)[self qt], (int)enable);
	return self;
}

- (BOOL) bottomScrollBar
{
	return (BOOL) qt_QListBox_bottomScrollBar((qt_QListBox *)[self qt]);
}

- setBottomScrollBar: (BOOL)enable
{
	qt_QListBox_setBottomScrollBar((qt_QListBox *)[self qt], (int)enable);
	return self;
}

- (BOOL) smoothScrolling
{
	return (BOOL) qt_QListBox_smoothScrolling((qt_QListBox *)[self qt]);
}

- setSmoothScrolling: (BOOL)arg1
{
	qt_QListBox_setSmoothScrolling((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- (BOOL) autoUpdate
{
	return (BOOL) qt_QListBox_autoUpdate((qt_QListBox *)[self qt]);
}

- setAutoUpdate: (BOOL)arg1
{
	qt_QListBox_setAutoUpdate((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- setFixedVisibleLines: (int)lines
{
	qt_QListBox_setFixedVisibleLines((qt_QListBox *)[self qt], (int)lines);
	return self;
}

- (int) inSort: (QListBoxItem *)arg1
{
	return (int) qt_QListBox_inSort((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
}

- (int) inSortWithString: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	return (int) qt_QListBox_inSort1((qt_QListBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
}

- (int) cellHeight: (int)i
{
	return (int) qt_QListBox_cellHeight((qt_QListBox *)[self qt], (int)i);
}

- (int) cellHeight
{
	return (int) qt_QListBox_cellHeight1((qt_QListBox *)[self qt]);
}

- (int) cellWidth
{
	return (int) qt_QListBox_cellWidth((qt_QListBox *)[self qt]);
}

- (int) cellWidth: (int)i
{
	return (int) qt_QListBox_cellWidth1((qt_QListBox *)[self qt], (int)i);
}

- (int) numCols
{
	return (int) qt_QListBox_numCols((qt_QListBox *)[self qt]);
}

- (int) itemHeight: (int)index
{
	return (int) qt_QListBox_itemHeight((qt_QListBox *)[self qt], (int)index);
}

- (int) itemHeight
{
	return (int) qt_QListBox_itemHeight((qt_QListBox *)[self qt], 0);
}

- (QListBoxItem*) itemAt: (QPoint*)arg1
{
	return (QListBoxItem*) [QtSupport objectForQtKey: qt_QListBox_itemAt((qt_QListBox *)[self qt], (qt_QPoint*) [arg1 qt]) withClass: [QListBoxItem class] allocatedInObjcWorld: YES];
}

- (QRect*) itemRect: (QListBoxItem *)item
{
	return (QRect*) [QtSupport objectForQtKey: qt_QListBox_itemRect((qt_QListBox *)[self qt], (qt_QListBoxItem *) [item qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (QListBoxItem*) firstItem
{
	return (QListBoxItem*) [QtSupport objectForQtKey: qt_QListBox_firstItem((qt_QListBox *)[self qt]) withClass: [QListBoxItem class] allocatedInObjcWorld: YES];
}

- sort: (BOOL)ascending
{
	qt_QListBox_sort((qt_QListBox *)[self qt], (int)ascending);
	return self;
}

- sort
{
	qt_QListBox_sort((qt_QListBox *)[self qt], 1);
	return self;
}

- clear
{
	qt_QListBox_clear((qt_QListBox *)[self qt]);
	return self;
}

- ensureCurrentVisible
{
	qt_QListBox_ensureCurrentVisible((qt_QListBox *)[self qt]);
	return self;
}

- clearSelection
{
	qt_QListBox_clearSelection((qt_QListBox *)[self qt]);
	return self;
}

- selectAll: (BOOL)select
{
	qt_QListBox_selectAll((qt_QListBox *)[self qt], (int)select);
	return self;
}

- invertSelection
{
	qt_QListBox_invertSelection((qt_QListBox *)[self qt]);
	return self;
}

- (BOOL) eventFilter: (QObject *)o e: (QEvent *)e
{
	return (BOOL) qt_QListBox_eventFilter((qt_QListBox *)[self qt], (qt_QObject *) [o qt], (qt_QEvent *) [e qt]);
}

- updateIntItem: (int)index
{
	qt_QListBox_updateItem((qt_QListBox *)[self qt], (int)index);
	return self;
}

- updateListBoxItem: (QListBoxItem *)arg1
{
	qt_QListBox_updateItem1((qt_QListBox *)[self qt], (qt_QListBoxItem *) [arg1 qt]);
	return self;
}

- updateCellWidth
{
	qt_QListBox_updateCellWidth((qt_QListBox *)[self qt]);
	return self;
}

- (int) totalWidth
{
	return (int) qt_QListBox_totalWidth((qt_QListBox *)[self qt]);
}

- (int) totalHeight
{
	return (int) qt_QListBox_totalHeight((qt_QListBox *)[self qt]);
}

- paintCell: (QPainter *)arg1 row: (int)row col: (int)col
{
	qt_QListBox_paintCell((qt_QListBox *)[self qt], (qt_QPainter *) [arg1 qt], (int)row, (int)col);
	return self;
}

- toggleCurrentItem
{
	qt_QListBox_toggleCurrentItem((qt_QListBox *)[self qt]);
	return self;
}

- (BOOL) isRubberSelecting
{
	return (BOOL) qt_QListBox_isRubberSelecting((qt_QListBox *)[self qt]);
}

- doLayout
{
	qt_QListBox_doLayout((qt_QListBox *)[self qt]);
	return self;
}

- windowActivationChange: (BOOL)arg1
{
	qt_QListBox_windowActivationChange((qt_QListBox *)[self qt], (int)arg1);
	return self;
}

- (BOOL) itemYPos: (int)index yPos: (int*)yPos
{
	return (BOOL) qt_QListBox_itemYPos((qt_QListBox *)[self qt], (int)index, (int*)yPos);
}

- (int) findItem: (int)yPos
{
	return (int) qt_QListBox_findItem1((qt_QListBox *)[self qt], (int)yPos);
}

- clearInputString
{
	qt_QListBox_clearInputString((qt_QListBox *)[self qt]);
	return self;
}

+ (int) Single
{
	return (int) QLISTBOX_Single;
}

+ (int) Multi
{
	return (int) QLISTBOX_Multi;
}

+ (int) Extended
{
	return (int) QLISTBOX_Extended;
}

+ (int) NoSelection
{
	return (int) QLISTBOX_NoSelection;
}

+ (int) FixedNumber
{
	return (int) QLISTBOX_FixedNumber;
}

+ (int) FitToWidth
{
	return (int) QLISTBOX_FitToWidth;
}

+ (int) FitToHeight
{
	return (int) QLISTBOX_FitToHeight;
}

+ (int) Variable
{
	return (int) QLISTBOX_Variable;
}

@end
