示例#1
0
/*****************************************************************
 * 
 * method :void	CEasyReport::AtTab(int inTabStop, const char *inText)
 *
 * parameters : inTabStop
 *				char *inText: text to display
 *
 * returns : nothing
 *
 * description: If a tabular section is in place (ie if m_NumDataCols
 * is non-zero, then we assume that this is a text area and we write
 * out a paragraph. If a tabular section is in place, we write the
 * data into the indicated column.
 *
 *
 ****************************************************************/
void	CEasyReport::AtTab(int inTabStop, const char *inText)
{
	CRect	aRect;

	if( m_NumDataCols == 0)
	{
		WriteParagraph(inText);
	}
	else
	{
		if( m_RedrawTblHdr )
		{
			if( m_DataTop + m_TableHeadingHt + GetDataFontSize().cy > (GetBottomEdge() - m_PageFtrHt) )
				EjectPage(false);
			if( !m_RepeatTblHdr )
				WriteTableHeader();
			m_RedrawTblHdr = false;
		}
		SetupRectForCol(inTabStop, aRect);

		CTextBox	*aBox = new CTextBox(&aRect,inText,eDataFont);
		aBox->SetDocPtr(this);

		ASSERT( inTabStop < m_NumDataCols);
		switch( m_DataCols[inTabStop].m_align)
		{
			case CColInfo::eLeft:
				aBox->SetAlign(DT_LEFT);
				break;
			case CColInfo::eDecimal:
			case CColInfo::eRight:

				// for fixed width fonts, if you control the format of data, then
				// simply aligning the text right aligns the decimal places. For 
				// propotional fonts, you will have to adjust the left edge of
				// the box.

				aBox->SetAlign(DT_RIGHT);
				break;
			case CColInfo::eCenter:
				aBox->SetAlign( DT_CENTER );
				break;
		}
		m_ReportItems.Add( aBox );
	}
}
示例#2
0
/*****************************************************************
 * 
 * method :void	CEasyReport::WriteTableHeader(void)
 *
 * parameters : 
 *
 * returns : 
 *
 * description: If a tabular section is in place, write the table
 * header.
 *
 ****************************************************************/
void	CEasyReport::WriteTableHeader(void)
{
	int		i;
	CRect	aRect;

	m_RedrawTblHdr = false;
	aRect.top = aRect.bottom = m_DataTop;
	aRect.bottom += m_TableHeadingHt;
	aRect.left= m_LeftMargin;
	for(i=0;i < m_NumDataCols; i++)
	{
		CColInfo	*aCol = m_DataCols+i;
		aRect.right = aRect.left + aCol->m_CharCount * m_TextSizes[eDataFont].cx;
		CTextBox	*aBox = new CTextBox(&aRect, aCol->m_Heading, eColHeadingFont);
		switch( aCol->m_align)
		{
			case CColInfo::eLeft:
				aBox->SetAlign(DT_LEFT);
				break;
			case CColInfo::eDecimal:
			case CColInfo::eRight:

				// for fixed width fonts, if you control the format of data, then
				// simply aligning the text right aligns the decimal places. For 
				// propotional fonts, you will have to adjust the left edge of
				// the box. Decimal cols will be supported in a later version

				aBox->SetAlign(DT_RIGHT);
				break;
			case CColInfo::eCenter:
				aBox->SetAlign( DT_CENTER );
				break;
		}

		aBox->SetDocPtr(this);
		m_ReportItems.Add(aBox);
		aRect.left = aRect.right;
	}
	m_DataTop += m_TableHeadingHt;
}