RTPDF-32
PDF Generator Library for RTOS-32
List of all members
acTable Class Reference

#include <acTable.h>

Table Class

//
// This sample code shows how to create a table object, set the size of rows and columns and set the attributes and contents of cells
//
acTable table;
RECT rc = { FLOAT2LONG(50.0f), FLOAT2LONG(50.0f), FLOAT2LONG(580.0f), FLOAT2LONG(290.0f) };
int rows = 5, cols = 4;
// intialize the table to 5 rows by 4 columns
table.InitTable(rows, cols, rc);
table.SetColWidth(0, FLOAT2LONG(150.0f), TRUE); // enlarge first column
table.SetColWidth(2, FLOAT2LONG(175.0f), FALSE); // enlarge column 3 and reduce column 4
table.SetRowHeight(0, FLOAT2LONG(25.0f), 1); // header row a bit smaller
// create a default font for all the table
HANDLE hFnt1 = RTPdfGetFont(pdev, "Helvetica", 0, 0, 0, 1, 0);
// create another font for the cell titles
HANDLE hFnt2 = RTPdfGetFont(pdev, "Helvetica-Bold", 0, 0, 0, 1, 0);
// initialize all cell attributes
for (int r = 0; r < rows; r++)
for (int c = 0; c < cols; c++)
{
acReportCell *cell = table.GetCell(r, c);
cell->horzBorders = acReportCell::HorzBorders::acHorzBorderBoth;
cell->font = hFnt1;
cell->pointSize = 11.5f;
cell->titleFont = hFnt2;
cell->titlePointSize = 9.0f;
cell->borderWidth = 10;
// make the first row different from the others
if (r == 0)
{
cell->backColor = RGB(0, 0xAA, 0xFF);
cell->textColor = RGB(0xFF, 0xFF, 0xFF);
}
else
{
cell->vertBorders = acReportCell::VertBorders::acVertBorderBoth;
if (c == cols - 1)
{
// text in last column is right-aligned
cell->horzAlign = acReportCell::HorzAlign::Right;
}
}
}
// merge the cells of the first row and set some text
table.MergeCells(0, 0, cols - 1, 0);
cell = table.GetCell(0, 0);
cell->horzAlign = acReportCell::HorzAlign::HCentered;
cell->SetText("Header Row");
// merge 4 cells and set a background image and a title
table.MergeCells(1, 2, 2, 3);
cell = table.GetCell(2, 1);
cell->horzAlign = acReportCell::HorzAlign::HCentered;
cell->backBmp = GetImageFromFile(pdev, "c:\\temp\\logo.png");
cell->SetTitleText("Image with a title");
// cell with title and long text string clipped to boundaries
cell = table.GetCell(3, 0);
cell->SetTitleText("Title");
cell->SetText("Cell contents clipped to boundaries");
cell->clipToBoundaries = TRUE;
// right-aligned text
cell = table.GetCell(2, cols - 1);
cell->SetText("0.00");
table.Draw(pdev);
HANDLE RTPdfGetFont(LPPDFINFO pdev, const char *szFontName, int bBold, int bItalic, int nCodePage, int bType1, int bCID)
Create a PDF font object and return a handle that can be used to render text on a page RTPdfStartDoc ...
void * HANDLE
Definition: RTPDF-32.h:22
Definition: acTable.h:197
int clipToBoundaries
Definition: acTable.h:334
COLORREF backColor
Definition: acTable.h:292
VertBorders vertBorders
Definition: acTable.h:313
HANDLE backBmp
Definition: acTable.h:287
HANDLE font
Definition: acTable.h:279
HorzAlign horzAlign
Definition: acTable.h:301
HANDLE titleFont
Definition: acTable.h:343
HorzBorders horzBorders
Definition: acTable.h:309
float titlePointSize
Definition: acTable.h:347
int borderWidth
Definition: acTable.h:317
COLORREF textColor
Definition: acTable.h:297
void SetTitleText(LPCSTR lpszTitle)
Set the cell's title.
void SetText(LPCSTR lpszText)
Set the cell's main text content.
float pointSize
Definition: acTable.h:283
Definition: acTable.h:26
int InitTable(UINT nRows, UINT nColumns, const RECT &rcBoundRect)
Initialize a table contains nRows and nColumns and position it on the page. The default row height is...
int SetRowHeight(UINT nRow, UINT nHeight, int bMoveNext)
Set the height of a specific row.
void Draw(HANDLE pdev)
Draw the table on the page. To be called after the table is fully constructed.
int MergeCells(UINT nLeft, UINT nTop, UINT nRight, UINT nBottom)
Merge a group of cells into a single cell.
int SetColWidth(UINT nCol, UINT nWidth, int bMoveNext)
Set the width of a specific column.
acReportCell * GetCell(UINT nRow, UINT nCol, int bReturnMainCell=1)
Get the Cell object from the cell coordinates.
 acTable ()
 
virtual ~acTable ()
 
int InitTable (UINT nRows, UINT nColumns, const RECT &rcBoundRect)
 Initialize a table contains nRows and nColumns and position it on the page. The default row height is set to the height of the table divided by the number of rows. Similarly, the default column (or cell) width is set to the width of the table divided by the number of columns. More...
 
acReportCellGetCell (UINT nRow, UINT nCol, int bReturnMainCell=1)
 Get the Cell object from the cell coordinates. More...
 
int MergeCells (UINT nLeft, UINT nTop, UINT nRight, UINT nBottom)
 Merge a group of cells into a single cell. More...
 
void GetCellsBoundRect (UINT nStartX, UINT nStartY, UINT nEndX, UINT nEndY, RECT &rc)
 Get the bounding rectangle for a group of cells. More...
 
int SetColWidth (UINT nCol, UINT nWidth, int bMoveNext)
 Set the width of a specific column. More...
 
int SetRowHeight (UINT nRow, UINT nHeight, int bMoveNext)
 Set the height of a specific row. More...
 
void Draw (HANDLE pdev)
 Draw the table on the page. To be called after the table is fully constructed. More...
 

Constructor & Destructor Documentation

◆ acTable()

acTable::acTable ( )

◆ ~acTable()

virtual acTable::~acTable ( )
virtual

Member Function Documentation

◆ Draw()

void acTable::Draw ( HANDLE  pdev)

Draw the table on the page. To be called after the table is fully constructed.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit

◆ GetCell()

acReportCell * acTable::GetCell ( UINT  nRow,
UINT  nCol,
int  bReturnMainCell = 1 
)

Get the Cell object from the cell coordinates.

Parameters
nRow0 indexed row of cell to return
nCol0 indexed column of cell to return
bReturnMainCellif 1 return the main cell of a group of merged cells
Returns
acReportCell* Cell object at specified row and column

◆ GetCellsBoundRect()

void acTable::GetCellsBoundRect ( UINT  nStartX,
UINT  nStartY,
UINT  nEndX,
UINT  nEndY,
RECT &  rc 
)

Get the bounding rectangle for a group of cells.

Parameters
nStartX0 indexed column of first cell
nStartY0 indexed row of first cell
nEndX0 indexed column of last cell
nEndY0 indexed row of last cell
rcBounding coordinates of specified cells relative to the origin of the table

◆ InitTable()

int acTable::InitTable ( UINT  nRows,
UINT  nColumns,
const RECT &  rcBoundRect 
)

Initialize a table contains nRows and nColumns and position it on the page. The default row height is set to the height of the table divided by the number of rows. Similarly, the default column (or cell) width is set to the width of the table divided by the number of columns.

Parameters
nRowsNumber of rows
nColumnsNumber of columns
rcBoundRectBounding rectangle
Returns
int 1 if successful, 0 otherwise

◆ MergeCells()

int acTable::MergeCells ( UINT  nLeft,
UINT  nTop,
UINT  nRight,
UINT  nBottom 
)

Merge a group of cells into a single cell.

Parameters
nLeft0 indexed column of first cell
nTop0 indexed row of first cell
nRight0 indexed column of last cell
nBottom0 indexed row of last cell
Returns
int 1 if successful, 0 otherwise

◆ SetColWidth()

int acTable::SetColWidth ( UINT  nCol,
UINT  nWidth,
int  bMoveNext 
)

Set the width of a specific column.

Parameters
nCol0 indexed column to modify
nWidthnew width of column
bMoveNextif 1, the next column is moved to the left or right, if 0 the next column is enlarged or shrinked
Returns
int 1 if successful, 0 otherwise

◆ SetRowHeight()

int acTable::SetRowHeight ( UINT  nRow,
UINT  nHeight,
int  bMoveNext 
)

Set the height of a specific row.

Parameters
nRow0 indexed row to modify
nHeightnew height of row
bMoveNextif 1, the next row is moved up or down, if 0 the next row is enlarged or shrinked
Returns
int 1 if successful, 0 otherwise

The documentation for this class was generated from the following file: