rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

List of all members | Public Member Functions
IlvTable Class Referenceabstract

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...
 

Detailed Description

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.

See Also
IlvAbstractMatrix, IlvMatrix, IlvSheet.

Member Function Documentation

virtual IlBoolean IlvTable::allowCellMode ( ) const
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.

Returns
A Boolean indicating whether to allow continuous cell mode or not.
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.

Parameters
bboxThe bounding box where the table is drawn.
rowThe row number of the cell.
colThe column number of the cell.
startrowThe starting row of the cell.
startcolThe starting column of the cell.
Returns
In rect, the rectangle where the item is drawn.
virtual void IlvTable::cellInfo ( IlUShort  rowno,
IlUShort  colno,
IlUShort startrow,
IlUShort startcol,
IlUShort nbrow,
IlUShort nbcol 
) const
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:

if ((rowno >= 10) && (rowno < 15) && (colno >= 10) && (colno < 15)) {
startrow =10;
startcol =10;
nbrow = 5;
nbcol = 5;
} else
IlvTable::cellInfo(rowno, colno,
startrow, startcol,
nbrow, nbcol);
Warning
[note] This feature will work only if you have overloaded the method allowCellMode to return IlTrue. You should not have cells that overlap.
Parameters
rownoA row number contained in the cell.
colnoA column number contained in the cell.
startrowThe starting row of the cell.
startcolThe starting column of the cell.
nbrowThe number of multiple rows.
nbcolThe number of multiple columns.
virtual IlBoolean IlvTable::columnSameWidth ( ) const
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.

Returns
A Boolean indicating whether all columns are the same width or not.
virtual void IlvTable::copyArea ( IlvSystemPort dst,
const IlvRect rect,
const IlvPoint at 
) const
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.

Parameters
dstThe drawing destination port.
rectThe rectangle to be moved.
atThe 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.

Parameters
dstThe drawing destination port.
firstcolThe first column index.
firstrowThe first row index.
nbColThe number of columns of the table.
nbRowThe number of rows of the table.
paletteThe palette used by the table for drawing the grid.
bboxThe bounding box where the table is drawn.
clipThe clipping rectangle.
virtual void IlvTable::drawItem ( IlvPort dst,
IlUShort  rowno,
IlUShort  colno,
const IlvRect itembbox,
const IlvRect clip 
) const
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.

Parameters
dstThe drawing destination port.
rownoA row number contained in the cell.
colnoA column number contained in the cell.
itembboxThe bounding box of the item.
clipThe clipping rectangle.
virtual IlvDim IlvTable::getColumnsDistance ( IlUShort  fromcol,
IlUShort  tocol 
) const
virtual

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.

Parameters
fromcolThe starting column number.
tocolThe ending column number.
Returns
The distance between the two columns.
virtual IlvDim IlvTable::getColumnWidth ( IlUShort  colno) const
pure virtual

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.

Parameters
colnoThe column number.
Returns
The width of the column.
virtual IlvDim IlvTable::getRowHeight ( IlUShort  rowno) const
pure virtual

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.

Parameters
rownoThe row number.
Returns
The row height.
virtual IlvDim IlvTable::getRowsDistance ( IlUShort  fromrow,
IlUShort  torow 
) const
virtual

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.

Parameters
fromrowThe starting row number.
torowThe ending row number.
Returns
The distance between the two rows.
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.

Parameters
bboxThe bounding box rectangle.
firstcolThe column index of the top left item.
firstrowThe row index of the top left item.
nbcolThe number of columns in the table.
nbrowThe number of rows in the table.
Returns
If there are visible items, returns their extent in fromx, tox and fromy, toy.
virtual void IlvTable::invalidateRect ( IlvPort dst,
const IlvRect rect 
) const
virtual

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.

Parameters
dstThe drawing destination port.
rectThe rectangle to redraw.
virtual IlBoolean IlvTable::isShowingGrid ( ) const
pure virtual

Sets whether the grid is showing or not.

Overload this method to decide if you want to draw a grid or not.

Returns
A Boolean indicating whether to show the 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.

Parameters
bboxThe bounding box rectangle.
pThe location point.
firstcolThe column index of the top left item.
firstrowThe row index of the top left item.
nbcolThe number of columns in the table.
nbrowThe number of rows in the table.
Returns
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).

Parameters
dstThe drawing destination port.
bboxThe bounding box where the table is drawn.
colThe index of the column resized.
deltaThe difference between the new and old widths.
firstcolThe 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).

Parameters
dstThe drawing destination port.
bboxThe bounding box where the table is drawn.
rwThe index of the row resized.
deltaThe difference between the new and old heights.
firstrowThe index of the left row.
virtual IlBoolean IlvTable::rowSameHeight ( ) const
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.

Returns
A Boolean indicating whether all rows are the same height or not.
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).

Parameters
dstThe drawing destination port.
oldrowThe first row index before the move.
oldcolumnThe first column index before the move.
rowThe first row index after the move.
columnThe first column index after the move.
bboxThe 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.