RTPDF-32
PDF Generator Library for RTOS-32
|
#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;
acReportCell *cell;
// 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
// create another font for the cell titles
// 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 ... Definition: acTable.h:197 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... | |
acReportCell * | GetCell (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... | |
acTable::acTable | ( | ) |
|
virtual |
void acTable::Draw | ( | HANDLE | pdev | ) |
Draw the table on the page. To be called after the table is fully constructed.
pdev | Pointer to PDFINFO structure returned by RTPdfInit |
acReportCell * acTable::GetCell | ( | UINT | nRow, |
UINT | nCol, | ||
int | bReturnMainCell = 1 |
||
) |
Get the Cell object from the cell coordinates.
nRow | 0 indexed row of cell to return |
nCol | 0 indexed column of cell to return |
bReturnMainCell | if 1 return the main cell of a group of merged cells |
void acTable::GetCellsBoundRect | ( | UINT | nStartX, |
UINT | nStartY, | ||
UINT | nEndX, | ||
UINT | nEndY, | ||
RECT & | rc | ||
) |
Get the bounding rectangle for a group of cells.
nStartX | 0 indexed column of first cell |
nStartY | 0 indexed row of first cell |
nEndX | 0 indexed column of last cell |
nEndY | 0 indexed row of last cell |
rc | Bounding coordinates of specified cells relative to the origin of the table |
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.
nRows | Number of rows |
nColumns | Number of columns |
rcBoundRect | Bounding rectangle |
int acTable::MergeCells | ( | UINT | nLeft, |
UINT | nTop, | ||
UINT | nRight, | ||
UINT | nBottom | ||
) |
Merge a group of cells into a single cell.
nLeft | 0 indexed column of first cell |
nTop | 0 indexed row of first cell |
nRight | 0 indexed column of last cell |
nBottom | 0 indexed row of last cell |
int acTable::SetColWidth | ( | UINT | nCol, |
UINT | nWidth, | ||
int | bMoveNext | ||
) |
Set the width of a specific column.
nCol | 0 indexed column to modify |
nWidth | new width of column |
bMoveNext | if 1, the next column is moved to the left or right, if 0 the next column is enlarged or shrinked |
int acTable::SetRowHeight | ( | UINT | nRow, |
UINT | nHeight, | ||
int | bMoveNext | ||
) |
Set the height of a specific row.
nRow | 0 indexed row to modify |
nHeight | new height of row |
bMoveNext | if 1, the next row is moved up or down, if 0 the next row is enlarged or shrinked |