www.pudn.com > DrawGrInDlg.rar > BaseGr.cpp
// BaseGr.cpp: implementation of the CBaseGr class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "BaseGr.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBaseGr::CBaseGr()
{
XName = _T("");
YName = _T("");
YMin = 0;
YMax = 100;
XMin = 0;
XMax = 100;
Title = _T("");
}
CBaseGr::~CBaseGr()
{
}
void CBaseGr::DrawLine(CDC* pDC,POINT FromPoint,POINT ToPoint,int LineSize,COLORREF LineColor)
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->MoveTo(FromPoint);
pDC->LineTo(ToPoint);
pDC->SelectObject(pOldPen);
}
void CBaseGr::DrawDashLine(CDC* pDC,POINT FromPoint,POINT ToPoint,int LineSize,COLORREF LineColor)
{
CPen pen(PS_DASH, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->MoveTo(FromPoint);
pDC->LineTo(ToPoint);
pDC->SelectObject(pOldPen);
}
void CBaseGr::DrawLine(CDC* pDC,int fpx,int fpy,int tpx,int tpy,int LineSize,COLORREF LineColor)
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->MoveTo(fpx,fpy);
pDC->LineTo(tpx,tpy);
pDC->SelectObject(pOldPen);
}
void CBaseGr::DrawDashLine(CDC* pDC,int fpx,int fpy,int tpx,int tpy,int LineSize,COLORREF LineColor)
{
CPen pen(PS_DASH, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->MoveTo(fpx,fpy);
pDC->LineTo(tpx,tpy);
pDC->SelectObject(pOldPen);
}
void CBaseGr::DrawRectangle(CDC* pDC,POINT LeftTop,POINT RightBottom,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
// Draw with a thick blue pen.
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
// And a solid red brush.
CBrush brush(FillColor);
CBrush* pOldBrush = pDC->SelectObject(&brush);
pDC->Rectangle(LeftTop.x,LeftTop.y,RightBottom.x,RightBottom.y);
// Put back the old objects.
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
void CBaseGr::DrawRectangle(CDC* pDC,int LeftTopx,int LeftTopy,int RightBottomx,int RightBottomy,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
// And a solid red brush.
CBrush brush(FillColor);
CBrush* pOldBrush = pDC->SelectObject(&brush);
pDC->Rectangle(LeftTopx,LeftTopy,RightBottomx,RightBottomy);
// Put back the old objects.
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
void CBaseGr::DrawPolygon(CDC* pDC,LPPOINT lpPoints,int nPointCounts,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
CBrush brush(FillColor);
CBrush* pOldBrush = pDC->SelectObject(&brush);
pDC->Polygon(lpPoints,nPointCounts);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
void CBaseGr::DrawArc(CDC* pDC,POINT pCoC,int nRadius,double AngleS,double AngleE,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
/***************************************
起始角度:dAngleS
终止角度: dAngleE
半径 : nRadius
圆点 : pCoc
起始坐标: PointS
终止坐标: PointE
基准坐标: PointBase
***************************************/
DrawArc(pDC,pCoC.x,pCoC.y,nRadius,AngleS,AngleE,LineSize,LineColor,FillColor);
}
void CBaseGr::DrawArc(CDC* pDC,int pCoCx,int pCoCy,int nRadius,double AngleS,double AngleE,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
/***************************************
起始角度:dAngleS
终止角度: dAngleE
半径 : nRadius
圆点 : pCocx,pCocy
起始坐标: PointS
终止坐标: PointE
基准坐标: PointBase
***************************************/
POINT PointS,PointE,PointBase;
PointBase.x = pCoCx - nRadius;
PointBase.y = pCoCy;
if(AngleS > AngleE)
{
double conv = AngleS;
AngleS = AngleE;
AngleE = conv;
}
PointS.x = pCoCx + (int)(nRadius*cos(AngleS) + 0.5);
PointS.y = pCoCy + (int)(nRadius*sin(AngleS) + 0.5);
PointE.x = pCoCx + (int)(nRadius*cos(AngleE) + 0.5);
PointE.y = pCoCy + (int)(nRadius*sin(AngleE) + 0.5);
double AngleTmp = AngleS;
double DetaAngle = PI/180;
int nCount = (int)((AngleE - AngleS)/DetaAngle + 0.5);
CPoint *ArcP = new CPoint[nCount+2];
(*(ArcP+0)).x = pCoCx;
(*(ArcP+0)).y = pCoCy;
int i = 1;
while(AngleTmp <= AngleE)
{
(*(ArcP+i)).x = pCoCx + (int)(nRadius*cos(AngleTmp) + 0.5);
(*(ArcP+i)).y = pCoCy + (int)(nRadius*sin(AngleTmp) + 0.5);
AngleTmp += DetaAngle;
i++;
}
(*(ArcP+nCount)) = PointE;
(*(ArcP+nCount+1)) = (*(ArcP+0));
DrawPolygon(pDC,ArcP,nCount+2,LineSize,LineColor,FillColor);
delete []ArcP;
}
void CBaseGr::DrawColumn(CDC* pDC,int LeftTopx,int LeftTopy,int RightBottomx,int RightBottomy,int Height,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
CBrush brush(FillColor);
CBrush* pOldBrush = pDC->SelectObject(&brush);
pDC->Rectangle(LeftTopx,LeftTopy+(RightBottomy-LeftTopy)/2,RightBottomx,LeftTopy+(RightBottomy-LeftTopy)/2+Height);
pDC->Ellipse(LeftTopx,LeftTopy,RightBottomx,RightBottomy);
pDC->Ellipse(LeftTopx,LeftTopy+Height,RightBottomx,RightBottomy+Height);
//Redraw ellipse
CPen PenWhite(PS_SOLID,LineSize,FillColor);
pOldPen = pDC->SelectObject(&PenWhite);
pDC->Ellipse(LeftTopx+LineSize,LeftTopy+Height-LineSize,RightBottomx-LineSize,RightBottomy+Height-LineSize);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
void CBaseGr::DrawCub(CDC* pDC,int Face1x,int Face1y,int Face2x,int Face2y,int Height,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
if(Face1x > Face2x)
{
int tmp = Face1x;
Face1x = Face2x;
Face2x = tmp;
}
CPoint pts[4];
//Draw Face
pts[0].x = Face1x;
pts[0].y = Face1y;
pts[1].x = Face2x;
pts[1].y = Face2y;
pts[2].x = Face2x;
pts[2].y = Face2y+Height;
pts[3].x = Face1x;
pts[3].y = Face1y+Height;
DrawPolygon(pDC,pts,4,LineSize,LineColor,FillColor);
//Draw Top
pts[0].x = Face1x + (Face2x-Face1x)/2;
pts[0].y = Face1y - (Face2x-Face1x)/2;
pts[1].x = Face2x + (Face2x-Face1x)/2;
pts[1].y = Face2y - (Face2x-Face1x)/2;
pts[2].x = Face2x;
pts[2].y = Face2y;
pts[3].x = Face1x;
pts[3].y = Face1y;
DrawPolygon(pDC,pts,4,LineSize,LineColor,FillColor);
//Draw Right
pts[0].x = Face2x;
pts[0].y = Face2y;
pts[1].x = Face2x + (Face2x-Face1x)/2;
pts[1].y = Face2y - (Face2x-Face1x)/2;
pts[2].x = Face2x + (Face2x-Face1x)/2;
pts[2].y = Face2y - (Face2x-Face1x)/2 + Height;
pts[3].x = Face2x;
pts[3].y = Face2y + Height;
DrawPolygon(pDC,pts,4,LineSize,LineColor,FillColor);
}
void CBaseGr::DrawPoint(CDC* pDC,int x,int y,PointType Mode,int Radius,int LineSize,COLORREF LineColor,COLORREF FillColor)
{
switch(Mode)
{
case CIRCLE:
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
CBrush BrushWhite(RGB(255,255,255));
CBrush* pOldBrush = pDC->SelectObject(&BrushWhite);
pDC->Ellipse(x-Radius,y-Radius,x+Radius,y+Radius);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
break;
case RECTANGLE:
{
DrawRectangle(pDC,x-Radius,y-Radius,x+Radius,y+Radius,LineSize,LineColor);
}
break;
case DIAMOND:
{
CPoint Diamonds[4];
Diamonds[0].x = x-Radius;
Diamonds[0].y = y;
Diamonds[1].x = x;
Diamonds[1].y = y-Radius;
Diamonds[2].x = x+Radius;
Diamonds[2].y = y;
Diamonds[3].x = x;
Diamonds[3].y = y+Radius;
DrawPolygon(pDC,Diamonds,4,LineSize,LineColor);
}
break;
case TRIANGLE:
{
CPoint Triangles[3];
Triangles[0].x = x;
Triangles[0].y = y-Radius;
Triangles[1].x = x+Radius;
Triangles[1].y = y+Radius;
Triangles[2].x = x-Radius;
Triangles[2].y = y+Radius;
DrawPolygon(pDC,Triangles,3,LineSize,LineColor);
}
break;
case FCIRCLE:
{
CPen pen(PS_SOLID, LineSize, LineColor);
CPen* pOldPen = pDC->SelectObject(&pen);
CBrush Brush(FillColor);
CBrush* pOldBrush = pDC->SelectObject(&Brush);
pDC->Ellipse(x-Radius,y-Radius,x+Radius,y+Radius);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
break;
case FRECTANGLE:
{
DrawRectangle(pDC,x-Radius,y-Radius,x+Radius,y+Radius,LineSize,LineColor,FillColor);
}
break;
case FDIAMOND:
{
CPoint Diamonds[4];
Diamonds[0].x = x-Radius;
Diamonds[0].y = y;
Diamonds[1].x = x;
Diamonds[1].y = y-Radius;
Diamonds[2].x = x+Radius;
Diamonds[2].y = y;
Diamonds[3].x = x;
Diamonds[3].y = y+Radius;
DrawPolygon(pDC,Diamonds,4,LineSize,LineColor,FillColor);
}
break;
case FTRIANGLE:
{
CPoint Triangles[3];
Triangles[0].x = x;
Triangles[0].y = y-Radius;
Triangles[1].x = x+Radius;
Triangles[1].y = y+Radius;
Triangles[2].x = x-Radius;
Triangles[2].y = y+Radius;
DrawPolygon(pDC,Triangles,3,LineSize,LineColor,FillColor);
}
break;
case FIRE:
DrawLine(pDC,x-Radius,y-Radius,x+Radius,y+Radius,LineSize,LineColor);
DrawLine(pDC,x-Radius,y+Radius,x+Radius,y-Radius,LineSize,LineColor);
DrawLine(pDC,x-Radius,y,x+Radius,y,LineSize,LineColor);
DrawLine(pDC,x,y-Radius,x,y+Radius,LineSize,LineColor);
break;
case CROSS:
DrawLine(pDC,x-Radius,y,x+Radius,y,LineSize,LineColor);
DrawLine(pDC,x,y-Radius,x,y+Radius,LineSize,LineColor);
break;
case XCROSS:
DrawLine(pDC,x-Radius,y-Radius,x+Radius,y+Radius,LineSize,LineColor);
DrawLine(pDC,x-Radius,y+Radius,x+Radius,y-Radius,LineSize,LineColor);
break;
}
}
void CBaseGr::DrawCoordinate(CDC* pDC,int LeftTopx,int LeftTopy,int RightBottomx,int RightBottomy,BOOL WithDash)
{
}
void CBaseGr::SetLegend(CString Name,double Value,COLORREF FillColor,PointType GraphMode,int LineSize,COLORREF LineColor)
{
Legend Legend;
Legend.Name = Name;
Legend.Value = Value;
Legend.Graph.FillColor = FillColor;
Legend.Graph.GraphMode = GraphMode;
Legend.Graph.LineColor = LineColor;
Legend.Graph.LineSize = LineSize;
m_Legend.Add(Legend);
}
void CBaseGr::DrawYCoordinateValue(CDC* pDC,int Startx,int Starty,CString Value,Align Mode,COLORREF FontColor)
{
CFont m_font;
m_font.CreateFont(
-12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
CFont *pOldFont = pDC->SelectObject(&m_font);
pDC->SetTextColor(FontColor);
// DrawText(pDC->GetSafeHdc(),Value,-1,&rcString,DT_RIGHT | DT_SINGLELINE);
pDC->ExtTextOut(Startx,Starty,ETO_OPAQUE,NULL,Value,NULL);
pDC->SelectObject(pOldFont);
}
void CBaseGr::DrawYName(CDC* pDC,int Startx,int Starty,CString Value,Align Mode,COLORREF FontColor)
{
CFont m_font;
m_font.CreateFont(
-12, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
CFont *pOldFont = pDC->SelectObject(&m_font);
pDC->SetTextColor(FontColor);
// DrawText(pDC->GetSafeHdc(),Value,-1,&rcString,DT_RIGHT | DT_SINGLELINE);
pDC->ExtTextOut(Startx,Starty,ETO_OPAQUE,NULL,Value,NULL);
pDC->SelectObject(pOldFont);
}
/*
void CBaseGr::DrawXCoordinate(CDC* pDC,int LeftTopx,int LeftTopy,int RightBottomx,int RightBottomy,GraphType Mode,Align AlignMode,BOOL WithDash)
{
switch(Mode)
{
case LINE:
break;
case BAR:
{
int nXDeta = (RightBottomx-LeftTopx)/(m_Legend.GetSize()+1);
for(int i=1;i<=m_Legend.GetSize();i++)
{
if(m_Legend.GetAt(i-1).Value > YMax)
{
Legend LegendTmp = m_Legend.GetAt(i-1);
LegendTmp.Value = YMax;
m_Legend.SetAt(i-1,LegendTmp);
}
if(m_Legend.GetAt(i-1).Value < YMin)
{
Legend LegendTmp = m_Legend.GetAt(i-1);
LegendTmp.Value = YMin;
m_Legend.SetAt(i-1,LegendTmp);
}
if(WithDash)
DrawDashLine(pDC,LeftTopx+nXDeta*i,RightBottomy,LeftTopx+nXDeta*i,LeftTopy);
int Height = ((int)(m_Legend.GetAt(i-1).Value+0.5)-YMin)*(RightBottomy-LeftTopy)/(YMax-YMin);
DrawRectangle(pDC,LeftTopx+nXDeta*i-nXDeta/2+1,RightBottomy-Height,LeftTopx+nXDeta*i+nXDeta/2-1,RightBottomy,m_Legend.GetAt(i-1).Graph.LineSize,m_Legend.GetAt(i-1).Graph.LineColor,m_Legend.GetAt(i-1).Graph.FillColor);
switch(AlignMode)
{
case LEFT:
case RIGHT:
case NONE:
break;
case TOP:
if(nXDeta < 12*m_Legend.GetAt(i-1).Name.GetLength())
DrawXCoordinateValue(pDC,LeftTopx+nXDeta*i-nXDeta/2+2,RightBottomy-Height-1,m_Legend.GetAt(i-1).Name,HOR);
else
DrawXCoordinateValue(pDC,LeftTopx+nXDeta*i-nXDeta/2+2,RightBottomy-Height-15,m_Legend.GetAt(i-1).Name);
break;
case BOTTOM:
DrawXCoordinateValue(pDC,LeftTopx+nXDeta*i-nXDeta/2+2,RightBottomy+15,m_Legend.GetAt(i-1).Name);
break;
case ON:
//if(nXDeta < 12*m_Legend.GetAt(i-1).Name.GetLength())
DrawXCoordinateValue(pDC,LeftTopx+nXDeta*i-nXDeta/2+2,RightBottomy-5,m_Legend.GetAt(i-1).Name,HOR);
//else
// DrawXCoordinateValue(pDC,LeftTopx+nXDeta*i-nXDeta/2+2,RightBottomy-5,m_Legend.GetAt(i-1).Name);
break;
}
}
if(XName != _T(""))
DrawXName(pDC,RightBottomx-12*XName.GetLength(),RightBottomy+15,XName);
}
break;
case PIE:
break;
}
}
*/
void CBaseGr::DrawXCoordinateValue(CDC* pDC,int Startx,int Starty,CString Value,Position Pos,COLORREF FontColor)
{
CFont m_font;
switch(Pos)
{
case VER:
m_font.CreateFont(
-12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
case HOR:
m_font.CreateFont(
-12, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
}
CFont *pOldFont = pDC->SelectObject(&m_font);
pDC->SetTextColor(FontColor);
// DrawText(pDC->GetSafeHdc(),Value,-1,&rcString,DT_RIGHT | DT_SINGLELINE);
pDC->ExtTextOut(Startx,Starty,ETO_OPAQUE,NULL,Value,NULL);
pDC->SelectObject(pOldFont);
}
void CBaseGr::DrawXName(CDC* pDC,int Startx,int Starty,CString Value,Align Mode,COLORREF FontColor)
{
CFont m_font;
switch(Mode)
{
case BOTTOM:
m_font.CreateFont(
-12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
case LEFT:
m_font.CreateFont(
-12, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
}
CFont *pOldFont = pDC->SelectObject(&m_font);
pDC->SetTextColor(FontColor);
// DrawText(pDC->GetSafeHdc(),Value,-1,&rcString,DT_RIGHT | DT_SINGLELINE);
pDC->ExtTextOut(Startx,Starty,ETO_OPAQUE,NULL,Value,NULL);
pDC->SelectObject(pOldFont);
}
void CBaseGr::DrawTitle(CDC* pDC,int LeftTopx,int LeftTopy,int RightBottomx,int RightBottomy,Align Mode,COLORREF FontColor)
{
CFont m_font;
int Startx,Starty;
Startx = (RightBottomx-LeftTopx)/2+12*Title.GetLength();
switch(Mode)
{
case ON:
case NONE:
break;
case BOTTOM:
Startx = LeftTopx+(RightBottomx-LeftTopx)/2-12*Title.GetLength()/2;
Starty = RightBottomy + 30;
m_font.CreateFont(
-12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
case TOP:
Startx = LeftTopx+(RightBottomx-LeftTopx)/2-12*Title.GetLength()/2;
Starty = LeftTopy - 30;
m_font.CreateFont(
-12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
case LEFT:
Startx = LeftTopx-15;
Starty = LeftTopy+(RightBottomy-LeftTopy)/2-12*Title.GetLength()/2;
m_font.CreateFont(
-12, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
case RIGHT:
Startx = RightBottomx+15;
Starty = LeftTopy+(RightBottomy-LeftTopy)/2-12*Title.GetLength()/2;
m_font.CreateFont(
-12, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
OEM_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_DONTCARE, // nPitchAndFamily
_T("宋体"));
break;
}
CFont *pOldFont = pDC->SelectObject(&m_font);
pDC->SetTextColor(FontColor);
// DrawText(pDC->GetSafeHdc(),Value,-1,&rcString,DT_RIGHT | DT_SINGLELINE);
pDC->ExtTextOut(Startx,Starty,ETO_OPAQUE,NULL,Title,NULL);
pDC->SelectObject(pOldFont);
}
void CBaseGr::DrawLegend(CDC* pDC,int Startx,int Starty,int Width,Align Mode,COLORREF FontColor)
{
int i=0;
// int nWidth=0;
// if(m_Legend.GetSize()>0)
// nWidth = m_Legend[0].Name.GetLength();
// for(i=1;iSelectObject(&m_font);
pDC->SetTextColor(FontColor);
switch(Mode)
{
case TOP:
DrawRectangle(pDC,Startx,Starty,Startx+Width,Starty+15*m_Legend.GetSize()*2);
for(i=0;iExtTextOut(Startx+2,Starty+15*i*2+1,ETO_OPAQUE,NULL,m_Legend[i].Name,NULL);
DrawRectangle(pDC,Startx+2,Starty+15*i*2+15+2,Startx+Width-2,Starty+15*(i+1)*2-2,m_Legend[i].Graph.LineSize,m_Legend[i].Graph.LineColor,m_Legend[i].Graph.FillColor);
}
break;
case BOTTOM:
DrawRectangle(pDC,Startx,Starty,Startx+Width,Starty+15*m_Legend.GetSize()*2);
for(i=0;iExtTextOut(Startx+2,Starty+15*i*2+15+1,ETO_OPAQUE,NULL,m_Legend[i].Name,NULL);
}
break;
case LEFT:
break;
case RIGHT:
break;
case ON:
break;
case NONE:
break;
}
pDC->SelectObject(pOldFont);
}
void CBaseGr::DrawContent(CDC* pDC,int LeftTopx,int LeftTopy,int RightBottomx,int RightBottomy)
{
}