You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/ntqgridview.html

262 lines
14 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qgridview.cpp:45 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQGridView Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQGridView Class Reference</h1>
<p>The TQGridView class provides an abstract base for
fixed-size grids.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qgridview-h.html">ntqgridview.h</a>&gt;</tt>
<p>Inherits <a href="ntqscrollview.html">TQScrollView</a>.
<p><a href="qgridview-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQGridView"><b>TQGridView</b></a> ( TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )</li>
<li class=fn><a href="#~TQGridView"><b>~TQGridView</b></a> ()</li>
<li class=fn>int <a href="#numRows"><b>numRows</b></a> () const</li>
<li class=fn>virtual void <a href="#setNumRows"><b>setNumRows</b></a> ( int )</li>
<li class=fn>int <a href="#numCols"><b>numCols</b></a> () const</li>
<li class=fn>virtual void <a href="#setNumCols"><b>setNumCols</b></a> ( int )</li>
<li class=fn>int <a href="#cellWidth"><b>cellWidth</b></a> () const</li>
<li class=fn>virtual void <a href="#setCellWidth"><b>setCellWidth</b></a> ( int )</li>
<li class=fn>int <a href="#cellHeight"><b>cellHeight</b></a> () const</li>
<li class=fn>virtual void <a href="#setCellHeight"><b>setCellHeight</b></a> ( int )</li>
<li class=fn>TQRect <a href="#cellRect"><b>cellRect</b></a> () const</li>
<li class=fn>TQRect <a href="#cellGeometry"><b>cellGeometry</b></a> ( int&nbsp;row, int&nbsp;column )</li>
<li class=fn>TQSize <a href="#gridSize"><b>gridSize</b></a> () const</li>
<li class=fn>int <a href="#rowAt"><b>rowAt</b></a> ( int&nbsp;y ) const</li>
<li class=fn>int <a href="#columnAt"><b>columnAt</b></a> ( int&nbsp;x ) const</li>
<li class=fn>void <a href="#repaintCell"><b>repaintCell</b></a> ( int&nbsp;row, int&nbsp;column, bool&nbsp;erase = TRUE )</li>
<li class=fn>void <a href="#updateCell"><b>updateCell</b></a> ( int&nbsp;row, int&nbsp;column )</li>
<li class=fn>void <a href="#ensureCellVisible"><b>ensureCellVisible</b></a> ( int&nbsp;row, int&nbsp;column )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>int <a href="#cellHeight-prop"><b>cellHeight</b></a>&nbsp;- the height of a grid row</li>
<li class=fn>int <a href="#cellWidth-prop"><b>cellWidth</b></a>&nbsp;- the width of a grid column</li>
<li class=fn>int <a href="#numCols-prop"><b>numCols</b></a>&nbsp;- the number of columns in the grid</li>
<li class=fn>int <a href="#numRows-prop"><b>numRows</b></a>&nbsp;- the number of rows in the grid</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#paintCell"><b>paintCell</b></a> ( TQPainter&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col ) = 0</li>
<li class=fn>virtual void <a href="#paintEmptyArea"><b>paintEmptyArea</b></a> ( TQPainter&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )</li>
<li class=fn>virtual void <a href="#dimensionChange"><b>dimensionChange</b></a> ( int&nbsp;oldNumRows, int&nbsp;oldNumCols )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQGridView class provides an abstract base for
fixed-size grids.
<p>
<p> A grid view consists of a number of abstract cells organized in
rows and columns. The cells have a fixed size and are identified
with a row index and a column index. The top-left cell is in row
0, column 0. The bottom-right cell is in row <a href="#numRows">numRows</a>()-1, column
<a href="#numCols">numCols</a>()-1.
<p> You can define <a href="#numRows-prop">numRows</a>, <a href="#numCols-prop">numCols</a>, <a href="#cellWidth-prop">cellWidth</a> and <a href="#cellHeight-prop">cellHeight</a>. Reimplement the pure virtual function <a href="#paintCell">paintCell</a>() to
draw the contents of a cell.
<p> With <a href="#ensureCellVisible">ensureCellVisible</a>(), you can ensure a certain cell is
visible. With <a href="#rowAt">rowAt</a>() and <a href="#columnAt">columnAt</a>() you can find a cell based on
the given x- and y-coordinates.
<p> If you need to monitor changes to the grid's dimensions (i.e. when
numRows or numCols is changed), reimplement the <a href="#dimensionChange">dimensionChange</a>()
change handler.
<p> Note: the row and column indices are always given in the order,
row (vertical offset) then column (horizontal offset). This order
is the opposite of all pixel operations, which are given in the
order x (horizontal offset), y (vertical offset).
<p> TQGridView is a very simple abstract class based on <a href="ntqscrollview.html">TQScrollView</a>. It
is designed to simplify the task of drawing many cells of the same
size in a potentially scrollable canvas. If you need rows and
columns with different sizes, use a <a href="ntqtable.html">TQTable</a> instead. If you need a
simple list of items, use a <a href="ntqlistbox.html">TQListBox</a>. If you need to present
hierachical data use a <a href="ntqlistview.html">TQListView</a>, and if you need random objects
at random positions, consider using either a <a href="tqiconview.html">TQIconView</a> or a
<a href="tqcanvas.html">TQCanvas</a>.
<p>See also <a href="abstractwidgets.html">Abstract Widget Classes</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQGridView"></a>TQGridView::TQGridView ( <a href="tqwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )
</h3>
Constructs a grid view.
<p> The <em>parent</em>, <em>name</em> and <a href="ntqt.html#WidgetFlags">widget flag</a>, <em>f</em>, arguments are passed
to the <a href="ntqscrollview.html">TQScrollView</a> constructor.
<h3 class=fn><a name="~TQGridView"></a>TQGridView::~TQGridView ()
</h3>
Destroys the grid view.
<h3 class=fn><a href="tqrect.html">TQRect</a> <a name="cellGeometry"></a>TQGridView::cellGeometry ( int&nbsp;row, int&nbsp;column )
</h3>
Returns the geometry of cell (<em>row</em>, <em>column</em>) in the content
coordinate system.
<p> <p>See also <a href="#cellRect">cellRect</a>().
<h3 class=fn>int <a name="cellHeight"></a>TQGridView::cellHeight () const
</h3><p>Returns the height of a grid row.
See the <a href="ntqgridview.html#cellHeight-prop">"cellHeight"</a> property for details.
<h3 class=fn><a href="tqrect.html">TQRect</a> <a name="cellRect"></a>TQGridView::cellRect () const
</h3>
<p> Returns the geometry of a cell in a cell's coordinate system. This
is a convenience function useful in <a href="#paintCell">paintCell</a>(). It is equivalent
to <a href="tqrect.html">TQRect</a>( 0, 0, <a href="#cellWidth">cellWidth</a>(), <a href="#cellHeight">cellHeight</a>() ).
<p> <p>See also <a href="#cellGeometry">cellGeometry</a>().
<p>
<h3 class=fn>int <a name="cellWidth"></a>TQGridView::cellWidth () const
</h3><p>Returns the width of a grid column.
See the <a href="ntqgridview.html#cellWidth-prop">"cellWidth"</a> property for details.
<h3 class=fn>int <a name="columnAt"></a>TQGridView::columnAt ( int&nbsp;x ) const
</h3>
<p> Returns the number of the column at position <em>x</em>. <em>x</em> must be
given in content coordinates.
<p> <p>See also <a href="#rowAt">rowAt</a>().
<h3 class=fn>void <a name="dimensionChange"></a>TQGridView::dimensionChange ( int&nbsp;oldNumRows, int&nbsp;oldNumCols )<tt> [virtual protected]</tt>
</h3>
<p> This change handler is called whenever any of the grid's
dimensions change. <em>oldNumRows</em> and <em>oldNumCols</em> contain the
old dimensions, <a href="#numRows">numRows</a>() and <a href="#numCols">numCols</a>() contain the new
dimensions.
<h3 class=fn>void <a name="ensureCellVisible"></a>TQGridView::ensureCellVisible ( int&nbsp;row, int&nbsp;column )
</h3>
Ensures cell (<em>row</em>, <em>column</em>) is visible, scrolling the grid
view if necessary.
<h3 class=fn><a href="tqsize.html">TQSize</a> <a name="gridSize"></a>TQGridView::gridSize () const
</h3>
<p> Returns the size of the grid in pixels.
<p>
<h3 class=fn>int <a name="numCols"></a>TQGridView::numCols () const
</h3><p>Returns the number of columns in the grid.
See the <a href="ntqgridview.html#numCols-prop">"numCols"</a> property for details.
<h3 class=fn>int <a name="numRows"></a>TQGridView::numRows () const
</h3><p>Returns the number of rows in the grid.
See the <a href="ntqgridview.html#numRows-prop">"numRows"</a> property for details.
<h3 class=fn>void <a name="paintCell"></a>TQGridView::paintCell ( <a href="tqpainter.html">TQPainter</a>&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col )<tt> [pure virtual protected]</tt>
</h3>
<p> This pure virtual function is called to paint the single cell at
(<em>row</em>, <em>col</em>) using painter <em>p</em>. The painter must be open when
<a href="#paintCell">paintCell</a>() is called and must remain open.
<p> The coordinate system is <a href="tqpainter.html#translate">translated</a> so that the origin is at the top-left corner of the cell
to be painted, i.e. <em>cell</em> coordinates. Do not scale or shear
the coordinate system (or if you do, restore the <a href="tqwmatrix.html#TransformationMode">transformation matrix</a> before you return).
<p> The painter is not clipped by default in order to get maximum
efficiency. If you want clipping, use
<p> <pre>
p-&gt;setClipRect( <a href="#cellRect">cellRect</a>(), TQPainter::CoordPainter );
//... your drawing code
p-&gt;setClipping( FALSE );
</pre>
<h3 class=fn>void <a name="paintEmptyArea"></a>TQGridView::paintEmptyArea ( <a href="tqpainter.html">TQPainter</a>&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )<tt> [virtual protected]</tt>
</h3>
This function fills the <em>cw</em> pixels wide and <em>ch</em> pixels high
rectangle starting at position (<em>cx</em>, <em>cy</em>) with the background
color using the painter <em>p</em>.
<p> <a href="#paintEmptyArea">paintEmptyArea</a>() is invoked by <a href="ntqscrollview.html#drawContents">drawContents</a>() to erase or fill
unused areas.
<h3 class=fn>void <a name="repaintCell"></a>TQGridView::repaintCell ( int&nbsp;row, int&nbsp;column, bool&nbsp;erase = TRUE )
</h3>
Repaints cell (<em>row</em>, <em>column</em>).
<p> If <em>erase</em> is TRUE, TQt erases the area of the cell before the
<a href="#paintCell">paintCell</a>() call; otherwise no erasing takes place.
<p> <p>See also <a href="tqwidget.html#repaint">TQWidget::repaint</a>().
<h3 class=fn>int <a name="rowAt"></a>TQGridView::rowAt ( int&nbsp;y ) const
</h3>
<p> Returns the number of the row at position <em>y</em>. <em>y</em> must be given
in content coordinates.
<p> <p>See also <a href="#columnAt">columnAt</a>().
<h3 class=fn>void <a name="setCellHeight"></a>TQGridView::setCellHeight ( int )<tt> [virtual]</tt>
</h3><p>Sets the height of a grid row.
See the <a href="ntqgridview.html#cellHeight-prop">"cellHeight"</a> property for details.
<h3 class=fn>void <a name="setCellWidth"></a>TQGridView::setCellWidth ( int )<tt> [virtual]</tt>
</h3><p>Sets the width of a grid column.
See the <a href="ntqgridview.html#cellWidth-prop">"cellWidth"</a> property for details.
<h3 class=fn>void <a name="setNumCols"></a>TQGridView::setNumCols ( int )<tt> [virtual]</tt>
</h3><p>Sets the number of columns in the grid.
See the <a href="ntqgridview.html#numCols-prop">"numCols"</a> property for details.
<h3 class=fn>void <a name="setNumRows"></a>TQGridView::setNumRows ( int )<tt> [virtual]</tt>
</h3><p>Sets the number of rows in the grid.
See the <a href="ntqgridview.html#numRows-prop">"numRows"</a> property for details.
<h3 class=fn>void <a name="updateCell"></a>TQGridView::updateCell ( int&nbsp;row, int&nbsp;column )
</h3>
Updates cell (<em>row</em>, <em>column</em>).
<p> <p>See also <a href="tqwidget.html#update">TQWidget::update</a>().
<hr><h2>Property Documentation</h2>
<h3 class=fn>int <a name="cellHeight-prop"></a>cellHeight</h3>
<p>This property holds the height of a grid row.
<p>All rows in a grid view have the same height.
<p> <p>See also <a href="#cellWidth-prop">cellWidth</a>.
<p>Set this property's value with <a href="#setCellHeight">setCellHeight</a>() and get this property's value with <a href="#cellHeight">cellHeight</a>().
<h3 class=fn>int <a name="cellWidth-prop"></a>cellWidth</h3>
<p>This property holds the width of a grid column.
<p>All columns in a grid view have the same width.
<p> <p>See also <a href="#cellHeight-prop">cellHeight</a>.
<p>Set this property's value with <a href="#setCellWidth">setCellWidth</a>() and get this property's value with <a href="#cellWidth">cellWidth</a>().
<h3 class=fn>int <a name="numCols-prop"></a>numCols</h3>
<p>This property holds the number of columns in the grid.
<p>Set this property's value with <a href="#setNumCols">setNumCols</a>() and get this property's value with <a href="#numCols">numCols</a>().
<p><p>See also <a href="#numRows-prop">numRows</a>.
<h3 class=fn>int <a name="numRows-prop"></a>numRows</h3>
<p>This property holds the number of rows in the grid.
<p>Set this property's value with <a href="#setNumRows">setNumRows</a>() and get this property's value with <a href="#numRows">numRows</a>().
<p><p>See also <a href="#numCols-prop">numCols</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>