// This is the SIP interface definition for TQListBox, TQListBoxItem,
// TQListBoxPixmap and TQListBoxText.
//
// Copyright (c) 2007
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// This file is part of PyTQt.
// 
// This copy of PyTQt 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.
// 
// PyTQt 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
// PyTQt; 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>TQListBox</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>.
(TQt v1.x)
</Para>
</Sect2>

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

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

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


class TQListBox : TQScrollView
{
%TypeHeaderCode
#include <tqlistbox.h>
%End

public:
	TQListBox(TQWidget * /TransferThis/ = 0,const char * = 0,WFlags = 0);

	virtual void setFont(const TQFont &);

	uint count() const;

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

	void insertItem(const TQListBoxItem * /Transfer/,int = -1);
	void insertItem(const TQListBoxItem * /Transfer/,const TQListBoxItem *);
	void insertItem(const TQString &,int = -1);
	void insertItem(const TQPixmap &,int = -1);
	void insertItem(const TQPixmap &,const TQString &,int = -1);

	void removeItem(int);

	TQString text(int) const;
	const TQPixmap *pixmap(int) const;

	void changeItem(const TQListBoxItem * /Transfer/,int);
	void changeItem(const TQString &,int);
	void changeItem(const TQPixmap &,int);
	void changeItem(const TQPixmap &,const TQString &,int);

	void takeItem(const TQListBoxItem * /TransferBack/);

	int numItemsVisible() const;

	int currentItem() const;
	TQString currentText() const;
	virtual void setCurrentItem(int);
	virtual void setCurrentItem(TQListBoxItem *);
	void centerCurrentItem();
	int topItem() const;
	virtual void setTopItem(int);
	virtual void setBottomItem(int);

	long maxItemWidth() const;

	enum SelectionMode {
		Single,
		Multi,
		Extended,
		NoSelection
	};

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

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

	virtual void setSelected(TQListBoxItem *,bool);
	void setSelected(int,bool);
	bool isSelected(int) const;
	bool isSelected(TQListBoxItem *) const;
	TQListBoxItem *selectedItem() const;

	TQSize sizeHint() const;
	TQSize minimumSizeHint() const;

	TQListBoxItem *item(int) const;
	int index(const TQListBoxItem *) const;
	TQListBoxItem *findItem(const TQString &,
			       ComparisonFlags = BeginsWith) const;

	void triggerUpdate(bool);

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

	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(TQPaintEvent *);

	int itemHeight(int = 0) const;
	TQListBoxItem *itemAt(TQPoint) const;

	TQRect itemRect(TQListBoxItem *) const;

	TQListBoxItem *firstItem() const;

	void sort(bool = 1);

public slots:
	void clear();
	virtual void ensureCurrentVisible();
	virtual void clearSelection();
	virtual void selectAll(bool);
	virtual void invertSelection();

signals:
	void highlighted(int);
	void selected(int);
	void highlighted(const TQString &);
	void selected(const TQString &);
	void highlighted(TQListBoxItem *);
	void selected(TQListBoxItem *);

	void selectionChanged();
	void selectionChanged(TQListBoxItem *);
	void currentChanged(TQListBoxItem *);
	void clicked(TQListBoxItem *);
	void clicked(TQListBoxItem *,const TQPoint &);
	void pressed(TQListBoxItem *);
	void pressed(TQListBoxItem *,const TQPoint &);

	void doubleClicked(TQListBoxItem *);
	void returnPressed(TQListBoxItem *);
	void rightButtonClicked(TQListBoxItem *,const TQPoint &);
	void rightButtonPressed(TQListBoxItem *,const TQPoint &);
	void mouseButtonPressed(int,TQListBoxItem *,const TQPoint &);
	void mouseButtonClicked(int,TQListBoxItem *,const TQPoint &);

	void contextMenuRequested(TQListBoxItem *,const TQPoint &);

	void onItem(TQListBoxItem *);
	void onViewport();

protected:
	void mousePressEvent(TQMouseEvent *);
	void mouseReleaseEvent(TQMouseEvent *);
	void mouseDoubleClickEvent(TQMouseEvent *);
	void mouseMoveEvent(TQMouseEvent *);

	void keyPressEvent(TQKeyEvent *);
	void focusInEvent(TQFocusEvent *);
	void focusOutEvent(TQFocusEvent *);
	void resizeEvent(TQResizeEvent *);
	void showEvent(TQShowEvent *);

	bool eventFilter(TQObject *,TQEvent *);

	void updateItem(int);
	void updateItem(TQListBoxItem *);

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

	void toggleCurrentItem();
	bool isRubberSelecting() const;

	void doLayout() const;

	void windowActivationChange(bool);

protected slots:
	void clearInputString();

private:
	TQListBox(const TQListBox &);
};


class TQListBoxItem
{
%TypeHeaderCode
#include <tqlistbox.h>
%End

public:
	TQListBoxItem(TQListBox * /TransferThis/ = 0);
	TQListBoxItem(TQListBox * /TransferThis/,TQListBoxItem *);

	virtual TQString text() const;
	virtual const TQPixmap *pixmap() const;

	virtual int height(const TQListBox *) const;
	virtual int width(const TQListBox *) const;

	bool isSelected() const;
	bool isCurrent() const;

	TQListBox *listBox() const;

	void setSelectable(bool);
	bool isSelectable() const;

	TQListBoxItem *next() const;
	TQListBoxItem *prev() const;

	virtual int rtti() const;

protected:
	virtual void paint(TQPainter *) = 0;
	virtual void setText(const TQString &);
	void setCustomHighlighting(bool);

private:
	TQListBoxItem(const TQListBoxItem &);
};

class TQListBoxText : TQListBoxItem
{
%TypeHeaderCode
#include <tqlistbox.h>
%End

public:
	TQListBoxText(TQListBox * /TransferThis/,
		     const TQString & = TQString::null);
	TQListBoxText(const TQString & = TQString::null);
	TQListBoxText(TQListBox * /TransferThis/,const TQString &,TQListBoxItem *);

	int height(const TQListBox *) const;
	int width(const TQListBox *) const;

	int rtti() const;

protected:
	void paint(TQPainter *);

private:
	TQListBoxText(const TQListBoxText &);
};

class TQListBoxPixmap : TQListBoxItem
{
%TypeHeaderCode
#include <tqlistbox.h>
%End

public:
	TQListBoxPixmap(TQListBox * /TransferThis/,const TQPixmap &);
	TQListBoxPixmap(const TQPixmap &);
	TQListBoxPixmap(TQListBox * /TransferThis/,const TQPixmap &,
		       TQListBoxItem *);
	TQListBoxPixmap(TQListBox * /TransferThis/,const TQPixmap &,
		       const TQString &);
	TQListBoxPixmap(const TQPixmap &,const TQString &);
	TQListBoxPixmap(TQListBox * /TransferThis/,const TQPixmap &,
		       const TQString &,TQListBoxItem *);

	const TQPixmap *pixmap() const;
	int height(const TQListBox *) const;
	int width(const TQListBox *) const;

	int rtti() const;

protected:
	void paint(TQPainter *);

private:
	TQListBoxPixmap(const TQListBoxPixmap &);
};
