// This is the SIP interface definition for TQTable, TQTableItem,
// TQCheckTableItem, TQComboTableItem and TQTableSelection.
//
// 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>TQTable (TQt v2.2+)</Title>
<Para>
<Literal>TQTable</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>TQTableItem (TQt v2.2+)</Title>
<Para>
<Literal>TQTableItem</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>TQCheckTableItem (TQt v3+)</Title>
<Para>
<Literal>TQCheckTableItem</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>TQComboTableItem (TQt v3+)</Title>
<Para>
<Literal>TQComboTableItem</Literal> is fully implemented.
</Para>
</Sect2>

<Sect2><Title>TQTableSelection (TQt v2.2+)</Title>
<Para>
<Literal>TQTableSelection</Literal> is fully implemented.
</Para>
</Sect2>
%End


%If (TQt_TABLE)
%If (TQt_2_2_0 -)

class TQTableSelection
{
%TypeHeaderCode
#include <tqtable.h>
%End

public:
	TQTableSelection();
%If (TQt_3_1_0 -)
	TQTableSelection(int,int,int,int);
%End

	void init(int,int);
	void expandTo(int,int);

	int topRow() const;
	int bottomRow() const;
	int leftCol() const;
	int rightCol() const;
	int anchorRow() const;
	int anchorCol() const;
%If (TQt_3_2_0 -)
	int numRows() const;
	int numCols() const;
%End

	bool isActive() const;
%If (TQt_3_2_0 -)
	bool isEmpty() const;
%End
};


class TQTableItem : TQt
{
%TypeHeaderCode
#include <tqtable.h>
%End

public:
	enum EditType {
		Never,
		OnTyping,
		WhenCurrent,
		Always
	};

	// Note that the TQt documentation is wrong.  Ownership is only taken by
	// TQTable::setItem().
%If (TQt_3_2_0 -)
	TQTableItem(TQTable *,EditType);
%End
	TQTableItem(TQTable *,EditType,const TQString &);
	TQTableItem(TQTable *,EditType,const TQString &,const TQPixmap &);

%ConvertToSubClassCode
	Py_BEGIN_ALLOW_THREADS

#if TQT_VERSION >= 0x030000
	int rtti = sipCpp -> rtti();

	if (rtti == TQCheckTableItem::RTTI)
		sipClass = sipClass_TQCheckTableItem;
	else if (rtti == TQComboTableItem::RTTI)
		sipClass = sipClass_TQComboTableItem;
	else
		sipClass = 0;
#else
	sipClass = 0;
#endif

	Py_END_ALLOW_THREADS
%End

	virtual TQPixmap pixmap() const;
	virtual TQString text() const;
	virtual void setPixmap(const TQPixmap &);
	virtual void setText(const TQString &);
	TQTable *table() const;

	virtual int alignment() const;
	virtual void setWordWrap(bool);
	bool wordWrap() const;

	EditType editType() const;
	virtual TQWidget *createEditor() const /Factory/;
	virtual void setContentFromEditor(TQWidget *);
	virtual void setReplaceable(bool);
	bool isReplaceable() const;

	virtual TQString key() const;
	virtual TQSize sizeHint() const;

	virtual void setSpan(int,int);
	int rowSpan() const;
	int colSpan() const;

	virtual void setRow(int);
	virtual void setCol(int);
	int row() const;
	int col() const;

	virtual void paint(TQPainter *,const TQColorGroup &,const TQRect &,bool);

	void updateEditor(int,int);

%If (TQt_3_0_0 -)
	virtual void setEnabled(bool);
	bool isEnabled() const;
 
	virtual int rtti() const;
%End

protected:
%If (TQt_3_2_0 - TQt_3_3_0)
	TQString content() const;
%End
};


%If (TQt_3_0_0 -)

class TQComboTableItem : TQTableItem
{
%TypeHeaderCode
#include <tqtable.h>
%End

public:
	// Note that the TQt documentation is wrong.  Ownership is only taken by
	// TQTable::setItem().
	TQComboTableItem(TQTable *,const TQStringList &,bool = 0);

	virtual TQWidget *createEditor() const /Factory/;
	virtual void setContentFromEditor(TQWidget *);
	virtual void paint(TQPainter *,const TQColorGroup &,const TQRect &,bool);
	virtual void setCurrentItem(int);
	virtual void setCurrentItem(const TQString &);
	int currentItem() const;
	TQString currentText() const;
	int count() const;
	TQString text(int) const;
	virtual void setEditable(bool);
	bool isEditable() const;
	virtual void setStringList(const TQStringList &);
 
	int rtti() const;

%If (TQt_3_0_6 -)
	TQSize sizeHint() const;
%End
};

%End


%If (TQt_3_0_0 -)

class TQCheckTableItem : TQTableItem
{
%TypeHeaderCode
#include <tqtable.h>
%End

public:
	// Note that the TQt documentation is wrong.  Ownership is only taken by
	// TQTable::setItem().
	TQCheckTableItem(TQTable *,const TQString &);

%If (TQt_3_2_0 -)
	void setText(const TQString &);
%End
	virtual TQWidget *createEditor() const /Factory/;
	virtual void setContentFromEditor(TQWidget *);
	virtual void paint(TQPainter *,const TQColorGroup &,const TQRect &,bool);
	virtual void setChecked(bool);
	bool isChecked() const;
 
	int rtti() const;

%If (TQt_3_0_6 -)
	TQSize sizeHint() const;
%End
};

%End


class TQTable : TQScrollView
{
%TypeHeaderCode
#include <tqtable.h>
%End

public:
	TQTable(TQWidget * /TransferThis/ = 0,const char * = 0);
	TQTable(int,int,TQWidget * /TransferThis/ = 0,const char * = 0);

%ConvertToSubClassCode
	sipClass = (sipCpp->inherits(sipName_TQTable) ? sipClass_TQTable : NULL);
%End

	TQHeader *horizontalHeader() const;
	TQHeader *verticalHeader() const;

%If (- TQt_3_0_0)
	enum SelectionMode {
		Single,
		Multi,
		NoSelection
	};
%End
%If (TQt_3_0_0 -)
	enum SelectionMode {
		Single,
		Multi,
		SingleRow,
		MultiRow,
		NoSelection
	};
%End

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

	virtual void setItem(int,int,TQTableItem * /Transfer/);
	virtual void setText(int,int,const TQString &);
	virtual void setPixmap(int,int,const TQPixmap &);
	virtual TQTableItem *item(int,int) const;
	virtual TQString text(int,int) const;
	virtual TQPixmap pixmap(int,int) const;
	virtual void clearCell(int,int);

	virtual TQRect cellGeometry(int,int) const;
	virtual int columnWidth(int) const;
	virtual int rowHeight(int) const;
	virtual int columnPos(int) const;
	virtual int rowPos(int) const;
	virtual int columnAt(int) const;
	virtual int rowAt(int) const;

%If (- TQt_3_0_0)
	int numRows() const;
	int numCols() const;
%End
%If (TQt_3_0_0 -)
	virtual int numRows() const;
	virtual int numCols() const;
%End

	void updateCell(int,int);

	bool eventFilter(TQObject *,TQEvent *);

	int currentRow() const;
	int currentColumn() const;
	void ensureCellVisible(int,int);

	bool isSelected(int,int) const;
	bool isRowSelected(int,bool = 0) const;
	bool isColumnSelected(int,bool = 0) const;
	int numSelections() const;
	TQTableSelection selection(int) const;
	virtual int addSelection(const TQTableSelection &);
	virtual void removeSelection(const TQTableSelection &);
	virtual void removeSelection(int);
	virtual int currentSelection() const;

%If (TQt_3_1_0 -)
	void selectCells(int,int,int,int);
	void selectRow(int);
	void selectColumn(int);
%End

	bool showGrid() const;

	bool columnMovingEnabled() const;
	bool rowMovingEnabled() const;

	virtual void sortColumn(int,bool = 1,bool = 0);

	bool sorting() const;

	virtual void takeItem(TQTableItem * /TransferBack/);

	virtual void setCellWidget(int,int,TQWidget * /Transfer/);
	virtual TQWidget *cellWidget(int,int) const;
	virtual void clearCellWidget(int,int);

%If (TQt_3_0_0 -)
	virtual TQRect cellRect(int,int) const;
%End

	virtual void paintCell(TQPainter *,int,int,const TQRect &,bool);
%If (TQt_3_0_0 -)
	virtual void paintCell(TQPainter *,int,int,const TQRect &,bool,
			       const TQColorGroup &);
%End
	virtual void paintFocus(TQPainter *,const TQRect &);
	TQSize sizeHint() const;

%If (TQt_3_0_0 -)
	bool isReadOnly() const;
	bool isRowReadOnly(int) const;
	bool isColumnReadOnly(int) const;
 
	void setEnabled(bool);
 
	void repaintSelections();
 
	enum FocusStyle {
		FollowStyle,
		SpreadSheet
	};

	virtual void setFocusStyle(FocusStyle);
	FocusStyle focusStyle() const;
%End

%If (TQt_3_1_0 -)
	void updateHeaderStates();
%End

public slots:
	virtual void setNumRows(int);
	virtual void setNumCols(int);
	virtual void setShowGrid(bool);
	virtual void hideRow(int);
	virtual void hideColumn(int);
	virtual void showRow(int);
	virtual void showColumn(int);
%If (TQt_3_3_0 -)
	bool isRowHidden(int) const;
	bool isColumnHidden(int) const;
%End

	virtual void setColumnWidth(int,int);
	virtual void setRowHeight(int,int);

	virtual void adjustColumn(int);
	virtual void adjustRow(int);

	virtual void setColumnStretchable(int,bool);
	virtual void setRowStretchable(int,bool);
	bool isColumnStretchable(int) const;
	bool isRowStretchable(int) const;
	virtual void setSorting(bool);
%If (- TQt_3_0_0)
	virtual void swapRows(int,int);
	virtual void swapColumns(int,int);
%End
%If (TQt_3_0_0 -)
	virtual void swapRows(int,int,bool = 0);
	virtual void swapColumns(int,int,bool = 0);
%End
	virtual void swapCells(int,int,int,int);

	virtual void setLeftMargin(int);
	virtual void setTopMargin(int);
	virtual void setCurrentCell(int,int);
	void clearSelection(bool = 1);
	virtual void setColumnMovingEnabled(bool);
	virtual void setRowMovingEnabled(bool);

%If (TQt_3_0_0 -)
	virtual void setReadOnly(bool);
	virtual void setRowReadOnly(int,bool);
	virtual void setColumnReadOnly(int,bool);
 
	virtual void setDragEnabled(bool);
	bool dragEnabled() const;
 
	virtual void insertRows(int,int = 1);
	virtual void insertColumns(int,int = 1);
	virtual void removeRow(int);
	virtual void removeRows(const TQMemArray<int> &);
	virtual void removeColumn(int);
	virtual void removeColumns(const TQMemArray<int> &);
 
	virtual void editCell(int,int,bool = 0);
%End

%If (TQt_3_1_0 -)
	void setRowLabels(const TQStringList &);
	void setColumnLabels(const TQStringList &);
%End

protected:
%If (TQt_3_0_0 -)
	enum EditMode {
		NotEditing,
		Editing,
		Replacing
	};
%End

	void drawContents(TQPainter *,int,int,int,int);
	void contentsMousePressEvent(TQMouseEvent *);
	void contentsMouseMoveEvent(TQMouseEvent *);
	void contentsMouseDoubleClickEvent(TQMouseEvent *);
	void contentsMouseReleaseEvent(TQMouseEvent *);
%If (TQt_3_0_0 -)
	void contentsContextMenuEvent(TQContextMenuEvent *);
%End
	void keyPressEvent(TQKeyEvent *);
	void focusInEvent(TQFocusEvent *);
	void focusOutEvent(TQFocusEvent *);
%If (- TQt_3_0_0)
	void resizeEvent(TQResizeEvent *);
%End
%If (TQt_3_0_0 -)
	void viewportResizeEvent(TQResizeEvent *);
%End
	void showEvent(TQShowEvent *);
%If (TQt_3_1_0 -)
	void paintEvent(TQPaintEvent *);
%End
%If (TQt_3_0_0 -)
	void setEditMode(EditMode,int,int);
	virtual void contentsDragEnterEvent(TQDragEnterEvent *);
	virtual void contentsDragMoveEvent(TQDragMoveEvent *);
	virtual void contentsDragLeaveEvent(TQDragLeaveEvent *);
	virtual void contentsDropEvent(TQDropEvent *);
	virtual TQDragObject *dragObject();
	virtual void startDrag();
%End

	virtual void paintEmptyArea(TQPainter *,int,int,int,int);
	virtual void activateNextCell();
	virtual TQWidget *createEditor(int,int,bool) const /Factory/;
	virtual void setCellContentFromEditor(int,int);
	virtual TQWidget *beginEdit(int,int,bool);
	virtual void endEdit(int,int,bool,bool);

	virtual void resizeData(int);
	virtual void insertWidget(int,int,TQWidget *);
	int indexOf(int,int) const;

%If (TQt_3_0_0 -)
	void windowActivationChange(bool);
	bool isEditing() const;
	EditMode editMode() const;
	int currEditRow() const;
	int currEditCol() const;
%End

protected slots:
	virtual void columnWidthChanged(int);
	virtual void rowHeightChanged(int);
	virtual void columnIndexChanged(int,int,int);
	virtual void rowIndexChanged(int,int,int);
	virtual void columnClicked(int);

signals:
	void currentChanged(int,int);
	void clicked(int,int,int,const TQPoint &);
	void doubleClicked(int,int,int,const TQPoint &);
	void pressed(int,int,int,const TQPoint &);
	void selectionChanged();
	void valueChanged(int,int);
%If (TQt_3_0_0 -)
	void contextMenuRequested(int,int,const TQPoint &);
	void dropped(TQDropEvent *);
%End

private:
%If (TQt_3_1_0 -)
	TQTable(const TQTable &);
%End
};

%End
%End
