示例#1
0
/*****************************************************************
 * 
 * method :void		WritePageHeader(CRect inRect)
 *
 * parameters : 
 *
 * returns : 
 *
 * description: Write the default page header. By default, this
 * contains the report title (centered) and date field, 
 * right aligned
 *
 ****************************************************************/
void	CEasyReport::WritePageHeader(CRect inRect)
{
	CRect		aRect(inRect);
	CTextBox	*aBox;

	aRect.bottom = aRect.top + GetHeadingFontSize().cy;
	aBox = new CTextBox(&aRect,m_ReportTitle,eColHeadingFont);
	aBox->SetDocPtr(this);
	m_ReportItems.Add(aBox);

	// make a text area 1/4 of the page width
	aRect.right = inRect.right;
	aRect.left = inRect.right - inRect.Width()/4;
	aBox = new CTextBox(&aRect, m_ReportDate, eColHeadingFont, DT_LEFT);
	aBox->SetDocPtr(this);
	m_ReportItems.Add(aBox);

	aRect.top = inRect.bottom-10;	// 1mm from the bottom
	aRect.bottom = inRect.bottom;
	aRect.left = inRect.left;
	aRect.right = inRect.right;
	CHline	*aLine = new CHline(&aRect,0);
	aLine->SetDocPtr(this);
	m_ReportItems.Add(aLine);
}
示例#2
0
/*****************************************************************
 * 
 * method :void		WriteReportHeader(CRect inRect)
 *
 * parameters : 
 *
 * returns : 
 *
 * description: Write the default report header, which is a 
 * simply the CompanyName centered across the page. You might 
 * want to add the address, etc.
 *
 ****************************************************************/
void	CEasyReport::WriteReportHeader(CRect inRect)
{
	CTextBox	*aBox = new CTextBox(&inRect, m_CompanyName, eCaptionFont, DT_CENTER);
	aBox->SetDocPtr(this);
	m_ReportItems.Add(aBox);

}
示例#3
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 );
	}
}
示例#4
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;
}
示例#5
0
/*****************************************************************
 * 
 * method :void		WriteParagraph(const char *inText)
 *
 * parameters : inText: Long text which may be word wrapped
 *
 * returns : nothing
 *
 * description: Write a paragraph of text. If the text extends 
 * beyond the right edge, the text is wrapped around. Note: This 
 * function is not called directly, but through AtTab with tabs
 * set to NULL.
 *
 ****************************************************************/
void	CEasyReport::WriteParagraph(const char *inText)
{
	int			aAbsBottom, aAbsWidth;
	int			aCurPos, aLen, aRight;
	char		aTempStr[128];	// non portable (should be TCHAR etc)!
	CRect		aRect;
	CSize		aSize;
	CTextBox	*aBox;
	
	aRect.left = m_LeftMargin;
	aRect.right = m_PageWidth - m_RightMargin;

	aAbsBottom = m_PageHeight - ( m_BottomMargin + m_PageFtrHt );
	aAbsWidth = m_PageWidth - ( m_LeftMargin + m_RightMargin);

	aLen = strlen(inText);
	aCurPos = 0;
	::SelectObject(m_PrinterDC,(HFONT)m_Fonts[eTextFont]);
	::SetTextCharacterExtra(m_PrinterDC,0);
	while(inText[aCurPos])
	{
		if( m_DataTop + m_TextSizes[eTextFont].cy > aAbsBottom )
		{
			EjectPage(false);
			aAbsBottom = m_PageHeight - ( m_BottomMargin + m_PageFtrHt );
		}

		// see if the remainder of the string will fit into the right margin
		::SetTextJustification(m_PrinterDC,0,0);
		::GetTextExtentExPoint(m_PrinterDC, inText + aCurPos, aLen - aCurPos, aAbsWidth, &aRight,NULL, &aSize);

		if( inText[aCurPos+aRight] != 0 )
		{
			while( inText [aCurPos + aRight ] != m_BreakChar )
			{
				--aRight;
				if( aRight <= 0 )
				{
					// Hopeless, the entire string is one big word !
					::GetTextExtentExPoint(m_PrinterDC, inText + aCurPos, aLen - aCurPos, aAbsWidth, &aRight,NULL, &aSize);
					--aRight;
					break;
				}
			}
		}

		ASSERT(aRight < sizeof(aTempStr));	// Warning ! this check is at compile time only !
		strncpy( aTempStr, inText + aCurPos, aRight);
		aTempStr[aRight] = 0;

		aRect.top = m_DataTop;
		aRect.bottom = aRect.top + m_TextSizes[eTextFont].cy;
		aBox = new CTextBox(&aRect, aTempStr, eTextFont);
		aBox->SetDocPtr( this );
		m_ReportItems.Add(aBox);
		if( inText[ aCurPos + aRight] == m_BreakChar)
			++aRight;
		aCurPos += aRight;
		m_DataTop += m_TextSizes[eTextFont].cy;
	}
}