I would like to hold an array of integers in my struct
struct HPDF_TableAttributes
{
HPDF_REAL rows;
HPDF_REAL cols;
HPDF_REAL rowH;
HPDF_REAL colW;
HPDF_REAL tabX;
HPDF_REAL tabY;
HPDF_REAL tabH;
HPDF_REAL tabW;
HPDF_Font font;
HPDF_REAL fontSize;
int colRatios[]; /// HERE
};
It seems not matter how I do it, the compiler wishes me to to initialize it here? Must I do that? I am trying to do something along the lines of the following for usage.
HPDFTableAttributes oTACent;
oTACent.rows = 3; oTACent.cols = 3;
oTACent.rowH = 20; oTACent.colW = pageWidth-70/oTACent.cols;
oTACent.tabH = oTACent.rows * oTACent.rowH;
oTACent.tabW = oTACent.cols * oTACent.colW;
oTACent.tabX = 35; oTACent.tabY = pageHeight - oTACent.tabH - 45;
oTACent.font = fontTimesBold; oTACent.fontSize = 20;
oTACent.colRatios = [1, 1, 2]; /// HERE
Then I send these attributes to my function which makes me a table and uses the ratio of the values in this integer array to space columns along the same lines.
void CReport::putTableOnPdf(HPDF_Page page, HPDFTableAttributes tabAtt, array_2d<CString> tabDat)
{
// Table Outline
HPDF_Page_SetLineWidth (page, 1);
HPDF_Page_Rectangle (page, tabAtt.tabX, tabAtt.tabY, tabAtt.tabW, tabAtt.tabH);
// Table row lines
HPDF_REAL rowsPut = 0;
while(rowsPut < tabAtt.rows)
{
rowsPut++;
HPDF_Page_MoveTo (page, tabAtt.tabX, tabAtt.tabY + rowsPut*tabAtt.rowH);
HPDF_Page_LineTo (page, tabAtt.tabX + tabAtt.tabW, tabAtt.tabY + rowsPut*tabAtt.rowH);
}
// Table col lines
/*int colRatioSum = 0;
for(int i = 0; i < tabAtt.colRatios.length; i++)
colRatioSum += tabAtt.colRatios[i];
tabAtt.colW = tabAtt.colW / colRatioSum;*/ /// HERE
HPDF_REAL colsPut = 0;
while(colsPut < tabAtt.cols)
{
colsPut++;
HPDF_Page_MoveTo (page, tabAtt.tabX + colsPut*tabAtt.colW, tabAtt.tabY);
HPDF_Page_LineTo (page, tabAtt.tabX + colsPut*tabAtt.colW, tabAtt.tabY + tabAtt.tabH);
}
HPDF_Page_Stroke (page);
}