📄 cpage.cpp
字号:
if(m_PrtDesc.rc.top > pRegion->bottom)
m_PrtDesc.rc.top=pRegion->bottom;
if(m_PrtDesc.rc.right > pRegion->right)
m_PrtDesc.rc.right=pRegion->right;
ThePrinter.DrawLine(&m_PrtDesc,LineSize);
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a line using parameters passed
// params:CPrintRegion*, position, line size 1--x,flag is pen flags (see header)
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::Line(CPrintRegion* pRegion,double top,double left,double bottom,double right,int LineSize,UINT flag)
{
SaveState();
if(flag != IGNORE_PARAM)
m_PrtDesc.uPenFlags=flag;
ConvertArea(top,left,bottom,right);
m_PrtDesc.rc.top=(int)top+pRegion->FirstY;
m_PrtDesc.rc.bottom=(int)bottom+pRegion->FirstY;
m_PrtDesc.rc.left=(int)left+pRegion->FirstX;
m_PrtDesc.rc.right=(int)right+pRegion->FirstX;
if(m_PrtDesc.rc.bottom > pRegion->bottom)
m_PrtDesc.rc.bottom=pRegion->bottom;
if(m_PrtDesc.rc.left > pRegion->right)
m_PrtDesc.rc.left=pRegion->right;
if(m_PrtDesc.rc.top > pRegion->bottom)
m_PrtDesc.rc.top=pRegion->bottom;
if(m_PrtDesc.rc.right > pRegion->right)
m_PrtDesc.rc.right=pRegion->right;
ThePrinter.DrawLine(&m_PrtDesc,LineSize);
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a rectangle using parameters passed
// params:CPrintRegion*, position, line size 1--x,flag is pen flags (see header)
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::Box(CPrintRegion* pRegion,int top,int left,int bottom,int right,int LineSize,UINT Fillflags,UINT PenFlags)
{
SaveState();
if(Fillflags != IGNORE_PARAM)
m_PrtDesc.uFillFlags=Fillflags;
if(PenFlags != IGNORE_PARAM)
m_PrtDesc.uPenFlags=PenFlags;
m_PrtDesc.rc.top=(int)top+pRegion->FirstY;
m_PrtDesc.rc.bottom=(int)bottom+pRegion->FirstY;
m_PrtDesc.rc.left=(int)left+pRegion->FirstX;
m_PrtDesc.rc.right=(int)right+pRegion->FirstX;
if(m_PrtDesc.rc.bottom > pRegion->bottom)
m_PrtDesc.rc.bottom=pRegion->bottom;
if(m_PrtDesc.rc.left > pRegion->right)
m_PrtDesc.rc.left=pRegion->right;
if(m_PrtDesc.rc.top > pRegion->bottom)
m_PrtDesc.rc.top=pRegion->bottom;
if(m_PrtDesc.rc.right > pRegion->right)
m_PrtDesc.rc.right=pRegion->right;
ThePrinter.DrawRect(&m_PrtDesc,LineSize);
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a rectangle using parameters passed
// params:CPrintRegion*, position, line size 1--x,flag is pen flags (see header)
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::Box(CPrintRegion* pRegion,double top,double left,double bottom,double right,int LineSize,UINT Fillflags,UINT PenFlags)
{
SaveState();
if(Fillflags != IGNORE_PARAM)
m_PrtDesc.uFillFlags=Fillflags;
if(PenFlags != IGNORE_PARAM)
m_PrtDesc.uPenFlags=PenFlags;
ConvertArea(top,left,bottom,right);
m_PrtDesc.rc.top=(int)top+pRegion->FirstY;
m_PrtDesc.rc.bottom=(int)bottom+pRegion->FirstY;
m_PrtDesc.rc.left=(int)left+pRegion->FirstX;
m_PrtDesc.rc.right=(int)right+pRegion->FirstX;
if(m_PrtDesc.rc.bottom > pRegion->bottom)
m_PrtDesc.rc.bottom=pRegion->bottom;
if(m_PrtDesc.rc.left > pRegion->right)
m_PrtDesc.rc.left=pRegion->right;
if(m_PrtDesc.rc.top > pRegion->bottom)
m_PrtDesc.rc.top=pRegion->bottom;
if(m_PrtDesc.rc.right > pRegion->right)
m_PrtDesc.rc.right=pRegion->right;
ThePrinter.DrawRect(&m_PrtDesc,LineSize);
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a checkbox using parameters passed
// params:
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::CheckBox(LPSTR Caption,BOOL Data,double top,double left,int FontSize,int Direction,int LineSize,UINT FillFlag,UINT PrintFlags)
{
ConvertPosition(top,left);
CheckBox(Caption,Data,(int) top,(int)left,FontSize,Direction,LineSize,FillFlag,PrintFlags);
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a checkbox using parameters passed
// params:
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::CheckBox(LPSTR Caption,BOOL Data,int top,int left,int FontSize,int Direction,int LineSize,UINT FillFlag,UINT PrintFlags)
{
SaveState();
if(Direction==LABEL_LEFT)
{
Print(top,left,PrintFlags,FontSize,Caption);
left=(int)GetNextLogicalColumn(FALSE,TRUE);
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
if(Data)
{
if(FillFlag!= FILL_NONE)
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize,FillFlag);
else
{
Line(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
Line(top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left,top,left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
}
}
}
else
{
Print(top,left+(2*ConvertToMappedUnits(FontSize/72.0,HORZRES)),PrintFlags,FontSize,Caption);
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
if(Data)
{
if(FillFlag!= FILL_NONE)
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize,FillFlag);
else
{
Line(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
Line(top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left,top,left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
}
}
}
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a checkbox using parameters passed
// params:
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::CheckBox(CPrintRegion* pRegion,LPSTR Caption,BOOL Data,double top,double left,int FontSize,int Direction,int LineSize,UINT FillFlag,UINT PrintFlags)
{
ConvertPosition(top,left);
CheckBox(pRegion,Caption,Data,(int) top,(int)left,FontSize,Direction,LineSize,FillFlag,PrintFlags);
}
////////////////////////////////////////////////////////////////////////////
// Desc: Draw a checkbox using parameters passed
// params:
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::CheckBox(CPrintRegion* pRegion,LPSTR Caption,BOOL Data,int top,int left,int FontSize,int Direction,int LineSize,UINT FillFlag,UINT PrintFlags)
{
SaveState();
m_PrtDesc.rc.bottom=pRegion->bottom;
m_PrtDesc.rc.right=pRegion->right;
m_PrtDesc.rc.left=pRegion->FirstX;
top+=pRegion->FirstY;
left+=pRegion->FirstX;
if(Direction==LABEL_LEFT)
{
Print(top,left,PrintFlags,FontSize,Caption);
left=(int)GetNextLogicalColumn(FALSE,TRUE);
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
if(Data)
{
if(FillFlag!= FILL_NONE)
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize,FillFlag);
else
{
Line(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
Line(top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left,top,left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
}
}
}
else
{
Print(top,left+(2*ConvertToMappedUnits(FontSize/72.0,HORZRES)),PrintFlags,FontSize,Caption);
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
if(Data)
{
if(FillFlag!= FILL_NONE)
Box(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize,FillFlag);
else
{
Line(top,left,top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
Line(top+ConvertToMappedUnits(FontSize/72.0,VERTRES),left,top,left+ConvertToMappedUnits(FontSize/72.0,HORZRES),LineSize);
}
}
}
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Creates a moveable print region
// params: location of region in 4 points
// Returns: Pointer to the new region or a NULL
///////////////////////////////////////////////////////////////////////////
CPrintRegion* CPage::CreateRegion(double ptop,double pleft,double pbottom, double pright)
{
ConvertArea(ptop,pleft,pbottom,pright);
return CreateRegion((int) ptop,(int) pleft,(int) pbottom, (int) pright);
}
////////////////////////////////////////////////////////////////////////////
// Desc: Create a CprintRegion structure and maintain a list of created structures
// to free allocated memory when destructor runs
// params: bounding rectangle for the region
// Returns: pointer to the created structure
///////////////////////////////////////////////////////////////////////////
CPrintRegion* CPage::CreateRegion(int ptop,int pleft,int pbottom, int pright)
{
CPrintRegion* pRegion= new CPrintRegion;
if(pRegion==NULL)
return pRegion;
if( pRegion->Create(this,ptop,pleft,pright, pbottom)==FALSE)
{
delete pRegion;
return (CPrintRegion*)0;
}
m_RegionList.Add(pRegion);
return pRegion;
}
////////////////////////////////////////////////////////////////////////////
// Desc: Constructor for a table descriptor class
// params:
// Returns:
///////////////////////////////////////////////////////////////////////////
TABLEHEADER::TABLEHEADER()
{
AutoSize=TRUE;
UseInches=FALSE;
PointSize=10;
LineSize=1;
NumColumns=2;
NumRows=2;
Border=TRUE;
VLines=TRUE;
HLines=TRUE;
NoHeader=HeaderOnly=FALSE;
HeaderLines=1;
NumPrintLines=1;
FillFlag=FILL_NONE;
StartRow=EndCol=StartCol=0;
pClsTable=NULL;
}
TABLEHEADER::~TABLEHEADER()
{
if(pClsTable != NULL)
delete pClsTable;
};
////////////////////////////////////////////////////////////////////////////
// Desc: Create and attach a table object to the print object. If the unit
// of measurment is in inches all conversions are done at this point.Once the
// table object is created it is displayed by the call to PrintTable.DO NOT CALL
// PRINTTABLE DIRECTLY ALWAYS USE THIS FUNCTION
// params: The table descriptor for the table
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::Table(TABLEHEADER* TheTable)
{
PRTTYPE temp;
if(TheTable->UseInches)
{
TheTable->StartRow=ConvertToMappedUnits(TheTable->StartRow,VERTRES);
TheTable->StartCol=ConvertToMappedUnits(TheTable->StartCol,HORZRES);
TheTable->EndCol=ConvertToMappedUnits(TheTable->EndCol,HORZRES);
TheTable->EndRow=ConvertToMappedUnits(TheTable->EndRow,VERTRES);
for(int y=0;y < TheTable->NumColumns;++y)
TheTable->ColDesc[y].Width=ConvertToMappedUnits(TheTable->ColDesc[y].Width,HORZRES);
}
// check for horizontal margins
if(TheTable->EndCol > SetRightMargin(0))
return;
// create a table printing object and attach it to the table descriptor
CPrintTable* pTable=new CPrintTable(TheTable,this);
// pTable will be freed when the destructor for Thetable runs
// if you free it early there will be a system crash
TheTable->pClsTable=pTable;
temp=m_PrtDesc;
// print rhe table
pTable->PrintTable();
if(TheTable->UseInches)
TheTable->EndRow=ConvertToInches((int)TheTable->EndRow,VERTRES);
m_PrtDesc=temp;
}
////////////////////////////////////////////////////////////////////////////
// Desc: See CPage::Print () for details
// params: The table row and cloumn to print into, pointsixe textflags and variable arg list
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::Print(TABLEHEADER* TheTable,int row,int col,int PointSize,UINT TextFlags,char* fmt,...)
{
CPrintTable* pTable=TheTable->pClsTable;
if(pTable==NULL)
return;
char* buff=new char[1000];
va_list t;
SaveState();
va_start(t,fmt);
vsprintf(buff,fmt,t);
if(TheTable->HeaderOnly==FALSE)
pTable->InsertItem(buff,row,col,PointSize,TextFlags);
else
pTable->InsertVirtualItem(buff,row,col,PointSize,TextFlags);
va_end(t);
delete[] buff;
m_nNextPos=m_PrtDesc.m_NextCharPos;
RestoreState();
}
////////////////////////////////////////////////////////////////////////////
// Desc: Print a disk based bitmapped imiage to the display
// params: The location in 4 points and full path to the imiage
// Returns:
///////////////////////////////////////////////////////////////////////////
void CPage::PrintBitMap(int top,int left,int bottom,int right,LPCSTR name)
{
extern BOOL WINAPI PrintTheBitMap(PRTTYPE *ps);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -