// This is the SIP interface definition for QListBox, QListBoxItem,
// QListBoxPixmap and QListBoxText.
//
// Copyright (c) 2007
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// This file is part of PyQt.
// 
// This copy of PyQt is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2, or (at your option) any later
// version.
// 
// PyQt is supplied in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
// details.
// 
// You should have received a copy of the GNU General Public License along with
// PyQt; see the file LICENSE.  If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


%ExportedDoc
<Sect2><Title>QListBox</Title>
<FuncSynopsis>
        <FuncDef>bool <Function>itemYPos</Function></FuncDef>
        <ParamDef>int <Parameter>index</Parameter></ParamDef>
        <ParamDef>int *<Parameter>yPos</Parameter></ParamDef>
</FuncSynopsis>
<Para>
This takes the <Literal>index</Literal> parameter and returns a tuple
containing the <Literal>bool</Literal> result and <Literal>yPos</Literal>.
(Qt v1.x)
</Para>
</Sect2>

<Sect2><Title>QListBoxItem</Title>
<Para>
<Literal>QListBoxItem</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>QListBoxPixmap</Title>
<Para>
<Literal>QListBoxPixmap</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>QListBoxText</Title>
<Para>
<Literal>QListBoxText</Literal> is fully implemented.
</Para>
</Sect2>
%End


%If (- Qt_2_00)

%ModuleHeaderCode
#include <qlistbox.h>
%End

// List box item types.
const int LBI_Undefined;
const int LBI_Text;
const int LBI_Pixmap;
const int LBI_UserDefined;


class QListBox : QTableView
{
%TypeHeaderCode
#include <qlistbox.h>
%End

public:
	QListBox(QWidget * /TransferThis/ = 0,const char * = 0,WFlags = 0);

	void setFont(const QFont &);
	uint count() const;
	void insertStrList(const QStrList *,int = -1);
//	void insertStrList(const char **,int = -1,int = -1);
	void insertItem(const QListBoxItem * /Transfer/,int = -1);
	void insertItem(const char *,int = -1);
	void insertItem(const QPixmap &,int = -1);
	void inSort(const QListBoxItem *);
	void inSort(const char *);
	void removeItem(int);
	void clear();
	const char *text(int) const;
	const QPixmap *pixmap(int) const;
	void changeItem(const QListBoxItem * /Transfer/,int);
	void changeItem(const char *,int);
	void changeItem(const QPixmap &,int);
	bool autoUpdate() const;
	void setAutoUpdate(bool);
	int numItemsVisible() const;
	void setFixedVisibleLines(int);
	int currentItem() const;
	void setCurrentItem(int);
	void centerCurrentItem();
	int topItem() const;
	void setTopItem(int);
	void setBottomItem(int);
	bool dragSelect() const;
	void setDragSelect(bool);
	bool autoScroll() const;
	void setAutoScroll(bool);
	bool autoScrollBar() const;
	void setAutoScrollBar(bool);
	bool scrollBar() const;
	void setScrollBar(bool);
	bool autoBottomScrollBar() const;
	void setAutoBottomScrollBar(bool);
	bool bottomScrollBar() const;
	void setBottomScrollBar(bool);
	bool smoothScrolling() const;
	void setSmoothScrolling(bool);
	int itemHeight() const;
	int itemHeight(int) const;
	long maxItemWidth() const;
	bool isMultiSelection() const;
	void setMultiSelection(bool);
	void setSelected(int,bool);
	bool isSelected(int) const;
	QSize sizeHint() const;

public slots:
	void clearSelection();

signals:
	void highlighted(int);
	void selected(int);
	void highlighted(const char *);
	void selected(const char *);
	void selectionChanged();

protected:
	QListBoxItem *item(int) const;
	bool itemVisible(int);
	int cellHeight(int = 0);
	void paintCell(QPainter *,int,int);
	void mousePressEvent(QMouseEvent *);
	void mouseReleaseEvent(QMouseEvent *);
	void mouseDoubleClickEvent(QMouseEvent *);
	void mouseMoveEvent(QMouseEvent *);
	void keyPressEvent(QKeyEvent *);
	void focusInEvent(QFocusEvent *);
	void focusOutEvent(QFocusEvent *);
	void resizeEvent(QResizeEvent *);
	void timerEvent(QTimerEvent *);
	int findItem(int) const;
	bool itemYPos(int,int *) const;
	void updateItem(int,bool = 1);
	void clearList();
	void updateCellWidth();
	void toggleCurrentItem();

private:
	QListBox(const QListBox &);
};

%End

%If (Qt_2_00 -)

class QListBox : QScrollView
{
%TypeHeaderCode
#include <qlistbox.h>
%End

public:
	QListBox(QWidget * /TransferThis/ = 0,const char * = 0,WFlags = 0);

	virtual void setFont(const QFont &);

	uint count() const;

	void insertStringList(const QStringList &,int = -1);
	void insertStrList(const QStrList *,int = -1);
//	void insertStrList(const QStrList &,int = -1);
//	void insertStrList(const char **,int = -1,int = -1);

	void insertItem(const QListBoxItem * /Transfer/,int = -1);
%If (Qt_2_1_0 -)
	void insertItem(const QListBoxItem * /Transfer/,const QListBoxItem *);
%End
	void insertItem(const QString &,int = -1);
	void insertItem(const QPixmap &,int = -1);
%If (Qt_2_1_0 -)
	void insertItem(const QPixmap &,const QString &,int = -1);
%End

	void removeItem(int);

%If (- Qt_3_0_0)
	void clear();
%End

	QString text(int) const;
	const QPixmap *pixmap(int) const;

	void changeItem(const QListBoxItem * /Transfer/,int);
	void changeItem(const QString &,int);
	void changeItem(const QPixmap &,int);
%If (Qt_2_1_0 -)
	void changeItem(const QPixmap &,const QString &,int);
%End

	void takeItem(const QListBoxItem * /TransferBack/);

	int numItemsVisible() const;

	int currentItem() const;
%If (Qt_2_1_0 -)
	QString currentText() const;
%End
	virtual void setCurrentItem(int);
	virtual void setCurrentItem(QListBoxItem *);
	void centerCurrentItem();
	int topItem() const;
	virtual void setTopItem(int);
	virtual void setBottomItem(int);

	long maxItemWidth() const;

%If (- Qt_2_1_0)
	enum SelectionMode {
		Single,
		Multi,
		Extended
	};
%End
%If (Qt_2_1_0 -)
	enum SelectionMode {
		Single,
		Multi,
		Extended,
		NoSelection
	};
%End

	virtual void setSelectionMode(SelectionMode);
	SelectionMode selectionMode() const;

	void setMultiSelection(bool);
	bool isMultiSelection() const;

	virtual void setSelected(QListBoxItem *,bool);
	void setSelected(int,bool);
	bool isSelected(int) const;
	bool isSelected(QListBoxItem *) const;
%If (Qt_3_1_0 -)
	QListBoxItem *selectedItem() const;
%End

	QSize sizeHint() const;
	QSize minimumSizeHint() const;

	QListBoxItem *item(int) const;
	int index(const QListBoxItem *) const;
%If (Qt_2_1_0 - Qt_3_0_0)
	QListBoxItem *findItem(const QString &) const;
%End
%If (Qt_3_0_0 -)
	QListBoxItem *findItem(const QString &,
			       ComparisonFlags = BeginsWith) const;
%End

	void triggerUpdate(bool);

	bool itemVisible(int);
	bool itemVisible(const QListBoxItem *);

	enum LayoutMode {
		FixedNumber,
		FitToWidth,
		FitToHeight = FitToWidth,
		Variable
	};

	virtual void setColumnMode(LayoutMode /Constrained/);
	virtual void setColumnMode(int);
	virtual void setRowMode(LayoutMode /Constrained/);
	virtual void setRowMode(int);

	LayoutMode columnMode() const;
	LayoutMode rowMode() const;

	int numColumns() const;
	int numRows() const;

	bool variableWidth() const;
	virtual void setVariableWidth(bool);

	bool variableHeight() const;
	virtual void setVariableHeight(bool);

	void viewportPaintEvent(QPaintEvent *);

	int itemHeight(int = 0) const;
	QListBoxItem *itemAt(QPoint) const;

	QRect itemRect(QListBoxItem *) const;

%If (Qt_2_1_0 -)
	QListBoxItem *firstItem() const;

	void sort(bool = 1);
%End

public slots:
%If (Qt_3_0_0 -)
	void clear();
%End
	virtual void ensureCurrentVisible();
	virtual void clearSelection();
%If (Qt_2_1_0 - Qt_3_0_0)
	void selectAll(bool);
	void invertSelection();
%End
%If (Qt_3_0_0 -)
	virtual void selectAll(bool);
	virtual void invertSelection();
%End

signals:
	void highlighted(int);
	void selected(int);
	void highlighted(const QString &);
	void selected(const QString &);
	void highlighted(QListBoxItem *);
	void selected(QListBoxItem *);

	void selectionChanged();
%If (Qt_2_1_0 -)
	void selectionChanged(QListBoxItem *);
	void currentChanged(QListBoxItem *);
	void clicked(QListBoxItem *);
	void clicked(QListBoxItem *,const QPoint &);
	void pressed(QListBoxItem *);
	void pressed(QListBoxItem *,const QPoint &);

	void doubleClicked(QListBoxItem *);
	void returnPressed(QListBoxItem *);
	void rightButtonClicked(QListBoxItem *,const QPoint &);
	void rightButtonPressed(QListBoxItem *,const QPoint &);
	void mouseButtonPressed(int,QListBoxItem *,const QPoint &);
	void mouseButtonClicked(int,QListBoxItem *,const QPoint &);
%End

%If (Qt_3_0_0 -)
	void contextMenuRequested(QListBoxItem *,const QPoint &);
%End

%If (Qt_2_1_0 -)
	void onItem(QListBoxItem *);
	void onViewport();
%End

protected:
%If (- Qt_3_0_0)
	void viewportMousePressEvent(QMouseEvent *);
	void viewportMouseReleaseEvent(QMouseEvent *);
	void viewportMouseDoubleClickEvent(QMouseEvent *);
	void viewportMouseMoveEvent(QMouseEvent *);
%End
	void mousePressEvent(QMouseEvent *);
	void mouseReleaseEvent(QMouseEvent *);
	void mouseDoubleClickEvent(QMouseEvent *);
	void mouseMoveEvent(QMouseEvent *);
%If (Qt_3_0_0 -)
	void contentsContextMenuEvent(QContextMenuEvent *);
%End

	void keyPressEvent(QKeyEvent *);
	void focusInEvent(QFocusEvent *);
	void focusOutEvent(QFocusEvent *);
	void resizeEvent(QResizeEvent *);
	void showEvent(QShowEvent *);

%If (Qt_3_0_0 -)
	bool eventFilter(QObject *,QEvent *);
%End

	void updateItem(int);
	void updateItem(QListBoxItem *);

	virtual void paintCell(QPainter *,int,int);

	void toggleCurrentItem();
%If (Qt_2_2_0 -)
	bool isRubberSelecting() const;
%End

	void doLayout() const;

%If (Qt_3_0_0 -)
	void windowActivationChange(bool);
%End

protected slots:
%If (Qt_2_1_0 -)
	void clearInputString();
%End

private:
	QListBox(const QListBox &);
};

%End


class QListBoxItem
{
%TypeHeaderCode
#include <qlistbox.h>
%End

public:
%If (- Qt_2_00)
	QListBoxItem();
%End
%If (Qt_2_00 -)
	QListBoxItem(QListBox * /TransferThis/ = 0);
%End
%If (Qt_2_1_0 -)
	QListBoxItem(QListBox * /TransferThis/,QListBoxItem *);
%End

%If (- Qt_2_00)
	virtual const char *text() const;
%End
%If (Qt_2_00 -)
	virtual QString text() const;
%End
	virtual const QPixmap *pixmap() const;

%If (- Qt_2_00)
	virtual int height(const QListBox *) const = 0;
	virtual int width(const QListBox *) const = 0;
%End
%If (Qt_2_00 -)
	virtual int height(const QListBox *) const;
	virtual int width(const QListBox *) const;
%End

%If (Qt_2_00 - Qt_3_0_0)
        bool selected() const;
%End
%If (Qt_2_1_0 - Qt_3_0_0)
	bool current() const;
%End
%If (Qt_3_0_0 -)
        bool isSelected() const;
	bool isCurrent() const;
%End

%If (Qt_2_00 -)
	QListBox *listBox() const;
%End

%If (Qt_2_1_0 -)
	void setSelectable(bool);
	bool isSelectable() const;

	QListBoxItem *next() const;
	QListBoxItem *prev() const;
%End

%If (Qt_3_0_0 -)
	virtual int rtti() const;
%End

protected:
	virtual void paint(QPainter *) = 0;
%If (- Qt_2_00)
	void setText(const char *);
%End
%If (Qt_2_00 -)
	virtual void setText(const QString &);
%End
%If (Qt_2_1_0 -)
	void setCustomHighlighting(bool);
%End

private:
	QListBoxItem(const QListBoxItem &);
};

class QListBoxText : QListBoxItem
{
%TypeHeaderCode
#include <qlistbox.h>
%End

public:
%If (- Qt_2_00)
	QListBoxText(const char * = 0);
%End
%If (Qt_2_00 -)
	QListBoxText(QListBox * /TransferThis/,
		     const QString & = QString::null);
	QListBoxText(const QString & = QString::null);
%End
%If (Qt_2_1_0 -)
	QListBoxText(QListBox * /TransferThis/,const QString &,QListBoxItem *);
%End

%If (- Qt_2_00)
	void paint(QPainter *);
%End
	int height(const QListBox *) const;
	int width(const QListBox *) const;

%If (Qt_3_0_0 -)
	int rtti() const;
%End

protected:
%If (Qt_2_00 -)
	void paint(QPainter *);
%End

private:
	QListBoxText(const QListBoxText &);
};

class QListBoxPixmap : QListBoxItem
{
%TypeHeaderCode
#include <qlistbox.h>
%End

public:
%If (Qt_2_00 -)
	QListBoxPixmap(QListBox * /TransferThis/,const QPixmap &);
%End
	QListBoxPixmap(const QPixmap &);
%If (Qt_2_1_0 -)
	QListBoxPixmap(QListBox * /TransferThis/,const QPixmap &,
		       QListBoxItem *);
	QListBoxPixmap(QListBox * /TransferThis/,const QPixmap &,
		       const QString &);
	QListBoxPixmap(const QPixmap &,const QString &);
	QListBoxPixmap(QListBox * /TransferThis/,const QPixmap &,
		       const QString &,QListBoxItem *);
%End

	const QPixmap *pixmap() const;
%If (Qt_2_00 -)
	int height(const QListBox *) const;
	int width(const QListBox *) const;
%End

%If (Qt_3_0_0 -)
	int rtti() const;
%End

protected:
	void paint(QPainter *);
%If (- Qt_2_00)
	int height(const QListBox *) const;
	int width(const QListBox *) const;
%End

private:
	QListBoxPixmap(const QListBoxPixmap &);
};
