PoDoFo::PdfTable Class Reference

#include <PdfTable.h>

List of all members.

Public Types

typedef PdfPage *(* CreatePageCallback )(PdfRect &rClipRect, void *pCustom)

Public Member Functions

 PdfTable (int nCols, int nRows)
virtual void Draw (double dX, double dY, PdfPainter *pPainter, const PdfRect &rClipRect=PdfRect(), double *pdLastX=NULL, double *pdLastY=NULL)
virtual double GetWidth (double dX, double dY, PdfCanvas *pPage) const
virtual double GetHeight (double dX, double dY, PdfCanvas *pPage) const
void SetModel (PdfTableModel *pModel)
const PdfTableModelGetModel () const
void SetColumnWidths (double *pdWidths)
void SetRowHeights (double *pdHeights)
void SetColumnWidth (double dWidth)
void SetRowHeight (double dHeight)
void SetTableWidth (double dWidth)
void SetTableHeight (double dHeight)
void SetAutoPageBreak (bool bPageBreak, CreatePageCallback callback, void *pCustomData=NULL)
bool GetAutoPageBreak () const
int GetCols () const
int GetRows () const

Protected Member Functions

void CalculateTableSize (const double dX, const double dY, const PdfCanvas *pCanvas, double *pdWidths, double *pdHeights, double *pdWidth, double *pdHeight) const
void DrawHorizontalBorders (int nRow, double dX, double dY, PdfPainter *pPainter, double *pdColWidths)
bool CheckForNewPage (double *pdY, double *pdCurY, double dRowHeight, PdfPainter *pPainter)

Detailed Description

This is a high level class of a table which can be drawn to a PdfPainter.

Use this class if you have to include data into your PDF as an table.


Member Typedef Documentation

typedef PdfPage*(* PoDoFo::PdfTable::CreatePageCallback)(PdfRect &rClipRect, void *pCustom)

Callback to create a new page for PdfTable.

See also:
SetAutoPageBreak
Parameters:
rClipRect this is an output parameter which has to be set to the clipping rectangle of the new page. If the new page has no clipping rectangle set it to PdfRect( 0, 0, PdfPage::GetPageSize().GetWidth(), PdfPage::GetPageSize().GetHeight() )
pCustom pointer to user defined data

Constructor & Destructor Documentation

PoDoFo::PdfTable::PdfTable ( int  nCols,
int  nRows 
)

Create a new PdfTable object.

Parameters:
nCols number of columns in the table. nRows number of rows in the table.

Member Function Documentation

void PoDoFo::PdfTable::CalculateTableSize ( const double  dX,
const double  dY,
const PdfCanvas pCanvas,
double *  pdWidths,
double *  pdHeights,
double *  pdWidth,
double *  pdHeight 
) const [protected]

Internal functions that calculates the total table size for a table with the current settings when drawn on a certain page.

Parameters:
dX the X coordinate of top left at which is drawn
dY the Y coordinate of top left at which is drawn
pCanvas the canvas object (usually a page) on which the table will be drawn.
pdWidths pointer to an array with GetCols() doubles where the width for each column will be stored
pdHeights pointer to an array with GetRows() doublesd where the height for each row will be stored
pdWidth pointer to a double where the total width of the table will be stored
pdHeight pointer to a double where the total height of the table will be stored
bool PoDoFo::PdfTable::CheckForNewPage ( double *  pdY,
double *  pdCurY,
double  dRowHeight,
PdfPainter pPainter 
) [protected]

Checks if there is enough space on the current page for one row! If necessary a new page is created.

If GetAutoPageBreak is false, this method does nothing.

Parameters:
pdY top of the table
pdCurY pointer to the current y position on the page. Might be reset to a new y position.
dRowHeight height of the next row.
pPainter painter used for drawing
Returns:
true if a new page was created, otherwise false
void PoDoFo::PdfTable::Draw ( double  dX,
double  dY,
PdfPainter pPainter,
const PdfRect rClipRect = PdfRect(),
double *  pdLastX = NULL,
double *  pdLastY = NULL 
) [virtual]

Draw the table with its current settings on a PdfPainter.

Parameters:
dX x coordinate of top left of the table
dY y coordinate of top left of the table
pPainter the painter to draw on. The painter has to have a page set currently.
rClipRect the clipping rectangle on the current page
pdLastX the last used X position by the table on the current page will be written to this value (usually bottom right)
pdLastY the last used Y positon by the table on the current page will be written to this value (usually bottom right)
void PoDoFo::PdfTable::DrawHorizontalBorders ( int  nRow,
double  dX,
double  dY,
PdfPainter pPainter,
double *  pdColWidths 
) [protected]

Draw one row of horizontal cell borders using the correct color for each cell.

Parameters:
nRow the current row
dX left x coordinate
dY y coordinate
pPainter use this painter object
pdColWidth an array containing all colomun widths
bool PoDoFo::PdfTable::GetAutoPageBreak (  )  const [inline]
Returns:
true if a new page is created automatically if more space is required to draw the table.
See also:
SetAutoPageBreak
int PoDoFo::PdfTable::GetCols (  )  const [inline]
Returns:
the number of columns in the table.
double PoDoFo::PdfTable::GetHeight ( double  dX,
double  dY,
PdfCanvas pPage 
) const [virtual]

Get the width of the table when drawn with the current settings at a certain position.

Parameters:
dX x coordinate of top left of the table
dY y coordinate of top left of the table
pPage the page on which the table will be drawn
Returns:
the width of the table
const PdfTableModel * PoDoFo::PdfTable::GetModel (  )  const [inline]

Get the current PdfTableModel

Returns:
the currently set PdfTableModel or NULL if none was set
int PoDoFo::PdfTable::GetRows (  )  const [inline]
Returns:
the number of rows in the table.
double PoDoFo::PdfTable::GetWidth ( double  dX,
double  dY,
PdfCanvas pPage 
) const [virtual]

Get the width of the table when drawn with the current settings at a certain position.

Parameters:
dX x coordinate of top left of the table
dY y coordinate of top left of the table
pPage the page on which the table will be drawn
Returns:
the width of the table
void PoDoFo::PdfTable::SetAutoPageBreak ( bool  bPageBreak,
CreatePageCallback  callback,
void *  pCustomData = NULL 
) [inline]

Automatically create a new page and continue drawing the table on the new page, if there is not enough space on the current page.

The newly created page will be set as the current page on the painter used to draw and will be created using the same size as the old page.

Parameters:
bPageBreak if true automatically create new pages if required.
callback a callback function that is called to create a new page. Please note: PdfTable cannot create new pages on its own. You always have to implement a callback which does the new page creation for the PdfTable.
pCustomData custom data that is passed to the callback

By default this feature is turned off and contents are clipped that do not fit on the current page.

See also:
GetAutoPageBreak
void PoDoFo::PdfTable::SetColumnWidth ( double  dWidth  )  [inline]

Set all columns to have the same width.

Parameters:
dWidth the width of every column

By default the column with is calculated automatically from either the table width or if no table width is set from the width of the page on which the table is drawn.

void PoDoFo::PdfTable::SetColumnWidths ( double *  pdWidths  ) 

Set the width of all columns.

Parameters:
pdWidths a pointer to an array of GetCols() doubles which are the individual width of a column.
See also:
GetCols()
void PoDoFo::PdfTable::SetModel ( PdfTableModel pModel  )  [inline]

Set the PdfTableModel that will supply all contents and formatting informations to the table.

Parameters:
pModel a PdfTableModel

The model will not be owned by the PdfTable and has to be deleted by the caller.

See also:
GetModel
void PoDoFo::PdfTable::SetRowHeight ( double  dHeight  )  [inline]

Set all rows to have the same height.

Parameters:
dHeight the height of every row

By default the row height is calculated automatically from either the table height or if no table height is set from the height of the page on which the table is drawn.

void PoDoFo::PdfTable::SetRowHeights ( double *  pdHeights  ) 

Set the height of all rows.

Parameters:
pdHeights a pointer to an array of GetRows() doubles which are the individual heights of a row.
See also:
GetRows()
void PoDoFo::PdfTable::SetTableHeight ( double  dHeight  )  [inline]

Set the height of the table.

Parameters:
dHeight the height of the whole table.

This height is used if no row height is set to calculate the height of every row. If this height is not set, the height of the page on which this table is drawn is used.

void PoDoFo::PdfTable::SetTableWidth ( double  dWidth  )  [inline]

Set the width of the table.

Parameters:
dWidth the width of the whole table.

This width is used if no column width is set to calculate the width of every column. If this width is not set, the width of the page on which this table is drawn is used.

Generated by  doxygen 1.6.2-20100208