Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Table class. More...
#include <ilviews/util/table.h>
Public Member Functions | |
IlvTable () | |
Constructor. | |
virtual IlBoolean | allowCellMode () const =0 |
Sets whether to allow continuous row or column drawing of items. More... | |
IlBoolean | cellBBox (IlvRect bbox, IlUShort row, IlUShort col, IlUShort startrow, IlUShort startcol, IlvRect &rect) const |
Determines a cell's bounding box. More... | |
virtual void | cellInfo (IlUShort rowno, IlUShort colno, IlUShort &startrow, IlUShort &startcol, IlUShort &nbrow, IlUShort &nbcol) const |
Draws an item in multiple cell mode. More... | |
virtual IlBoolean | columnSameWidth () const =0 |
Tests if all columns are the same width. More... | |
virtual void | copyArea (IlvSystemPort *dst, const IlvRect &rect, const IlvPoint &at) const |
Copies an area of the table. More... | |
void | draw (IlvPort *dst, IlUShort firstcol, IlUShort firstrow, IlUShort nbCol, IlUShort nbRow, IlvPalette *palette, const IlvRect &bbox, const IlvRect &clip) const |
Draws a table. More... | |
virtual void | drawItem (IlvPort *dst, IlUShort rowno, IlUShort colno, const IlvRect &itembbox, const IlvRect &clip) const =0 |
Draws a table item. More... | |
virtual IlvDim | getColumnsDistance (IlUShort fromcol, IlUShort tocol) const |
Gets the distance between two columns. More... | |
virtual IlvDim | getColumnWidth (IlUShort colno) const =0 |
Gets a column width. More... | |
virtual IlvDim | getRowHeight (IlUShort rowno) const =0 |
Gets the row height. More... | |
virtual IlvDim | getRowsDistance (IlUShort fromrow, IlUShort torow) const |
Gets the distance between two rows. More... | |
void | getVisibleItems (const IlvRect &bbox, IlUShort firstcol, IlUShort firstrow, IlUShort nbcol, IlUShort nbrow, IlUShort &fromx, IlUShort &tox, IlUShort &fromy, IlUShort &toy) const |
Gets the visible items of a table. More... | |
virtual void | invalidateRect (IlvPort *dst, const IlvRect &rect) const |
Invalidate a rectangle for redrawing. More... | |
virtual IlBoolean | isShowingGrid () const =0 |
Sets whether the grid is showing or not. More... | |
IlBoolean | pointToPosition (const IlvRect &bbox, const IlvPoint &p, IlUShort firstcol, IlUShort firstrow, IlUShort nbcol, IlUShort nbrow, IlUShort &colno, IlUShort &rowno) const |
Points to the position of an item. More... | |
void | resizeColumn (IlvSystemPort *dst, const IlvRect &bbox, IlUShort col, IlvPos delta, IlUShort firstcol) const |
Resizes a column. More... | |
void | resizeRow (IlvSystemPort *dst, const IlvRect &bbox, IlUShort rw, IlvPos delta, IlUShort firstRow) const |
Resizes a row. More... | |
virtual IlBoolean | rowSameHeight () const =0 |
Tests if all rows are the same height. More... | |
void | scrollTo (IlvSystemPort *dst, IlUShort oldrow, IlUShort oldcolumn, IlUShort row, IlUShort column, const IlvRect &bbox) |
Changes the table indexes for scrolling. More... | |
Table class.
Library: views
This class is an abstract class that draws a table. This class is supposed to be subclassed and used inside a graphic object to draw a table. The IlvTable
does not contain any value. When subclassing the IlvTable
, you must specify the number of rows and columns, the height of each row, the width of each column, whether you want to draw a grid around items, and a way of drawing items in the table. The IlvTable
can also draw items that are placed on multiple continuous rows or columns. We call a cell an item that is drawn on multiple lines or columns.
IlvAbstractMatrix
, IlvMatrix
, IlvSheet
.
|
pure virtual |
Sets whether to allow continuous row or column drawing of items.
Overload this method to return IlTrue
if you want the IlvTable
to be able to draw items on several continuous rows or columns, IlFalse
if not. To have an item drawn on several rows or columns, overload the method cellInfo
.
IlBoolean IlvTable::cellBBox | ( | IlvRect | bbox, |
IlUShort | row, | ||
IlUShort | col, | ||
IlUShort | startrow, | ||
IlUShort | startcol, | ||
IlvRect & | rect | ||
) | const |
Determines a cell's bounding box.
This method returns in rect the rectangle where the item positioned at row and column is drawn. You must give the rectangle where you draw the table in bbox and the first row and first column you draw in startcol and startrow. This method returns IlTrue
if the item is visible, IlFalse
if not. Note that if the item is drawn on multiple continuous lines or columns, cellBBox
returns the full rectangle of the cell and might return IlTrue
if only a part of the cell is visible.
bbox | The bounding box where the table is drawn. |
row | The row number of the cell. |
col | The column number of the cell. |
startrow | The starting row of the cell. |
startcol | The starting column of the cell. |
|
virtual |
Draws an item in multiple cell mode.
Overloading this method will allow you to draw an item on multiple continuous rows or columns. We call a cell an item that is drawn on multiple rows or columns. In this method rowno and colno is a position contained in the cell. Given this position, you must return the starting position of the cell (top left position) in startrow and startcol and the number of rows and columns of the cell in nbrow and nbcol.
For example, if you want to have a cell positioned on 10,10 with a width of five rows and five columns, you should write:
allowCellMode
to return IlTrue
. You should not have cells that overlap. rowno | A row number contained in the cell. |
colno | A column number contained in the cell. |
startrow | The starting row of the cell. |
startcol | The starting column of the cell. |
nbrow | The number of multiple rows. |
nbcol | The number of multiple columns. |
|
pure virtual |
Tests if all columns are the same width.
Overload this method to return IlTrue
if the columns of your table have the same width, IlFalse
if not. If you return IlTrue
, the drawing will be optimized.
|
virtual |
Copies an area of the table.
This method is called by the scrollTo
, resizeRow
and resizeColumn
methods of the table, when this method needs to copy a part of the table to another position. The parameter dst is the drawing destination port. The parameter rect is the rectangle to be moved, and at is the destination point. This method is implemented as doing nothing. You should overload this method so that it copies the rectangle rect at the location point at. You may use the IlvPort::drawBitmap
method.
dst | The drawing destination port. |
rect | The rectangle to be moved. |
at | The destination point. |
void IlvTable::draw | ( | IlvPort * | dst, |
IlUShort | firstcol, | ||
IlUShort | firstrow, | ||
IlUShort | nbCol, | ||
IlUShort | nbRow, | ||
IlvPalette * | palette, | ||
const IlvRect & | bbox, | ||
const IlvRect & | clip | ||
) | const |
Draws a table.
This method draws the table in the port dst, the rectangle bbox, is the rectangle where the table will be drawn, the rectangle clip is the clipping rectangle for drawing. firstcol and firstrow are the indexes of the top left item drawn. nbCol the number of columns of the table, nbRow the number of rows. palette is the palette used by the table to draw the grid.
dst | The drawing destination port. |
firstcol | The first column index. |
firstrow | The first row index. |
nbCol | The number of columns of the table. |
nbRow | The number of rows of the table. |
palette | The palette used by the table for drawing the grid. |
bbox | The bounding box where the table is drawn. |
clip | The clipping rectangle. |
|
pure virtual |
Draws a table item.
Overload this method to draw a table item. This method gives you the position of the item in the table (rowno, colno>); this position might be the top left position of the item if this item is drawn on multiple continuous rows or columns (see cellInfo
). This method also gives you the destination drawing port dst, the bounding box of the item, that is, the rectangle where you should draw the item, and the clipping rectangle clip.
dst | The drawing destination port. |
rowno | A row number contained in the cell. |
colno | A column number contained in the cell. |
itembbox | The bounding box of the item. |
clip | The clipping rectangle. |
Gets the distance between two columns.
This method computes the distance between the column fromcol and tocol. It is implemented with the sum of getColumnWidth(i)
from fromcol to tocol -1. You might overload this method if your subclass has a faster way of computing this distance. Note that it is already optimized if columns have same width.
fromcol | The starting column number. |
tocol | The ending column number. |
Gets a column width.
Overload this method to return the width of the column numbered colno. Note that the number starts at 0. You must overload this method even if all columns have same width, in this case the IlvTable
will use getColumnWidth(0)
. This method must be as fast as possible to optimize the drawing.
colno | The column number. |
Gets the row height.
Overload this method to return the height of the row numbered rowno. Note that the number starts at 0. You must overload this method even if all rows have same height; in this case the IlvTable
will use getRowHeight(0)
. This method must be as fast as possible to optimize the drawing.
rowno | The row number. |
Gets the distance between two rows.
This method computes the distance between the row fromrow and torow. It is implemented with the sum of getRowHeight(i)
from fromrow to torow -1. You might overload this method if your subclass has a faster way of computing this distance. Note that it is already optimized if rows have same height.
fromrow | The starting row number. |
torow | The ending row number. |
void IlvTable::getVisibleItems | ( | const IlvRect & | bbox, |
IlUShort | firstcol, | ||
IlUShort | firstrow, | ||
IlUShort | nbcol, | ||
IlUShort | nbrow, | ||
IlUShort & | fromx, | ||
IlUShort & | tox, | ||
IlUShort & | fromy, | ||
IlUShort & | toy | ||
) | const |
Gets the visible items of a table.
This method computes the visible items of the table. The parameter bbox is the rectangle where you draw the table, firstrow and firstcol the indexes of the top left item, nbcol the number of columns of the table and nbrow the number of rows of the table. The method fills the parameter fromx with the first visible column, tox with the last visible column, fromy with the first visible row and toy with the last visible row.
bbox | The bounding box rectangle. |
firstcol | The column index of the top left item. |
firstrow | The row index of the top left item. |
nbcol | The number of columns in the table. |
nbrow | The number of rows in the table. |
Invalidate a rectangle for redrawing.
This method is called by the scrollTo
, resizeRow
and resizeColumn
methods of the table, when this method needs to redraw a part of the table. The parameter dst is the drawing destination port. The parameter rect is the rectangle to redraw. This method is implemented as doing nothing. You should overload this method so that it redraws the rectangle rect.
dst | The drawing destination port. |
rect | The rectangle to redraw. |
|
pure virtual |
Sets whether the grid is showing or not.
Overload this method to decide if you want to draw a grid or not.
IlBoolean IlvTable::pointToPosition | ( | const IlvRect & | bbox, |
const IlvPoint & | p, | ||
IlUShort | firstcol, | ||
IlUShort | firstrow, | ||
IlUShort | nbcol, | ||
IlUShort | nbrow, | ||
IlUShort & | colno, | ||
IlUShort & | rowno | ||
) | const |
Points to the position of an item.
This method looks for the item located at the point p, if such item exists, its position is returned in colno, rowno and the method returns IlTrue
. The parameter bbox is the rectangle where you draw the table, firstcol and firstrow are the indexes of the top left item, nbcol the number of columns of the table and nbrow the number of rows of the table.
bbox | The bounding box rectangle. |
p | The location point. |
firstcol | The column index of the top left item. |
firstrow | The row index of the top left item. |
nbcol | The number of columns in the table. |
nbrow | The number of rows in the table. |
IlTrue
if the item is found and returns in the column number, and in rowno the row number. void IlvTable::resizeColumn | ( | IlvSystemPort * | dst, |
const IlvRect & | bbox, | ||
IlUShort | col, | ||
IlvPos | delta, | ||
IlUShort | firstcol | ||
) | const |
Resizes a column.
This method must be called when a column has changed width. dst is the port where the table is drawn. bbox is the rectangle where the table is drawn. The parameter col is the index of the column resized, firstcol the index of the top column, delta is the difference between the new width and the old width. The method copies the areas that are still visible, if any, using the method copyArea
of IlvTable
(see this method) and updates the areas that were not visible using the method invalidateRect
(see this method).
dst | The drawing destination port. |
bbox | The bounding box where the table is drawn. |
col | The index of the column resized. |
delta | The difference between the new and old widths. |
firstcol | The index of the top column. |
void IlvTable::resizeRow | ( | IlvSystemPort * | dst, |
const IlvRect & | bbox, | ||
IlUShort | rw, | ||
IlvPos | delta, | ||
IlUShort | firstRow | ||
) | const |
Resizes a row.
This method must be called when a row has changed height. dst is the port where the table is drawn. bbox is the rectangle where the table is drawn. The parameter rw is the index of the row resized, firstrow the index of the left row, delta is the difference between the new height and the old height. The method copies the areas that are still visible, if any, using the method copyArea
of IlvTable
(see this method) and updates the areas that were not visible using the method invalidateRect
(see this method).
dst | The drawing destination port. |
bbox | The bounding box where the table is drawn. |
rw | The index of the row resized. |
delta | The difference between the new and old heights. |
firstrow | The index of the left row. |
|
pure virtual |
Tests if all rows are the same height.
Overload this method to return IlTrue
if the rows of your table have the same height, IlFalse
if not. If you return IlTrue
, the drawing will be optimized.
void IlvTable::scrollTo | ( | IlvSystemPort * | dst, |
IlUShort | oldrow, | ||
IlUShort | oldcolumn, | ||
IlUShort | row, | ||
IlUShort | column, | ||
const IlvRect & | bbox | ||
) |
Changes the table indexes for scrolling.
When you use the method draw
, you specify the indexes of the top left item drawn. This method allows you to change the top left item drawn, so it is useful to implement a scrolling mechanism. The parameter bbox is the rectangle where the table is drawn, dst the port where the table is drawn. The parameters oldrow and oldcolumn are the indexes of the old top left item, row and column are the indexes of the new top left item. The method will copy the areas that are still visible, if any, using the method copyArea
of table (see this method) and update the rows and columns that where not visible using the method invalidateRect
(see this method).
dst | The drawing destination port. |
oldrow | The first row index before the move. |
oldcolumn | The first column index before the move. |
row | The first row index after the move. |
column | The first column index after the move. |
bbox | The bounding box where the table is drawn. |
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.