📄 vmreportpage.cpp
字号:
return( m_PrtDesc.pDC->SetTextColor( Color ) );
}
/* End of function "VMPage::SetColor"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::SetBackColor
DESCRIPTION: Sets The text Color if the device supports colored text
INPUT: Color - The color
OUTPUT: none
RETURNS: The old color
*/
COLORREF VMPage::SetBackColor( COLORREF Color )
{
return( m_PrtDesc.pDC->SetBkColor( Color ) );
}
/* End of function "VMPage::SetBackColor"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::SetFontSize
DESCRIPTION: changes the default font size
INPUT: sz - the new size
OUTPUT: none
RETURNS: the old size
*/
int VMPage::SetFontSize( int sz )
{
int temp = m_PrtDesc.PointSize;
m_PrtDesc.PointSize = sz / m_dblZoomFactor;
return( temp );
}
/* End of function "VMPage::SetFontSize"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::GetDisplayContext
DESCRIPTION: fetch the display context used by this object
INPUT: void
OUTPUT: none
RETURNS: a pointer to the display context
*/
CDC* VMPage::GetDisplayContext( void )
{
return m_PrtDesc.pDC;
}
/* End of function "VMPage::GetDisplayContext"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::GetNextLogicalColumn
DESCRIPTION: returns the next logical print column. Used in printing
continious text that may have different text attributes
INPUT: Convert - flag to indicate conversion to inches.
AddOffset - flag add a extra space.
OUTPUT:
RETURNS: the logical column offset.double is used so it can handle
all mapping units. If Convert is true the result is in
inches else in device units.
*/
double VMPage::GetNextLogicalColumn( BOOL Convert,BOOL AddOffset )
{
if ( Convert == FALSE )
{
if ( AddOffset )
{
return( m_nNextPos + tm.tmMaxCharWidth );
}
else
{
return( m_nNextPos );
}
}
else
{
if ( AddOffset )
{
return( ConvertToInches( m_nNextPos + tm.tmMaxCharWidth, HORZRES ) );
}
else
{
return( ConvertToInches( m_nNextPos, HORZRES ) );
}
}
}
/* End of function "VMPage::GetNextLogicalColumn"
/*****************************************************************************/
///////////////////////////////////////////////////////////////////////////////
//
// U N I T C O N V E R S I O N R O U T I N E S
//
///////////////////////////////////////////////////////////////////////////////
/*
conversion is done as follows:
mapmode = MM_TEXT;
The number of inches are multiplied by the constant for the # of pixels per inch
in the dimension requested. The value(s) for the # of pixels are set at creation
of the object and are retrieved from the GetDevCaps function
mapmode = MM_ANISOTROPIC:
The size in inches for the requested dimension are devided by 1000 to get the
size in inches for each unit. This value is divided into the requested size
to return the physical offset, for example:
width of display is 10 inches
10 / 1000= .01
To go three inches to the right 3.0 / .01 = 300 logical units
height of display is 12 inches
12 / 1000 = .012
To move 5 inches down 5.0 / .012 = 417 logical units
NOTES:
These conversion routines attempt to normalize positioning between the two allowed
mapping modes but are not exact due to cumalitive rounding errors.While in MM_TEXT
mode the units will be much smaller than in MM_ANISOTROPIC mode and therefore the
class can position the text with a much finer position. When in ANISOTROPIC mode
the smallest unit can be as much as 2.8 pixels per unit resulting in small but
noticable differences in positioning
*/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::ConvertToMappedUnits
DESCRIPTION: Converts inches to physical units based on the mapping mode
INPUT: dwInch - the number of inches
bWidth - either VERTRES or HORTZRES
OUTPUT:
RETURNS: the physical device displacment representing the number
of inches
*/
int VMPage::ConvertToMappedUnits( double dwInch, int bWidth )
{
double tempx;
double tempy;
if ( dwInch <= 0 )
{
return( 0 );
}
if ( m_PrtDesc.pDC->GetMapMode() == MM_TEXT )
{
if ( bWidth == HORZRES )
{
return( (int)( dwInch * m_PixPerInchX ) );
}
else
{
return( (int)( dwInch * m_PixPerInchY ) );
}
}
tempx = m_WidthInches / m_PrtDesc.n_maxWidth;
tempy = m_LengthInches / m_PrtDesc.n_maxLength;
if ( bWidth == HORZRES )
{
return( (int)( dwInch / tempx ) );
}
else
{
return( (int)( dwInch/tempy ) );
}
}
/* End of function "VMPage::ConvertToMappedUnits"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::ConvertToInches
DESCRIPTION: Converts physical device units to inches
INPUT: value - the # of physical units to convert
bWidth - HORZRES or VERTRES
OUTPUT:
RETURNS: The number of inches defined by the displacment
*/
double VMPage::ConvertToInches( int value, int bWidth )
{
double tempx;
double tempy;
if ( value <= 0 )
{
return( 0 );
}
if ( m_PrtDesc.pDC->GetMapMode() == MM_TEXT )
{
if ( bWidth == HORZRES )
{
return( (double)value / (double)m_PixPerInchX );
}
else
{
return( (double)value / (double)m_PixPerInchY );
}
}
tempx = m_WidthInches / (double)m_PrtDesc.n_maxWidth;
tempy = m_LengthInches / (double)m_PrtDesc.n_maxLength;
if ( bWidth == HORZRES )
{
return( (double)( value * tempx ) );
}
else
return( (double)( value * tempy ) );
}
/* End of function "VMPage::ConvertToInches"
/*****************************************************************************/
///////////////////////////////////////////////////////////////////////////////
//
// C O N V E R S I O N R O U T I N E S -->> P I X E L S T O I N C H E S
//
///////////////////////////////////////////////////////////////////////////////
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::ConvertPosition
DESCRIPTION: Converts a position in inches to logical units
INPUT: Row - same as rect.top
Col - same as rect.left
OUTPUT:
RETURNS: none but parameters are changed indirectly
*/
void VMPage::ConvertPosition( double& Row, double& Col )
{
Row = ConvertToMappedUnits( Row, VERTRES );
Col = ConvertToMappedUnits( Col, HORZRES );
}
/* End of function "VMPage::ConvertPosition"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::ConvertArea
DESCRIPTION: same as above but does the whole rectangle at once
INPUT: top -
left -
bottom -
right -
OUTPUT:
RETURNS: void -
*/
void VMPage::ConvertArea( double& top, double& left, double& bottom, double& right )
{
top = ConvertToMappedUnits( top, VERTRES );
left = ConvertToMappedUnits( left, HORZRES );
bottom = ConvertToMappedUnits( bottom, VERTRES );
right = ConvertToMappedUnits( right, HORZRES );
}
/* End of function "VMPage::ConvertArea"
/*****************************************************************************/
///////////////////////////////////////////////////////////////////////////////
//
// T E X T P R I N T R O U T I N E S
//
///////////////////////////////////////////////////////////////////////////////
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::Print
DESCRIPTION: Very low level call. All Print Routines end up here.
Do not call directly
INPUT: Text - the text to print
StartPos - tarting column
flags -
PointSize -
OUTPUT:
RETURNS: The next logical vertical print position
*/
int VMPage::Print( LPCSTR Text, int StartPos, UINT flags, int PointSize )
{
if ( StartPos > SetRightMargin( 0 ) )
{
return( m_PrtDesc.rc.top );
}
if ( m_PrtDesc.rc.top > SetBottomMargin( 0 ) )
{
return( m_PrtDesc.rc.top );
}
//m_PrtDesc.rc.left+=MarginOffset;
m_PrtDesc.Text = Text;
if ( PointSize > 0 )
{
m_PrtDesc.PointSize = PointSize / m_dblZoomFactor;
}
if ( flags != IGNORE_PARAM )
{
m_PrtDesc.uTextFlags = flags;
}
if ( StartPos == -1 )
{
m_PrtDesc.rc.left = m_PrtDesc.m_NextCharPos;
}
else
{
m_PrtDesc.rc.left = StartPos;
}
ThePrinter.PrintText( &m_PrtDesc, m_Spacing );
m_nNextPos = m_PrtDesc.m_NextCharPos;
return( m_PrtDesc.LastPrintArea.bottom );
}
/* End of function "VMPage::Print"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::Print
DESCRIPTION: Prints using printf variable length print arguments
INPUT: row - location in logical units
col - location in logical units
fmt - format string for arguments
... - arguments
OUTPUT:
RETURNS: The next logical print line using the current font
size and line spacing
*/
int VMPage::Print( int row, int col, const char* fmt, ... )
{
va_list t;
va_start( t, fmt );
vsprintf( Buffer, fmt, t );
m_PrtDesc.rc.top = row;
int res = Print( Buffer, col, m_PrtDesc.uTextFlags, m_PrtDesc.PointSize );
va_end( t );
int nLineSpacing = m_Spacing > 1
? (int)( ConvertToMappedUnits( m_PrtDesc.PointSize / 72.0, VERTRES ) * ( m_Spacing - 1 ) )
: 0;
return( res + nLineSpacing );
}
/* End of function "VMPage::Print"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::Print
DESCRIPTION: Prints using printf variable length print arguments
INPUT: row - location in inches
col - location in inches
fmt - format string for arguments
... - arguments
OUTPUT:
RETURNS: The next print line location in inches using the current
font size and line spacing
*/
double VMPage::Print( double row, double col, const char* fmt, ... )
{
va_list t;
va_start( t, fmt );
vsprintf( Buffer, fmt, t );
ConvertPosition( row, col );
m_PrtDesc.rc.top = (int)row;
int res = Print( Buffer,(int)col, m_PrtDesc.uTextFlags, m_PrtDesc.PointSize );
va_end( t );
int nLineSpacing = m_Spacing > 1
? (int)( ConvertToMappedUnits( m_PrtDesc.PointSize / 72.0, VERTRES ) * ( m_Spacing -1 ) )
: 0;
return( ConvertToInches( res + nLineSpacing, VERTRES ));
}
/* End of function "VMPage::Print"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::Print
DESCRIPTION: Prints using data supplied as return value from user function
INPUT: row - Location Coordinates in logical units
col - Location Coordinates in logical units
ID - ID to be supplied to user function
OUTPUT:
RETURNS: The next logical print line using the current font size
and line spacing
*/
int VMPage::Print( int row, int col, int ID )
{
if ( pUserFunc == NULL )
{
return( 0 );
}
m_PrtDesc.rc.top = row;
int res = Print( pUserFunc( ID ), col, m_PrtDesc.uTextFlags, m_PrtDesc.PointSize );
int nLineSpacing = m_Spacing > 1
? (int)( ConvertToMappedUnits( m_PrtDesc.PointSize / 72.0, VERTRES ) * ( m_Spacing - 1 ) )
: 0;
return( res + nLineSpacing );
}
/* End of function "VMPage::Print"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: VMPage::Print
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -