资源简介
High-speed Charting Control--MFC绘制图表(折线图、饼图、柱形图)控件,在CodeProject中原文的源代码文件
代码片段和文件信息
/*
*
* ChartAxis.cpp
*
* Written by C閐ric Moonen (cedric_moonen@hotmail.com)
*
*
*
* This code may be used for any non-commercial and commercial purposes in a compiled form.
* The code may be redistributed as long as it remains unmodified and providing that the
* author name and this disclaimer remain intact. The sources can be modified WITH the author
* consent only.
*
* This code is provided without any garanties. I cannot be held responsible for the damage or
* the loss of time it causes. Use it at your own risks
*
* An e-mail to notify me that you are using this code is appreciated also.
*
*/
#include “stdafx.h“
#include “ChartAxis.h“
#include “ChartAxisLabel.h“
#include “ChartGrid.h“
#include “ChartCtrl.h“
#include “Math.h“
#include
using namespace std;
CChartAxis::CChartAxis()
: m_pParentCtrl(NULL) m_bIsHorizontal(true) m_bIsInverted(false)
m_AutoMode(NotAutomatic) m_bIsVisible(true) m_bIsSecondary(false)
m_MaxValue(0) m_MinValue(0) m_UnzoomMax(0) m_UnzoomMin(0)
m_bAutoTicks(true) m_bDiscrete(false)m_StartPos(0) m_EndPos(0)
m_nFontSize(80) m_strFontName(_T(“Microsoft Sans Serif“)) m_TextColor(0)
m_bAutoMargin(true) m_iMarginSize(0) m_bZoomEnabled(true)
m_dZoomLimit(0.001) m_pScrollBar(NULL) m_AxisColor(RGB(000))
{
m_pAxisGrid = new CChartGrid();
m_pAxisLabel = new CChartAxisLabel();
}
CChartAxis::~CChartAxis()
{
if (m_pAxisGrid)
{
delete m_pAxisGrid;
m_pAxisGrid = NULL;
}
if (m_pAxisLabel)
{
delete m_pAxisLabel;
m_pAxisLabel = NULL;
}
if (m_pScrollBar)
{
delete m_pScrollBar;
m_pScrollBar = NULL;
}
}
int CChartAxis::GetPosition()
{
if (m_bIsHorizontal)
{
if (m_bIsSecondary)
return 0;
else
return 100;
}
else
{
if (m_bIsSecondary)
return 100;
else
return 0;
}
}
void CChartAxis::SetParent(CChartCtrl* pParent)
{
m_pParentCtrl = pParent;
m_pAxisGrid->m_pParentCtrl = pParent;
m_pAxisLabel->m_pParentCtrl = pParent;
}
void CChartAxis::SetHorizontal(bool bHorizontal)
{
m_bIsHorizontal = bHorizontal;
m_pAxisGrid->m_bIsHorizontal = bHorizontal;
m_pAxisLabel->SetHorizontal(bHorizontal);
}
void CChartAxis::Draw(CDC *pDC)
{
if (!m_bIsVisible)
return;
if (pDC->GetSafeHdc() == NULL)
return;
// Initialize the different GDI objects
CPen SolidPen(PS_SOLID0m_AxisColor);
CFont NewFont;
NewFont.CreatePointFont(m_nFontSizem_strFontName.c_str()pDC) ;
CPen* pOldPen = pDC->Selectobject(&SolidPen);
CFont* pOldFont = pDC->Selectobject(&NewFont);
COLORREF OldTextColor = pDC->SetTextColor(m_TextColor);
int iPrevMode = pDC->SetBkMode(TRANSPARENT);
// Draw the axis line
int Pos = 0;
if (m_bIsHorizontal)
{
if (!m_bIsSecondary)
Pos = m_AxisRect.top+1;
else
Pos = m_AxisRect.bottom-1;
pDC->MoveTo(m_StartPosPos);
pDC->LineTo(m_EndPosPos);
}
else
{
if (!m_bIsSec
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4320 2009-12-20 12:44 ChartCandlestickSerie.h
文件 1757 2009-02-08 12:48 ChartCrossHairCursor.cpp
文件 1972 2009-03-08 18:14 ChartCrossHairCursor.h
文件 31179 2010-06-04 19:53 ChartCtrl.cpp
文件 21115 2009-12-28 11:32 ChartCtrl.h
文件 1483 2009-02-17 20:35 ChartCursor.cpp
文件 3819 2010-01-21 20:31 ChartCursor.h
文件 10516 2009-12-26 18:41 ChartDateTimeAxis.cpp
文件 5216 2009-03-07 13:01 ChartDateTimeAxis.h
文件 2438 2009-02-03 21:09 ChartDragLineCursor.cpp
文件 2189 2009-03-08 18:19 ChartDragLineCursor.h
文件 3375 2009-05-18 21:00 ChartFont.cpp
文件 2923 2009-03-07 20:43 ChartFont.h
文件 5823 2009-12-28 11:29 ChartGanttSerie.cpp
文件 5010 2009-12-21 11:38 ChartGanttSerie.h
文件 3765 2009-02-14 12:39 ChartGradient.cpp
文件 1863 2009-03-08 12:58 ChartGradient.h
文件 2628 2009-04-04 11:28 ChartGrid.cpp
文件 2186 2009-03-08 12:23 ChartGrid.h
文件 3699 2009-12-23 12:16 ChartLabel.h
文件 1621 2009-12-22 12:07 ChartLabel.inl
文件 9104 2009-06-02 20:33 ChartLegend.cpp
文件 4850 2009-03-07 20:58 ChartLegend.h
文件 9816 2010-07-10 11:47 ChartLineSerie.cpp
文件 3423 2009-08-16 10:58 ChartLineSerie.h
文件 4923 2009-04-04 11:32 ChartLogarithmicAxis.cpp
文件 1815 2009-04-04 11:28 ChartLogarithmicAxis.h
文件 2677 2009-12-27 16:05 ChartMouseListener.h
文件 6022 2009-12-21 11:22 ChartPointsArray.h
文件 8339 2009-12-21 11:23 ChartPointsArray.inl
文件 8736 2010-01-17 14:31 ChartPointsSerie.cpp
............此处省略27个文件信息
- 上一篇:灭火机器人c语言代码国赛一等奖
- 下一篇:大学物理实验——密立根实验计算器程序
评论
共有 条评论