commit 37e595f0ce073a9f6cc19b03f77564b7e67819da Author: wanttobeno Date: Wed Jun 10 18:11:21 2020 +0800 init diff --git a/ChartDemo.exe b/ChartDemo.exe new file mode 100644 index 0000000..1d12f77 Binary files /dev/null and b/ChartDemo.exe differ diff --git a/ChartDemo/ChartCtrl/ChartAxis.cpp b/ChartDemo/ChartCtrl/ChartAxis.cpp new file mode 100644 index 0000000..c937a9a --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartAxis.cpp @@ -0,0 +1,850 @@ +/* + * + * 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(0,0,0)) +{ + 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_SOLID,0,m_AxisColor); + CFont NewFont; + NewFont.CreatePointFont(m_nFontSize,m_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_StartPos,Pos); + pDC->LineTo(m_EndPos,Pos); + } + else + { + if (!m_bIsSecondary) + Pos = m_AxisRect.right-1; + else + Pos = m_AxisRect.left+1; + pDC->MoveTo(Pos,m_StartPos); + pDC->LineTo(Pos,m_EndPos); + } + + // Draw the label + DrawLabel(pDC); + // Clear the ticks on the grid + m_pAxisGrid->ClearTicks(); + + // Now draw all the ticks and their label. + if (m_MaxValue == m_MinValue) + DrawTick(pDC,m_MinValue); + else + { + double TickValue = GetFirstTickValue(); + do + { + DrawTick(pDC,TickValue); + } while (GetNextTickValue(TickValue, TickValue)); + } + + // Draw the grid. + m_pAxisGrid->Draw(pDC); + + // Reset the GDI objects + pDC->SelectObject(pOldPen); + SolidPen.DeleteObject(); + pDC->SelectObject(pOldFont); + NewFont.DeleteObject(); + pDC->SetTextColor(OldTextColor); + pDC->SetBkMode(iPrevMode); +} + +void CChartAxis::DrawTick(CDC* pDC, + double dTickVal) +{ + long TickPos = GetTickPos(dTickVal); + long lLabelPos = ValueToScreen(dTickVal); + TChartString strBuffer = GetTickLabel(dTickVal); + CSize TextSize = pDC->GetTextExtent(strBuffer.c_str()); + CSize LabelSize = m_pAxisLabel->GetSize(pDC); + + bool bLabelOnAxis = IsLabelOnAxis(dTickVal); + bool bTickOnAxis = true; + if (m_bIsHorizontal) + { + if (TickPosm_EndPos) + bTickOnAxis = false; + if (!m_bIsSecondary) + { + if (bTickOnAxis) + { + pDC->MoveTo(TickPos,m_AxisRect.top+1); + pDC->LineTo(TickPos,m_AxisRect.top+4); + } + if (bLabelOnAxis) + { + pDC->ExtTextOut(lLabelPos-TextSize.cx/2,m_AxisRect.top+5, + ETO_CLIPPED|ETO_OPAQUE,NULL,strBuffer.c_str(),NULL); + } + } + else + { + if (bTickOnAxis) + { + pDC->MoveTo(TickPos,m_AxisRect.bottom-1); + pDC->LineTo(TickPos,m_AxisRect.bottom-4); + } + if (bLabelOnAxis) + { + pDC->ExtTextOut(lLabelPos-TextSize.cx/2,m_AxisRect.bottom-5-TextSize.cy, + ETO_CLIPPED|ETO_OPAQUE,NULL,strBuffer.c_str(),NULL); + } + } + } + else + { + if (TickPos>m_StartPos || TickPosMoveTo(m_AxisRect.right-1,TickPos); + pDC->LineTo(m_AxisRect.right-4,TickPos); + } + if (bLabelOnAxis) + { + pDC->ExtTextOut(m_AxisRect.left+LabelSize.cx+4,lLabelPos-TextSize.cy/2, + ETO_CLIPPED|ETO_OPAQUE,NULL,strBuffer.c_str(),NULL); + } + } + else + { + if (bTickOnAxis) + { + pDC->MoveTo(m_AxisRect.left+1,TickPos); + pDC->LineTo(m_AxisRect.left+4,TickPos); + } + if (bLabelOnAxis) + { + pDC->ExtTextOut(m_AxisRect.left+6,lLabelPos-TextSize.cy/2, + ETO_CLIPPED|ETO_OPAQUE,NULL,strBuffer.c_str(),NULL); + } + } + } + m_pAxisGrid->AddTick(TickPos); +} + +bool CChartAxis::IsLabelOnAxis(double TickVal) +{ + long lLabelPos = ValueToScreen(TickVal); + bool bLabelOnAxis = true; + if (m_bIsHorizontal) + { + if (lLabelPosm_EndPos) + bLabelOnAxis = false; + } + else + { + if (lLabelPos>m_StartPos || lLabelPosGetSize(pDC); + int HalfAxisPos = (int)fabs((m_EndPos + m_StartPos)/2.0); + int XPos = 0; + int YPos = 0; + if (m_bIsHorizontal) + { + if (!m_bIsSecondary) + { + CSize TextSize = GetLargestTick(pDC); + YPos = m_AxisRect.top + TextSize.cy + 2; + XPos = HalfAxisPos - LabelSize.cx/2; + } + else + { + YPos = m_AxisRect.top + 0; + XPos = HalfAxisPos - LabelSize.cx/2; + } + } + else + { + if (!m_bIsSecondary) + { + YPos = HalfAxisPos + LabelSize.cy/2; + XPos = m_AxisRect.left + 0; + } + else + { + YPos = HalfAxisPos + LabelSize.cy/2; + XPos = m_AxisRect.right - LabelSize.cx - 2; + } + } + m_pAxisLabel->SetPosition(XPos,YPos,pDC); + m_pAxisLabel->Draw(pDC); +} + +CSize CChartAxis::GetLargestTick(CDC* pDC) +{ + CFont NewFont; + NewFont.CreatePointFont(m_nFontSize,m_strFontName.c_str(),pDC); + CFont* pOldFont = pDC->SelectObject(&NewFont); + + CSize MaxSize(0,0); + if (m_MaxValue == m_MinValue) + { + TChartString strLabel = GetTickLabel(m_MinValue); + MaxSize = pDC->GetTextExtent(strLabel.c_str(),strLabel.size()); + } + else + { + double TickValue = GetFirstTickValue(); + do + { + if (IsLabelOnAxis(TickValue)) + { + TChartString strLabel = GetTickLabel(TickValue); + CSize TextSize = pDC->GetTextExtent(strLabel.c_str(),strLabel.size()); + if (TextSize.cy > MaxSize.cy) + MaxSize.cy = TextSize.cy; + if (TextSize.cx > MaxSize.cx) + MaxSize.cx = TextSize.cx; + } + } while (GetNextTickValue(TickValue, TickValue)); + } + + pDC->SelectObject(pOldFont); + NewFont.DeleteObject(); + return MaxSize; +} + +void CChartAxis::SetInverted(bool bInverted) +{ + m_bIsInverted = bInverted; + RefreshScrollBar(); + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetAutomatic(bool bAutomatic) +{ +// m_bIsAutomatic = bAutomatic; + if (bAutomatic) + { + m_AutoMode = FullAutomatic; + m_MinValue = m_MaxValue = 0; + } + else + m_AutoMode = NotAutomatic; + + if (RefreshAutoAxis()) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetAutomaticMode(EAxisAutoModes AutoMode) +{ + m_AutoMode = AutoMode; + if (m_AutoMode != NotAutomatic) + m_MinValue = m_MaxValue = 0; + + if (RefreshAutoAxis()) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetDiscrete(bool bDiscrete) +{ + m_bDiscrete = bDiscrete; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetMinMax(double Minimum, double Maximum) +{ + ASSERT(Maximum>=Minimum); + + m_MinValue = m_UnzoomMin = Minimum; + m_MaxValue = m_UnzoomMax = Maximum; + RefreshScrollBar(); + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::RegisterSeries(CChartSerie* pSeries) +{ + // First check if the series is already present in the list + SeriesList::iterator iter = m_pRelatedSeries.begin(); + for (iter; iter!=m_pRelatedSeries.end(); iter++) + { + if ( (*iter) == pSeries) + return; + } + + m_pRelatedSeries.push_back(pSeries); +} + +void CChartAxis::UnregisterSeries(CChartSerie* pSeries) +{ + SeriesList::iterator iter = m_pRelatedSeries.begin(); + for (iter; iter!=m_pRelatedSeries.end(); iter++) + { + if ( (*iter) == pSeries) + { + m_pRelatedSeries.erase(iter); + return; + } + } +} + +bool CChartAxis::RefreshAutoAxis() +{ + RefreshScrollBar(); + bool bNeedRefresh = false; + if (m_AutoMode == NotAutomatic) + return bNeedRefresh; + + double SeriesMin = 0; + double SeriesMax = 0; + if (m_AutoMode == FullAutomatic) + GetSeriesMinMax(SeriesMin, SeriesMax); + if (m_AutoMode == ScreenAutomatic) + GetSeriesScreenMinMax(SeriesMin, SeriesMax); + + if ( (SeriesMax!=m_MaxValue) || (SeriesMin!=m_MinValue) ) + SetMinMax(SeriesMin,SeriesMax); + + return bNeedRefresh; +} + +bool CChartAxis::RefreshScreenAutoAxis() +{ + RefreshScrollBar(); + bool bNeedRefresh = false; + if (m_AutoMode != ScreenAutomatic) + return bNeedRefresh; + return RefreshAutoAxis(); +} + +void CChartAxis::GetSeriesMinMax(double& Minimum, double& Maximum) +{ + Minimum = 0; + Maximum = 0; + double TempMin = 0; + double TempMax = 0; + + SeriesList::iterator iter = m_pRelatedSeries.begin(); + if (iter != m_pRelatedSeries.end()) + { + if (m_bIsHorizontal) + (*iter)->GetSerieXMinMax(Minimum,Maximum); + else + (*iter)->GetSerieYMinMax(Minimum,Maximum); + } + + for (iter; iter!=m_pRelatedSeries.end(); iter++) + { + if (m_bIsHorizontal) + (*iter)->GetSerieXMinMax(TempMin,TempMax); + else + (*iter)->GetSerieYMinMax(TempMin,TempMax); + + if (TempMin < Minimum) + Minimum = TempMin; + if (TempMax > Maximum) + Maximum = TempMax; + } +} + +void CChartAxis::GetSeriesScreenMinMax(double& Minimum, double& Maximum) +{ + Minimum = 0; + Maximum = 0; + double TempMin = 0; + double TempMax = 0; + + SeriesList::iterator iter = m_pRelatedSeries.begin(); + if (iter != m_pRelatedSeries.end()) + { + if (m_bIsHorizontal) + (*iter)->GetSerieXScreenMinMax(Minimum,Maximum); + else + (*iter)->GetSerieYScreenMinMax(Minimum,Maximum); + } + + for (iter; iter!=m_pRelatedSeries.end(); iter++) + { + if (m_bIsHorizontal) + (*iter)->GetSerieXScreenMinMax(TempMin,TempMax); + else + (*iter)->GetSerieYScreenMinMax(TempMin,TempMax); + + if (TempMin < Minimum) + Minimum = TempMin; + if (TempMax > Maximum) + Maximum = TempMax; + } +} + +long CChartAxis::ValueToScreen(double Value) const +{ + long Offset = 0; + long retVal = 0; + if (m_MaxValue==m_MinValue) + { + Offset = (int)fabs((m_EndPos-m_StartPos)/2.0); + if (m_bIsHorizontal) + retVal = m_StartPos + Offset; + else + retVal = m_StartPos - Offset; + } + else if (!m_bDiscrete) + retVal = ValueToScreenStandard(Value); + else + retVal = ValueToScreenDiscrete(Value); + + return retVal; +} + +long CChartAxis::ValueToScreenStandard(double Value) const +{ + long Offset = 0; + long retVal = 0; + + Offset = (int)floor( (Value - m_MinValue) * GetAxisLenght()/(m_MaxValue-m_MinValue) ); + if (m_bIsHorizontal) + { + if (!m_bIsInverted) + retVal = (m_StartPos + Offset); + else + retVal = (m_EndPos - Offset); + } + else + { + if (!m_bIsInverted) + retVal = (m_StartPos - Offset); + else + retVal = (m_EndPos + Offset); + } + return retVal; +} + +double CChartAxis::ScreenToValue(long ScreenVal) const +{ + if (m_MaxValue==m_MinValue) + return m_MinValue; + + int AxisOffset = 0; + if (!m_bIsHorizontal) + { + if (m_bIsInverted) + AxisOffset = ScreenVal - m_EndPos; + else + AxisOffset = m_StartPos - ScreenVal; + } + else + { + if (!m_bIsInverted) + AxisOffset = ScreenVal - m_StartPos; + else + AxisOffset = m_EndPos - ScreenVal; + } + + return ( (AxisOffset * 1.0 / GetAxisLenght()*(m_MaxValue-m_MinValue)) + m_MinValue); +} + +void CChartAxis::PanAxis(long PanStart, long PanEnd) +{ + double StartVal = ScreenToValue(PanStart); + double EndVal = ScreenToValue(PanEnd); + + double Shift = StartVal - EndVal; + SetZoomMinMax(m_MinValue+Shift,m_MaxValue+Shift); +} + +void CChartAxis::SetZoomMinMax(double Minimum, double Maximum) +{ + if (!m_bZoomEnabled) + return; + if (m_MinValue == m_MaxValue) + return; + + ASSERT(Maximum>=Minimum); + + m_MinValue = Minimum; + if ( (Maximum - Minimum) < m_dZoomLimit) + m_MaxValue = m_MinValue + m_dZoomLimit; + else + m_MaxValue = Maximum; + RefreshScrollBar(); +} + +long CChartAxis::GetAxisLenght() const +{ + long Length = (long)fabs( (m_EndPos-m_StartPos) * 1.0); + return Length; +} + +void CChartAxis::SetVisible(bool bVisible) +{ + m_bIsVisible = bVisible; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::CreateScrollBar() +{ + m_pScrollBar = new CChartScrollBar(this); + m_pScrollBar->CreateScrollBar(m_pParentCtrl->GetPlottingRect()); +} + +void CChartAxis::UpdateScrollBarPos() +{ + CRect PlottingRect = m_pParentCtrl->GetPlottingRect(); + PlottingRect.top++; PlottingRect.left++; + + // TODO: check if other toolbars are already present + // on other axes. + CRect Temp; + m_pScrollBar->GetWindowRect(&Temp); + if (m_bIsHorizontal && !m_bIsSecondary) + PlottingRect.top = PlottingRect.bottom - Temp.Height(); + if (!m_bIsHorizontal && !m_bIsSecondary) + PlottingRect.right = PlottingRect.left + Temp.Width(); + if (m_bIsHorizontal && m_bIsSecondary) + PlottingRect.bottom = PlottingRect.top + Temp.Height(); + if (!m_bIsHorizontal && m_bIsSecondary) + PlottingRect.left = PlottingRect.right - Temp.Width(); + + m_pScrollBar->MoveWindow(&PlottingRect); +} + +void CChartAxis::RefreshScrollBar() +{ + if (m_pScrollBar) + m_pScrollBar->Refresh(); +} + +void CChartAxis::SetTextColor(COLORREF NewColor) +{ + m_TextColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetAxisColor(COLORREF NewColor) +{ + m_AxisColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetFont(int nPointSize, + const TChartString& strFaceName) +{ + m_nFontSize = nPointSize; + m_strFontName = strFaceName; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::SetMarginSize(bool bAuto, int iNewSize) +{ + m_bAutoMargin = bAuto; + m_iMarginSize = iNewSize; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxis::EnableScrollBar(bool bEnabled) +{ + if (m_pScrollBar) + { + m_pScrollBar->SetEnabled(bEnabled); + if (bEnabled) + m_pScrollBar->ShowWindow(SW_SHOW); + else + m_pScrollBar->ShowWindow(SW_HIDE); + } +} + +void CChartAxis::SetAutoHideScrollBar(bool bAutoHide) +{ + if (m_pScrollBar) + m_pScrollBar->SetAutoHide(bAutoHide); +} + +bool CChartAxis::GetAutoHideScrollBar() const +{ + if (m_pScrollBar) + return (m_pScrollBar->GetAutoHide()); + else + return false; +} + +void CChartAxis::UndoZoom() +{ + SetMinMax(m_UnzoomMin,m_UnzoomMax); +} + +void CChartAxis::SetAxisSize(const CRect& ControlRect, + const CRect& MarginRect) +{ + if (m_bIsHorizontal) + { + m_StartPos = MarginRect.left; + m_EndPos = MarginRect.right; + + if (!m_bIsSecondary) + { + m_AxisRect = ControlRect; + m_AxisRect.top = MarginRect.bottom; + } + else + { + m_AxisRect = ControlRect; + m_AxisRect.bottom = MarginRect.top; + } + } + else + { + m_StartPos = MarginRect.bottom; + m_EndPos = MarginRect.top; + + if (!m_bIsSecondary) + { + m_AxisRect = ControlRect; + m_AxisRect.right = MarginRect.left; + } + else + { + m_AxisRect = ControlRect; + m_AxisRect.left = MarginRect.right; + } + } +} + +int CChartAxis::ClipMargin(CRect ControlRect, CRect& MarginRect,CDC* pDC) +{ + if (!m_bIsVisible) + return 0; + + int Size = 0; + CSize TickSize = GetLargestTick(pDC); + CSize LabelSize = m_pAxisLabel->GetSize(pDC); + + if (m_bIsHorizontal) + { + if (!m_bAutoMargin) + Size = m_iMarginSize; + else + { + Size += 4 + 2; //Space above and under the text + + Size += TickSize.cy; + Size += LabelSize.cy; + + m_iMarginSize = Size; + } + + if (!m_bIsSecondary) + { + ControlRect.bottom -= Size; + ControlRect.right -= TickSize.cx/2+3; + + if (ControlRect.bottom < MarginRect.bottom) + MarginRect.bottom = ControlRect.bottom; + if (ControlRect.right < MarginRect.right) + MarginRect.right = ControlRect.right; + } + else + { + ControlRect.top += Size; + ControlRect.right -= TickSize.cx/2+3; + + if (ControlRect.top > MarginRect.top) + MarginRect.top = ControlRect.top; + if (ControlRect.right < MarginRect.right) + MarginRect.right = ControlRect.right; + } + + } + else + { + if (!m_bAutoMargin) + Size = m_iMarginSize; + else + { + Size += 7 + 1; //Space before and after the text + Tick + + Size += TickSize.cx; + Size += LabelSize.cx + 2; + m_iMarginSize = Size; + } + + if (!m_bIsSecondary) + { + ControlRect.left += Size; + ControlRect.top += TickSize.cy/2+3; + + if (ControlRect.top > MarginRect.top) + MarginRect.top = ControlRect.top; + if (ControlRect.left > MarginRect.left) + MarginRect.left = ControlRect.left; + } + else + { + ControlRect.right -= Size; + ControlRect.top += TickSize.cy/2+3; + + if (ControlRect.top > MarginRect.top) + MarginRect.top = ControlRect.top; + if (ControlRect.right < MarginRect.right) + MarginRect.right = ControlRect.right; + } + } + + return Size; +} + +void CChartAxis::Recalculate() +{ + if (m_bAutoTicks) + RefreshTickIncrement(); + RefreshFirstTick(); +} + +void CChartAxis::GetScrollbarSteps(int& iTotalSteps, + int& iCurrentStep) +{ + double SeriesMin=0, SeriesMax=0; + GetSeriesMinMax(SeriesMin,SeriesMax); + + if ((m_MaxValue-m_MinValue) == 0 || (SeriesMax-SeriesMin)==0 ) + { + iTotalSteps = 1; + iCurrentStep = 1; + } + else + { + double dStep = (m_MaxValue - m_MinValue) / 10.0; + iTotalSteps = (int)ceil((SeriesMax - SeriesMin)/dStep); + iCurrentStep = (int)(iTotalSteps * ((m_MinValue - SeriesMin)/(SeriesMax-SeriesMin))); + } +} + +void CChartAxis::SetAxisToScrollStep(int iPreviousStep, + int iCurrentStep, + bool bScrollInverted) +{ + double dStep = (m_MaxValue - m_MinValue) / 10.0; + double dOffset = (iCurrentStep - iPreviousStep) * dStep; + if (bScrollInverted) + SetZoomMinMax(m_MinValue-dOffset,m_MaxValue-dOffset); + else + SetZoomMinMax(m_MinValue+dOffset,m_MaxValue+dOffset); + m_pParentCtrl->RefreshScreenAutoAxes(); +} + +BOOL CChartAxis::IsPointInside(const CPoint& screenPoint) const +{ + return m_AxisRect.PtInRect(screenPoint); +} diff --git a/ChartDemo/ChartCtrl/ChartAxis.h b/ChartDemo/ChartCtrl/ChartAxis.h new file mode 100644 index 0000000..e96568c --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartAxis.h @@ -0,0 +1,526 @@ +/* + * + * ChartAxis.h + * + * 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. + * + * + */ + +#ifndef _CHARTAXIS_H_ +#define _CHARTAXIS_H_ + +#include "ChartScrollBar.h" +#include "ChartString.h" +#include + +#include + +class CChartCtrl; +class CChartGrid; +class CChartSerie; +class CChartAxisLabel; + +//! Base class that takes care of the management of a chart axis. +/** + This class cannot be instanciated but should be overriden in order + to provide the required functionality (this is already done for + standard axis, date/time axis and logarithmic axis).
+ The class provides already a lot of functionalities but delegate the + ticks positioning and labeling to the child classes.
+ By default, the class manages a continues range of double values (which + is the case for standard axis and date/time axis) but in some cases, this + is not valid (for instance, a logarithmic scale). In that case, you should + in addition override some specific functions (e.g. those handling the scrollbar). + Take a look at the CChartLogarithmicAxis class for more details. +**/ +class CChartAxis +{ + friend CChartCtrl; + friend CChartGrid; + friend CChartSerie; + friend CChartScrollBar; + +public: + //! Default constructor + CChartAxis(); + //! Default destructor + virtual ~CChartAxis(); + + //! Retrieves the position (in %) of the axis. + int GetPosition(); + + //! Sets the axis in reverse. + /** + For an inverted axis, the values on the axis are + in decreasing order. + @param bInverted + true if the axis has to be inverted. + **/ + void SetInverted(bool bInverted); + //! Retrieves if the axis is inverted or not. + bool IsInverted() const { return m_bIsInverted; } + + //! Sets the axis in automatic or manual mode. + /** + In automatic mode, the axis min and max will be updated + depending on the series related to this axis. + @param bAutomatic + true if the axis should be automatic. + @deprecated You should use the SetAutomaticType instead. + **/ + void SetAutomatic(bool bAutomatic); + //! Returns true if an automatic mode has been set on this axis. + /** + @deprecated You should use the GetAutomaticType instead. + **/ + bool IsAutomatic() const { return m_AutoMode != NotAutomatic; } + + //! The different modes of automatic modes for an axis. + enum EAxisAutoModes + { + //! The axis min and max values are set manually + NotAutomatic, + //! The axis min and max values of the axis are the min and max values of all series associated with this axis. This corresponds to the "standard" automatic mode that was implemented before version 3.0. + FullAutomatic, + //! The axis min and max values of the axis are the visible min and max values of all series associated with this axis. The end result will then depends on how the other axes are configured. + ScreenAutomatic + }; + + //! Sets the automatic mode of the axis + void SetAutomaticMode(EAxisAutoModes AutoMode); + //! Gets the automatic type of the axis + EAxisAutoModes GetAutomaticMode() const { return m_AutoMode; } + + //! Sets the axis visible/invisible. + void SetVisible(bool bVisible); + //! Retrieves the axis automatic mode. + bool IsVisible() const { return m_bIsVisible; } + + //! Sets the axis min and max values. + /** + This doesn't take into account the real type of the axis, + so double values should be provided. + @param Minimum + The min value of the axis + @param Maximum + The max value of the axis. + **/ + void SetMinMax(double Minimum, double Maximum); + //! Gets the min anx max values of the axis. + void GetMinMax(double& Minimum, double& Maximum) const + { + Minimum = m_MinValue; + Maximum = m_MaxValue; + } + + //! Sets the axis color. + void SetAxisColor(COLORREF NewColor); + //! Sets the tick labels color. + void SetTextColor(COLORREF NewColor); + //! Gets the tick labels color. + COLORREF GetTextColor() const { return m_TextColor; } + //! Sets the tick labels font + /** + @param nPointSize + The font point size + @param strFaceName + The font face name + **/ + void SetFont(int nPointSize, const TChartString& strFaceName); + + //! Retrieves the chart axis label object + CChartAxisLabel* GetLabel() const { return m_pAxisLabel; } + //! Retrieves the chart axis grid object + CChartGrid* GetGrid() const { return m_pAxisGrid; } + + //! Sets the margin size + /** + @param bAuto + Specifies if the margin size is automatic or not. + In automatic mode, the iNewSize parameter is ignored + and the margin size is calculated automatically. + @param iNewSize + The new size of the margin, in manual mode. + **/ + void SetMarginSize(bool bAuto, int iNewSize); + + //! Enable the pan and zoom for this axis. + void SetPanZoomEnabled(bool bEnabled) { m_bZoomEnabled = bEnabled; } + //! Sets the zoom limit. + /** + The zoom limit is the minimum lenght (in values) of the axis. + **/ + void SetZoomLimit(double dLimit) { m_dZoomLimit = dLimit; } + + //! Enables/disables the scroll bar. + void EnableScrollBar(bool bEnabled); + //! Retrieves if the scroll bar is enabled or not. + bool ScrollBarEnabled() const + { + if (m_pScrollBar) + return (m_pScrollBar->GetEnabled()); + else + return false; + } + //! Specifies if the scroll bar is in auto-hide mode. + /** + In auto-hide mode, the scroll bar will be hidden until + you hover the mouse over it. + **/ + void SetAutoHideScrollBar(bool bAutoHide); + //! Retrieves if the scroll bar is in auto-hide mode. + bool GetAutoHideScrollBar() const; + + //! Sets the axis in discrete mode + /** + @param bDiscrete + true if the axis has to be discrete, false otherwise. + In discrete mode, the axis doesn't have a continuous range of values + but only steps which are defined by the tick interval. In this mode, + you won't be able to plot points at a different location that in the + middle of two ticks. For instance, if you have a tick interval of 1.0, + trying to plot a value of 0.9 will display the point at the same position + as if the value was 0.3: it will be displayed in the middle of tick 0.0 and + tick 1.0. +
It is mainly used to display the tick label in the middle of two ticks. + This is for instance nice with date/time axis. + **/ + virtual void SetDiscrete(bool bDiscrete); + + //! Converts a value on the axis to a screen position + /** + The functions takes care of the discrete mode (internally, + it calls ValueToScreenStandard or ValueToScreenDiscrete + depending on the discrete mode). + @param Value + The value to convert + @return the screen position of the value + **/ + long ValueToScreen(double Value) const; + //! Converts a screen position to a value on the axis + /** + The function is implemented for an axis with a standard + behavior (the axis shows a continuous range of doubles). + It is the case for standard axis and date/time axis (date + are converted to doubles internally). Axis that needs a different + behavior should override this function (e.g. a logarithmic axis). + The function does not take care of the discrete mode. + @param ScreenVal + The screen value to convert + @return the double value + **/ + virtual double ScreenToValue(long ScreenVal) const; + + //! Returns true if the axis is horizontal + bool IsHorizontal() const { return m_bIsHorizontal; } + + //! Returns true if a screen point is in the region of the axis. + BOOL IsPointInside(const CPoint& screenPoint) const; + +protected: + //! Returns the first tick value. + /** + This pure virtual function must be implemented for specific + axes type. + **/ + virtual double GetFirstTickValue() const = 0; + //! Retrieves the next tick value after a given tick. + /** + This pure virtual function must be implemented for specific + axes type. + @param dCurrentTick + The value of the current tick + @param dNextTick + The value of the next tick will be stored in this parameter + @return true if there is a next or false when the current tick is the last one. + **/ + virtual bool GetNextTickValue(double dCurrentTick, double& dNextTick) const = 0; + //! Retrieves the screen position of a certain tick. + /** + This pure virtual function must be implemented for specific + axes type. + @param Value + The value of the tick for which we want to retrieve the position + @return + the screen position of the tick + **/ + virtual long GetTickPos(double Value) const = 0; + //! Converts a value on the axis to a screen position. + /** + This function is called internally only when the axis is in + discrete mode. This pure virtual function must be implemented for specific + axes type. + @param Value + The value to convert + @return the screen position of the value + **/ + virtual long ValueToScreenDiscrete(double Value) const = 0; + //! Converts a value on the axis to a screen position. + /** + This function is called internally only when the axis is in + standard mode. This virtual function can be overriden when the + axis doesn't display a continuous range of values (e.g. log axis). + @param Value + The value to convert + @return the screen position of the value + **/ + virtual long ValueToScreenStandard(double Value) const; + + //! Retrieves the label for a specific tick. + /** + This pure virtual function must be implemented for specific + axes type. + @param TickValue + The tick value for which we need to get the label. + @return A TChartString containing the label for the tick. + **/ + virtual TChartString GetTickLabel(double TickValue) const = 0; + + //! Forces a recalculation of the tick increment. + virtual void RefreshTickIncrement() = 0; + //! Forces a recalculation of the first tick value. + virtual void RefreshFirstTick() = 0; + + //! Retrieves the step information related to the scrollbar. + /** + This function can be implemented for specific axis types which + should provide a behavior different than the standard behavior + (for instance log axis). + @param iTotalSteps + Stores the total number of steps for the scrollbar + @param iCurrentStep + Stores the current step index for the scrollbar + **/ + virtual void GetScrollbarSteps(int& iTotalSteps, int& iCurrentStep); + //! Sets the axis to the specified scrollbar step. + /** + This function can be implemented for specific axis types which + should provide a behavior different than the standard behavior + (for instance log axis). + @param iPreviousStep + The previous scroll step. + @param iCurrentStep + The current scroll step to which the axis should be moved. + @param bScrollInverted + Specifies if the scroll is inverted or not. + **/ + virtual void SetAxisToScrollStep(int iPreviousStep, int iCurrentStep, bool bScrollInverted); + + //! Pan the axis + /** + This function can be overriden in case the axis doesn't display + a continuous range of values (e.g. log axis). + @param PanStart + The position of the start of the pan + @param PanEnd + The position of the end of the pan + **/ + virtual void PanAxis(long PanStart, long PanEnd); + //! Sets the min and max values of the axis due to a zoom operation. + virtual void SetZoomMinMax(double Minimum, double Maximum); + //! Reverts the zoom and pan settings. + void UndoZoom(); + + //! Retrieves the lenght (in pixels) of the axis + long GetAxisLenght() const; + //! Retrieves the min and max values for all the series related to this axis + void GetSeriesMinMax(double& Minimum, double& Maximum); + //! Retrieves the screen min and max values for all the series related to this axis + void GetSeriesScreenMinMax(double& Minimum, double& Maximum); + +private: + //! Refresh the axis if it is automatic + /** + @return true if the axis has changed + **/ + bool RefreshAutoAxis(); + //! Refresh the axis if it is automatic for the screen only + /** + @return true if the axis has changed + **/ + bool RefreshScreenAutoAxis(); + + //! Returns the largest tick width and the largest tick heigh. + /** + The function returns a CSize object for which the x value + is the largest width and the y value is the largest height. + They do not necessarily belong to the same tick. + **/ + CSize GetLargestTick(CDC* pDC); + + //! Sets the axis as a secondary axis. + /** + A secondary axis is on top for horizontal axis and on the + right for vertical axis. + **/ + void SetSecondary(bool bSecondary) { m_bIsSecondary = bSecondary; } + //! Returns true if the axis is secondary. + bool IsSecondary() const { return m_bIsSecondary; } + //! Sets the axis to horizontal/vertical + void SetHorizontal(bool bHorizontal); + + //! Draw the axis on the chart + /** + @param pDC + The DC used to draw the axis. + **/ + void Draw(CDC* pDC); + //! Draw the axis label + /** + @param pDC + The DC used to draw the axis. + **/ + void DrawLabel(CDC* pDC); + //! Draw a specific tick on the axis. + /** + @param pDC + The DC used to draw the axis. + @param dTickVal + The tick value. + The tick label will be drawn on the tick or between two ticks + depending if the axis is set as standard or discrete. + **/ + void DrawTick(CDC* pDC, double dTickVal); + //! Check whether a specific label is still on the axis. + /** + @param dTickVal + The tick value. + The function returns false if the label is outside + the axis range (and thus, should not be drawn). + **/ + bool IsLabelOnAxis(double TickVal); + + //! Register a series that is associated with this axis. + /** + This is used when the axis is in automatic mode. + **/ + void RegisterSeries(CChartSerie* pSeries); + //! Unregister a series with this axis. + void UnregisterSeries(CChartSerie* pSeries); + + //! Creates and attach a new scroll bar to the axis + void CreateScrollBar(); + //! Update the scroll bar position depending on the plotting rect. + void UpdateScrollBarPos(); + //! Refreshes the scroll bar. + void RefreshScrollBar(); + + //! Sets the parent charting control. + void SetParent(CChartCtrl* pParent); + + //! Sets the axis size + /** + @param ControlRect + The rectangle of the control + @param MarginRect + The rectangle in which the axis should be contained + **/ + void SetAxisSize(const CRect& ControlRect, const CRect& MarginRect); + //! Removes the margin needed for the axis from the full control rect. + /** + @param ControlRect + The rectangle of the control + @param MarginRect + The rectangle in which the axis should be contained + @param pDC + The CDC used to draw the axis. + **/ + int ClipMargin(CRect ControlRect,CRect& MarginRect,CDC* pDC); + //! Recalculate the axis properties. + /** + This function simply calls RefreshTickIncrement and + RefreshFirstTick. + **/ + void Recalculate(); + +protected: + //! The parent chart control. + CChartCtrl* m_pParentCtrl; + + //! Indicates if this is an horizontal or vertical axis + bool m_bIsHorizontal; + //! Indicates if the axis is inverted + bool m_bIsInverted; + //! Indicates if the axis is automatic +// bool m_bIsAutomatic; + //! Indicates the automatic mode of the axis + EAxisAutoModes m_AutoMode; + + //! Indicates if the axis is visible or not + bool m_bIsVisible; + + //! Specifies if the axis is secondary + /** + The secondary axis is either on the top (for horizontal + axis) or on the right (for vertical axis) of the chart. + **/ + bool m_bIsSecondary; + + //! The axis max value + double m_MaxValue; + //! The axis min value + double m_MinValue; + //! Min value of the axis before it has been zoomed + double m_UnzoomMin; + //! Max value of the axis before it has been zoomed + double m_UnzoomMax; + + //! Specify if the tick increment is manual or automatic + bool m_bAutoTicks; + //! Specify if the axis has to be in discrete mode or not + bool m_bDiscrete; + + //! Start position of the axis (in pixels) + int m_StartPos; + //! End position of the axis (in pixels) + int m_EndPos; + //! The rectangle in which the axis is contained. + CRect m_AxisRect; + +private: + //! The font size used for the axis labels + int m_nFontSize; + //! The font face name used for the axis labels + TChartString m_strFontName; + //! The color used for the axis labels + COLORREF m_TextColor; + //! The color used for the axis line + COLORREF m_AxisColor; + + //! The grid related to this axis + CChartGrid* m_pAxisGrid; + //! The axis label associated with this axis + CChartAxisLabel* m_pAxisLabel; + + typedef std::list SeriesList; + //! List containing pointers to series related to this axis + SeriesList m_pRelatedSeries; + + //! Specify if the margin size is calculated automatically + bool m_bAutoMargin; + //! The margin size, used in manual mode + int m_iMarginSize; + + //! Specifies if the zoom is enabled for this axis + bool m_bZoomEnabled; + //! The zoom limit (axis can't be zoomed under this limit) + double m_dZoomLimit; + + //! The axis scrollbar + CChartScrollBar* m_pScrollBar; +}; + +#endif // _CHARTAXIS_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartAxisLabel.cpp b/ChartDemo/ChartCtrl/ChartAxisLabel.cpp new file mode 100644 index 0000000..da12574 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartAxisLabel.cpp @@ -0,0 +1,157 @@ +/* + * + * ChartAxisLabel.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. + * + * History: + * - 24/08/2007: Bug fix in color of the label (text was always black) + * + * + */ + +#include "stdafx.h" +#include "ChartAxisLabel.h" +#include "ChartCtrl.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartAxisLabel::CChartAxisLabel() + : m_pParentCtrl(NULL), m_bIsVisible(true), m_TextColor(RGB(0,0,0)), + m_bIsHorizontal(true), m_Font(), m_strLabelText(_T("")) +{ + m_Font.SetVertical(!m_bIsHorizontal); +} + +CChartAxisLabel::~CChartAxisLabel() +{ +} + +void CChartAxisLabel::SetVisible(bool bVisible) +{ + m_bIsVisible = bVisible; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxisLabel::SetColor(COLORREF NewColor) +{ + m_TextColor = NewColor; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxisLabel::SetText(const TChartString& NewText) +{ + m_strLabelText = NewText; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxisLabel::SetFont(int nPointSize, const TChartString& strFaceName) +{ + m_Font.SetFont(strFaceName, nPointSize); + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartAxisLabel::SetHorizontal(bool bHorizontal) +{ + m_bIsHorizontal = bHorizontal; + m_Font.SetVertical(!m_bIsHorizontal); +} + +void CChartAxisLabel::SetFont(const CChartFont& newFont) +{ + m_Font = newFont; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +CSize CChartAxisLabel::GetSize(CDC *pDC) const +{ + CSize LabelSize; + LabelSize.cx = 0; + LabelSize.cy = 0; + + if (!m_bIsVisible) + return LabelSize; + if (!pDC->GetSafeHdc()) + return LabelSize; + if (m_strLabelText == _T("")) + return LabelSize; + + m_Font.SelectFont(pDC); + + LabelSize = pDC->GetTextExtent(m_strLabelText.c_str()); + LabelSize.cx += 4; + LabelSize.cy += 4; + if (!m_bIsHorizontal) + { + int Width = LabelSize.cy; + int Height = LabelSize.cx; + LabelSize.cx = Width; + LabelSize.cy = Height; + } + m_Font.UnselectFont(pDC); + + return LabelSize; +} + +void CChartAxisLabel::Draw(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + if (m_strLabelText == _T("")) + return; + + int iPrevMode = pDC->SetBkMode(TRANSPARENT); + COLORREF OldColor = pDC->SetTextColor(m_TextColor); + + m_Font.SelectFont(pDC); + if (!m_bIsHorizontal) + { + pDC->ExtTextOut(m_TextRect.left + 2,m_TextRect.top, + ETO_CLIPPED,NULL,m_strLabelText.c_str(),NULL); + } + else + { + pDC->ExtTextOut(m_TextRect.left,m_TextRect.top + 2, + ETO_CLIPPED,NULL,m_strLabelText.c_str(),NULL); + } + m_Font.UnselectFont(pDC); + + pDC->SetBkMode(iPrevMode); + pDC->SetTextColor(OldColor); +} + +void CChartAxisLabel::SetPosition(int LeftBorder, int TopBorder, CDC *pDC) +{ + CSize NewSize = GetSize(pDC); + m_TextRect.top = TopBorder; + m_TextRect.bottom = TopBorder + NewSize.cy; + m_TextRect.left = LeftBorder; + m_TextRect.right = LeftBorder + NewSize.cx; +} diff --git a/ChartDemo/ChartCtrl/ChartAxisLabel.h b/ChartDemo/ChartCtrl/ChartAxisLabel.h new file mode 100644 index 0000000..1e420a8 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartAxisLabel.h @@ -0,0 +1,112 @@ +/* + * + * ChartAxisLabel.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTAXISLABEL_H__0E5519C8_A2F4_4CED_9681_32A56B25D0C5__INCLUDED_) +#define AFX_CHARTAXISLABEL_H__0E5519C8_A2F4_4CED_9681_32A56B25D0C5__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartString.h" +#include "ChartFont.h" + +class CChartCtrl; +class CChartAxis; + +//! Draws the label of an axis +/** + The label axis is displayed under or next to the tick values. + The label is retrieved by calling CChartAxis::GetAxisLabel. +**/ +class CChartAxisLabel +{ + friend CChartAxis; + +public: + //! Sets the text of the axis label. + void SetText(const TChartString& NewText); + //! Retrieves the text of the axis label. + TChartString GetText() const { return m_strLabelText; } + + //! Sets the font of the text. + /** + @param nPointSize + The font point size. + @param strFaceName + The font face name ("Times New Roman", "Arial", ...) + **/ + void SetFont(int nPointSize, const TChartString& strFaceName); + //! Sets the font of the text. + /** + This function allows to set extended font style by passing + a CChartFont object. + @param newFont + The new font. + **/ + void SetFont(const CChartFont& newFont); + + //! Shows/hides the title. + void SetVisible(bool bVisible); + //! Returns true if the title is visible. + bool IsVisible() const { return m_bIsVisible; } + + //! Retrieves the text color. + COLORREF GetColor() const { return m_TextColor; } + //! Sets the text color. + void SetColor(COLORREF NewColor); + +private: + //! Constructor + CChartAxisLabel(); + //! Destructor + virtual ~CChartAxisLabel(); + + //! Sets in horizontal or vertical mode. + void SetHorizontal(bool bHorizontal); + //! Sets the position of the label. + void SetPosition(int LeftBorder, int TopBorder, CDC *pDC); + //! Draws the label. + void Draw(CDC* pDC); + //! Retrieves the size of the label. + CSize GetSize(CDC* pDC) const; + + + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + //! Specifies if the label is visible or not. + bool m_bIsVisible; + + //! The rectangle in which the label is displayed. + CRect m_TextRect; + //! The text color. + COLORREF m_TextColor; + + //! Specifies if the axis is horizontal or not. + bool m_bIsHorizontal; + //! The font used for the text label. + CChartFont m_Font; + + //! The string to display for the label. + TChartString m_strLabelText; +}; + +#endif // !defined(AFX_CHARTAXISLABEL_H__0E5519C8_A2F4_4CED_9681_32A56B25D0C5__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartBalloonLabel.h b/ChartDemo/ChartCtrl/ChartBalloonLabel.h new file mode 100644 index 0000000..7634bb2 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartBalloonLabel.h @@ -0,0 +1,101 @@ +/* + * + * ChartBalloonLabel.h + * + * 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. + * + * + */ + +#ifndef _CHARTBALLOONLABEL_H_ +#define _CHARTBALLOONLABEL_H_ + +#include "ChartLabel.h" +#include "ChartFont.h" + +//! Specialization of the CChartLabel to display a balloon label. +/** + A balloon label is a label with a rounded rectangle area in which the + text is displayed and which is connected with a line to the point to + which it is attached. +**/ +template +class CChartBalloonLabel : public CChartLabel +{ + friend CChartSerieBase; + +public: + //! Sets the background color of the text area. + void SetBackgroundColor(COLORREF colBackground); + //! Retrieves the background color of the text area. + COLORREF GetBackgroundColor() const { return m_colBackground; } + //! Sets the color of the line connecting the point to the text area. + void SetLineColor(COLORREF colArrow); + //! Retrieves the color of the line connecting the point to the text area. + COLORREF GetLineColor() const { return m_colLine; } + //! Sets the color of border's text area. + void SetBorderColor(COLORREF colBorder); + //! Retrieves the color of border's text area. + COLORREF GetBorderColor() const { return m_colBorder; } + + //! Specifies if the text area is rounded or not. + void SetRoundedRect(bool bRounded); + //! Returns true if the text area is rounded. + bool GetRoundedRect() const { return m_bRoundedRect; } + + //! Sets the font of the text. + /** + @param nPointSize + The font point size. + @param strFaceName + The font face name ("Times New Roman", "Arial", ...) + **/ + void SetFont(int nPointSize, const TChartString& strFaceName); + //! Sets the font of the text. + /** + This function allows to set extended font style by passing + a CChartFont object. + @param newFont + The new font. + **/ + void SetFont(const CChartFont& newFont); + + //! Constructor + CChartBalloonLabel(CChartCtrl* pParentCtrl, CChartSerieBase* pParentSeries); + //! Destructor + ~CChartBalloonLabel(); + +protected: + //! Draw the label. + void Draw(CDC* pDC, unsigned uPointIndex); + +private: + //! Color of the liune connecting the point to the text area. + COLORREF m_colLine; + //! Color of the text area's background. + COLORREF m_colBackground; + //! Color of border's text area. + COLORREF m_colBorder; + + //! The font used for the text label. + CChartFont m_Font; + + //! Specifies if the rectangle is rounded or not. + bool m_bRoundedRect; +}; + +#include "ChartBalloonLabel.inl" + +#endif // _CHARTBALLOONLABEL_H_ diff --git a/ChartDemo/ChartCtrl/ChartBalloonLabel.inl b/ChartDemo/ChartCtrl/ChartBalloonLabel.inl new file mode 100644 index 0000000..db49930 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartBalloonLabel.inl @@ -0,0 +1,138 @@ +/* + * + * ChartBalloonLabel.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 "ChartCtrl.h" +#include "ChartSerie.h" +#include "ChartBalloonLabel.h" + +template +CChartBalloonLabel::CChartBalloonLabel(CChartCtrl* pParentCtrl, + CChartSerieBase* pParentSeries) + : CChartLabel(pParentCtrl, pParentSeries), m_bRoundedRect(true) +{ + m_colBackground = RGB(255,255,225); + m_colLine = RGB(255,255,255); + m_colBorder = RGB(0,0,0); +} + +template +CChartBalloonLabel::~CChartBalloonLabel() +{ +} + +template +void CChartBalloonLabel::SetBackgroundColor(COLORREF colBackground) +{ + m_colBackground = colBackground; + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartBalloonLabel::SetLineColor(COLORREF colArrow) +{ + m_colLine = colArrow; + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartBalloonLabel::SetBorderColor(COLORREF colBorder) +{ + m_colBorder = colBorder; + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartBalloonLabel::SetRoundedRect(bool bRounded) +{ + m_bRoundedRect = bRounded; + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartBalloonLabel::SetFont(int nPointSize, const TChartString& strFaceName) +{ + m_Font.SetFont(strFaceName, nPointSize); + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartBalloonLabel::SetFont(const CChartFont& newFont) +{ + m_Font = newFont; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartBalloonLabel::Draw(CDC* pDC, unsigned uPointIndex) +{ + if (m_pLabelProvider) + { + PointType Point = m_pParentSeries->GetPoint(uPointIndex); + m_strLabelText = m_pLabelProvider->GetText(m_pParentSeries, uPointIndex); + } + if (m_strLabelText == _T("")) + return; + + CPoint screenPt = m_pParentSeries->GetPointScreenCoord(uPointIndex); + + // Create the pen for the arrow + CPen newPen(PS_SOLID, 1, m_colLine); + CPen* pOldPen = pDC->SelectObject(&newPen); + + // Draw first the arrow + pDC->MoveTo(screenPt); + pDC->LineTo(screenPt.x,screenPt.y-20); + + // Create and select a new pen for the border + newPen.DeleteObject(); + newPen.CreatePen(PS_SOLID, 1, m_colBorder); + pDC->SelectObject(&newPen); + m_Font.SelectFont(pDC); + + // Create the brush to fill the rectangle + CBrush newBrush(m_colBackground); + CBrush* pOldBrush = pDC->SelectObject(&newBrush); + + // Calculate the size of the + CSize labelSize = pDC->GetTextExtent(m_strLabelText.c_str()); + labelSize += CSize(10,10); + int x = screenPt.x; + int y = screenPt.y; + CRect labelRect(CPoint(x-labelSize.cx/2,y-19-labelSize.cy),labelSize); + + // Draw the rectangle + if (m_bRoundedRect) + pDC->RoundRect(labelRect,CPoint(10,10)); + else + pDC->Rectangle(labelRect); + + // Draw the text + pDC->TextOut(labelRect.left+5,labelRect.top+5,m_strLabelText.c_str()); + + // Clean the objects + pDC->SelectObject(pOldPen); + pDC->SelectObject(pOldBrush); + newPen.DeleteObject(); + newBrush.DeleteObject(); + m_Font.UnselectFont(pDC); +} \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartBarSerie.cpp b/ChartDemo/ChartCtrl/ChartBarSerie.cpp new file mode 100644 index 0000000..eed94ec --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartBarSerie.cpp @@ -0,0 +1,392 @@ +/* + * + * ChartBarSerie.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 "ChartBarSerie.h" +#include "ChartCtrl.h" +#include + +using namespace std; + +int CChartBarSerie::m_iInterSpace = 0; +std::list CChartBarSerie::m_lstBarSeries; + +CChartBarSerie::CChartBarSerie(CChartCtrl* pParent) + : CChartXYSerie(pParent), m_iBarWidth(20), m_iBorderWidth(1), + m_BorderColor(RGB(0,0,0)), m_uGroupId(0), m_bGradient(true), + m_GradientColor(RGB(255,255,255)), m_GradientType(gtHorizontalDouble), + m_bHorizontal(false), m_dBaseLine(0), m_bAutoBaseLine(true), m_bStacked(false) +{ + m_lstBarSeries.push_back(this); + m_iShadowDepth = 3; + m_bShadow = false; +} + +CChartBarSerie::~CChartBarSerie() +{ + TBarSeriesList::iterator iter = m_lstBarSeries.begin(); + while (iter!=m_lstBarSeries.end()) + { + if ((*iter) == this) + iter = m_lstBarSeries.erase(iter); + else + iter++; + } +} + +void CChartBarSerie::SetHorizontal(bool bHorizontal) +{ + m_bHorizontal = bHorizontal; + if (m_bHorizontal) + SetSeriesOrdering(poYOrdering); + else + SetSeriesOrdering(poXOrdering); + m_pParentCtrl->RefreshCtrl(); +} + +void CChartBarSerie::SetBorderColor(COLORREF BorderColor) +{ + m_BorderColor = BorderColor; + m_pParentCtrl->RefreshCtrl(); +} +void CChartBarSerie::SetBorderWidth(int Width) +{ + m_iBorderWidth = Width; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartBarSerie::SetBarWidth(int Width) +{ + m_iBarWidth = Width; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartBarSerie::SetGroupId(unsigned GroupId) +{ + m_uGroupId = GroupId; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartBarSerie::ShowGradient(bool bShow) +{ + m_bGradient = bShow; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartBarSerie::SetGradient(COLORREF GradientColor, EGradientType GradientType) +{ + m_GradientColor = GradientColor; + m_GradientType = GradientType; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartBarSerie::SetStacked(bool bStacked) +{ + m_bStacked = bStacked; + m_pParentCtrl->RefreshCtrl(); +} + +bool CChartBarSerie::IsStacked() +{ + return m_bStacked; +} + +void CChartBarSerie::DrawBar(CDC* pDC, CBrush* pFillBrush, CBrush* pBorderBrush, + CRect BarRect) +{ + if (m_bShadow) + { + CBrush ShadowBrush(m_ShadowColor); + CRect ShadowRect(BarRect); + ShadowRect.OffsetRect(m_iShadowDepth,m_iShadowDepth); + pDC->FillRect(ShadowRect,&ShadowBrush); + } + pDC->FillRect(BarRect,pBorderBrush); + + CRect FillRect(BarRect); + FillRect.DeflateRect(m_iBorderWidth,m_iBorderWidth); + if (m_bGradient) + { + CChartGradient::DrawGradient(pDC,FillRect,m_SerieColor,m_GradientColor, + m_GradientType); + } + else + { + pDC->FillRect(FillRect,pFillBrush); + } +} + +void CChartBarSerie::Draw(CDC* pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + RefreshStackedCache(); + int iMinorOffset = GetMinorOffset(); + + CRect TempClipRect(m_PlottingRect); + TempClipRect.DeflateRect(1,1); + pDC->SetBkMode(TRANSPARENT); + pDC->IntersectClipRect(TempClipRect); + + CBrush BorderBrush(m_BorderColor); + CBrush FillBrush(m_SerieColor); + //Draw all points that haven't been drawn yet + for (m_uLastDrawnPoint;m_uLastDrawnPoint<(int)GetPointsCount();m_uLastDrawnPoint++) + { + CRect BarRect = GetBarRectangle(m_uLastDrawnPoint,iMinorOffset); + DrawBar(pDC, &FillBrush, &BorderBrush, BarRect); + } + + pDC->SelectClipRgn(NULL); + DeleteObject(BorderBrush); + DeleteObject(FillBrush); +} + +void CChartBarSerie::DrawAll(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + RefreshStackedCache(); + int iMinorOffset = GetMinorOffset(); + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + CRect TempClipRect(m_PlottingRect); + TempClipRect.DeflateRect(1,1); + if (uFirst>0) + uFirst--; + if (uLastSetBkMode(TRANSPARENT); + pDC->IntersectClipRect(TempClipRect); + + CBrush BorderBrush(m_BorderColor); + CBrush FillBrush(m_SerieColor); + for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++) + { + CRect BarRect = GetBarRectangle(m_uLastDrawnPoint,iMinorOffset); + DrawBar(pDC, &FillBrush, &BorderBrush, BarRect); + } + + pDC->SelectClipRgn(NULL); + DeleteObject(BorderBrush); + DeleteObject(FillBrush); +} + +void CChartBarSerie::DrawLegend(CDC* pDC, const CRect& rectBitmap) const +{ + if (m_strSerieName== _T("")) + return; + + //Draw bar: + CBrush BorderBrush(m_BorderColor); + pDC->FillRect(rectBitmap,&BorderBrush); + + CRect FillRect(rectBitmap); + CBrush FillBrush(m_SerieColor); + FillRect.DeflateRect(m_iBorderWidth,m_iBorderWidth); + if (m_bGradient) + { + CChartGradient::DrawGradient(pDC,FillRect,m_SerieColor,m_GradientColor,m_GradientType); + } + else + { + pDC->FillRect(FillRect,&FillBrush); + } +} + +bool CChartBarSerie::IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const +{ + uIndex = INVALID_POINT; + if (!m_bIsVisible) + return false; + + RefreshStackedCache(); + int iMinorOffset = GetMinorOffset(); + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return false; + + bool bResult = false; + for (unsigned i=uFirst ; i < uLast ; i++) + { + CRect BarRect = GetBarRectangle(i,iMinorOffset); + if (BarRect.PtInRect(screenPoint)) + { + bResult = true; + uIndex = i; + break; + } + } + return bResult; +} + +int CChartBarSerie::GetMinorOffset() const +{ + int iOffset = 0; + int iTotalWidth = 0; + int iLargestStacked = 0; + bool bFound = false; + + TBarSeriesList::const_iterator iter = m_lstBarSeries.begin(); + for (iter; iter!=m_lstBarSeries.end(); iter++) + { + // Skip the series with a different group Id + if ((*iter)->GetGroupId() != m_uGroupId) + continue; + + if ((*iter)->IsStacked() ) + { + if ((*iter)->GetBarWidth() > iLargestStacked) + iLargestStacked = (*iter)->GetBarWidth(); + } + else + { + if (!bFound) + { + if ((*iter)==this) + bFound = true; + else + iOffset += (*iter)->GetBarWidth() + m_iInterSpace; + } + iTotalWidth += (*iter)->GetBarWidth() + m_iInterSpace; + } + } + // Remove the interspace because it has been counted once too much. + iTotalWidth -= m_iInterSpace; + + if (iLargestStacked > 0) + iTotalWidth += iLargestStacked + m_iInterSpace; + + // If this series is a stacked series, it is put at the start + if (m_bStacked) + iOffset = 0; + else if (iLargestStacked > 0) + { + iOffset += iLargestStacked + m_iInterSpace; + } + return (iOffset - iTotalWidth/2); +} + +CRect CChartBarSerie::GetBarRectangle(unsigned uPointIndex, int minorOffset) const +{ + SChartXYPoint point = GetPoint(uPointIndex); + TBarSeriesList::const_iterator iter = m_lstStackedSeries.begin(); + + bool bCalcOffset = false; + if (m_bStacked && (*iter)!=this) + bCalcOffset = true; + + double dXOffset = 0; + double dYOffset = 0; + if (bCalcOffset) + { + for (iter; iter!=m_lstStackedSeries.end(); iter++) + { + if ( (*iter)->GetPointsCount() <= uPointIndex) + continue; + + if ( (*iter) == this) + break; + + dXOffset += (*iter)->GetPoint(uPointIndex).GetX(); + dYOffset += (*iter)->GetPoint(uPointIndex).GetY(); + } + } + + int barXStart, barXEnd, barYStart, barYEnd; + if (m_bHorizontal) + { + if (bCalcOffset) + { + barXStart = m_pHorizontalAxis->ValueToScreen(dXOffset); + barXEnd = m_pHorizontalAxis->ValueToScreen(dXOffset+point.X); + } + else + { + barXEnd = m_pHorizontalAxis->ValueToScreen(point.X); + if (!m_bAutoBaseLine) + barXStart = m_pHorizontalAxis->ValueToScreen(m_dBaseLine); + else + { + double Position = m_pVerticalAxis->GetPosition()/100.00; + barXStart = m_PlottingRect.left + (int)(Position * (m_PlottingRect.right-m_PlottingRect.left)); + } + } + barYStart = m_pVerticalAxis->ValueToScreen(point.Y) + minorOffset; + barYEnd = m_pVerticalAxis->ValueToScreen(point.Y) + minorOffset + m_iBarWidth; + } + else + { + if (bCalcOffset) + { + barYStart = m_pVerticalAxis->ValueToScreen(dYOffset); + barYEnd = m_pVerticalAxis->ValueToScreen(dYOffset+point.Y); + } + else + { + barYEnd = m_pVerticalAxis->ValueToScreen(point.Y); + if (!m_bAutoBaseLine) + barYStart = m_pVerticalAxis->ValueToScreen(m_dBaseLine); + else + { + double Position = m_pHorizontalAxis->GetPosition()/100.00; + barYStart = m_PlottingRect.left + (int)(Position * (m_PlottingRect.bottom-m_PlottingRect.top)); + } + } + barXStart = m_pHorizontalAxis->ValueToScreen(point.X) + minorOffset; + barXEnd = m_pHorizontalAxis->ValueToScreen(point.X) + minorOffset + m_iBarWidth; + } + + CRect barRect(min(barXStart, barXEnd), min(barYStart, barYEnd), + max(barXStart, barXEnd), max(barYStart, barYEnd) ); + return barRect; +} + +void CChartBarSerie::RefreshStackedCache() const +{ + m_lstStackedSeries.clear(); + if (!m_bStacked) + return; + + TBarSeriesList::const_iterator iter = m_lstBarSeries.begin(); + for (iter; iter!=m_lstBarSeries.end(); iter++) + { + // Skip the series with a different group Id + if ((*iter)->GetGroupId() != m_uGroupId) + continue; + + if ((*iter)->IsStacked() ) + { + m_lstStackedSeries.push_back(*iter); + } + } +} diff --git a/ChartDemo/ChartCtrl/ChartBarSerie.h b/ChartDemo/ChartCtrl/ChartBarSerie.h new file mode 100644 index 0000000..5f536b5 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartBarSerie.h @@ -0,0 +1,203 @@ +/* + * + * ChartBarSerie.h + * + * 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. + * + * + */ + +#pragma once +#include "ChartXYSerie.h" +#include "ChartGradient.h" +#include + +//! Specialization of a CChartSerie to display a bars series. +/** + This class is a specialized series class used to display vertical (default) + or horizontal bars. Each bar in the series is centered around its X value + (for vertical bars) or Y value (for horizontal bars). Bars can be grouped + together, so that they do not overlap but are stacked next to each other + (or on top of each other). This is done by specifying a group Id: bar series + with the same group Id will be grouped together (stacked). Series with different + group Id will be independant (they will be drawn as if they were the only one, + meaning that the different series will probably overlap). +**/ +class CChartBarSerie : public CChartXYSerie +{ +public: + //! Constructor + CChartBarSerie(CChartCtrl* pParent); + //! Destructor + ~CChartBarSerie(); + + //! Specifies if the bars are vertical or horizontal. + void SetHorizontal(bool bHorizontal); + //! Returns true if bars are horizontal, false otherwise. + bool GetHorizontal() const { return m_bHorizontal; } + + //! Sets the bars border color + void SetBorderColor(COLORREF BorderColor); + //! Returns the bars border color + COLORREF GetBorderColor() const { return m_BorderColor; } + //! Sets the bars border width + void SetBorderWidth(int Width); + //! Returns the bars border width + int GetBorderWidth() const { return m_iBorderWidth; } + //! Sets the bars width (in pixels) + void SetBarWidth(int Width); + //! Returns the bars width (in pixels) + int GetBarWidth() const { return m_iBarWidth; } + + //! Set the group Id of the series + /** + The group Id allows to stack series next to each other (or on top of + each other). + **/ + void SetGroupId(unsigned GroupId); + //! Returns the group Id of the series + unsigned GetGroupId() const { return m_uGroupId; } + + //! Specifies if the series is stacked with other bar series + /** + All bar series with the same group Id and with the stacked + flag to true will be drawn on top of each other (for vertical + bars). + **/ + void SetStacked(bool bStacked); + //! Returns true if the series is stacked + bool IsStacked(); + + //! Specifies if a gradient is applied to the bars + void ShowGradient(bool bShow); + //! Sets the gradient style + /** + @param GradientColor + The second color used for the gradient (the first one being + the original series color). + @param GradientType + The type of gradient used between the two colors (vertical, horizontal, ...) + **/ + void SetGradient(COLORREF GradientColor, EGradientType GradientType); + + //! Static function used to specify the space (in pixels) between series of the same group + static void SetInterSpace(int Space) { m_iInterSpace = Space; } + //! Static function returning the space between series of the same group. + static int GetInterSpace() { return m_iInterSpace; } + + //! Specifies a base line for the bars. + /** + If a baseline is specified, the bars will be drawn between that value + and the point value, instead of being drawn between the axis ans the + point value. + @param bAutomatic + If true, the bars are drawn between the axis and the point value. + @param dBaseLine + The value of the baseline. This parameter is ignored if bAutomatic is true. + **/ + void SetBaseLine(bool bAutomatic, double dBaseLine) + { + m_bAutoBaseLine = bAutomatic; + m_dBaseLine = dBaseLine; + } + + //! Check whether a screen point is on the series. + /** + This function returns true if the screen point is on one of the bars of + the series. In that case, the index of the point is stored in the uIndex + parameter. + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const; + +private: + typedef std::list TBarSeriesList; + + //! Draws the legend icon for the series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + void DrawLegend(CDC* pDC, const CRect& rectBitmap) const; + + //! Draws the most recent points of the series. + /** + This pure virtual function should be overriden by child classes. + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + void Draw(CDC* pDC); + //! Redraws the full series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + **/ + void DrawAll(CDC *pDC); + + void DrawBar(CDC* pDC, CBrush* pFillBrush, CBrush* pBorderBrush, + CRect BarRect); + + // Retrieves the offset of the serie along the minor axis (horizontal + // axis for vertical bars). This offset is based on series with the + // same group Id. + int GetMinorOffset() const; + CRect GetBarRectangle(unsigned uPointIndex, int minorOffset) const; + + void RefreshStackedCache() const; + + + //! Space between two series of the same group. + static int m_iInterSpace; + //! List of all bar series added to the control + static TBarSeriesList m_lstBarSeries; + + //! Specifies if the bars are horizontal or vertical. + bool m_bHorizontal; + + // The base line specifies the position (in terms of the value + // axis) where the bars start from. If m_bAutoBaseLine is true + // they start from the axis position. + double m_dBaseLine; + bool m_bAutoBaseLine; + + // Specifies to which group this series belongs to. Series in the same group are + // 'stacked' next to each other. + unsigned m_uGroupId; + + int m_iBarWidth; + int m_iBorderWidth; + COLORREF m_BorderColor; + + bool m_bGradient; + COLORREF m_GradientColor; + EGradientType m_GradientType; + + // Specifies if the bar series has to be stacked with other bar + // series with the same group Id + bool m_bStacked; + + // Cache of the stacked series with the same group Id as this series. + mutable TBarSeriesList m_lstStackedSeries; +}; diff --git a/ChartDemo/ChartCtrl/ChartCandlestickSerie.cpp b/ChartDemo/ChartCtrl/ChartCandlestickSerie.cpp new file mode 100644 index 0000000..2a90c4a --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCandlestickSerie.cpp @@ -0,0 +1,243 @@ +/* + * + * ChartCandlestickSerie.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 "ChartCandlestickSerie.h" +#include "ChartCtrl.h" + +CChartCandlestickSerie::CChartCandlestickSerie(CChartCtrl* pParent) + : CChartSerieBase(pParent), m_iCandlestickWidth(7) +{ + m_bShadow = true; +} + +CChartCandlestickSerie::~CChartCandlestickSerie() +{ +} + +void CChartCandlestickSerie::AddPoint(double XVal, + double Low, + double High, + double Open, + double Close) +{ + SChartCandlestickPoint NewPoint(XVal, Low, High, Open, Close); + CChartSerieBase::AddPoint(NewPoint); +} + +void CChartCandlestickSerie::SetWidth(int Width) +{ + m_iCandlestickWidth = Width; + m_pParentCtrl->RefreshCtrl(); +} + +bool CChartCandlestickSerie::IsPointOnSerie(const CPoint& screenPoint, + unsigned& uIndex) const +{ + uIndex = INVALID_POINT; + if (!m_bIsVisible) + return false; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return false; + if (uFirst>0) + uFirst--; + if (uLastValueToScreen(Point.XVal); + int ScreenLow = m_pVerticalAxis->ValueToScreen(Point.Low); + int ScreenHigh = m_pVerticalAxis->ValueToScreen(Point.High); + + int halfWidth = m_iCandlestickWidth/2; + CRect Rectangle; + if (ScreenLow > ScreenHigh) + Rectangle.SetRect(ScreenXVal-halfWidth, ScreenHigh, + ScreenXVal+halfWidth+1, ScreenLow+1); + else + Rectangle.SetRect(ScreenXVal-halfWidth, ScreenLow, + ScreenXVal+halfWidth+1, ScreenHigh+1); + if (Rectangle.PtInRect(screenPoint)) + { + bResult = true; + uIndex = i; + break; + } + } + return bResult; +} + +void CChartCandlestickSerie::DrawLegend(CDC* pDC, const CRect& rectBitmap) const +{ + if (m_strSerieName == _T("")) + return; + if (!pDC->GetSafeHdc()) + return; + + NewPen.CreatePen(PS_SOLID,1,m_SerieColor); + BrushFill.CreateSolidBrush(m_SerieColor); + CBrush* pOldBrush = pDC->SelectObject(&BrushFill); + CPen* pOldPen = pDC->SelectObject(&NewPen); + int OldBkMode = pDC->SetBkMode(TRANSPARENT); + + int margin = (rectBitmap.Width() - m_iCandlestickWidth)/2; + CRect CandleRect(rectBitmap.left+margin, rectBitmap.top+4, + rectBitmap.right-margin+1, rectBitmap.bottom-3); + pDC->Rectangle(CandleRect); + int MiddleX = rectBitmap.left + rectBitmap.Width()/2; + pDC->MoveTo(MiddleX, CandleRect.top); + pDC->LineTo(MiddleX, rectBitmap.top); + pDC->MoveTo(MiddleX, CandleRect.bottom); + pDC->LineTo(MiddleX, rectBitmap.bottom); + + pDC->SetBkMode(OldBkMode); + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldPen); + pDC->SelectObject(pOldBrush); + BrushFill.DeleteObject(); + NewPen.DeleteObject(); +} + +void CChartCandlestickSerie::Draw(CDC* pDC) +{ + if (!m_bIsVisible) + return; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + if (pDC->GetSafeHdc()) + { + ShadowBrush.CreateSolidBrush(m_ShadowColor); + NewPen.CreatePen(PS_SOLID,1,m_SerieColor); + ShadowPen.CreatePen(PS_SOLID,1,m_ShadowColor); + BrushFill.CreateSolidBrush(m_SerieColor); + BrushEmpty.CreateSolidBrush(RGB(255,255,255)); + + int OldBkMode = pDC->SetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + pDC->IntersectClipRect(m_PlottingRect); + + for (m_uLastDrawnPoint;m_uLastDrawnPointSetBkMode(OldBkMode); + pDC->SelectClipRgn(NULL); + BrushFill.DeleteObject(); + BrushEmpty.DeleteObject(); + NewPen.DeleteObject(); + ShadowBrush.DeleteObject(); + ShadowPen.DeleteObject(); + } +} + +void CChartCandlestickSerie::DrawAll(CDC *pDC) +{ + if (!m_bIsVisible) + return; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + if (pDC->GetSafeHdc()) + { + ShadowBrush.CreateSolidBrush(m_ShadowColor); + NewPen.CreatePen(PS_SOLID,1,m_SerieColor); + ShadowPen.CreatePen(PS_SOLID,1,m_ShadowColor); + BrushFill.CreateSolidBrush(m_SerieColor); + BrushEmpty.CreateSolidBrush(RGB(255,255,255)); + + pDC->SetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + pDC->IntersectClipRect(m_PlottingRect); + + for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++) + { + SChartCandlestickPoint Point = GetPoint(m_uLastDrawnPoint); + DrawCandleStick(pDC, Point); + } + + pDC->SelectClipRgn(NULL); + BrushFill.DeleteObject(); + BrushEmpty.DeleteObject(); + NewPen.DeleteObject(); + ShadowBrush.DeleteObject(); + ShadowPen.DeleteObject(); + } +} + +void CChartCandlestickSerie::DrawCandleStick(CDC* pDC, SChartCandlestickPoint Point) +{ + int ScreenXVal = m_pHorizontalAxis->ValueToScreen(Point.XVal); + int ScreenOpen = m_pVerticalAxis->ValueToScreen(Point.Open); + int ScreenClose = m_pVerticalAxis->ValueToScreen(Point.Close); + int ScreenLow = m_pVerticalAxis->ValueToScreen(Point.Low); + int ScreenHigh = m_pVerticalAxis->ValueToScreen(Point.High); + + int halfWidth = m_iCandlestickWidth/2; + CPoint TopLeft, BottomRight; + CRect Body; + CRect ShadowBody; + if (ScreenOpen > ScreenClose) + Body.SetRect(ScreenXVal-halfWidth, ScreenClose, + ScreenXVal+halfWidth+1, ScreenOpen+1); + else + Body.SetRect(ScreenXVal-halfWidth, ScreenOpen, + ScreenXVal+halfWidth+1, ScreenClose+1); + + ShadowBody = Body; + ShadowBody.OffsetRect(m_iShadowDepth, m_iShadowDepth); + + CBrush* pOldBrush = pDC->SelectObject(&ShadowBrush); + CPen* pOldPen = pDC->SelectObject(&ShadowPen); + + if (m_bShadow) + pDC->Rectangle(ShadowBody); + if (Point.Open > Point.Close) + pDC->SelectObject(&BrushFill); + else + pDC->SelectObject(&BrushEmpty); + + if (m_bShadow) + { + pDC->MoveTo(ScreenXVal+m_iShadowDepth, ScreenOpen+m_iShadowDepth); + pDC->LineTo(ScreenXVal+m_iShadowDepth, ScreenHigh+m_iShadowDepth); + pDC->MoveTo(ScreenXVal+m_iShadowDepth, ScreenClose+m_iShadowDepth); + pDC->LineTo(ScreenXVal+m_iShadowDepth, ScreenLow+m_iShadowDepth); + } + pDC->SelectObject(&NewPen); + pDC->MoveTo(ScreenXVal, ScreenOpen); pDC->LineTo(ScreenXVal, ScreenHigh); + pDC->MoveTo(ScreenXVal, ScreenClose); pDC->LineTo(ScreenXVal, ScreenLow); + + pDC->Rectangle(Body); + pDC->SelectObject(pOldBrush); + pDC->SelectObject(pOldPen); +} \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartCandlestickSerie.h b/ChartDemo/ChartCtrl/ChartCandlestickSerie.h new file mode 100644 index 0000000..87d7ed8 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCandlestickSerie.h @@ -0,0 +1,142 @@ +/* + * + * ChartCandlestickSerie.h + * + * 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. + * + * + */ + +#pragma once +#include "ChartSerieBase.h" + +//! Point structure used as template parameter for candlestick series +struct SChartCandlestickPoint +{ + SChartCandlestickPoint() { } + SChartCandlestickPoint(double XValue, double LowVal, + double HighVal, double OpenVal, double CloseVal): + XVal(XValue), Low(LowVal), High(HighVal), + Open(OpenVal), Close(CloseVal) { } + + //! The X value of the point (usually, a time) + double XVal; + //! The low market price + double Low; + //! The high market price + double High; + //! The open market price + double Open; + //! The close market price + double Close; + + //! Returns the X value of the point + double GetX() const { return XVal; } + //! Returns the Y value of the point, which is the average between low and high + double GetY() const { return (Low+High)/2; } + //! Returns the minimum X value of the point + double GetXMin() const { return XVal; } + //! Returns the maximum X value of the point + double GetXMax() const { return XVal; } + //! Returns the minimum Y value of the point (the low value) + double GetYMin() const { return Low; } + //! Returns the maximum Y value of the point (the high value) + double GetYMax() const { return High; } +}; + +//! Specialization of a CChartSerieBase to display a candlestick series. +/** + Each point in the series has an X value (the time), a high value + (the highest market price), a low value (the lowest market price), + an open value (the market price at the opening) and a close value + (the market price at the closing). +**/ +class CChartCandlestickSerie : public CChartSerieBase +{ +public: + //! Constructor + CChartCandlestickSerie(CChartCtrl* pParent); + //! Destructor + ~CChartCandlestickSerie(); + + //! Tests if a certain screen point is on the series. + /** + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const; + + //! Adds a new point in the series + /** + @param XVal + The X value of the point (the time) + @param Low + The lowest market price + @param High + The highest market price + @param Open + The market price at the opening + @param Close + The market price at the closing + **/ + void AddPoint(double XVal, double Low, double High, + double Open, double Close); + //! Sets the width (in pixels) of all candlestick points in the series + void SetWidth(int Width); + //! Returns the width (in pixels) of a point in the series + int GetWidth() { return m_iCandlestickWidth; } + +protected: + //! Draws the legend icon for the series. + /** + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + void DrawLegend(CDC* pDC, const CRect& rectBitmap) const; + + //! Draws the most recent points of the series. + /** + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + void Draw(CDC* pDC); + //! Redraws the full series. + /** + @param pDC + The device context used to draw + **/ + void DrawAll(CDC *pDC); + +private: + //! Draws a candle stick point + void DrawCandleStick(CDC *pDC, SChartCandlestickPoint Point); + + //! The candlestick width + int m_iCandlestickWidth; + + // Caches the pen and brushes to avoid creating them for each point + mutable CBrush ShadowBrush; + mutable CPen NewPen; + mutable CPen ShadowPen; + mutable CBrush BrushFill; + mutable CBrush BrushEmpty; +}; \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartCrossHairCursor.cpp b/ChartDemo/ChartCtrl/ChartCrossHairCursor.cpp new file mode 100644 index 0000000..a0bb398 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCrossHairCursor.cpp @@ -0,0 +1,62 @@ +/* + * + * ChartCrossHairCursor.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 "ChartCrossHairCursor.h" +#include "ChartCtrl.h" + +CChartCrossHairCursor::CChartCrossHairCursor(CChartCtrl* pParent, + CChartAxis* pHorizAxis, + CChartAxis* pVertAxis) + : CChartCursor(pParent), m_pHorizontalAxis(pHorizAxis), m_pVerticalAxis(pVertAxis), + m_lXPos(0), m_lYPos(0) +{ +} + +CChartCrossHairCursor::~CChartCrossHairCursor() +{ +} + +void CChartCrossHairCursor::Draw(CDC* pDC) +{ + CPen NewPen(PS_SOLID,1,m_colCursor); + CPen* pOldPen = pDC->SelectObject(&NewPen); + + CRect plottingRect = m_pParentCtrl->GetPlottingRect(); + + pDC->MoveTo(m_lXPos, plottingRect.top); + pDC->LineTo(m_lXPos, plottingRect.bottom); + pDC->MoveTo(plottingRect.left, m_lYPos); + pDC->LineTo(plottingRect.right, m_lYPos); + + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} + +void CChartCrossHairCursor::OnMouseMove(CPoint mousePoint) +{ + m_lXPos = mousePoint.x; + m_lYPos = mousePoint.y; + + double XVal = m_pHorizontalAxis->ScreenToValue(m_lXPos); + double YVal = m_pVerticalAxis->ScreenToValue(m_lYPos); + CursorMoved(XVal, YVal); +} diff --git a/ChartDemo/ChartCtrl/ChartCrossHairCursor.h b/ChartDemo/ChartCtrl/ChartCrossHairCursor.h new file mode 100644 index 0000000..66b8ba2 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCrossHairCursor.h @@ -0,0 +1,72 @@ +/* + * + * ChartCrossHairCursor.h + * + * 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. + * + * + */ + +#ifndef _CHARTCROSSHAIRCURSOR_H_ +#define _CHARTCROSSHAIRCURSOR_H_ + +#include "ChartCursor.h" + +class CChartAxis; + +//! Specialization of a CChartCursor class for a cross-hair cursor. +/** + A cross-hair cursor is a simple cross displayed in the plotting area. + The cursor moves along with the mouse (but stay within the bounds of + the plot area).
+ To create a cross-hair cursor, call the CreateCrossHairCursor from the + CChartCtrl class. +**/ +class CChartCrossHairCursor : public CChartCursor +{ + friend CChartCtrl; + +protected: + //! Called when the mouse is moved over the plot area. + void OnMouseMove(CPoint mousePoint); + //! Draws the cursor. + void Draw(CDC* pDC); + +private: + //! Constructor + /** + @param pParent + The parent charting control + @param pHorizAxis + The associated horizontal axis + @param pVertAxis + The associated vertical axis + **/ + CChartCrossHairCursor(CChartCtrl* pParent, CChartAxis* pHorizAxis, CChartAxis* pVertAxis); + //! Destructor + ~CChartCrossHairCursor(); + + //! The associated horizontal axis + CChartAxis* m_pHorizontalAxis; + //! The associated vertical axis + CChartAxis* m_pVerticalAxis; + + //! The current X screen position + long m_lXPos; + //! The current Y screen position + long m_lYPos; +}; + +#endif // _CHARTCROSSHAIRCURSOR_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartCtrl.cpp b/ChartDemo/ChartCtrl/ChartCtrl.cpp new file mode 100644 index 0000000..9cd2e03 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCtrl.cpp @@ -0,0 +1,1143 @@ +/* + * + * ChartCtrl.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. + * + * + * History: + * - 18/05/2006: Added support for panning + * - 28/05/2006: Bug corrected in RemoveAllSeries + * - 28/05/2006: Added support for resizing + * - 12/06/2006: Added support for manual zoom + * - 10/08/2006: Added SetZoomMinMax and UndoZoom + * - 24/03/2007: GDI leak corrected + * - 24/03/2007: Invisible series are not taken in account for auto axis + * and legend (thanks to jerminator-jp). + * - 24/03/2007: possibility to specify a margin for the axis. Needs to be improved + * - 05/04/2007: ability to change the text color of the axis. + * - 05/04/2007: ability to change the color of the border of the drawing area. + * - 05/04/2007: Surface series added. + * - 26/08/2007: The clipping area of the series is a bit larger (they will be + * drawn over the bottom and right axes). + * - 12/01/2007: Ability to change the color of the zoom rectangle. + * - 08/02/2008: Added convenience functions to convert from date to value and + * opposite. + * - 21/02/2008: The zoom doesn't do anything if the user only clicks on the control + * (thanks to Eugene Pustovoyt). + * - 29/02/2008: The auto axis are now refreshed when a series is removed (thanks to + * Bruno Lavier). + * - 08/03/2008: EnableRefresh function added (thanks to Bruno Lavier). + * - 21/03/2008: Added support for scrolling. + * - 25/03/2008: UndoZoom function added. + * - 25/03/2008: A series can now be removed using its pointer. + * - 12/08/2008: Performance patch (thanks to Nick Holgate). + * - 18/08/2008: Added support for printing. + * - 31/10/2008: Fixed a bug for unicode. + * + */ + +#include "stdafx.h" +#include "ChartCtrl.h" + +#include "ChartSerie.h" +#include "ChartGradient.h" +#include "ChartStandardAxis.h" +#include "ChartDateTimeAxis.h" +#include "ChartLogarithmicAxis.h" +#include "ChartCrossHairCursor.h" +#include "ChartDragLineCursor.h" + +#include "ChartPointsSerie.h" +#include "ChartLineSerie.h" +#include "ChartSurfaceSerie.h" +#include "ChartBarSerie.h" +#include "ChartCandlestickSerie.h" +#include "ChartGanttSerie.h" + +#if _MFC_VER > 0x0600 +#include "atlImage.h" +#endif + +using namespace std; + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define CHARTCTRL_CLASSNAME _T("ChartCtrl") // Window class name + + +COLORREF pSeriesColorTable[] = { RGB(255,0,0), RGB(0,150,0), RGB(0,0,255), RGB(255,255,0), RGB(0,255,255), + RGB(255,128,0), RGB(128,0,128), RGB(128,128,0), RGB(255,0,255), RGB(64,128,128)}; + +///////////////////////////////////////////////////////////////////////////// +// CChartCtrl + +CChartCtrl::CChartCtrl() +{ + RegisterWindowClass(); + + m_iEnableRefresh = 1; + m_bPendingRefresh = false; + m_BorderColor = RGB(0,0,0); + m_BackColor = GetSysColor(COLOR_BTNFACE); + EdgeType = EDGE_RAISED; + m_BackGradientType = gtVertical; + m_bBackGradient = false; + m_BackGradientCol1 = m_BackGradientCol2 = m_BackColor; + + for (int i=0;i<4;i++) + m_pAxes[i] = NULL; + + m_pLegend = new CChartLegend(this); + m_pTitles = new CChartTitle(this); + + m_bMemDCCreated = false; + m_bPanEnabled = true; + m_bRMouseDown = false; + + m_bZoomEnabled = true; + m_bLMouseDown = false; + m_ZoomRectColor = RGB(255,255,255); + + m_bToolBarCreated = false; + m_pMouseListener = NULL; + m_bMouseVisible = true; +} + +CChartCtrl::~CChartCtrl() +{ + TSeriesMap::iterator seriesIter = m_mapSeries.begin(); + for (seriesIter; seriesIter!=m_mapSeries.end(); seriesIter++) + { + delete (seriesIter->second); + } + TCursorMap::iterator cursorIter = m_mapCursors.begin(); + for (cursorIter; cursorIter!=m_mapCursors.end(); cursorIter++) + { + delete (cursorIter->second); + } + + for (int i=0; i<4 ;i++) + { + if (m_pAxes[i]) + delete m_pAxes[i]; + } + + if (m_pLegend) + { + delete m_pLegend; + m_pLegend = NULL; + } + if (m_pTitles) + { + delete m_pTitles; + m_pTitles = NULL; + } +} + + +BEGIN_MESSAGE_MAP(CChartCtrl, CWnd) + //{{AFX_MSG_MAP(CChartCtrl) + ON_WM_PAINT() + ON_WM_ERASEBKGND() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() + ON_WM_LBUTTONDBLCLK() + ON_WM_RBUTTONDOWN() + ON_WM_RBUTTONUP() + ON_WM_RBUTTONDBLCLK() + ON_WM_SIZE() + ON_WM_HSCROLL() + ON_WM_VSCROLL() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CChartCtrl message handlers + +void CChartCtrl::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + if (!m_bMemDCCreated) + { + RefreshCtrl(); + m_bMemDCCreated = true; + } + + // Get Size of Display area + CRect rect; + GetClientRect(&rect); + dc.BitBlt(0, 0, rect.Width(), rect.Height(), + &m_BackgroundDC, 0, 0, SRCCOPY) ; + + // Draw the zoom rectangle + if (m_bZoomEnabled && m_bLMouseDown) + { + CPen NewPen(PS_SOLID,1,m_ZoomRectColor); + CPen* pOldPen = dc.SelectObject(&NewPen); + + dc.MoveTo(m_rectZoomArea.TopLeft()); + dc.LineTo(m_rectZoomArea.right,m_rectZoomArea.top); + dc.LineTo(m_rectZoomArea.BottomRight()); + dc.LineTo(m_rectZoomArea.left,m_rectZoomArea.bottom); + dc.LineTo(m_rectZoomArea.TopLeft()); + + dc.SelectObject(pOldPen); + DeleteObject(NewPen); + } + + // Draw the cursors. + TCursorMap::iterator iter = m_mapCursors.begin(); + for (iter; iter!=m_mapCursors.end(); iter++) + iter->second->Draw(&dc); +} + +BOOL CChartCtrl::OnEraseBkgnd(CDC* ) +{ + // To avoid flickering +// return CWnd::OnEraseBkgnd(pDC); + return FALSE; +} + +CChartCrossHairCursor* CChartCtrl::CreateCrossHairCursor(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartAxis* pHorizAxis = NULL; + CChartAxis* pVertAxis = NULL; + if (bSecondaryHorizAxis) + pHorizAxis = m_pAxes[TopAxis]; + else + pHorizAxis = m_pAxes[BottomAxis]; + if (bSecondaryVertAxis) + pVertAxis = m_pAxes[RightAxis]; + else + pVertAxis = m_pAxes[LeftAxis]; + + ASSERT(pHorizAxis != NULL); + ASSERT(pVertAxis != NULL); + + CChartCrossHairCursor* pNewCursor = new CChartCrossHairCursor(this, pHorizAxis, pVertAxis); + m_mapCursors[pNewCursor->GetCursorId()] = pNewCursor; + return pNewCursor; +} + +CChartDragLineCursor* CChartCtrl::CreateDragLineCursor(EAxisPos relatedAxis) +{ + ASSERT(m_pAxes[relatedAxis] != NULL); + + CChartDragLineCursor* pNewCursor = new CChartDragLineCursor(this, m_pAxes[relatedAxis]); + m_mapCursors[pNewCursor->GetCursorId()] = pNewCursor; + return pNewCursor; +} + +void CChartCtrl::AttachCustomCursor(CChartCursor* pCursor) +{ + m_mapCursors[pCursor->GetCursorId()] = pCursor; +} + +void CChartCtrl::RemoveCursor(unsigned cursorId) +{ + TCursorMap::iterator iter = m_mapCursors.find(cursorId); + if (iter != m_mapCursors.end()) + { + delete iter->second; + m_mapCursors.erase(iter); + } +} + +void CChartCtrl::ShowMouseCursor(bool bShow) +{ + m_bMouseVisible = bShow; + if (!bShow) + SetCursor(NULL); +} + +CChartStandardAxis* CChartCtrl::CreateStandardAxis(EAxisPos axisPos) +{ + CChartStandardAxis* pAxis = new CChartStandardAxis(); + AttachCustomAxis(pAxis, axisPos); + return pAxis; +} + +CChartLogarithmicAxis* CChartCtrl::CreateLogarithmicAxis(EAxisPos axisPos) +{ + CChartLogarithmicAxis* pAxis = new CChartLogarithmicAxis(); + AttachCustomAxis(pAxis, axisPos); + return pAxis; +} + +CChartDateTimeAxis* CChartCtrl::CreateDateTimeAxis(EAxisPos axisPos) +{ + CChartDateTimeAxis* pAxis = new CChartDateTimeAxis(); + AttachCustomAxis(pAxis, axisPos); + return pAxis; +} + +void CChartCtrl::AttachCustomAxis(CChartAxis* pAxis, EAxisPos axisPos) +{ + // The axis should not be already attached to another control + ASSERT(pAxis->m_pParentCtrl == NULL); + pAxis->SetParent(this); + + if ( (axisPos==RightAxis) || (axisPos==TopAxis) ) + pAxis->SetSecondary(true); + if ( (axisPos==BottomAxis) || (axisPos==TopAxis) ) + pAxis->SetHorizontal(true); + else + pAxis->SetHorizontal(false); + pAxis->CreateScrollBar(); + + // Beofre storing the new axis, we should delete the previous one if any + if (m_pAxes[axisPos]) + delete m_pAxes[axisPos]; + m_pAxes[axisPos] = pAxis; +} + +bool CChartCtrl::RegisterWindowClass() +{ + WNDCLASS wndcls; + HINSTANCE hInst = AfxGetInstanceHandle(); + + if (!(::GetClassInfo(hInst, CHARTCTRL_CLASSNAME, &wndcls))) + { + memset(&wndcls, 0, sizeof(WNDCLASS)); + + wndcls.hInstance = hInst; + wndcls.lpfnWndProc = ::DefWindowProc; + wndcls.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW); + wndcls.hIcon = 0; + wndcls.lpszMenuName = NULL; + wndcls.hbrBackground = (HBRUSH) ::GetStockObject(WHITE_BRUSH); + wndcls.style = CS_DBLCLKS; + wndcls.cbClsExtra = 0; + wndcls.cbWndExtra = 0; + wndcls.lpszClassName = CHARTCTRL_CLASSNAME; + + if (!RegisterClass(&wndcls)) + { + // AfxThrowResourceException(); + return false; + } + } + + return true; + +} + +int CChartCtrl::Create(CWnd *pParentWnd, const RECT &rect, UINT nID, DWORD dwStyle) +{ + dwStyle |= WS_CLIPCHILDREN; + int Result = CWnd::Create(CHARTCTRL_CLASSNAME, _T(""), dwStyle, rect, pParentWnd, nID); + + if (Result) + RefreshCtrl(); + + return Result; +} + +void CChartCtrl::SetBackGradient(COLORREF Col1, COLORREF Col2, EGradientType GradientType) +{ + m_bBackGradient = true; + m_BackGradientCol1 = Col1; + m_BackGradientCol2 = Col2; + m_BackGradientType = GradientType; + RefreshCtrl(); +} + +void CChartCtrl::EnableRefresh(bool bEnable) +{ + if (bEnable) + m_iEnableRefresh++; + else + m_iEnableRefresh--; + if (m_iEnableRefresh > 0 && m_bPendingRefresh) + { + m_bPendingRefresh = false; + RefreshCtrl(); + } +} + +void CChartCtrl::UndoPanZoom() +{ + EnableRefresh(false); + if (m_pAxes[BottomAxis]) + m_pAxes[BottomAxis]->UndoZoom(); + if (m_pAxes[LeftAxis]) + m_pAxes[LeftAxis]->UndoZoom(); + if (m_pAxes[TopAxis]) + m_pAxes[TopAxis]->UndoZoom(); + if (m_pAxes[RightAxis]) + m_pAxes[RightAxis]->UndoZoom(); + EnableRefresh(true); +} + +void CChartCtrl::RefreshCtrl() +{ + // Window is not created yet, so skip the refresh. + if (!GetSafeHwnd()) + return; + if (m_iEnableRefresh < 1) + { + m_bPendingRefresh = true; + return; + } + + // Retrieve the client rect and initialize the + // plotting rect + CClientDC dc(this) ; + CRect ClientRect; + GetClientRect(&ClientRect); + m_PlottingRect = ClientRect; + + // If the backgroundDC was not created yet, create it (it + // is used to avoid flickering). + if (!m_BackgroundDC.GetSafeHdc() ) + { + CBitmap memBitmap; + m_BackgroundDC.CreateCompatibleDC(&dc) ; + memBitmap.CreateCompatibleBitmap(&dc, ClientRect.Width(),ClientRect.Height()) ; + m_BackgroundDC.SelectObject(&memBitmap) ; + } + + // Draw the chart background, which is not part of + // the DrawChart function (to avoid a background when + // printing). + DrawBackground(&m_BackgroundDC, ClientRect); + ClientRect.DeflateRect(3,3); + DrawChart(&m_BackgroundDC,ClientRect); + for (int i=0; i<4 ;i++) + { + if (m_pAxes[i]) + m_pAxes[i]->UpdateScrollBarPos(); + } + Invalidate(); +} + +void CChartCtrl::DrawChart(CDC* pDC, CRect ChartRect) +{ + m_PlottingRect = ChartRect; + CSize TitleSize = m_pTitles->GetSize(pDC); + CRect rcTitle; + rcTitle = ChartRect; + rcTitle.bottom = TitleSize.cy; + + ChartRect.top += TitleSize.cy; + m_pTitles->SetTitleRect(rcTitle); + m_pTitles->Draw(pDC); + + m_pLegend->ClipArea(ChartRect,pDC); + + //Clip all the margins (axis) of the client rect + int n=0; + for (n=0;n<4;n++) + { + if (m_pAxes[n]) + { + m_pAxes[n]->SetAxisSize(ChartRect,m_PlottingRect); + m_pAxes[n]->Recalculate(); + m_pAxes[n]->ClipMargin(ChartRect,m_PlottingRect,pDC); + } + } + for (n=0;n<4;n++) + { + if (m_pAxes[n]) + { + m_pAxes[n]->SetAxisSize(ChartRect,m_PlottingRect); + m_pAxes[n]->Recalculate(); + m_pAxes[n]->Draw(pDC); + } + } + + CPen SolidPen(PS_SOLID,0,m_BorderColor); + CPen* pOldPen = pDC->SelectObject(&SolidPen); + + pDC->MoveTo(m_PlottingRect.left,m_PlottingRect.top); + pDC->LineTo(m_PlottingRect.right,m_PlottingRect.top); + pDC->LineTo(m_PlottingRect.right,m_PlottingRect.bottom); + pDC->LineTo(m_PlottingRect.left,m_PlottingRect.bottom); + pDC->LineTo(m_PlottingRect.left,m_PlottingRect.top); + + pDC->SelectObject(pOldPen); + DeleteObject(SolidPen); + + TSeriesMap::iterator iter = m_mapSeries.begin(); + for (iter; iter!=m_mapSeries.end(); iter++) + { + CRect drawingRect = m_PlottingRect; + drawingRect.bottom += 1; + drawingRect.right += 1; + iter->second->SetPlottingRect(drawingRect); + iter->second->DrawAll(pDC); + } + + pDC->IntersectClipRect(m_PlottingRect); + // Draw the labels when all series have been drawn + for (iter=m_mapSeries.begin(); iter!=m_mapSeries.end(); iter++) + { + iter->second->DrawLabels(pDC); + } + pDC->SelectClipRgn(NULL); + + // Draw the legend at the end (when floating it should come over the plotting area). + m_pLegend->Draw(pDC); +} + +void CChartCtrl::DrawBackground(CDC* pDC, CRect ChartRect) +{ + CBrush BrushBack; + BrushBack.CreateSolidBrush(m_BackColor) ; + if (!m_bBackGradient) + { + pDC->SetBkColor(m_BackColor); + pDC->FillRect(ChartRect,&BrushBack); + } + else + { + CChartGradient::DrawGradient(pDC,ChartRect,m_BackGradientCol1, + m_BackGradientCol2,m_BackGradientType); + } + + // Draw the edge. + pDC->DrawEdge(ChartRect,EdgeType,BF_RECT); +} + +void CChartCtrl::RefreshScreenAutoAxes() +{ + for (int n=0;n<4;n++) + { + if (m_pAxes[n]) + m_pAxes[n]->RefreshScreenAutoAxis(); + } +} + +CChartPointsSerie* CChartCtrl::CreatePointsSerie(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartPointsSerie* pNewSerie = new CChartPointsSerie(this); + AttachCustomSerie(pNewSerie, bSecondaryHorizAxis, bSecondaryVertAxis); + return pNewSerie; +} + +CChartLineSerie* CChartCtrl::CreateLineSerie(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartLineSerie* pNewSerie = new CChartLineSerie(this); + AttachCustomSerie(pNewSerie, bSecondaryHorizAxis, bSecondaryVertAxis); + return pNewSerie; +} + +CChartSurfaceSerie* CChartCtrl::CreateSurfaceSerie(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartSurfaceSerie* pNewSerie = new CChartSurfaceSerie(this); + AttachCustomSerie(pNewSerie, bSecondaryHorizAxis, bSecondaryVertAxis); + return pNewSerie; +} + +CChartBarSerie* CChartCtrl::CreateBarSerie(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartBarSerie* pNewSerie = new CChartBarSerie(this); + AttachCustomSerie(pNewSerie, bSecondaryHorizAxis, bSecondaryVertAxis); + return pNewSerie; +} + +CChartCandlestickSerie* CChartCtrl::CreateCandlestickSerie(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartCandlestickSerie* pNewSerie = new CChartCandlestickSerie(this); + AttachCustomSerie(pNewSerie, bSecondaryHorizAxis, bSecondaryVertAxis); + return pNewSerie; +} + +CChartGanttSerie* CChartCtrl::CreateGanttSerie(bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + CChartGanttSerie* pNewSerie = new CChartGanttSerie(this); + AttachCustomSerie(pNewSerie, bSecondaryHorizAxis, bSecondaryVertAxis); + return pNewSerie; +} + +void CChartCtrl::AttachCustomSerie(CChartSerie* pNewSeries, + bool bSecondaryHorizAxis, + bool bSecondaryVertAxis) +{ + size_t ColIndex = m_mapSeries.size()%10; + + CChartAxis* pHorizAxis = NULL; + CChartAxis* pVertAxis = NULL; + if (bSecondaryHorizAxis) + pHorizAxis = m_pAxes[TopAxis]; + else + pHorizAxis = m_pAxes[BottomAxis]; + if (bSecondaryVertAxis) + pVertAxis = m_pAxes[RightAxis]; + else + pVertAxis = m_pAxes[LeftAxis]; + + ASSERT(pHorizAxis != NULL); + ASSERT(pVertAxis != NULL); + + if (pNewSeries) + { + pNewSeries->SetPlottingRect(m_PlottingRect); + pNewSeries->SetColor(pSeriesColorTable[ColIndex]); + pNewSeries->m_pHorizontalAxis = pHorizAxis; + pNewSeries->m_pVerticalAxis = pVertAxis; + m_mapSeries[pNewSeries->GetSerieId()] = pNewSeries; + + EnableRefresh(false); + pVertAxis->RegisterSeries(pNewSeries); + pVertAxis->RefreshAutoAxis(); + pHorizAxis->RegisterSeries(pNewSeries); + pHorizAxis->RefreshAutoAxis(); + + // The series will need to be redrawn so we need to refresh the control + RefreshCtrl(); + EnableRefresh(true); + } +} + +CChartSerie* CChartCtrl::GetSerie(size_t uSerieId) const +{ + CChartSerie* pToReturn = NULL; + TSeriesMap::const_iterator iter = m_mapSeries.find(uSerieId); + if (iter != m_mapSeries.end()) + { + pToReturn = iter->second; + } + + return pToReturn; +} + +void CChartCtrl::RemoveSerie(unsigned uSerieId) +{ + TSeriesMap::iterator iter = m_mapSeries.find(uSerieId); + if (iter != m_mapSeries.end()) + { + CChartSerie* pToDelete = iter->second; + m_mapSeries.erase(iter); + + EnableRefresh(false); + pToDelete->m_pVerticalAxis->UnregisterSeries(pToDelete); + pToDelete->m_pHorizontalAxis->UnregisterSeries(pToDelete); + pToDelete->m_pVerticalAxis->RefreshAutoAxis(); + pToDelete->m_pHorizontalAxis->RefreshAutoAxis(); + delete pToDelete; + RefreshCtrl(); + EnableRefresh(true); + } +} + +void CChartCtrl::RemoveAllSeries() +{ + TSeriesMap::iterator iter = m_mapSeries.begin(); + for (iter; iter != m_mapSeries.end(); iter++) + { + delete iter->second; + } + + m_mapSeries.clear(); + RefreshCtrl(); +} + + +CChartAxis* CChartCtrl::GetBottomAxis() const +{ + return (m_pAxes[BottomAxis]); +} + +CChartAxis* CChartCtrl::GetLeftAxis() const +{ + return (m_pAxes[LeftAxis]); +} + +CChartAxis* CChartCtrl::GetTopAxis() const +{ + return (m_pAxes[TopAxis]); +} + +CChartAxis* CChartCtrl::GetRightAxis() const +{ + return (m_pAxes[RightAxis]); +} + + +CDC* CChartCtrl::GetDC() +{ + return &m_BackgroundDC; +} + + +size_t CChartCtrl::GetSeriesCount() const +{ + return m_mapSeries.size(); +} + +///////////////////////////////////////////////////////////////////////////// +// Mouse events + +void CChartCtrl::OnMouseMove(UINT nFlags, CPoint point) +{ + if (m_bRMouseDown && m_bPanEnabled) + { + if (point != m_PanAnchor) + { + EnableRefresh(false); + if (m_pAxes[LeftAxis]) + m_pAxes[LeftAxis]->PanAxis(m_PanAnchor.y,point.y); + if (m_pAxes[RightAxis]) + m_pAxes[RightAxis]->PanAxis(m_PanAnchor.y,point.y); + if (m_pAxes[BottomAxis]) + m_pAxes[BottomAxis]->PanAxis(m_PanAnchor.x,point.x); + if (m_pAxes[TopAxis]) + m_pAxes[TopAxis]->PanAxis(m_PanAnchor.x,point.x); + RefreshCtrl(); + EnableRefresh(true); + // Force an immediate repaint of the window, so that the mouse messages + // are by passed (this allows for a smooth pan) + UpdateWindow(); + + m_PanAnchor = point; + } + } + + if (m_bLMouseDown && m_bZoomEnabled) + { + m_rectZoomArea.BottomRight() = point; + Invalidate(); + } + + for (int i=0; i<4; i++) + { + if (m_pAxes[i]) + m_pAxes[i]->m_pScrollBar->OnMouseLeave(); + } + CWnd* pWnd = ChildWindowFromPoint(point); + if (pWnd != this) + { + CChartScrollBar* pScrollBar = dynamic_cast(pWnd); + if (pScrollBar) + pScrollBar->OnMouseEnter(); + } + + if (m_PlottingRect.PtInRect(point)) + { + TCursorMap::iterator iter = m_mapCursors.begin(); + for (iter; iter!=m_mapCursors.end(); iter++) + iter->second->OnMouseMove(point); + + Invalidate(); + } + + if (!m_bMouseVisible && m_PlottingRect.PtInRect(point)) + SetCursor(NULL); + else + SetCursor(::LoadCursor(NULL,IDC_ARROW)); + + SendMouseEvent(CChartMouseListener::MouseMove, point); + CWnd::OnMouseMove(nFlags, point); +} + +void CChartCtrl::OnLButtonDown(UINT nFlags, CPoint point) +{ + SetCapture(); + if (m_bZoomEnabled) + { + m_bLMouseDown = true; + m_rectZoomArea.TopLeft() = point; + m_rectZoomArea.BottomRight() = point; + } + + if (m_PlottingRect.PtInRect(point)) + { + TCursorMap::iterator iter = m_mapCursors.begin(); + for (iter; iter!=m_mapCursors.end(); iter++) + iter->second->OnMouseButtonDown(point); + + Invalidate(); + } + + SendMouseEvent(CChartMouseListener::LButtonDown, point); + CWnd::OnLButtonDown(nFlags, point); +} + +void CChartCtrl::OnLButtonUp(UINT nFlags, CPoint point) +{ + ReleaseCapture(); + m_bLMouseDown = false; + if (m_bZoomEnabled) + { + if ( (m_rectZoomArea.left > m_rectZoomArea.right) || + (m_rectZoomArea.top > m_rectZoomArea.bottom)) + { + UndoPanZoom(); + } + else if ( (m_rectZoomArea.left!=m_rectZoomArea.right) && + (m_rectZoomArea.top!=m_rectZoomArea.bottom)) + { + double MinVal = 0; + double MaxVal = 0; + + if (m_pAxes[BottomAxis]) + { + if (m_pAxes[BottomAxis]->IsInverted()) + { + MaxVal = m_pAxes[BottomAxis]->ScreenToValue(m_rectZoomArea.left); + MinVal = m_pAxes[BottomAxis]->ScreenToValue(m_rectZoomArea.right); + } + else + { + MinVal = m_pAxes[BottomAxis]->ScreenToValue(m_rectZoomArea.left); + MaxVal = m_pAxes[BottomAxis]->ScreenToValue(m_rectZoomArea.right); + } + m_pAxes[BottomAxis]->SetZoomMinMax(MinVal,MaxVal); + } + + if (m_pAxes[LeftAxis]) + { + if (m_pAxes[LeftAxis]->IsInverted()) + { + MaxVal = m_pAxes[LeftAxis]->ScreenToValue(m_rectZoomArea.bottom); + MinVal = m_pAxes[LeftAxis]->ScreenToValue(m_rectZoomArea.top); + } + else + { + MinVal = m_pAxes[LeftAxis]->ScreenToValue(m_rectZoomArea.bottom); + MaxVal = m_pAxes[LeftAxis]->ScreenToValue(m_rectZoomArea.top); + } + m_pAxes[LeftAxis]->SetZoomMinMax(MinVal,MaxVal); + } + + if (m_pAxes[TopAxis]) + { + if (m_pAxes[TopAxis]->IsInverted()) + { + MaxVal = m_pAxes[TopAxis]->ScreenToValue(m_rectZoomArea.left); + MinVal = m_pAxes[TopAxis]->ScreenToValue(m_rectZoomArea.right); + } + else + { + MinVal = m_pAxes[TopAxis]->ScreenToValue(m_rectZoomArea.left); + MaxVal = m_pAxes[TopAxis]->ScreenToValue(m_rectZoomArea.right); + } + m_pAxes[TopAxis]->SetZoomMinMax(MinVal,MaxVal); + } + + if (m_pAxes[RightAxis]) + { + if (m_pAxes[RightAxis]->IsInverted()) + { + MaxVal = m_pAxes[RightAxis]->ScreenToValue(m_rectZoomArea.bottom); + MinVal = m_pAxes[RightAxis]->ScreenToValue(m_rectZoomArea.top); + } + else + { + MinVal = m_pAxes[RightAxis]->ScreenToValue(m_rectZoomArea.bottom); + MaxVal = m_pAxes[RightAxis]->ScreenToValue(m_rectZoomArea.top); + } + m_pAxes[RightAxis]->SetZoomMinMax(MinVal,MaxVal); + } + + RefreshCtrl(); + } + } + + if (m_PlottingRect.PtInRect(point)) + { + TCursorMap::iterator iter = m_mapCursors.begin(); + for (iter; iter!=m_mapCursors.end(); iter++) + iter->second->OnMouseButtonUp(point); + + Invalidate(); + } + + SendMouseEvent(CChartMouseListener::LButtonUp, point); + CWnd::OnLButtonUp(nFlags, point); +} + +void CChartCtrl::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + SendMouseEvent(CChartMouseListener::LButtonDoubleClick, point); + CWnd::OnLButtonDblClk(nFlags, point); +} + +void CChartCtrl::OnRButtonDown(UINT nFlags, CPoint point) +{ + SetCapture(); + m_bRMouseDown = true; + if (m_bPanEnabled) + m_PanAnchor = point; + + SendMouseEvent(CChartMouseListener::RButtonDown, point); + CWnd::OnRButtonDown(nFlags, point); +} + +void CChartCtrl::OnRButtonUp(UINT nFlags, CPoint point) +{ + ReleaseCapture(); + m_bRMouseDown = false; + + SendMouseEvent(CChartMouseListener::RButtonUp, point); + CWnd::OnRButtonUp(nFlags, point); +} + +void CChartCtrl::OnRButtonDblClk(UINT nFlags, CPoint point) +{ + SendMouseEvent(CChartMouseListener::RButtonDoubleClick, point); + CWnd::OnRButtonDblClk(nFlags, point); +} + +void CChartCtrl::SendMouseEvent(CChartMouseListener::MouseEvent mouseEvent, + const CPoint& screenPoint) const +{ + if (m_pMouseListener) + { + // Check where the click occured. + if (m_pTitles->IsPointInside(screenPoint)) + m_pMouseListener->OnMouseEventTitle(mouseEvent,screenPoint); + if (m_pLegend->IsPointInside(screenPoint)) + m_pMouseListener->OnMouseEventLegend(mouseEvent,screenPoint); + for (int i=0; i<4; i++) + { + if ( m_pAxes[i] && m_pAxes[i]->IsPointInside(screenPoint) ) + m_pMouseListener->OnMouseEventAxis(mouseEvent,screenPoint,m_pAxes[i]); + } + if (m_PlottingRect.PtInRect(screenPoint)) + m_pMouseListener->OnMouseEventPlotArea(mouseEvent,screenPoint); + } + + // Check all the series in reverse order (check the series on top first). + TSeriesMap::const_reverse_iterator rIter = m_mapSeries.rbegin(); + for(rIter; rIter!=m_mapSeries.rend(); rIter++) + { + if (rIter->second->OnMouseEvent(mouseEvent, screenPoint)) + break; + } +} + +void CChartCtrl::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + // Force recreation of background DC + if (m_BackgroundDC.GetSafeHdc() ) + m_BackgroundDC.DeleteDC(); + + RefreshCtrl(); +} + +double CChartCtrl::DateToValue(const COleDateTime& Date) +{ + return (DATE)Date; +} + +COleDateTime CChartCtrl::ValueToDate(double Value) +{ + COleDateTime RetDate((DATE)Value); + return RetDate; +} + +void CChartCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + CChartScrollBar* pChartBar = dynamic_cast(pScrollBar); + if (pChartBar) + pChartBar->OnHScroll(nSBCode, nPos); + + CWnd::OnHScroll(nSBCode, nPos, pScrollBar); + RefreshCtrl(); +} + +void CChartCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + CChartScrollBar* pChartBar = dynamic_cast(pScrollBar); + if (pChartBar) + pChartBar->OnVScroll(nSBCode, nPos); + + CWnd::OnVScroll(nSBCode, nPos, pScrollBar); + RefreshCtrl(); +} + +void CChartCtrl::Print(const TChartString& strTitle, CPrintDialog* pPrntDialog) +{ + CDC dc; + if (pPrntDialog == NULL) + { + CPrintDialog printDlg(FALSE); + if (printDlg.DoModal() != IDOK) // Get printer settings from user + return; + + dc.Attach(printDlg.GetPrinterDC()); // attach a printer DC + } + else + dc.Attach(pPrntDialog->GetPrinterDC()); // attach a printer DC + dc.m_bPrinting = TRUE; + + DOCINFO di; // Initialise print doc details + memset(&di, 0, sizeof (DOCINFO)); + di.cbSize = sizeof (DOCINFO); + di.lpszDocName = strTitle.c_str(); + + BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job + + CPrintInfo Info; + Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES)); + + OnBeginPrinting(&dc, &Info); // Initialise printing + for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++) + { + dc.StartPage(); // begin new page + Info.m_nCurPage = page; + OnPrint(&dc, &Info); // Print page + bPrintingOK = (dc.EndPage() > 0); // end page + } + OnEndPrinting(&dc, &Info); // Clean up after printing + + if (bPrintingOK) + dc.EndDoc(); // end a print job + else + dc.AbortDoc(); // abort job. + + dc.Detach(); // detach the printer DC +} + +void CChartCtrl::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) +{ + // OnBeginPrinting() is called after the user has committed to + // printing by OK'ing the Print dialog, and after the framework + // has created a CDC object for the printer or the preview view. + + // This is the right opportunity to set up the page range. + // Given the CDC object, we can determine how many rows will + // fit on a page, so we can in turn determine how many printed + // pages represent the entire document. + ASSERT(pDC && pInfo); + + // Get a DC for the current window (will be a screen DC for print previewing) + CDC *pCurrentDC = GetDC(); // will have dimensions of the client area + if (!pCurrentDC) + return; + + CSize PaperPixelsPerInch(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); + CSize ScreenPixelsPerInch(pCurrentDC->GetDeviceCaps(LOGPIXELSX), pCurrentDC->GetDeviceCaps(LOGPIXELSY)); + + // Create the printer font + int nFontSize = -10; + CString strFontName = _T("Arial"); + m_PrinterFont.CreateFont(nFontSize, 0,0,0, FW_NORMAL, 0,0,0, DEFAULT_CHARSET, + OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, strFontName); + CFont *pOldFont = pDC->SelectObject(&m_PrinterFont); + + // Get the page sizes (physical and logical) + m_PaperSize = CSize(pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES)); + + m_LogicalPageSize.cx = ScreenPixelsPerInch.cx * m_PaperSize.cx / PaperPixelsPerInch.cx * 3 / 4; + m_LogicalPageSize.cy = ScreenPixelsPerInch.cy * m_PaperSize.cy / PaperPixelsPerInch.cy * 3 / 4; + + + // Set up the print info + pInfo->SetMaxPage(1); + pInfo->m_nCurPage = 1; // start printing at page# 1 + + ReleaseDC(pCurrentDC); + pDC->SelectObject(pOldFont); +} + +void CChartCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo) +{ + if (!pDC || !pInfo) + return; + + CFont *pOldFont = pDC->SelectObject(&m_PrinterFont); + + // Set the page map mode to use GraphCtrl units + pDC->SetMapMode(MM_ANISOTROPIC); + pDC->SetWindowExt(m_LogicalPageSize); + pDC->SetViewportExt(m_PaperSize); + pDC->SetWindowOrg(0, 0); + + // Header + pInfo->m_rectDraw.top = 0; + pInfo->m_rectDraw.left = 0; + pInfo->m_rectDraw.right = m_LogicalPageSize.cx; + pInfo->m_rectDraw.bottom = m_LogicalPageSize.cy; + + DrawChart(pDC, &pInfo->m_rectDraw); + + // SetWindowOrg back for next page + pDC->SetWindowOrg(0,0); + + pDC->SelectObject(pOldFont); +} + +void CChartCtrl::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + m_PrinterFont.DeleteObject(); + // RefreshCtrl is needed because the print job + // modifies the chart components (axis, ...) + RefreshCtrl(); +} + +void CChartCtrl::GoToFirstSerie() +{ + m_currentSeries = m_mapSeries.begin(); +} + +CChartSerie* CChartCtrl::GetNextSerie() +{ + CChartSerie* pSeries = NULL; + if (m_currentSeries != m_mapSeries.end()) + { + pSeries = m_currentSeries->second; + m_currentSeries++; + } + + return pSeries; +} + +#if _MFC_VER > 0x0600 +void CChartCtrl::SaveAsImage(const TChartString& strFilename, + const CRect& rect, + int nBPP, + REFGUID guidFileType) +{ + CImage chartImage; + CRect chartRect = rect; + if (chartRect.IsRectEmpty()) + { + GetClientRect(&chartRect); + } + + chartImage.Create(chartRect.Width(), chartRect.Height(), nBPP); + CDC newDC; + newDC.Attach(chartImage.GetDC()); + + DrawBackground(&newDC, chartRect); + chartRect.DeflateRect(3,3); + DrawChart(&newDC, chartRect); + + newDC.Detach(); + chartImage.Save(strFilename.c_str(), guidFileType); + chartImage.ReleaseDC(); +} +#endif diff --git a/ChartDemo/ChartCtrl/ChartCtrl.h b/ChartDemo/ChartCtrl/ChartCtrl.h new file mode 100644 index 0000000..c733d57 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCtrl.h @@ -0,0 +1,586 @@ +/* + * + * ChartCtrl.h + * + * 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. + * + * + */ + + +#pragma once + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include "ChartSerie.h" +#include "ChartAxis.h" +#include "ChartGrid.h" +#include "ChartLegend.h" +#include "ChartTitle.h" +#include "ChartGradient.h" +#include "ChartCursor.h" +#include "ChartMouseListener.h" +#include "ChartStandardAxis.h" +#include "ChartLogarithmicAxis.h" +#include "ChartDateTimeAxis.h" +#include "ChartCrossHairCursor.h" +#include "ChartDragLineCursor.h" + +#include + + +class CChartStandardAxis; +class CChartLogarithmicAxis; +class CChartDateTimeAxis; +class CChartCrossHairCursor; +class CChartDragLineCursor; + +class CChartPointsSerie; +class CChartLineSerie; +class CChartSurfaceSerie; +class CChartBarSerie; +class CChartCandlestickSerie; +class CChartGanttSerie; + +///////////////////////////////////////////////////////////////////////////// +// CChartCtrl window + +//! The main chart control class. +/** + +**/ +class CChartCtrl : public CWnd +{ + +public: + //! Retrieves de device context. + /** + This function is used for internal purposes only. + **/ + CDC* GetDC(); + //! Retrieves the plotting rectangle. + CRect GetPlottingRect() const { return m_PlottingRect; } + + //! Returns a pointer to the legend object. + CChartLegend* GetLegend() const { return m_pLegend; } + //! Returns a pointer to the title object. + CChartTitle* GetTitle() const { return m_pTitles; } + + //! An enumeration of the different axis positions. + enum EAxisPos + { + LeftAxis = 0, + BottomAxis, + RightAxis, + TopAxis + }; + + //! Create and attach a standard axis to the control. + /** + @param axisPos + The position of the axis. + @return The created standard axis. + **/ + CChartStandardAxis* CreateStandardAxis(EAxisPos axisPos); + //! Create and attach a logarithmic axis to the control. + /** + @param axisPos + The position of the axis. + @return The created logarithmic axis. + **/ + CChartLogarithmicAxis* CreateLogarithmicAxis(EAxisPos axisPos); + //! Create and attach a date/time axis to the control. + /** + @param axisPos + The position of the axis. + @return The created date/time axis. + **/ + CChartDateTimeAxis* CreateDateTimeAxis(EAxisPos axisPos); + //! Attach a custom axis to the control. + /** + This function takes ownership of the axis pointer, so you + must not destroy it. If the axis is alread attached to a + chart control (even this one), the function will fail with + an assertion. This function should be used only when you want + to provide a custom axis to the control, otherwise you should + use the AttachStandardAxis, AttachLogarithmicAxis and + AttachDateTimeAxis instead. + @param pAxis + The axis to attach to the control. + @param axisPos + The position of the axis. This value can be: + - LeftAxis + - BottomAxis + - RightAxis + - TopAxis + **/ + void AttachCustomAxis(CChartAxis* pAxis, EAxisPos axisPos); + + //! Create and attach a point series to the control + /** + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created chart point series. + @remark The function will assert if the associated axes are not attached + to the control. + @see AttachCustomSerie for more info about the parameters of the function. + **/ + CChartPointsSerie* CreatePointsSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Create and attach a line series to the control + /** + The function will assert if the associated axes are not attached + to the control. + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created chart line series. + @remark The function will assert if the associated axes are not attached + to the control. + @see AttachCustomSerie for more info about the parameters of the function. + **/ + CChartLineSerie* CreateLineSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Create and attach a surface series to the control + /** + The function will assert if the associated axes are not attached + to the control. + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created chart surface series. + @remark The function will assert if the associated axes are not attached + to the control. + @see AttachCustomSerie for more info about the parameters of the function. + **/ + CChartSurfaceSerie* CreateSurfaceSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Create and attach a bar series to the control + /** + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created chart bar series. + @remark The function will assert if the associated axes are not attached + to the control. + @see AttachCustomSerie for more info about the parameters of the function. + **/ + CChartBarSerie* CreateBarSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Create and attach a candlestick series to the control + /** + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created chart candlestick series. + @remark The function will assert if the associated axes are not attached + to the control. + @see AttachCustomSerie for more info about the parameters of the function. + **/ + CChartCandlestickSerie* CreateCandlestickSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Create and attach a gantt series to the control + /** + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created chart gantt series. + @remark The function will assert if the associated axes are not attached + to the control. + @see AttachCustomSerie for more info about the parameters of the function. + **/ + CChartGanttSerie* CreateGanttSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Attaches a custom series to the chart + /** + You should only use this function if you want to attach a custom series + to the control. Otherwise, you should use the CreateXXXSerie helper functions. + The function will assert if the associated axes are not attached + to the control. + @param pNewSeries + The new series to be added. The control will take ownership of + the pointer, so dont't delete it yourself. + @param bSecondaryHorizAxis + Specifies if the associated horizontal axis is secondary or not. + If this value is false, the associated horizontal axis is the + bottom axis, otherwise it is the top axis. + @param bSecondaryVertAxis + Specifies if the associated vertical axis is secondary or not. + If this value is false, the associated vertical axis is the + left axis, otherwise it is the right axis. + **/ + void AttachCustomSerie(CChartSerie* pNewSeries, bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Retrieves a specific series from the chart + /** + @param uSerieId + The Id of the series to retrieve + @return The series or NULL if uSerieId is not attributed. + **/ + CChartSerie* GetSerie(unsigned uSerieId) const; + //! Removes a specific series from the chart + /** + @param uSerieId + The Id of the series to be removed. + **/ + void RemoveSerie(unsigned uSerieId); + //! Removes all the series from the chart + void RemoveAllSeries(); + //! Returns the number of series in the chart + size_t GetSeriesCount() const; + + //! Create and attach a cross-hair cursor to the control + /** + A cross-hair cursor display a cross on the control and move accordingly + to the mouse. It is attached to an horizontal and a vertical axis. + @param bSecondaryHorizAxis + Specifies if the horizontal axis is the secondary axis or not. + @param bSecondaryVertAxis + Specifies if the vertical axis is the secondary axis or not. + @return The created cross-hair cursor. + @remark The function will assert if the associated axes are not attached + to the control. + **/ + CChartCrossHairCursor* CreateCrossHairCursor(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false); + //! Create and attach a drag-line cursor to the control + /** + A drag-line cursor is a simple line (horizontal or vertical) that can be + dragged with the mouse by clicking on it. It is attached to a specific axis. + @param relatedAxis + The axis position to which the cursor is attached to. + @return The created drag-line cursor. + @remark The function will assert if the associated axis is not attached + to the control. + **/ + CChartDragLineCursor* CreateDragLineCursor(EAxisPos relatedAxis); + //! Attach a custom cursor to the control + /** + You should only use this function if you want to attach a custom cursor + to the control. Otherwise, you should use the CreateXXXCursor helper functions. + @param pCursor + The custom cursor to be attached to the control. + **/ + void AttachCustomCursor(CChartCursor* pCursor); + //! Removes a cursor with a specific Id from the control. + /** + The cursor Id can be retrieved on through the CChartCursor::GetCursorId function. + @param cursorId + The Id of the cursor to remove from the control. + **/ + void RemoveCursor(unsigned cursorId); + + //! Shows/hides the mouse cursor when it is over the plotting area. + void ShowMouseCursor(bool bShow); + + CChartAxis* GetBottomAxis() const; + CChartAxis* GetLeftAxis() const; + CChartAxis* GetTopAxis() const; + CChartAxis* GetRightAxis() const; + //! Returns a specific axis attached to the control + /** + If the specified axis does not exist, NULL is returned. + @param axisPos + The axis position (left, bottom, right or top). + **/ + CChartAxis* GetAxis(EAxisPos axisPos) const + { + return m_pAxes[axisPos]; + } + + //! Returns the type of the edge used as border. + UINT GetEdgeType() const { return EdgeType; } + //! Sets the edge type. + /** + @param NewEdge + The type of the edge. See the DrawEdge function in MSDN for + a list of the different types. + **/ + void SetEdgeType(UINT NewEdge) + { + EdgeType = NewEdge; + RefreshCtrl(); + } + + //! Returns the background color + COLORREF GetBackColor() const { return m_BackColor; } + //! Sets the background color. + void SetBackColor(COLORREF NewCol) + { + m_BackColor = NewCol; + m_bBackGradient = false; + RefreshCtrl(); + } + //! Returns the color of the plotting area's border + COLORREF GetBorderColor() const { return m_BorderColor; } + //! Sets the color of the plotting area's border + void SetBorderColor(COLORREF NewCol) { m_BorderColor = NewCol; RefreshCtrl(); } + //! Returns the color of the zoom rectangle + COLORREF GetZoomRectColor() const { return m_ZoomRectColor; } + //! Sets the color of the zoom rectangle + void SetZoomRectColor(COLORREF NewCol) { m_ZoomRectColor = NewCol; RefreshCtrl(); } + //! Sets a gradient background + /** + @param Col1 + The first gradient color + @param Col2 + The second gradient color + @param GradientType + The type of gradient used from Col1 to Col2. It can take the following values: + - gtHorizontal: a simple left-to-right gradient, from Col1 to Col2. + - gtVertical: a simple top-to-bottom gradient, from Col1 to Col2. + - gtHorizontalDouble: a left-to-middle-to-right gradient, with Col2 in the middle. + - gtVerticalDouble: a top-to-middle-to-bottom gradient, with Col2 in the middle. + **/ + void SetBackGradient(COLORREF Col1, COLORREF Col2, EGradientType GradientType); + + //! Enables/disables the pan feature + void SetPanEnabled(bool bEnabled) { m_bPanEnabled = bEnabled; } + //! Returns true if the pan feature is enabled + bool GetPanEnabled() const { return m_bPanEnabled; } + //! Enables/disables the zoom feature + void SetZoomEnabled(bool bEnabled) { m_bZoomEnabled = bEnabled; } + //! Returns true if the zoom feature is enabled + bool GetZoomEnabled() const { return m_bZoomEnabled; } + //! Undo all pan and zoom operations that were done on the chart + void UndoPanZoom(); + + //! Forces a refresh of the control. + /** + This function is used for internal purposes. + **/ + void RefreshCtrl(); + //! Enables/disables the refresh of the control + /** + This function is used when several settings have to be changed at the same + time on the control. This way we can avoid refreshing the control when it + is not needed. + @param bEnable + false to disable the refresh and true to re-enable the refresh. + **/ + void EnableRefresh(bool bEnable); + //! Creates the control dynamically. + /** + @param pParentWnd + Parent window of the control + @param rect + Position of the control + @param nID + ID of the control + @param dwStyle + Style of the control + **/ + int Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle=WS_VISIBLE); + + //! Helper function to convert a date to a double value + static double DateToValue(const COleDateTime& Date); + //! Helper function to convert a double value to a date + static COleDateTime ValueToDate(double Value); + + //! Print the chart + /** + @param strTitle + The title of the print document. + @param pPrntDialog + A pointer to a CPrintDialog. + If NULL is passed, the default print dialog will be displayed. + **/ + virtual void Print(const TChartString& strTitle, CPrintDialog* pPrntDialog = NULL); + +#if _MFC_VER > 0x0600 + //! Saves the chart to an image file + /** + This function is not available for VC6 and earlier. + @param strFilename + The name of the file in which to save the image. + @param rect + The size of the image. If an empty rectangle is provided, the + size of the chart on screen will be used (this results in an identical + image as what is seen on the screen). + @param nBPP + The numbers of bits per pixel in the bitmap. Usually 4, 8, 16, 24, or 32. + @param guidFileType + The file type to save the image as. See the CImage::Save in MSDN + for more information. + **/ + void SaveAsImage(const TChartString& strFilename, const CRect& rect, + int nBPP, REFGUID guidFileType= GUID_NULL); +#endif + + //! Default constructor + CChartCtrl(); + //! Default destructor + virtual ~CChartCtrl(); + + //! Register a mouse listener with the control. + /** + This listener will be notified each time a mouse event occurs on the control. + @param pMouseListener + The mouse listener to register with this control. + **/ + void RegisterMouseListener(CChartMouseListener* pMouseListener) { m_pMouseListener = pMouseListener;} + + //! Tell the control to set the current series to the first series. + /** + This function is used with the GetNextSerie to iterate over all + series in the control. + **/ + void GoToFirstSerie(); + //! Returns the next series in the control. + /** + This function is used with the GoToFirstSerie to iterate over all + series in the control. First call GoToFirstSerie and then call this + function until it returns NULL to iterate over all series. + Warning: calling this function without calling GoToFirstSerie before + might lead to unpredicted results. The same if you add or remove + series between the call to GetFirstSerie and the call to GetNextSerie. + @return the next series or NULL if we already are at the last series. + **/ + CChartSerie* GetNextSerie(); + + //! Refreshes all the axes which are automatic for the screen. + void RefreshScreenAutoAxes(); + + // Generated message map functions +protected: + //{{AFX_MSG(CChartCtrl) + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +protected: + virtual void OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo); + virtual void OnPrint(CDC *pDC, CPrintInfo *pInfo); + virtual void OnEndPrinting(CDC *pDC, CPrintInfo *pInfo); + + // This function can be called to draw the chart + // on the screen or for printing. + virtual void DrawChart(CDC* pDC, CRect ChartRect); + virtual void DrawBackground(CDC* pDC, CRect ChartRect); + +private: + //! Register the window class used for this control + bool RegisterWindowClass(); + + //! Notifies the mouse listeners about a mouse event on the control. + /** + The function detects on which part of the control the event happened. + @param mouseEvent + The type of the mouse event + @param screenPoint + The screen point on which the event occured. + **/ + void SendMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint& screenPoint) const; + + //! Specifies if the refresh is currently enabled or not. + int m_iEnableRefresh ; + //! Specifies if there is a pending refresh. + /** + If true, once EnableRefresh(true) is called, a refresh of the control + will be done. + **/ + bool m_bPendingRefresh; + //! Memory bitmap on which the chart background is drawn (axis, grid, title, ...) + CDC m_BackgroundDC; + //! Specifies if the memory bitmap has already been created. + bool m_bMemDCCreated; + + //! Specifies if the background is gradient or solid + bool m_bBackGradient; + //! First gradient color for the background + COLORREF m_BackGradientCol1; + //! Second gradient color for the background + COLORREF m_BackGradientCol2; + //! The gradient type used for the background + EGradientType m_BackGradientType; + //! The background color (if no gradient used) + COLORREF m_BackColor; + //! The border color + COLORREF m_BorderColor; + //! The type of edge + UINT EdgeType; + + //! Zone in wich the series will be plotted + CRect m_PlottingRect; + + typedef std::map TSeriesMap; + //! Map containing all the series added to the chart. + TSeriesMap m_mapSeries; + //! The four axis of the control. + CChartAxis* m_pAxes[4]; + + //! The chart legend + CChartLegend* m_pLegend; + //! The chart titles + CChartTitle* m_pTitles; + + //! Specifies if the mouse panning is enabled + bool m_bPanEnabled; + //! Specifies if the right mouse button is currently pressed + bool m_bRMouseDown; + //! The point on which the panning started + CPoint m_PanAnchor; + + //! Specifies if the zoom is enabled + bool m_bZoomEnabled; + //! Specifies if the left mouse button is currently pressed + bool m_bLMouseDown; + //! The rectangle of the zoom area + CRect m_rectZoomArea; + //! The color of the zoom rectangle + COLORREF m_ZoomRectColor; + + //! Specifies if the toolbars have already been created + bool m_bToolBarCreated; + + //! The font used for printing + CFont m_PrinterFont; + //! Page size in chartctrl units. + CSize m_LogicalPageSize; + //! Page size in device units. + CSize m_PaperSize; + + typedef std::map TCursorMap; + //! The map containing all the cursors + TCursorMap m_mapCursors; + + //! The mouse listener registered with this control + CChartMouseListener* m_pMouseListener; + + //! Specifies if the mouse is visible when over the plotting area. + bool m_bMouseVisible; + + typedef TSeriesMap::const_iterator TSeriesMapIter; + //! The iterator of the current series + TSeriesMapIter m_currentSeries; +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + diff --git a/ChartDemo/ChartCtrl/ChartCtrl_source.zip b/ChartDemo/ChartCtrl/ChartCtrl_source.zip new file mode 100644 index 0000000..299c614 Binary files /dev/null and b/ChartDemo/ChartCtrl/ChartCtrl_source.zip differ diff --git a/ChartDemo/ChartCtrl/ChartCursor.cpp b/ChartDemo/ChartCtrl/ChartCursor.cpp new file mode 100644 index 0000000..2ab64c8 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCursor.cpp @@ -0,0 +1,56 @@ +/* + * + * ChartCursor.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 "ChartCursor.h" +#include "ChartCtrl.h" + +unsigned CChartCursor::m_uNextFreeId = 0; + +CChartCursor::CChartCursor(CChartCtrl* pParent) + : m_colCursor(RGB(0,0,0)), m_pParentCtrl(pParent), m_uCursorId(0), + m_lstListeners() +{ + m_uCursorId = m_uNextFreeId; + m_uNextFreeId++; +} + +CChartCursor::~CChartCursor() +{ +} + +void CChartCursor::SetColor(COLORREF cursorColor) +{ + m_colCursor = cursorColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartCursor::RegisterListener(CChartCursorListener* pListener) +{ + m_lstListeners.push_back(pListener); +} + +void CChartCursor::CursorMoved(double newXValue, double newYValue) +{ + TListenerList::iterator iter = m_lstListeners.begin(); + for (iter; iter!=m_lstListeners.end(); iter++) + (*iter)->OnCursorMoved(this, newXValue, newYValue); +} diff --git a/ChartDemo/ChartCtrl/ChartCursor.h b/ChartDemo/ChartCtrl/ChartCursor.h new file mode 100644 index 0000000..010c555 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartCursor.h @@ -0,0 +1,125 @@ +/* + * + * ChartCursor.h + * + * 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. + * + * + */ + +#ifndef _CHARTCURSOR_H_ +#define _CHARTCURSOR_H_ + +#include + +class CChartCtrl; +class CChartCursor; + +//! Interface to implement in order to be notified about a cursor movement. +/** + This class must be overriden and registered with a CChartCursor by + calling RegisterListener. +**/ +class CChartCursorListener +{ +public: + //! Default constructor + CChartCursorListener() { } + //! Destructor + virtual ~CChartCursorListener() { } + + //! Pure virtual function to implement in order to be notified about a cursor movement. + /** + Note that not all cursor types have an X and a Y value, in which case, only + the relevant information is passed, the other value will be 0. + @param pCursor + The cursor which was moved + @param xValue + The cursor xValue + @param yValue + The cursor yValue + **/ + virtual void OnCursorMoved(CChartCursor* pCursor, double xValue, double yValue) = 0; +}; + +//! Base class for cursors which can be added to the chart control. +/** + This class must be overriden for specific cursor types. This is already done + for a cross-hair cursor and a dragline cursor. Each cursor is assigned an Id + when it is added to the control. +**/ +class CChartCursor +{ + friend CChartCtrl; + +public: + //! Sets the cursor color. + void SetColor(COLORREF cursorColor); + //! Retrieves the cursor Id. + unsigned GetCursorId() const { return m_uCursorId; } + + //! Registers a cursor listener with this cursor. + void RegisterListener(CChartCursorListener* pListener); + +protected: + //! Default constructor + CChartCursor(CChartCtrl* pParent); + //! Default destructor + virtual ~CChartCursor(); + + //! Pure virtual function that is called when the mouse moved on the plot area. + /** + This function must be overriden by child classes to take appropriate + actions on the mouse move event. + **/ + virtual void OnMouseMove(CPoint mousePoint) = 0; + //! Virtual function that is called when the left mouse button is pressed. + /** + This function can be overriden by child classes to take appropriate + actions on the mouse click event. + **/ + virtual void OnMouseButtonDown(CPoint /*mousePoint*/) { } + //! Virtual function that is called when the left mouse button is released. + /** + This function can be overriden by child classes to take appropriate + actions on the mouse click event. + **/ + virtual void OnMouseButtonUp(CPoint /*mousePoint*/) { } + + //! Pure virtual function that draws the cursor. + virtual void Draw(CDC* pDC) = 0; + //! Function that is called by the child classes when the cursor has been moved. + /** + This will notify all the listeners registered with the cursor. + **/ + void CursorMoved(double newXValue, double newYValue); + + + //! The color of the cursor. + COLORREF m_colCursor; + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + + //! Static variable holding the next free cursor Id. + static unsigned m_uNextFreeId; + //! The Id of this curosr. + unsigned m_uCursorId; + + typedef std::list TListenerList; + //! List of all listeners registered with this cursor. + TListenerList m_lstListeners; +}; + +#endif // _CHARTCURSOR_H_ diff --git a/ChartDemo/ChartCtrl/ChartDateTimeAxis.cpp b/ChartDemo/ChartCtrl/ChartDateTimeAxis.cpp new file mode 100644 index 0000000..7cc3b48 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartDateTimeAxis.cpp @@ -0,0 +1,411 @@ +/* + * + * ChartDateTimeAxis.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 "ChartDateTimeAxis.h" +#include "ChartCtrl.h" +#include +#include +#include +#include + +using namespace std; + +CChartDateTimeAxis::CChartDateTimeAxis() + : CChartAxis(), m_strDTTickFormat(), + m_bAutoTickFormat(true), m_BaseInterval(tiDay), + m_iDTTickIntervalMult(1), m_dFirstTickValue(0) +{ + m_ReferenceTick.SetDate(2000,1,1); +} + +CChartDateTimeAxis::~CChartDateTimeAxis() +{ +} + + +void CChartDateTimeAxis::SetTickIncrement(bool bAuto, + TimeInterval Interval, + int Multiplier) +{ + m_bAutoTicks = bAuto; + if (!m_bAutoTicks) + { + m_BaseInterval = Interval; + m_iDTTickIntervalMult = Multiplier; + } +} + +void CChartDateTimeAxis::SetTickLabelFormat(bool bAutomatic, + const TChartString& strFormat) +{ + m_bAutoTickFormat = bAutomatic; + m_strDTTickFormat = strFormat; + m_pParentCtrl->RefreshCtrl(); +} + +double CChartDateTimeAxis::GetFirstTickValue() const +{ + double dRetVal = m_dFirstTickValue; + if (m_bDiscrete) + { + COleDateTime dtTick((DATE)m_dFirstTickValue); + COleDateTimeSpan dtSpan; + switch (m_BaseInterval) + { + case tiSecond: + dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult); + dtTick -= dtSpan; + break; + case tiMinute: + dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0); + dtTick -= dtSpan; + break; + case tiHour: + dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0); + dtTick -= dtSpan; + break; + case tiDay: + dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0); + dtTick -= dtSpan; + break; + case tiMonth: + dtTick = AddMonthToDate(dtTick,-m_iDTTickIntervalMult); + break; + case tiYear: + dtTick = AddMonthToDate(dtTick,-12*m_iDTTickIntervalMult); + break; + } + } + return dRetVal; + +} + +bool CChartDateTimeAxis::GetNextTickValue(double dCurrentTick, double& dNextTick) const +{ + if (m_MinValue == m_MaxValue) + return false; + + COleDateTime dtTick((DATE)dCurrentTick); + COleDateTimeSpan dtSpan; + switch (m_BaseInterval) + { + case tiSecond: + dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult); + dtTick += dtSpan; + break; + case tiMinute: + dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0); + dtTick += dtSpan; + break; + case tiHour: + dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0); + dtTick += dtSpan; + break; + case tiDay: + dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0); + dtTick += dtSpan; + break; + case tiMonth: + dtTick = AddMonthToDate(dtTick,m_iDTTickIntervalMult); + break; + case tiYear: + dtTick = AddMonthToDate(dtTick,12*m_iDTTickIntervalMult); + break; + } + + dNextTick = (DATE)dtTick; + if (dNextTick <= m_MaxValue) + return true; + else + return false; +} + +TChartString CChartDateTimeAxis::GetTickLabel(double TickValue) const +{ + COleDateTime tickTime((DATE)TickValue); + TChartString strLabel = tickTime.Format(m_strDTTickFormat.c_str()); + return strLabel; +} + +long CChartDateTimeAxis::ValueToScreenDiscrete(double dValue) const +{ + // In discrete mode, all values between two ticks relates + // to the middle of the interval (there's no other values than + // the tick values). + double tickAfter; + double tickBefore = GetTickBeforeVal(dValue); + GetNextTickValue(tickBefore, tickAfter); + + long tickPosBefore = ValueToScreenStandard(tickBefore); + long tickPosAfter = ValueToScreenStandard(tickAfter); + return tickPosBefore + (tickPosAfter-tickPosBefore)/2; +} + +long CChartDateTimeAxis::GetTickPos(double TickVal) const +{ + // The tick is always at the same position, + // even if the axis is discrete. + return ValueToScreenStandard(TickVal); +} + +COleDateTime CChartDateTimeAxis::AddMonthToDate(const COleDateTime& Date, + int iMonthsToAdd) const +{ + COleDateTime newDate; + int nMonths = Date.GetMonth()-1 + iMonthsToAdd; + int nYear = Date.GetYear() + nMonths/12;; + // We can 'add' a negative number of months + if (nMonths<0) + { + nYear = Date.GetYear() - (-nMonths)/12; + nMonths += (-nMonths)/12 * 12; + } + + newDate.SetDateTime(nYear,nMonths%12+1,Date.GetDay(),Date.GetHour(), + Date.GetMinute(),Date.GetSecond()); + return newDate; +} + +void CChartDateTimeAxis::RefreshTickIncrement() +{ + if (!m_bAutoTicks) + return; + + if (m_MaxValue == m_MinValue) + { + m_iDTTickIntervalMult = 1; + return; + } + + int PixelSpace; + if (m_bIsHorizontal) + PixelSpace = 60; + else + PixelSpace = 20; + + int MaxTickNumber = (int)fabs((m_EndPos-m_StartPos)/PixelSpace * 1.0); + if (MaxTickNumber == 0) + MaxTickNumber = 1; + + COleDateTime StartDate(m_MinValue); + COleDateTime EndDate(m_MaxValue); + + COleDateTimeSpan minTickInterval = (EndDate - StartDate)/MaxTickNumber; + double Seconds = minTickInterval.GetTotalSeconds(); + double Minutes = minTickInterval.GetTotalMinutes(); + double Hours = minTickInterval.GetTotalHours(); + double Days = minTickInterval.GetTotalDays(); + if (Seconds < 60) + { + m_BaseInterval = tiSecond; + if (Seconds > 30) + { + m_BaseInterval = tiMinute; + m_iDTTickIntervalMult = 1; + } + else if (Seconds > 10) + m_iDTTickIntervalMult = 30; + else if (Seconds > 5) + m_iDTTickIntervalMult = 10; + else if (Seconds > 2) + m_iDTTickIntervalMult = 5; + else + m_iDTTickIntervalMult = 1; + } + else if (Minutes < 60) + { + m_BaseInterval = tiMinute; + if (Minutes > 30) + { + m_BaseInterval = tiHour; + m_iDTTickIntervalMult = 1; + } + else if (Minutes > 10) + m_iDTTickIntervalMult = 30; + else if (Minutes > 5) + m_iDTTickIntervalMult = 10; + else if (Minutes > 2) + m_iDTTickIntervalMult = 5; + else + m_iDTTickIntervalMult = 2; + } + else if (Hours < 24) + { + m_BaseInterval = tiHour; + if (Hours > 12) + { + m_BaseInterval = tiDay; + m_iDTTickIntervalMult = 1; + } + else if (Hours > 6) + m_iDTTickIntervalMult = 12; + else if (Hours > 2) + m_iDTTickIntervalMult = 6; + else + m_iDTTickIntervalMult = 2; + } + else if (Days < 31) + { + m_BaseInterval = tiDay; + if (Days > 7) + { + m_BaseInterval = tiMonth; + m_iDTTickIntervalMult = 1; + } + else if (Days > 2) + { + m_BaseInterval = tiDay; + m_iDTTickIntervalMult = 7; + } + else + m_iDTTickIntervalMult = 2; + } + else if (Days < 365) + { + m_BaseInterval = tiMonth; + if (Days > 186) // Approx 6 months + { + m_BaseInterval = tiYear; + m_iDTTickIntervalMult = 1; + } + else if (Days > 124) + m_iDTTickIntervalMult = 6; + else if (Days > 62) + m_iDTTickIntervalMult = 4; + else + m_iDTTickIntervalMult = 2; + } + else + { + m_BaseInterval = tiYear; + m_iDTTickIntervalMult = (int)Days/365 + 1; + } +} + +void CChartDateTimeAxis::RefreshFirstTick() +{ + m_dFirstTickValue = GetTickBeforeVal(m_MinValue); + if (m_bAutoTickFormat) + RefreshDTTickFormat(); +} + +void CChartDateTimeAxis::SetReferenceTick(COleDateTime referenceTick) +{ + m_ReferenceTick = referenceTick; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartDateTimeAxis::RefreshDTTickFormat() +{ + switch (m_BaseInterval) + { + case tiSecond: + m_strDTTickFormat = _T("%H:%M:%S"); + break; + case tiMinute: + m_strDTTickFormat = _T("%H:%M"); + break; + case tiHour: + m_strDTTickFormat = _T("%H:00"); + break; + case tiDay: + m_strDTTickFormat = _T("%d %b"); + break; + case tiMonth: + m_strDTTickFormat = _T("%b %Y"); + break; + case tiYear: + m_strDTTickFormat = _T("%Y"); + break; + } +} + +double CChartDateTimeAxis::GetTickBeforeVal(double dValue) const +{ + double precision = 0.0000000001; + if (dValue < 0) + precision = -0.0000000001; + + COleDateTime tickBefore; + COleDateTime valueTime = COleDateTime(DATE(dValue+precision)); + COleDateTimeSpan dtSpan = valueTime - m_ReferenceTick; + switch (m_BaseInterval) + { + case tiSecond: + { + int totalSecs = (int)dtSpan.GetTotalSeconds(); + totalSecs = (totalSecs/m_iDTTickIntervalMult) * m_iDTTickIntervalMult; + int Days = totalSecs/86400; // 86400 seconds in one day + int Hours = (totalSecs%86400)/3600; // 3600 seconds in one hour + int Minutes = ((totalSecs%86400)%3600)/60; // 60 seconds in one minute + int Seconds = ((totalSecs%86400)%3600)%60; + dtSpan.SetDateTimeSpan(Days, Hours, Minutes, Seconds); + tickBefore = m_ReferenceTick + dtSpan; + } + break; + case tiMinute: + { + int totalMinutes = (int)dtSpan.GetTotalMinutes(); + totalMinutes = (totalMinutes/m_iDTTickIntervalMult) * m_iDTTickIntervalMult; + int Days = totalMinutes/1440; // 1440 minutes in one day + int Hours = (totalMinutes%1440)/60; // 60 minutes in one hour + int Minutes = (totalMinutes%1440)%60; + dtSpan.SetDateTimeSpan(Days, Hours, Minutes, 0); + tickBefore = m_ReferenceTick + dtSpan; + } + break; + case tiHour: + { + int totalHours = (int)dtSpan.GetTotalHours(); + totalHours = (totalHours/m_iDTTickIntervalMult) * m_iDTTickIntervalMult; + int Days = totalHours/24; // 24 hours in one day + int Hours = totalHours%24; + dtSpan.SetDateTimeSpan(Days, Hours, 0, 0); + tickBefore = m_ReferenceTick + dtSpan; + } + break; + case tiDay: + { + int totalDays = (int)dtSpan.GetTotalDays(); + totalDays = (totalDays/m_iDTTickIntervalMult) * m_iDTTickIntervalMult; + dtSpan.SetDateTimeSpan(totalDays, 0, 0, 0); + tickBefore = m_ReferenceTick + dtSpan; + } + break; + case tiMonth: + { + int yearDiff = valueTime.GetYear() - m_ReferenceTick.GetYear(); + int monthDiff = valueTime.GetMonth() - m_ReferenceTick.GetMonth(); + int totalMonths = ((yearDiff*12+monthDiff)/m_iDTTickIntervalMult) * m_iDTTickIntervalMult; + tickBefore = AddMonthToDate(m_ReferenceTick,totalMonths); + } + break; + case tiYear: + { + int yearDiff = valueTime.GetYear() - m_ReferenceTick.GetYear(); + int year = ((yearDiff)/m_iDTTickIntervalMult) * m_iDTTickIntervalMult; + tickBefore = AddMonthToDate(m_ReferenceTick,year*12); + } + break; + } + + return (DATE)tickBefore; +} diff --git a/ChartDemo/ChartCtrl/ChartDateTimeAxis.h b/ChartDemo/ChartCtrl/ChartDateTimeAxis.h new file mode 100644 index 0000000..dcf7330 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartDateTimeAxis.h @@ -0,0 +1,150 @@ +/* + * + * ChartDateTimeAxis.h + * + * 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. + * + * + */ + +#ifndef _CHARTDATETIMEAXIS_H_ +#define _CHARTDATETIMEAXIS_H_ + +#include "ChartAxis.h" +#include "ChartString.h" + +//! A specialization of the CChartAxis class for displaying date and time data. +class CChartDateTimeAxis : public CChartAxis +{ + friend CChartCtrl; + +public: + //! Enum listing the different base intervals. + enum TimeInterval + { + tiSecond, + tiMinute, + tiHour, + tiDay, + tiMonth, + tiYear + }; + + //! Sets the tick increment. + /** + The tick increment is the value between two adjacents + ticks on the axis. In case of a date time axis, the interval + is specified by a time period because this interval might not + be constant (for instance, if a tick interval of one month is + specified, the distance between two adjacents ticks is not + constant: it depends on the number of days in the month). + The full tick interval is made of a base interval (day, month, + hour, ...) and a multiplier, that is applied to this base interval. + So, for an interval of three months between two ticks, you have to + specify tiMonth for the interval and 3 for the multiplier. + @param bAuto + Specifies if the tick increment is automatically calculated. + @param Interval + The base interval. + @param Multiplier + The multiplier applied to the base interval. + **/ + void SetTickIncrement(bool bAuto, TimeInterval Interval, int Multiplier); + //! Sets the format of the tick labels. + /** + @param bAutomatic + Specifies if the format is calculated automatically. + @param strFormat + The format to apply to the tick label if bAutomatic is false. +
Check the documentation of the COleDateTime::Format function on + MSDN for more information about the format string. + **/ + void SetTickLabelFormat(bool bAutomatic, const TChartString& strFormat); + //! Sets the reference tick. + /** + The reference tick is a date/time which specifies a tick which should + always be displayed on the axis. This is needed when the tick + interval multiplier is not 1 (e.g. the interval between two ticks is 3 + months). In that specific case, there is no way for the control to know + which ticks should be displayed (in our example, the chart doesn't know + if the first tick will be january, february or march). This is particularly + annoying when the axis is panned (in that case, if we always take the first + month on the axis as first tick, the ticks will always switch from one month + to another). By having a refence tick, this forces the control to calculate + all tick intervals based on this reference. It is set to January 1st 2000 by + default. + **/ + void SetReferenceTick(COleDateTime referenceTick); + +private: + //! Default constructor + CChartDateTimeAxis(); + //! Default destructor + ~CChartDateTimeAxis(); + + double GetFirstTickValue() const; + bool GetNextTickValue(double dCurrentTick, double& dNextTick) const; + TChartString GetTickLabel(double TickValue) const; + long ValueToScreenDiscrete(double Value) const; + long GetTickPos(double TickVal) const; + + void RefreshTickIncrement(); + void RefreshFirstTick(); + //! Forces a refresh of the date/time tick label format + void RefreshDTTickFormat(); + + //! Add a number of months to a date. + /** + The function takes care of 'overflow' (total number + of months higher than 12) error when adding the months. + @param Date + The date to which months will be added. + @param iMonthsToAdd + The number of months to add to the date. + @return the resulting date. + **/ + COleDateTime AddMonthToDate(const COleDateTime& Date, + int iMonthsToAdd) const; + + double GetTickBeforeVal(double dValue) const; + + //! Format of the date/time tick labels + TChartString m_strDTTickFormat; + //! Specifies if the tick labels format is automatic + bool m_bAutoTickFormat; + //! Specifies the base time interval for ticks + /** + This specifies an base interval in sec, min, hour, + day, month or year. The total tick increment is + a mutliple of this base interval (specified by + m_iDTTickIntervalMult). E.g: 2 days + **/ + TimeInterval m_BaseInterval; + //! Specifies the multiplicator for the base interval + /** + This multiplies the base interval for the ticks, resulting + in something like 3 minutes (a multiplicator of 1 can also + be specified). + **/ + int m_iDTTickIntervalMult; + + //! Caches the value of the first tick. + double m_dFirstTickValue; + + //! The reference tick. See the SetReferenceTick function for details. + COleDateTime m_ReferenceTick; +}; + +#endif // _CHARTDATETIMEAXIS_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartDragLineCursor.cpp b/ChartDemo/ChartCtrl/ChartDragLineCursor.cpp new file mode 100644 index 0000000..6eb6dcf --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartDragLineCursor.cpp @@ -0,0 +1,103 @@ +/* + * + * ChartDragLineCursor.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 "ChartDragLineCursor.h" +#include "ChartCtrl.h" + +CChartDragLineCursor::CChartDragLineCursor(CChartCtrl* pParent, + CChartAxis* pRelatedAxis) + : CChartCursor(pParent), m_pRelatedAxis(pRelatedAxis), m_lPosition(0), + m_bDragged(false) +{ +} + +CChartDragLineCursor::~CChartDragLineCursor() +{ +} + +void CChartDragLineCursor::Draw(CDC* pDC) +{ + CPen NewPen(PS_SOLID,1,m_colCursor); + CPen* pOldPen = pDC->SelectObject(&NewPen); + + CRect plottingRect = m_pParentCtrl->GetPlottingRect(); + + if (m_pRelatedAxis->IsHorizontal()) + { + pDC->MoveTo(m_lPosition, plottingRect.top); + pDC->LineTo(m_lPosition, plottingRect.bottom); + } + else + { + pDC->MoveTo(plottingRect.left, m_lPosition); + pDC->LineTo(plottingRect.right, m_lPosition); + } + + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} + +void CChartDragLineCursor::OnMouseButtonDown(CPoint mousePoint) +{ + long position = 0; + if (m_pRelatedAxis->IsHorizontal()) + position = mousePoint.x; + else + position = mousePoint.y; + + if ( (position >= m_lPosition-3) && + (position <= m_lPosition+3) ) + { + m_bDragged = true; + } +} + +void CChartDragLineCursor::OnMouseButtonUp(CPoint /*mousePoint*/) +{ + m_bDragged = false; +} + +void CChartDragLineCursor::OnMouseMove(CPoint mousePoint) +{ + if (!m_bDragged) + return; + + double XVal = 0; + double YVal = 0; + if (m_pRelatedAxis->IsHorizontal()) + { + m_lPosition = mousePoint.x; + XVal = m_pRelatedAxis->ScreenToValue(m_lPosition); + } + else + { + m_lPosition = mousePoint.y; + YVal = m_pRelatedAxis->ScreenToValue(m_lPosition); + } + + CursorMoved(XVal, YVal); +} + +void CChartDragLineCursor::SetPosition(double dPosition) +{ + m_lPosition = m_pRelatedAxis->ValueToScreen(dPosition); +} diff --git a/ChartDemo/ChartCtrl/ChartDragLineCursor.h b/ChartDemo/ChartCtrl/ChartDragLineCursor.h new file mode 100644 index 0000000..9a07270 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartDragLineCursor.h @@ -0,0 +1,72 @@ +/* + * + * ChartDragLineCursor.h + * + * 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. + * + * + */ + +#ifndef _CHARTDRAGLINECURSOR_H_ +#define _CHARTDRAGLINECURSOR_H_ + +#include "ChartCursor.h" + +class CChartAxis; + +//! Specialization of a CChartCursor class for a dragline cursor. +/** + A dragline cursor is a simple vertical or horizontal line associated + with a specific axis. The line can be moved if the user clicks on the + line (and keeps the button pressed) and moves the mouse. Once the mouse + button is released, the line doesn't move anymore.
+ To create a dragline cursor, call the CreateDragLineCursor from the + CChartCtrl class. +**/ +class CChartDragLineCursor : public CChartCursor +{ + friend CChartCtrl; + +public: + //! Sets the position (by value) of the cursor. + void SetPosition(double dPosition); + +protected: + //! Called when the mouse is moved over the plot area. + void OnMouseMove(CPoint mousePoint); + //! Called when the mouse button is pressed over the plot area. + void OnMouseButtonDown(CPoint mousePoint); + //! Called when the mouse button is released over the plot area. + void OnMouseButtonUp(CPoint mousePoint); + + //! Draw the cursor. + void Draw(CDC* pDC); + +private: + //! Constructor + CChartDragLineCursor(CChartCtrl* pParent, CChartAxis* pRelatedAxis); + //! Destructor + ~CChartDragLineCursor(); + + //! The axis to which this cursor is attached. + CChartAxis* m_pRelatedAxis; + + //! flag specifying if the cursor is currently being dragged. + bool m_bDragged; + //! The current screen position of the cursor. + long m_lPosition; +}; + +#endif // _CHARTDRAGLINECURSOR_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartFont.cpp b/ChartDemo/ChartCtrl/ChartFont.cpp new file mode 100644 index 0000000..deae84f --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartFont.cpp @@ -0,0 +1,145 @@ +/* + * + * ChartFont.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 "ChartFont.h" + +CChartFont::CChartFont(const TChartString& strFaceName, int iPointSize) + : m_strFaceName(strFaceName), m_iPointSize(iPointSize), m_bItalic(false), + m_bBold(false), m_bUnderline(false), m_bVertical(false), m_Font(), m_bDirty(true), + m_pOldFont(NULL) +{ +} + +CChartFont::CChartFont(const CChartFont& copy) +{ + *this = copy; +} + +CChartFont::CChartFont() + : m_strFaceName(_T("Microsoft Sans Serif")), m_iPointSize(100), m_bItalic(false), + m_bBold(false), m_bUnderline(false), m_bVertical(false), m_Font(), m_bDirty(true), + m_pOldFont(NULL) +{ +} + +CChartFont::~CChartFont() +{ + m_Font.DeleteObject(); +} + +/*CFont* CChartFont::GetFont(CDC* pDC) +{ + if (!m_pFont) + m_pFont = new CFont(); + + if (m_bDirty) + { + LOGFONT lf; + memset(&lf, 0, sizeof(LOGFONT)); + lf.lfHeight = m_iPointSize; + _tcscpy_s(lf.lfFaceName,LF_FACESIZE-1 , m_strFaceName.c_str()); + lf.lfItalic = m_bItalic; + lf.lfUnderline = m_bUnderline; + if (m_bBold) + lf.lfWeight = FW_BOLD; + else + lf.lfWeight = FW_NORMAL; + + m_pFont->CreatePointFontIndirect(&lf, pDC); + } + + return m_pFont; +}*/ + +void CChartFont::operator=(const CChartFont& objectSrc) +{ + m_strFaceName = objectSrc.m_strFaceName; + m_iPointSize = objectSrc.m_iPointSize; + + m_bItalic = objectSrc.m_bItalic; + m_bBold = objectSrc.m_bBold; + m_bUnderline = objectSrc.m_bUnderline; + m_bVertical = objectSrc.m_bVertical; + + m_bDirty = true; +} + +void CChartFont::SelectFont(CDC* pDC) const +{ + if (m_bDirty) + { + LOGFONT lf; + memset(&lf, 0, sizeof(LOGFONT)); + lf.lfHeight = m_iPointSize; +#ifdef _CRT_INSECURE_DEPRECATE + _tcscpy_s(lf.lfFaceName,LF_FACESIZE-1 , m_strFaceName.c_str()); +#else + _tcscpy(lf.lfFaceName, m_strFaceName.c_str()); +#endif + lf.lfItalic = m_bItalic; + lf.lfUnderline = m_bUnderline; + if (m_bBold) + lf.lfWeight = FW_BOLD; + else + lf.lfWeight = FW_NORMAL; + + if (m_bVertical) + { + lf.lfOrientation = 900; + lf.lfEscapement = 900; + } + + m_Font.DeleteObject(); + m_Font.CreatePointFontIndirect(&lf, pDC); + m_bDirty = false; + } + + m_pOldFont = pDC->SelectObject(&m_Font); +} + +void CChartFont::UnselectFont(CDC* pDC) const +{ + ASSERT(m_pOldFont); + pDC->SelectObject(m_pOldFont); + m_pOldFont = NULL; +} + +void CChartFont::SetFont(const TChartString& strFaceName, + int iPointSize, + bool bItalic, + bool bBold, + bool bUnderline) +{ + m_strFaceName = strFaceName; + m_iPointSize = iPointSize; + + m_bItalic = bItalic; + m_bBold = bBold; + m_bUnderline = bUnderline; + + m_bDirty = true; +} + +void CChartFont::SetVertical(bool bVertical) +{ + m_bVertical = bVertical; + m_bDirty = true; +} diff --git a/ChartDemo/ChartCtrl/ChartFont.h b/ChartDemo/ChartCtrl/ChartFont.h new file mode 100644 index 0000000..6f689d3 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartFont.h @@ -0,0 +1,111 @@ +/* + * + * ChartFont.h + * + * 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. + * + * + */ + +#ifndef _CHARTFONT_H_ +#define _CHARTFONT_H_ + +#include "ChartString.h" +#include + +//! Wrapper class for fonts with advanced properties (italic, bold or underlined). +class CChartFont +{ +public: + //! Copy constructor. + CChartFont(const CChartFont& copy); + //! Constructor + /** + @param strFaceName + The font face name + @param iPointSize + The font point size + **/ + CChartFont(const TChartString& strFaceName, int iPointSize); + //! Default constructor + /** + Construct a font with the "Microsoft Sans Serif" face name and + with a point size of 100. + **/ + CChartFont(); + //! Destructor + ~CChartFont(); + + //! Sets the font with extended properties. + /** + @param strFaceName + The font face name + @param iPointSize + The font point size + @param bItalic + Specifies if the text is in italic + @param bBold + Specifies if the text is in bold + @param bUnderline + Specifies if the text is underlined + **/ + void SetFont(const TChartString& strFaceName, int iPointSize, + bool bItalic=false, bool bBold=false, bool bUnderline=false); + + //! Select this font in the device context passed in argument. + /** + This function stores the current font selected in the DC to + set it back when calling UnselectFont. This function is mainly + used internally. + **/ + void SelectFont(CDC* pDC) const; + //! Reset the font to its original in the device context. + void UnselectFont(CDC* pDC) const; + + //! Sets the text in vertical mode. + /** + This function is mainly used internally. + **/ + void SetVertical(bool bVertical); + + //! Assignement operator. + void operator=(const CChartFont& objectSrc); + +private: + //! The font face name + TChartString m_strFaceName; + //! The font point size + int m_iPointSize; + + //! Specifies if the font is italic + bool m_bItalic; + //! Specifies if the font is bold + bool m_bBold; + //! Specifies if the font is underlined + bool m_bUnderline; + + //! Specifies if the font is vertical + bool m_bVertical; + + //! Caches the current font + mutable CFont m_Font; + //! Specifies if the font information has been modified + mutable bool m_bDirty; + + //! The old font which is stored when calling SelectFont + mutable CFont* m_pOldFont; +}; + +#endif // _CHARTFONT_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartGanttSerie.cpp b/ChartDemo/ChartCtrl/ChartGanttSerie.cpp new file mode 100644 index 0000000..1e34103 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartGanttSerie.cpp @@ -0,0 +1,228 @@ +/* + * + * ChartGanttSerie.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 "ChartGanttSerie.h" +#include "ChartCtrl.h" + +CChartGanttSerie::CChartGanttSerie(CChartCtrl* pParent) + : CChartSerieBase(pParent), m_iBarWidth(10), m_iBorderWidth(1), + m_BorderColor(RGB(0,0,0)), m_bGradient(true), + m_GradientColor(RGB(255,255,255)), m_GradientType(gtHorizontalDouble) +{ + m_bShadow = true; + this->SetSeriesOrdering(poYOrdering); +} + +CChartGanttSerie::~CChartGanttSerie() +{ +} + +void CChartGanttSerie::AddPoint(double StartTime, double EndTime, double YValue) +{ + SChartGanttPoint newPoint(StartTime, EndTime, YValue); + CChartSerieBase::AddPoint(newPoint); +} + +bool CChartGanttSerie::IsPointOnSerie(const CPoint& screenPoint, + unsigned& uIndex) const +{ + uIndex = INVALID_POINT; + if (!m_bIsVisible) + return false; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return false; + if (uFirst>0) + uFirst--; + if (uLastGetSafeHdc()) + return; + + //Draw bar: + CBrush BorderBrush(m_BorderColor); + pDC->FillRect(rectBitmap,&BorderBrush); + + CRect FillRect(rectBitmap); + CBrush FillBrush(m_SerieColor); + FillRect.DeflateRect(m_iBorderWidth,m_iBorderWidth); + if (m_bGradient) + { + CChartGradient::DrawGradient(pDC,FillRect,m_SerieColor,m_GradientColor,m_GradientType); + } + else + { + pDC->FillRect(FillRect,&FillBrush); + } +} + +void CChartGanttSerie::Draw(CDC* pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + CRect TempClipRect(m_PlottingRect); + TempClipRect.DeflateRect(1,1); + pDC->SetBkMode(TRANSPARENT); + pDC->IntersectClipRect(TempClipRect); + + CBrush BorderBrush(m_BorderColor); + CBrush FillBrush(m_SerieColor); + //Draw all points that haven't been drawn yet + for (m_uLastDrawnPoint;m_uLastDrawnPoint<(int)GetPointsCount();m_uLastDrawnPoint++) + { + CRect BarRect = GetBarRectangle(m_uLastDrawnPoint); + DrawBar(pDC, &FillBrush, &BorderBrush, BarRect); + } + + pDC->SelectClipRgn(NULL); + DeleteObject(BorderBrush); + DeleteObject(FillBrush); +} + +void CChartGanttSerie::DrawAll(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + CRect TempClipRect(m_PlottingRect); + TempClipRect.DeflateRect(1,1); + if (uFirst>0) + uFirst--; + if (uLastSetBkMode(TRANSPARENT); + pDC->IntersectClipRect(TempClipRect); + + CBrush BorderBrush(m_BorderColor); + CBrush FillBrush(m_SerieColor); + for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++) + { + CRect BarRect = GetBarRectangle(m_uLastDrawnPoint); + DrawBar(pDC, &FillBrush, &BorderBrush, BarRect); + } + + pDC->SelectClipRgn(NULL); + DeleteObject(BorderBrush); + DeleteObject(FillBrush); +} + +void CChartGanttSerie::SetBorderColor(COLORREF BorderColor) +{ + m_BorderColor = BorderColor; + m_pParentCtrl->RefreshCtrl(); +} +void CChartGanttSerie::SetBorderWidth(int Width) +{ + m_iBorderWidth = Width; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartGanttSerie::SetBarWidth(int Width) +{ + m_iBarWidth = Width; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartGanttSerie::ShowGradient(bool bShow) +{ + m_bGradient = bShow; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartGanttSerie::SetGradient(COLORREF GradientColor, EGradientType GradientType) +{ + m_GradientColor = GradientColor; + m_GradientType = GradientType; + m_pParentCtrl->RefreshCtrl(); +} + +CRect CChartGanttSerie::GetBarRectangle(unsigned uPointIndex) const +{ + SChartGanttPoint point = GetPoint(uPointIndex); + int PointXStart = m_pHorizontalAxis->ValueToScreen(point.StartTime); + int PointXEnd = m_pHorizontalAxis->ValueToScreen(point.EndTime); + int YVal = m_pVerticalAxis->ValueToScreen(point.YValue); + int PointYStart = YVal - m_iBarWidth; + int PointYEnd = YVal + m_iBarWidth; + CRect PointRect(min(PointXStart, PointXEnd), min(PointYStart, PointYEnd), + max(PointXStart, PointXEnd), max(PointYStart, PointYEnd) ); + return PointRect; +} + +void CChartGanttSerie::DrawBar(CDC* pDC, CBrush* pFillBrush, CBrush* pBorderBrush, + CRect BarRect) +{ + if (m_bShadow) + { + CBrush ShadowBrush(m_ShadowColor); + CRect ShadowRect(BarRect); + ShadowRect.OffsetRect(m_iShadowDepth,m_iShadowDepth); + pDC->FillRect(ShadowRect,&ShadowBrush); + } + pDC->FillRect(BarRect,pBorderBrush); + + CRect FillRect(BarRect); + FillRect.DeflateRect(m_iBorderWidth,m_iBorderWidth); + if (m_bGradient) + { + CChartGradient::DrawGradient(pDC,FillRect,m_SerieColor,m_GradientColor, + m_GradientType); + } + else + { + pDC->FillRect(FillRect,pFillBrush); + } +} \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartGanttSerie.h b/ChartDemo/ChartCtrl/ChartGanttSerie.h new file mode 100644 index 0000000..ccbaaf2 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartGanttSerie.h @@ -0,0 +1,162 @@ +/* + * + * ChartGanttSerie.h + * + * 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. + * + * + */ + +#pragma once +#include "ChartSerieBase.h" + +//! Point structure used as template parameter for gantt series +struct SChartGanttPoint +{ + //! Default constructor + SChartGanttPoint() : StartTime(0.0), EndTime(0.0), YValue(0.0) { } + //! Construct a new gantt point with the specifed values + SChartGanttPoint(double Start, double End, double YVal) + : StartTime(Start), EndTime(End), YValue(YVal) { } + + //! The start time of the gantt point + double StartTime; + //! The end time of the gantt point + double EndTime; + //! The Y value of the gantt point + double YValue; + + //! Returns the X value of the point, which is the average between start time and end time + double GetX() const { return (EndTime-StartTime)/2; } + //! Returns the Y value + double GetY() const { return YValue; } + //! Returns the start time + double GetXMin() const { return StartTime; } + //! Returns the end time + double GetXMax() const { return EndTime; } + //! Returns the Y value + double GetYMin() const { return YValue; } + //! Returns the Y value + double GetYMax() const { return YValue; } +}; + +//! Specialization of a CChartSerieBase to display a gantt series. +/** + Each point in a gantt series is amde of three values: a start and + end time and an Y value. The points are displayed as horizontal bars + that are positionned on the Y axis depending on their Y value and + which starts at the start time and end at the end time along the X + axis. +**/ +class CChartGanttSerie : public CChartSerieBase +{ +public: + //! Constructor + CChartGanttSerie(CChartCtrl* pParent); + //! Destructor + ~CChartGanttSerie(); + + //! Adds a new point to the series. + /** + @param StartTime + The start time of the Gantt bar + @param EndTime + The end time of the Gantt bar + @param YValue + The YValue of the Gantt bar + **/ + void AddPoint(double StartTime, double EndTime, double YValue); + + //! Tests if a certain screen point is on the series. + /** + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const; + + //! Sets the bars border color + void SetBorderColor(COLORREF BorderColor); + //! Returns the bars border color + COLORREF GetBorderColor() const { return m_BorderColor; } + //! Sets the bars border width + void SetBorderWidth(int Width); + //! Returns the bars border width + int GetBorderWidth() const { return m_iBorderWidth; } + //! Sets the bars width (in pixels) + void SetBarWidth(int Width); + //! Returns the bars width (in pixels) + int GetBarWidth() const { return m_iBarWidth; } + + //! Specifies if a gradient is applied to the bars + void ShowGradient(bool bShow); + //! Sets the gradient style + /** + @param GradientColor + The second color used for the gradient (the first one being + the original series color). + @param GradientType + The type of gradient used between the two colors (vertical, horizontal, ...) + **/ + void SetGradient(COLORREF GradientColor, EGradientType GradientType); + +protected: + //! Draws the legend icon for the series. + /** + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + void DrawLegend(CDC* pDC, const CRect& rectBitmap) const; + + //! Draws the most recent points of the series. + /** + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + void Draw(CDC* pDC); + //! Redraws the full series. + /** + @param pDC + The device context used to draw + **/ + void DrawAll(CDC *pDC); + +private: + //! Returns the rectangle of a specific point of the series. + CRect GetBarRectangle(unsigned uPointIndex) const; + + void DrawBar(CDC* pDC, CBrush* pFillBrush, CBrush* pBorderBrush, + CRect BarRect); + + //! The bar width + int m_iBarWidth; + //! The bar border width + int m_iBorderWidth; + //! The bar border color + COLORREF m_BorderColor; + + //! True if a gradient is applied to fill the bar + bool m_bGradient; + //! The second color of the gradient + COLORREF m_GradientColor; + //! The type of gradient to apply + EGradientType m_GradientType; +}; diff --git a/ChartDemo/ChartCtrl/ChartGradient.cpp b/ChartDemo/ChartCtrl/ChartGradient.cpp new file mode 100644 index 0000000..40cf252 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartGradient.cpp @@ -0,0 +1,127 @@ +/* + * + * ChartGradient.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 "ChartGradient.h" + +CChartGradient::CChartGradient() +{ +} + +CChartGradient::~CChartGradient() +{ +} + +void CChartGradient::DrawGradient(CDC* pDC, const CRect& GradientRect, COLORREF Color1, + COLORREF Color2, EGradientType GradientType) +{ +#if _MFC_VER > 0x0600 + if ( (GradientType == gtHorizontal) || (GradientType == gtVertical) ) + { + TRIVERTEX vertex[2] ; + vertex[0].x = GradientRect.left; + vertex[0].y = GradientRect.top; + vertex[0].Red = ((COLOR16)GetRValue(Color1))<<8; + vertex[0].Green = ((COLOR16)GetGValue(Color1))<<8; + vertex[0].Blue = ((COLOR16)GetBValue(Color1))<<8; + vertex[0].Alpha = 0x0000; + vertex[1].x = GradientRect.right; + vertex[1].y = GradientRect.bottom; + vertex[1].Red = ((COLOR16)GetRValue(Color2))<<8; + vertex[1].Green = ((COLOR16)GetGValue(Color2))<<8; + vertex[1].Blue = ((COLOR16)GetBValue(Color2))<<8; + vertex[1].Alpha = 0x0000; + GRADIENT_RECT gRect; + gRect.UpperLeft = 0; + gRect.LowerRight = 1; + if (GradientType == gtHorizontal) + pDC->GradientFill(vertex,2,&gRect,1,GRADIENT_FILL_RECT_H); + else + pDC->GradientFill(vertex,2,&gRect,1,GRADIENT_FILL_RECT_V); + } + else + { + for (int i=0;i<2; i++) + { + TRIVERTEX vertex[2] ; + if (GradientType == gtHorizontalDouble) + { + vertex[0].x = GradientRect.left + (GradientRect.Width()/2) * i; + vertex[0].y = GradientRect.top; + } + else + { + vertex[0].x = GradientRect.left; + vertex[0].y = GradientRect.top + (GradientRect.Height()/2) * i; + } + if (i==0) + { + vertex[0].Red = ((COLOR16)GetRValue(Color1))<<8; + vertex[0].Green = ((COLOR16)GetGValue(Color1))<<8; + vertex[0].Blue = ((COLOR16)GetBValue(Color1))<<8; + } + else + { + vertex[0].Red = ((COLOR16)GetRValue(Color2))<<8; + vertex[0].Green = ((COLOR16)GetGValue(Color2))<<8; + vertex[0].Blue = ((COLOR16)GetBValue(Color2))<<8; + } + vertex[0].Alpha = 0x0000; + if (GradientType == gtHorizontalDouble) + { + vertex[1].x = GradientRect.left + (GradientRect.Width()/2) * (i+1); + vertex[1].y = GradientRect.bottom; + } + else + { + vertex[1].x = GradientRect.right; + vertex[1].y = GradientRect.top + (GradientRect.Height()/2) * (i+1); + } + if (i==0) + { + vertex[1].Red = ((COLOR16)GetRValue(Color2))<<8; + vertex[1].Green = ((COLOR16)GetGValue(Color2))<<8; + vertex[1].Blue = ((COLOR16)GetBValue(Color2))<<8; + } + else + { + vertex[1].Red = ((COLOR16)GetRValue(Color1))<<8; + vertex[1].Green = ((COLOR16)GetGValue(Color1))<<8; + vertex[1].Blue = ((COLOR16)GetBValue(Color1))<<8; + } + vertex[1].Alpha = 0x0000; + + GRADIENT_RECT gRect; + gRect.UpperLeft = 0; + gRect.LowerRight = 1; + if (GradientType == gtHorizontalDouble) + pDC->GradientFill(vertex,2,&gRect,1,GRADIENT_FILL_RECT_H); + else + pDC->GradientFill(vertex,2,&gRect,1,GRADIENT_FILL_RECT_V); + } + } +#else + CBrush NewBrush(Color1); + pDC->FillRect(GradientRect,&NewBrush); + DeleteObject(NewBrush); +#endif + +} diff --git a/ChartDemo/ChartCtrl/ChartGradient.h b/ChartDemo/ChartCtrl/ChartGradient.h new file mode 100644 index 0000000..00b16c1 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartGradient.h @@ -0,0 +1,65 @@ +/* + * + * ChartGradient.h + * + * 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. + * + * + */ + +#pragma once + +//! Types of gradients that can be used +enum EGradientType +{ + //! A simple horizontal gradient (from the first color to the second) + gtHorizontal, + //! A simple Vertical gradient (from the first color to the second) + gtVertical, + //! A double horizontal gradient (first color to second and back to first) + gtHorizontalDouble, + //! A double vertical gradient (first color to second and back to first) + gtVerticalDouble +}; + +//! Helper class to draw gradient. +/** + It only contains a static function to draw the gradient. This is + mainly used internally. +**/ +class CChartGradient +{ +public: + //! Constructor + CChartGradient(); + //! Destructor + ~CChartGradient(); + + //! Draws a gradient between two colors inside a rectangle. + /** + @param pDC + The device context with which to draw. + @param GradientRect + The rectangle in which to draw the gradient + @param Color1 + The first gradient color + @param Color2 + The second gradient color + @param GradientType + The type of gradient to use in the rectangle + **/ + static void DrawGradient(CDC* pDC, const CRect& GradientRect, COLORREF Color1, + COLORREF Color2, EGradientType GradientType); +}; diff --git a/ChartDemo/ChartCtrl/ChartGrid.cpp b/ChartDemo/ChartCtrl/ChartGrid.cpp new file mode 100644 index 0000000..400ce76 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartGrid.cpp @@ -0,0 +1,123 @@ +/* + * + * ChartGrid.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 "ChartGrid.h" +#include "ChartAxis.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +using namespace std; + + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartGrid::CChartGrid() + : m_GridColor(RGB(128,128,128)), m_pParentCtrl(NULL), m_bIsVisible(true), + m_bIsHorizontal(true), m_lstTickPos() +{ +} + +CChartGrid::~CChartGrid() +{ + +} + +void CChartGrid::AddTick(int Position) +{ + m_lstTickPos.push_back(Position); +} + +void CChartGrid::ClearTicks() +{ + m_lstTickPos.clear(); +} + +void CChartGrid::Draw(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc() ) + return; + + CRect plottingRect = m_pParentCtrl->GetPlottingRect(); + pDC->IntersectClipRect(plottingRect); + + CPen* pOldPen; + CPen NewPen(PS_SOLID,0,m_GridColor); + pOldPen = pDC->SelectObject(&NewPen); + + list::iterator iter = m_lstTickPos.begin(); + int ActuPosition = 0; + + for (iter; iter!=m_lstTickPos.end(); iter++) + { + ActuPosition = *iter; + if (!m_bIsHorizontal) + { + int ActuX = plottingRect.left; + + while (ActuXMoveTo(ActuX,ActuPosition); + ActuX += 3; + pDC->LineTo(ActuX,ActuPosition); + ActuX += 3; + } + } + else + { + int ActuY = plottingRect.bottom; + + while (ActuY>plottingRect.top) + { + pDC->MoveTo(ActuPosition,ActuY); + ActuY -= 3; + pDC->LineTo(ActuPosition,ActuY); + ActuY -= 3; + } + } + } + + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); +} + +void CChartGrid::SetVisible(bool bVisible) +{ + m_bIsVisible = bVisible; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} + +void CChartGrid::SetColor(COLORREF NewColor) +{ + m_GridColor = NewColor; + if (m_pParentCtrl) + m_pParentCtrl->RefreshCtrl(); +} diff --git a/ChartDemo/ChartCtrl/ChartGrid.h b/ChartDemo/ChartCtrl/ChartGrid.h new file mode 100644 index 0000000..b5e7c01 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartGrid.h @@ -0,0 +1,83 @@ +/* + * + * ChartGrid.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTGRID_H__ECCBEFF4_2365_49CD_A865_F1B4DD8CA138__INCLUDED_) +#define AFX_CHARTGRID_H__ECCBEFF4_2365_49CD_A865_F1B4DD8CA138__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include +#include "ChartCtrl.h" + + +class CChartAxis; + +//! Class which draws the grid associated with a specific axis. +/** + This object is retrieved through the CChartAxis::GetGrid function. +**/ +class CChartGrid +{ + friend CChartAxis; + +public: + //! Shows/hides the grid. + void SetVisible(bool bVisible); + //! Returns true if the grid is visible. + bool IsVisible() const { return m_bIsVisible; } + + //! Sets the color of the grid. + void SetColor(COLORREF NewColor); + //! Returns the grid color. + COLORREF GetColor() const { return m_GridColor; } + +private: + //! Constructor + CChartGrid(); + //! Destructor + virtual ~CChartGrid(); + + //! Draws the grid + void Draw(CDC* pDC); + + //! Add a tick at a certain position + void AddTick(int Position); + //! Removes all the ticks. + void ClearTicks(); + + + //! The grid color. + COLORREF m_GridColor; + + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + //! Specifies if the grid is visible or not. + bool m_bIsVisible; + + //! List containing all the tick positions. + std::list m_lstTickPos; + //! Specifies if the grid is associated with a vertical or horizontal axis. + bool m_bIsHorizontal; +}; + +#endif // !defined(AFX_CHARTGRID_H__ECCBEFF4_2365_49CD_A865_F1B4DD8CA138__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartLabel.h b/ChartDemo/ChartCtrl/ChartLabel.h new file mode 100644 index 0000000..d9fb23a --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLabel.h @@ -0,0 +1,122 @@ +/* + * + * ChartLabel.h + * + * 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. + * + * + */ + +#ifndef _CHARTLABEL_H_ +#define _CHARTLABEL_H_ + +template +class CChartSerieBase; + +//! Interface which should be implemented in order to provide text to a label. +/** + This class is a template class with the template parameter being the point + type of the series to which the label is attached. + + Using a CChartLabelProvider provides more flexibility in the way to + supply text to the label. You can for instance embedd in the string some + information about the point (XValue, YValue, index, ...). In that case, a + single CChartLabelProvider object can be provided for all labels. Changing + the displayed text of all labels becomes also easier: you only have to adapt + the string returned by this object and refresh the control and all labels will + be updated. +**/ +template +class CChartLabelProvider +{ +public: + //! Constructor + CChartLabelProvider() { } + //! Destructor + virtual ~CChartLabelProvider() { } + + //! Method to override in order to provide the text of the label. + /** + @param pSerie + The series to which the label is attached + @param uPtIndex + The index of the point in the series to which the label is attached + @return a string which will be the text displayed in the label. + **/ + virtual TChartString GetText(CChartSerieBase* pSerie, + unsigned PointIndex) = 0; +}; + +//! Draws a label containing some text which is attached to a point of a series. +/** + This is a base class which should be overriden for specific label types. +**/ +template +class CChartLabel +{ + friend CChartSerieBase; + +public: + //! Sets a static text to be displayed in the label. + void SetLabelText(const TChartString& strText); + //! Sets the font of the text label. + /** + @param nPointSize + The font point size + @param strFaceName + The font face name + **/ + void SetFont(int nPointSize, const TChartString& strFaceName); + //! Shows/hides the label. + void SetVisisble(bool bVisible); + //! Sets a label provider for more flexibility in how the text is supplied. + void SetLabelProvider(CChartLabelProvider* pProvider) + { + m_pLabelProvider = pProvider; + } + +protected: + //! Constructor + CChartLabel(CChartCtrl* pParentCtrl, CChartSerieBase* pParentSeries); + //! Destructor + virtual ~CChartLabel(); + + //! Draws the label. + /** + This pure virtual function must be overriden by all child classes. + **/ + virtual void Draw(CDC* pDC, unsigned uPointIndex) = 0; + + //! Specifies if the label is visible or not. + bool m_bIsVisible; + //! The text font size. + int m_iFontSize; + //! The text font face name. + TChartString m_strFontName; + + //! The static text of the label. + TChartString m_strLabelText; + //! The text provider. + CChartLabelProvider* m_pLabelProvider; + + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + //! The parent series. + CChartSerieBase* m_pParentSeries; +}; + +#include "ChartLabel.inl" + +#endif // _CHARTLABEL_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartLabel.inl b/ChartDemo/ChartCtrl/ChartLabel.inl new file mode 100644 index 0000000..9b887ed --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLabel.inl @@ -0,0 +1,59 @@ +/* + * + * ChartLabel.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 "ChartCtrl.h" + +template +CChartLabel::CChartLabel(CChartCtrl* pParentCtrl, + CChartSerieBase* pParentSeries) + : m_iFontSize(100),m_strFontName(_T("Microsoft Sans Serif")), + m_strLabelText(_T("")), m_pLabelProvider(NULL), m_pParentCtrl(pParentCtrl), + m_pParentSeries(pParentSeries) +{ +} + +template +CChartLabel::~CChartLabel() +{ +} + +template +void CChartLabel::SetLabelText(const TChartString& strText) +{ + m_strLabelText = strText; + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartLabel::SetFont(int nPointSize, const TChartString& strFaceName) +{ + m_iFontSize = nPointSize; + m_strFontName = strFaceName; + m_pParentCtrl->RefreshCtrl(); +} + +template +void CChartLabel::SetVisisble(bool bVisible) +{ + m_bIsVisible = bVisible; + m_pParentCtrl->RefreshCtrl(); +} + diff --git a/ChartDemo/ChartCtrl/ChartLegend.cpp b/ChartDemo/ChartCtrl/ChartLegend.cpp new file mode 100644 index 0000000..bfbcb11 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLegend.cpp @@ -0,0 +1,357 @@ +/* + * + * ChartLegend.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. + * + * History: + * - 02/03/2008: Legend can now be docked on any side or can be floating. + * - 02/03/2008: Added support for transparent legend. + * - 24/03/2008: Bug fix for invisible series. + * - 28/03/2008: Support for horizontal legend. + * - 28/03/2008: Bitmap size is now the same for all series. + * + */ + +#include "stdafx.h" +#include "ChartLegend.h" +#include "ChartSerie.h" +#include "ChartCtrl.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartLegend::CChartLegend(CChartCtrl* pParent) +{ + m_pParentCtrl = pParent; + m_BackColor = RGB(255,255,255); + m_iFontSize = 100; + m_strFontName = _T("Times New Roman"); + + m_bIsVisible = false; + + m_bDocked = true; + m_DockSide = dsDockRight; + m_iLeftPos = m_iTopPos = 0; + m_bIsTransparent = false; + m_bIsHorizontal = false; + + m_bShadow = true; + m_iShadowDepth = 3; + m_BitmapSize.cx = 16; + m_BitmapSize.cy = 16; +} + +CChartLegend::~CChartLegend() +{ +} + +void CChartLegend::SetVisible(bool bVisible) +{ + m_bIsVisible = bVisible; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::SetBackColor(COLORREF NewColor) +{ + m_BackColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::SetShadowColor(COLORREF NewColor) +{ + m_ShadowColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::EnableShadow(bool bEnable) +{ + m_bShadow = bEnable; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::SetShadowDepth(int Depth) +{ + m_iShadowDepth = Depth; + m_pParentCtrl->RefreshCtrl(); +} + +BOOL CChartLegend::IsPointInside(const CPoint& screenPoint) const +{ + return m_LegendRect.PtInRect(screenPoint); +} + +void CChartLegend::SetFont(int iPointSize, const TChartString& strFaceName) +{ + m_iFontSize = iPointSize; + m_strFontName = strFaceName; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::SetTransparent(bool bTransparent) +{ + m_bIsTransparent = bTransparent; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::SetHorizontalMode(bool bHorizontal) +{ + m_bIsHorizontal = bHorizontal; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::DockLegend(DockSide dsSide) +{ + m_bDocked = true; + m_DockSide = dsSide; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::UndockLegend(int iLeftPos, int iTopPos) +{ + m_bDocked = false; + m_iLeftPos = iLeftPos; + m_iTopPos = iTopPos; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLegend::ClipArea(CRect& rcControl, CDC* pDC) +{ + UpdatePosition(pDC,rcControl); + if (m_LegendRect.IsRectEmpty()) + return; + + if (m_bDocked) + { + switch (m_DockSide) + { + case dsDockRight: + rcControl.right = m_LegendRect.left + 2; + break; + case dsDockLeft: + rcControl.left = m_LegendRect.right - 2; + break; + case dsDockTop: + rcControl.top = m_LegendRect.bottom + 2; + break; + case dsDockBottom: + rcControl.bottom = m_LegendRect.top - 2; + break; + } + } +} + +void CChartLegend::UpdatePosition(CDC* pDC, const CRect& rcControl) +{ + CRect NewPosition; + NewPosition.SetRectEmpty(); + if (!m_bIsVisible) + { + m_LegendRect = NewPosition; + return; + } + + CFont* pOldFont; + CFont NewFont; + NewFont.CreatePointFont(m_iFontSize,m_strFontName.c_str(),pDC); + pOldFont = pDC->SelectObject(&NewFont); + + int Height = 0; + int Width = 0; + int MaxText = 0; + CSize TextSize; + + m_pParentCtrl->GoToFirstSerie(); + int Drawn = 0; + while (CChartSerie* pSerie=m_pParentCtrl->GetNextSerie()) + { + if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() ) + continue; + + Drawn++; + TextSize = pDC->GetTextExtent(pSerie->GetName().c_str()); + + if (!m_bIsHorizontal) + { + if (TextSize.cy>m_BitmapSize.cy) + Height += TextSize.cy + 2; + else + Height += m_BitmapSize.cy + 2; + + if (TextSize.cx > MaxText) + MaxText = TextSize.cx; + } + else + { + Width += TextSize.cx + 4 + m_BitmapSize.cx + 10; + if (TextSize.cy > MaxText) + MaxText = TextSize.cy; + } + } + pDC->SelectObject(pOldFont); + DeleteObject(NewFont); + + if (!Drawn) + { + m_LegendRect = NewPosition; + return; + } + + if (!m_bIsHorizontal) + { + Width += MaxText + m_BitmapSize.cx + 12; + Height += 4 + 4 - 2; // Top and bottom margins. -2 because space counted once too much + } + else + { + Width += 2 + 2 - 10; + Height = 4 + max(m_BitmapSize.cy,MaxText) + 4; + } + + if (!m_bDocked) + { + NewPosition.top = m_iTopPos; + NewPosition.left = m_iLeftPos; + NewPosition.bottom = m_iTopPos + Height + 2; + NewPosition.right = m_iLeftPos + Width; + } + else + { + switch (m_DockSide) + { + case dsDockRight: + NewPosition.top = ((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2); + NewPosition.left = rcControl.right - (Width + 6); + NewPosition.bottom = NewPosition.top + Height; + NewPosition.right = NewPosition.left + Width; + break; + case dsDockLeft: + NewPosition.top = ((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2); + NewPosition.left = rcControl.left + 3; + NewPosition.bottom = NewPosition.top + Height; + NewPosition.right = NewPosition.left + Width; + break; + case dsDockTop: + NewPosition.top = rcControl.top + 3; //((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2); + NewPosition.left = ((rcControl.right-rcControl.left)/2) - (Width/2); // rcControl.left + 3; + NewPosition.bottom = NewPosition.top + Height; + NewPosition.right = NewPosition.left + Width; + break; + case dsDockBottom: + NewPosition.top = rcControl.bottom - (Height + 2); //((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2); + NewPosition.left = ((rcControl.right-rcControl.left)/2) - (Width/2); // rcControl.left + 3; + NewPosition.bottom = NewPosition.top + Height; + NewPosition.right = NewPosition.left + Width; + break; + } + } + m_LegendRect = NewPosition; +} + +void CChartLegend::Draw(CDC *pDC) +{ + if (!pDC->GetSafeHdc()) + return; + if (!m_bIsVisible) + return; + if (m_LegendRect.IsRectEmpty()) + return; + + CPen SolidPen(PS_SOLID,0,RGB(0,0,0)); + CPen* pOldPen; + CFont* pOldFont; + CFont NewFont; + NewFont.CreatePointFont(m_iFontSize,m_strFontName.c_str(),pDC); + + // Draw the shadow + if (m_bShadow) + { + CRect ShadowRect = m_LegendRect; + ShadowRect.OffsetRect(m_iShadowDepth,m_iShadowDepth); + CBrush BrushShadow; + BrushShadow.CreateSolidBrush(m_ShadowColor) ; + pDC->FillRect(ShadowRect,&BrushShadow); + } + + if (!m_bIsTransparent) + { + //Fill back color + CBrush BrushBack; + BrushBack.CreateSolidBrush(m_BackColor) ; + pDC->FillRect(m_LegendRect,&BrushBack); + } + + pOldFont = pDC->SelectObject(&NewFont); + pOldPen = pDC->SelectObject(&SolidPen); + + //Draw rectangle: + pDC->MoveTo(m_LegendRect.left,m_LegendRect.top); + pDC->LineTo(m_LegendRect.right,m_LegendRect.top); + pDC->LineTo(m_LegendRect.right,m_LegendRect.bottom); + pDC->LineTo(m_LegendRect.left,m_LegendRect.bottom); + pDC->LineTo(m_LegendRect.left,m_LegendRect.top); + + int iPrevMode = pDC->SetBkMode(TRANSPARENT); + CRect rectBitmap(m_LegendRect.left+2,m_LegendRect.top+5, + m_LegendRect.left+2+m_BitmapSize.cx, + m_LegendRect.top+6+m_BitmapSize.cy); + m_pParentCtrl->GoToFirstSerie(); + while (CChartSerie* pSerie=m_pParentCtrl->GetNextSerie()) + { + if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() ) + continue; + + int MaxHeight = 0; + CSize TextSize = pDC->GetTextExtent(pSerie->GetName().c_str()); + if (TextSize.cy > m_BitmapSize.cy) + { + pDC->ExtTextOut(rectBitmap.right+4,rectBitmap.top,ETO_CLIPPED,NULL,pSerie->GetName().c_str(),NULL); + CRect rectTemp(rectBitmap); + int YOffset = TextSize.cy/2 - rectBitmap.Height()/2; + rectTemp.OffsetRect(0,YOffset); + pSerie->DrawLegend(pDC,rectTemp); + MaxHeight = TextSize.cy; + } + else + { + int YOffset = rectBitmap.CenterPoint().y - TextSize.cy/2; + pDC->ExtTextOut(rectBitmap.right+4,YOffset,ETO_CLIPPED,NULL,pSerie->GetName().c_str(),NULL); + MaxHeight = m_BitmapSize.cy; + pSerie->DrawLegend(pDC,rectBitmap); + } + + + if (!m_bIsHorizontal) + rectBitmap.OffsetRect(0,MaxHeight+2); + else + rectBitmap.OffsetRect(m_BitmapSize.cx+4+TextSize.cx+10,0); + } + + pDC->SetBkMode(iPrevMode); + pDC->SelectObject(pOldFont); + DeleteObject(NewFont); + pDC->SelectObject(pOldPen); + DeleteObject(SolidPen); +} + + + diff --git a/ChartDemo/ChartCtrl/ChartLegend.h b/ChartDemo/ChartCtrl/ChartLegend.h new file mode 100644 index 0000000..6b24d4d --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLegend.h @@ -0,0 +1,155 @@ +/* + * + * ChartLegend.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTLEGEND_H__CD72E5A0_8F52_472A_A611_C588F642080B__INCLUDED_) +#define AFX_CHARTLEGEND_H__CD72E5A0_8F52_472A_A611_C588F642080B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartCtrl.h" + +#include "ChartString.h" + +class CChartSerie; + +//! This class is responsible for the legend displayed on the control. +/** + Series which are named will be displayed in the legend. The legend + object is retrieved by calling the GetLegend() function on the + CChartCtrl class. +**/ +class CChartLegend +{ + friend CChartCtrl; + +public: + //! Sets the font used to display the series names. + void SetFont(int iPointSize, const TChartString& strFaceName); + + //! Enumeration specifying on which side of the control the legend is docked. + enum DockSide + { + dsDockRight, + dsDockLeft, + dsDockTop, + dsDockBottom + }; + + //! Dock the legend on a specific side of the control. Default is right. + void DockLegend(DockSide dsSide); + //! Undock the legend. + /** + When the legend is undocked (floating), it doesn't take any margin size + but is drawn on top of the control at the specified location (it can be + above the plotting area for instance). + @param iLeftPos + The left position of the legend, in pixels (from the left of the control) + @param iTopPos + The top position of the legend, in pixels (from the top of the control) + **/ + void UndockLegend(int iLeftPos, int iTopPos); + + //! Sets the background of the legend transparent. + void SetTransparent(bool bTransparent); + //! Sets the legend in horizontal/vertical mode. + /** + In horizontal mode, the names are drawn next to each other + instead of on top of each other. + **/ + void SetHorizontalMode(bool bHorizontal); + + //! Sets the legend visible/invisible. + void SetVisible(bool bVisible); + //! Returns true if the legend is visible. + bool IsVisible() const { return m_bIsVisible; } + + //! Returns the back color of the legend. + COLORREF GetBackColor() const { return m_BackColor; } + //! Sets the back color of the legend. + void SetBackColor(COLORREF NewColor); + //! Returns the shadow color. + COLORREF GetShadowColor() const { return m_ShadowColor; } + //! Sets the shadow color. + void SetShadowColor(COLORREF NewColor); + //! Enables/disables the shadow. + void EnableShadow(bool bEnable); + //! Sets the shadow depth (in pixels). + void SetShadowDepth(int Depth); + + //! Returns true if the screen point is on the legend region. + BOOL IsPointInside(const CPoint& screenPoint) const; + +private: + //! Constructor + CChartLegend(CChartCtrl* pParent); + //! Destructor + virtual ~CChartLegend(); + + //! Draw the legend. + void Draw(CDC* pDC); + //! Remove the area needed for the legend from the chart rectangle. + void ClipArea(CRect& rcControl, CDC* pDC); + //! Recalculate the legend size and position. + void UpdatePosition(CDC* pDC, const CRect& rcControl); + + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + //! The rectangle used to draw the legend. + CRect m_LegendRect; + + //! The font face name used to display the series names. + TChartString m_strFontName; + //! The font point size. + int m_iFontSize; + + //! True if the legend is docked + bool m_bDocked; + //! The side of the control on which the legend is docked. + DockSide m_DockSide; + + //! The left position of the legend if in floating mode. + int m_iLeftPos; + //! The top position of the legend if in floating mode. + int m_iTopPos; + + //! Specifies if the legend is visible. + bool m_bIsVisible; + //! Specifies if the background of the legend is transparent. + bool m_bIsTransparent; + //! Specifies if the legend is in horizontal mode. + bool m_bIsHorizontal; + //! Specifies if the legend shadow should be displayed. + bool m_bShadow; + //! Specifies the shadow depth (in pixels). + int m_iShadowDepth; + + //! Specifies the legend back color. + COLORREF m_BackColor; + //! Specifies the shadow color. + COLORREF m_ShadowColor; + + //! Specifies the size of the bitmap used by each series. + CSize m_BitmapSize; +}; + +#endif // !defined(AFX_CHARTLEGEND_H__CD72E5A0_8F52_472A_A611_C588F642080B__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartLineSerie.cpp b/ChartDemo/ChartCtrl/ChartLineSerie.cpp new file mode 100644 index 0000000..e3c87fe --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLineSerie.cpp @@ -0,0 +1,360 @@ +/* + * + * ChartLineSerie.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. + * + * History: + * - 25/03/2008: Line series with a width > 1 can now have a style other than solid + * (thanks to Bruno Lavier). + * - 12/08/2008: Performance fix: pen use the PS_GEOMETRIC style only when necessary + * (thanks to Nick Holgate). + * + * + */ + +#include "stdafx.h" +#include "ChartLineSerie.h" +#include "ChartCtrl.h" + +#include "Math.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartLineSerie::CChartLineSerie(CChartCtrl* pParent) : CChartXYSerie(pParent) +{ + m_iLineWidth = 1; + m_iPenStyle = PS_SOLID; + m_bSmooth = false; + m_bShadow = false; +} + +CChartLineSerie::~CChartLineSerie() +{ + +} + +void CChartLineSerie::SetPenStyle(int NewStyle) +{ + m_iPenStyle = NewStyle; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLineSerie::SetWidth(int PenWidth) +{ + m_iLineWidth = PenWidth; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLineSerie::SetSmooth(bool bSmooth) +{ + m_bSmooth = bSmooth; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartLineSerie::DrawAll(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + if (uFirst>0) + uFirst--; + if (uLastSetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + pDC->IntersectClipRect(m_PlottingRect); + pOldPen = pDC->SelectObject(&NewPen); + + if (m_bSmooth) + { + // For a Bezier curve, all points must be drawn. + uFirst = 0; + uLast = GetPointsCount() - 1; + SChartXYPoint* pKnots = NULL; + SChartXYPoint* pFirstControlPts = NULL; + SChartXYPoint* pSecondControlPts = NULL; + GetBezierControlPoints(uFirst,uLast,pKnots,pFirstControlPts,pSecondControlPts); + + unsigned Count = uLast - uFirst; + CPoint* pBezierPts = new CPoint[3*(Count-1)+1]; + CPoint* pShadowPts = NULL; + if (m_bShadow) + pShadowPts = new CPoint[3*(Count-1)+1]; + + unsigned index = 0; + for (unsigned n=0; nSelectObject(&ShadowPen); + pDC->PolyBezier(pShadowPts,3*(Count-1)+1); + pDC->SelectObject(&NewPen); + delete[] pShadowPts; + } + pDC->PolyBezier(pBezierPts,3*(Count-1)+1); + + delete[] pKnots; + delete[] pFirstControlPts; + delete[] pSecondControlPts; + delete[] pBezierPts; + } + else // Non-smoothed curve + { + if (uLast-uFirst >= 1) + { + CPoint* pPoints = new CPoint[uLast-uFirst+1]; + CPoint* pShadow = NULL; + if (m_bShadow) + pShadow = new CPoint[uLast-uFirst+1]; + + unsigned long pointsCount = 0; + CPoint LastScreenPoint; + for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++) + { + //We don't draw a line between the origin and the first point -> we must have + // a least 2 points before begining drawing + SChartXYPoint Point = GetPoint(m_uLastDrawnPoint); + CPoint ScreenPoint; + ValueToScreen(Point.X, Point.Y, ScreenPoint); + + if(LastScreenPoint != ScreenPoint) + { + //Only collate the unique points + pPoints[pointsCount] = ScreenPoint; + LastScreenPoint = ScreenPoint; + + if (m_bShadow) + { + ScreenPoint.Offset(m_iShadowDepth,m_iShadowDepth); + pShadow[pointsCount] = ScreenPoint; + } + pointsCount++; + } + } + + // We have to do that in order for the Draw function to work properly. + m_uLastDrawnPoint--; + if (m_bShadow) + { + pDC->SelectObject(&ShadowPen); + pDC->Polyline(pShadow, pointsCount); + } + pDC->SelectObject(&NewPen); + pDC->Polyline(pPoints, pointsCount); + + delete[] pPoints; + delete[] pShadow; + } + } + + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldPen); + NewPen.DeleteObject(); + ShadowPen.DeleteObject(); +} + +void CChartLineSerie::Draw(CDC* pDC) +{ + if (!m_bIsVisible) + return; + + // If shadow or smooth is enabled, then the complete series + // must be redrawn. + if (m_bShadow || m_bSmooth) + { + DrawAll(pDC); + return; + } + + if (pDC->GetSafeHdc()) + { + CPen NewPen; + if (m_iPenStyle != PS_SOLID) + { + LOGBRUSH lb; + lb.lbStyle = BS_SOLID; + lb.lbColor = m_SerieColor; + NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb); + } + else + { + NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_SerieColor); + } + CPen* pOldPen; + + pDC->SetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + pDC->IntersectClipRect(m_pParentCtrl->GetPlottingRect()); + pOldPen = pDC->SelectObject(&NewPen); + + //Draw all points that haven't been drawn yet + for (m_uLastDrawnPoint;m_uLastDrawnPointMoveTo(ScreenPoint.x,ScreenPoint.y); + + Point = GetPoint(m_uLastDrawnPoint+1); + ValueToScreen(Point.X, Point.Y, ScreenPoint); + pDC->LineTo(ScreenPoint.x,ScreenPoint.y); + } + + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldPen); + DeleteObject(NewPen); + } +} + +void CChartLineSerie::DrawLegend(CDC *pDC, const CRect& rectBitmap) const +{ + if (m_strSerieName== _T("")) + return; + + //Draw line: + LOGBRUSH lb; + lb.lbStyle = BS_SOLID; + lb.lbColor = m_SerieColor; + CPen NewPen(PS_GEOMETRIC | m_iPenStyle,m_iLineWidth,&lb); + CPen* pOldPen = pDC->SelectObject(&NewPen); + pDC->MoveTo(rectBitmap.left,rectBitmap.CenterPoint().y); + pDC->LineTo(rectBitmap.right,rectBitmap.CenterPoint().y); + pDC->SelectObject(pOldPen); + DeleteObject(NewPen); +} + +bool CChartLineSerie::IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const +{ + uIndex = INVALID_POINT; + if (!m_bIsVisible) + return false; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst, uLast)) + return false; + if (uFirst>0) + uFirst--; + if (uLast 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartXYSerie.h" + +//! Specialization of a CChartSerie to display a line series. +/** + The data points are connected by line segments. The curve can also + be smoothed. +**/ +class CChartLineSerie : public CChartXYSerie +{ +public: + //! Returns the pen style (plain, dashed, dotted, ...) + /** + For a list of pen styles available, see the CreatePen function in MSDN. + **/ + int GetPenStyle() const { return m_iPenStyle; } + //! Sets the pen style (plain, dashed, dotted, ...) + /** + For a list of pen styles available, see the CreatePen function in MSDN. + **/ + void SetPenStyle(int NewStyle); + + //! Returns the pen width + int GetWidth() const { return m_iLineWidth; } + //! Sets the pen width + void SetWidth(int PenWidth); + //! Enables the smoothing of the curve (slower). + void SetSmooth(bool bSmooth); + + //! Constructor + CChartLineSerie(CChartCtrl* pParent); + //! Destructor + virtual ~CChartLineSerie(); + + //! Check whether a screen point is on the series. + /** + This function returns true if the screen point is close to a line segment. + If the screen point is also close to a specific point of the series, the + index of the point is stored in the uIndex parameter. Otherwise, this + parameter contains INVALID_POINT. + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const; + +private: + //! Draws the legend icon for the series. + /** + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + void DrawLegend(CDC* pDC, const CRect& rectBitmap) const; + + //! Draws the most recent points of the series. + /** + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + void Draw(CDC* pDC); + //! Redraws the full series. + /** + @param pDC + The device context used to draw + **/ + void DrawAll(CDC *pDC); + + //! Checks whether a point is close to a line segment + bool IsNearLine(long Axl, long Ayl,long Bxl, + long Byl, long Cxl, long Cyl) const; + + + //! The pen width + int m_iLineWidth; + //! The pen style + int m_iPenStyle; + //! Specifies if the curve is smoothed + bool m_bSmooth; +}; + +#endif // !defined(AFX_CHARTLINESERIE_H__792C2F20_9650_42FA_B13D_E63911C98CE5__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartLogarithmicAxis.cpp b/ChartDemo/ChartCtrl/ChartLogarithmicAxis.cpp new file mode 100644 index 0000000..05a1b8d --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLogarithmicAxis.cpp @@ -0,0 +1,190 @@ +/* + * + * ChartLogarithmicAxis.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 "ChartLogarithmicAxis.h" +#include "ChartCtrl.h" +#include +#include +#include +#include + +using namespace std; + +CChartLogarithmicAxis::CChartLogarithmicAxis() + : CChartAxis(), m_dFirstTickValue(1) +{ +} + +CChartLogarithmicAxis::~CChartLogarithmicAxis() +{ +} + +double CChartLogarithmicAxis::GetFirstTickValue() const +{ + double dRetVal = m_dFirstTickValue; + if (m_bDiscrete) + dRetVal = m_dFirstTickValue/10; + return dRetVal; +} + +bool CChartLogarithmicAxis::GetNextTickValue(double dCurrentTick, + double& dNextTick) const +{ + dNextTick = dCurrentTick * 10; + if (dNextTick <= m_MaxValue) + return true; + else + return false; +} + +TChartString CChartLogarithmicAxis::GetTickLabel(double TickValue) const +{ + double fLogDecCount; + int nLogDecCount; + + fLogDecCount = log10(TickValue); + + if (fLogDecCount < 0.0) + nLogDecCount = (int)(fabs(fLogDecCount) + 0.1); + else + nLogDecCount = 0; + + TChartStringStream ssLabel; + ssLabel << fixed << setprecision(nLogDecCount) << TickValue; + return ssLabel.str(); +} + +long CChartLogarithmicAxis::ValueToScreenStandard(double Value) const +{ + long Offset = 0; + long retVal = 0; + + Offset = (int)floor((log10(Value)-log10(m_MinValue)) * GetAxisLenght()/(log10(m_MaxValue)-log10(m_MinValue)) ); + if (m_bIsHorizontal) + { + if (!m_bIsInverted) + retVal = (m_StartPos + Offset); + else + retVal = (m_EndPos - Offset); + } + else + { + if (!m_bIsInverted) + retVal = (m_StartPos - Offset); + else + retVal = (m_EndPos + Offset); + } + return retVal; +} + +long CChartLogarithmicAxis::ValueToScreenDiscrete(double Value) const +{ + // In discrete mode, al values between two ticks are "directed" + // to the middle of the interval. + double lowTick = pow(10,floor(log10(Value))); + double highTick = pow(10,floor(log10(Value*10))); + + long lowTickPos = ValueToScreenStandard(lowTick); + long highTickPos = ValueToScreenStandard(highTick); + return (lowTickPos + (highTickPos-lowTickPos)/2); +} + +double CChartLogarithmicAxis::ScreenToValue(long ScreenVal) const +{ + if (m_MaxValue==m_MinValue) + return m_MinValue; + + int AxisOffset = 0; + if (!m_bIsHorizontal) + { + if (m_bIsInverted) + AxisOffset = ScreenVal - m_EndPos; + else + AxisOffset = m_StartPos - ScreenVal; + } + else + { + if (!m_bIsInverted) + AxisOffset = ScreenVal - m_StartPos; + else + AxisOffset = m_EndPos - ScreenVal; + } + + return (pow(10.0,(AxisOffset *1.0 / GetAxisLenght()*(log10(m_MaxValue)-log10(m_MinValue)) ) + log10(m_MinValue)) ); +} + +void CChartLogarithmicAxis::PanAxis(long PanStart, long PanEnd) +{ + double StartVal = ScreenToValue(PanStart); + double EndVal = ScreenToValue(PanEnd); + + double Factor = StartVal/EndVal; + SetZoomMinMax(m_MinValue*Factor,m_MaxValue*Factor); +} + +long CChartLogarithmicAxis::GetTickPos(double TickVal) const +{ + // The tick is always at the same position, + // even if the axis is discrete. + return ValueToScreenStandard(TickVal); +} + +void CChartLogarithmicAxis::RefreshTickIncrement() +{ + // Do nothing. This is done by the user. +} + +void CChartLogarithmicAxis::RefreshFirstTick() +{ + int LogBase = (int)log10(m_MinValue); + m_dFirstTickValue = pow(10.0,LogBase); +} + +void CChartLogarithmicAxis::GetScrollbarSteps(int& iTotalSteps, int& iCurrentStep) +{ + double SeriesMin=0, SeriesMax=0; + GetSeriesMinMax(SeriesMin,SeriesMax); + + if ((m_MaxValue-m_MinValue) == 0 || (SeriesMax-SeriesMin)==0 || + (SeriesMin<=0) ) + { + iTotalSteps = 1; + iCurrentStep = 1; + } + else + { + double dStep = pow(m_MaxValue/m_MinValue,0.1); + iTotalSteps = (int)ceil(log(SeriesMax/SeriesMin)/log10(dStep)); + iCurrentStep = (int)(log(m_MinValue/SeriesMin)/log10(dStep)); + } +} + +void CChartLogarithmicAxis::SetAxisToScrollStep(int iPreviousStep, + int iCurrentStep, + bool bScrollInverted) +{ + double dStep = pow(m_MaxValue/m_MinValue,0.1); + double dFactor = pow(dStep,(iCurrentStep - iPreviousStep)); + if (bScrollInverted) + SetZoomMinMax(m_MinValue/dFactor,m_MaxValue/dFactor); + else + SetZoomMinMax(m_MinValue*dFactor,m_MaxValue*dFactor); +} diff --git a/ChartDemo/ChartCtrl/ChartLogarithmicAxis.h b/ChartDemo/ChartCtrl/ChartLogarithmicAxis.h new file mode 100644 index 0000000..de8678d --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartLogarithmicAxis.h @@ -0,0 +1,62 @@ +/* + * + * ChartLogarithmicAxis.h + * + * 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. + * + * + */ + +#ifndef _CHARTLOGARITHMICAXIS_H_ +#define _CHARTLOGARITHMICAXIS_H_ + +#include "ChartAxis.h" + +//! Specialization of a CChartAxis to display a logarithmic scale. +/** + Currently this class only allows to have a logarithmic axis with a + base of 10. +**/ +class CChartLogarithmicAxis : public CChartAxis +{ + friend CChartCtrl; + +private: + //! Constructor + CChartLogarithmicAxis(); + //! Destructor + ~CChartLogarithmicAxis(); + + double ScreenToValue(long ScreenVal) const; + void PanAxis(long PanStart, long PanEnd); + + double GetFirstTickValue() const; + bool GetNextTickValue(double dCurrentTick, double& dNextTick) const; + TChartString GetTickLabel(double TickValue) const; + long ValueToScreenStandard(double Value) const; + long ValueToScreenDiscrete(double Value) const; + long GetTickPos(double TickVal) const; + + void RefreshTickIncrement(); + void RefreshFirstTick(); + + void GetScrollbarSteps(int& iTotalSteps, int& iCurrentStep); + void SetAxisToScrollStep(int iPreviousStep, int iCurrentStep, bool bScrollInverted); + + //! Caches the value of the first tick. + double m_dFirstTickValue; +}; + +#endif // _CHARTLOGARITHMICAXIS_H_ diff --git a/ChartDemo/ChartCtrl/ChartMouseListener.h b/ChartDemo/ChartCtrl/ChartMouseListener.h new file mode 100644 index 0000000..36761d7 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartMouseListener.h @@ -0,0 +1,90 @@ +/* + * + * ChartMouseListener.h + * + * 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. + * + * + */ + +#ifndef _CHARTMOUSELISTENER_H_ +#define _CHARTMOUSELISTENER_H_ + +#pragma warning( disable : 4100 ) + +//! Listener for mouse events occuring on the chart control. +/** + This is an interface which must be implemented in order to receive + mouse notifications. You can then register your class with the chart + control by calling RegisterMouseListener. +**/ +class CChartMouseListener +{ +public: + //! Constructor + CChartMouseListener() { } + //! Destructor + virtual ~CChartMouseListener() { } + + //! Enumeration listing the type of mouse events + enum MouseEvent + { + MouseMove, + LButtonUp, + LButtonDown, + LButtonDoubleClick, + RButtonUp, + RButtonDown, + RButtonDoubleClick, + }; + + //! Virtual function to implement in order to be notified when the title is clicked. + /** + @param mouseEvent + The mouse event which occured + @param point + The screen point on which the event occured + **/ + virtual void OnMouseEventTitle(MouseEvent mouseEvent, CPoint point) { } + //! Virtual function to implement in order to be notified when an axis is clicked. + /** + @param mouseEvent + The mouse event which occured + @param point + The screen point on which the event occured + @param pAxisClicked + The axis on which the event occured + **/ + virtual void OnMouseEventAxis(MouseEvent mouseEvent, CPoint point, + CChartAxis* pAxisClicked) { } + //! Virtual function to implement in order to be notified when the legend is clicked. + /** + @param mouseEvent + The mouse event which occured + @param point + The screen point on which the event occured + **/ + virtual void OnMouseEventLegend(MouseEvent mouseEvent, CPoint point) { } + //! Virtual function to implement in order to be notified when the plotting area is clicked. + /** + @param mouseEvent + The mouse event which occured + @param point + The screen point on which the event occured + **/ + virtual void OnMouseEventPlotArea(MouseEvent mouseEvent, CPoint point) { } +}; + +#endif // _CHARTMOUSELISTENER_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartPointsArray.h b/ChartDemo/ChartCtrl/ChartPointsArray.h new file mode 100644 index 0000000..938c58e --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartPointsArray.h @@ -0,0 +1,170 @@ +/* + * + * ChartPointsArray.h + * + * 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. + * + * + */ + +#pragma once + +#include "PointsOrdering.h" + +//! Manages an array of points which supports fast resizing. +/** + This class is used internally to store the data for all the points. The data + is stored in a C-style array. The internal buffer can grow dynamically depending + on the needs. + + The class is a template class with the template parameter being the type of + the points to be stored. The points have to provide the following methods: +
  • double GetXMin()
  • +
  • double GetX()
  • +
  • double GetXMax()
  • +
  • double GetYMin()
  • +
  • double GetY()
  • +
  • double GetYMax()
+**/ +template +class CChartPointsArray +{ +public: + //! Constructor + /** + @param iResize + The size by which the internal buffer is increased when reallocation occurs + **/ + CChartPointsArray(unsigned iResize = 1000); + //! Destructor + ~CChartPointsArray(); + + //! Returns the number of points currently stored. + unsigned GetPointsCount() const { return m_iCurrentPoints; } + //! Sets the size by which the internal buffer is increased when reallocation occurs + void SetResize(int iResize) { m_iResize = iResize; } + + //! Adds a new point in the array. + /** + @param newPoint + The new point to add + **/ + void AddPoint(const T& newPoint); + //! Adds multiple points in the array. + /** + The points are added to the ones currently stored in the array. + @param pPoints + Array containing the points + @param uCount + The number of points to add + **/ + void AddPoints(T* pPoints, unsigned uCount); + //! Sets multiple points in the array. + /** + The points currently stored in the array are first removed + before adding the new points. + @param pPoints + Array containing the new points + @param uCount + The number of points to add + **/ + void SetPoints(T* pPoints, unsigned uCount); + //! Removes all the points from the array. + void Clear(); + //! Removes a certain amount of points from the begining of the series. + void RemovePointsFromBegin(unsigned Count); + //! Removes a certain amount of points from the end of the series. + void RemovePointsFromEnd(unsigned Count); + //! Retrieves the points at the specified index + T& operator[](unsigned Index); + //! Retrieves the points at the specified index + const T& operator[](unsigned Index) const; + + //! Retrieves the minimum and maximum X values of the points stored in the array. + bool GetSerieXMinMax(double& Min, double& Max) const; + //! Retrieves the minimum and maximum Y values of the points stored in the array. + bool GetSerieYMinMax(double& Min, double& Max) const; + + //! Specifies how the points should be ordered in the array. + /** + This specifies if the points should be ordered on their X values, + on their Y values or not ordered (kept in order they are added to + the control). Ordering can improve performances a lot but makes it + impossible to draw some specific curves (for instance, drawing an + ellipse is only possible if no ordering is set). + **/ + void SetOrdering(PointsOrdering newOrdering); + //! Retrieves the ordering of the points in the array. + PointsOrdering GetOrdering() const { return m_Ordering; } + //! Refreshes the point ordering. + void ReorderPoints(); + + //! Retrieves the index of the points which are between two given values. + /** + If the points are not ordered, uFirstPt will contain 0 and uLastPt + will contain the index of the last point in the array. + @param dAxisMin + The minimum value to retrieve the first visible point + @param dAxisMax + The maximum value to retrieve the last visible point + @param uFirstPt + This parameter will store the index of the first visible point + @param uLastPt + This parameter will store the index of the last visible point + @return false if no points are in the array. + **/ + bool GetVisiblePoints(double dAxisMin, double dAxisMax, + unsigned& uFirstPt, unsigned& uLastPt) const; + + + //! Returns the internal buffer of the array + T* GetInternalBuffer() const { return m_pPoints; } + +private: + //! Caches the minimum X value. + double m_dXMinVal; + //! Caches the maximum X value. + double m_dXMaxVal; + //! Caches the minimum Y value. + double m_dYMinVal; + //! Caches the maximum Y value. + double m_dYMaxVal; + + //! Recalculates the min and max values. + void RefreshMinMax(); + //! Inserts a new point in the array. + void InsertNewPoint(const T& newPoint); + //! Inserts a new point at a specific position in the array. + void InsertPointAtPos(const T& newPoint, int iPos); + //! Comparison function which compares two points based on their X values. + static int ComparePointsOnX(void const* pA, void const* pB); + //! Comparison function which compares two points based on their Y values. + static int ComparePointsOnY(void const* pA, void const* pB); + //! Implements a binary search used to find the index of a points give the X or Y value. + int BinarySearch(unsigned uLeft, unsigned uRight, double dFind) const; + + //! The array of points + T* m_pPoints; + //! The number of allocated points + unsigned m_iMaxPoints; + //! The number of points currently used + unsigned m_iCurrentPoints; + //! The size by which the array is incremented once it is full + unsigned m_iResize; + //! The ordering of the points + PointsOrdering m_Ordering; +}; + +#include "ChartPointsArray.inl" \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartPointsArray.inl b/ChartDemo/ChartCtrl/ChartPointsArray.inl new file mode 100644 index 0000000..ce4b61c --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartPointsArray.inl @@ -0,0 +1,351 @@ +/* + * + * ChartPointsArray.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 "ChartPointsArray.h" + +template +CChartPointsArray::CChartPointsArray(unsigned iResize) + : m_pPoints(NULL), m_iMaxPoints(iResize), m_iCurrentPoints(0), + m_iResize(iResize), m_Ordering(poXOrdering) +{ + m_pPoints = new T[iResize]; +} + +template +CChartPointsArray::~CChartPointsArray() +{ + if (m_pPoints) + { + delete[] m_pPoints; + m_pPoints = NULL; + } +} + +template +void CChartPointsArray::AddPoint(const T& newPoint) +{ + if (m_iCurrentPoints == m_iMaxPoints) + { + m_iMaxPoints += m_iResize; + T* pOldPoints = m_pPoints; + m_pPoints = new T[m_iMaxPoints]; + memcpy(m_pPoints,pOldPoints,m_iCurrentPoints*sizeof(T)); + delete[] pOldPoints; + } + + if (m_iCurrentPoints == 0) + { + m_dXMinVal = newPoint.GetXMin(); + m_dXMaxVal = newPoint.GetXMax(); + m_dYMinVal = newPoint.GetYMin(); + m_dYMaxVal = newPoint.GetYMax(); + } + else + { + if (newPoint.GetXMax() > m_dXMaxVal) m_dXMaxVal = newPoint.GetXMax(); + if (newPoint.GetXMin() < m_dXMinVal) m_dXMinVal = newPoint.GetXMin(); + if (newPoint.GetYMax() > m_dYMaxVal) m_dYMaxVal = newPoint.GetYMax(); + if (newPoint.GetYMin() < m_dYMinVal) m_dYMinVal = newPoint.GetYMin(); + } + + if (m_Ordering==poNoOrdering) + { + m_pPoints[m_iCurrentPoints] = newPoint; + m_iCurrentPoints++; + } + else + { + InsertNewPoint(newPoint); + } +} + +template +void CChartPointsArray::AddPoints(T* pPoints, + unsigned uCount) +{ + if (m_iCurrentPoints+uCount > m_iMaxPoints) + { + m_iMaxPoints = m_iCurrentPoints+uCount; + T* pOldPoints = m_pPoints; + m_pPoints = new T[m_iMaxPoints]; + memcpy(m_pPoints,pOldPoints,m_iCurrentPoints*sizeof(T)); + delete[] pOldPoints; + } + for (unsigned i=0; i +void CChartPointsArray::SetPoints(T* pPoints, + unsigned uCount) +{ + if (uCount > m_iMaxPoints) + { + if (m_pPoints) + delete[] m_pPoints; + m_pPoints = new T[uCount]; + m_iMaxPoints = uCount; + } + m_iCurrentPoints = uCount; + + for (unsigned i=0;i +void CChartPointsArray::Clear() +{ + if (m_pPoints) + delete[] m_pPoints; + m_pPoints = new T[m_iResize]; + m_iMaxPoints = m_iResize; + m_iCurrentPoints = 0; +} + +template +void CChartPointsArray::RemovePointsFromBegin(unsigned Count) +{ + ASSERT (Count < m_iCurrentPoints); + T* pSource = m_pPoints + Count; + memmove(m_pPoints, pSource, sizeof(T) * (m_iCurrentPoints-Count)); + m_iCurrentPoints -= Count; + RefreshMinMax(); +} + +template +void CChartPointsArray::RemovePointsFromEnd(unsigned Count) +{ + ASSERT (Count < m_iCurrentPoints); + m_iCurrentPoints -= Count; + RefreshMinMax(); +} + +template +T& CChartPointsArray::operator[](unsigned Index) +{ + ASSERT(Index < m_iCurrentPoints); + return m_pPoints[Index]; +} + +template +const T& CChartPointsArray::operator[](unsigned Index) const +{ + ASSERT(Index < m_iCurrentPoints); + return m_pPoints[Index]; +} + +template +bool CChartPointsArray::GetSerieXMinMax(double& Min, double& Max) const +{ + if (m_iCurrentPoints==0) + return false; + + Min = m_dXMinVal; + Max = m_dXMaxVal; + return true; +} + +template +bool CChartPointsArray::GetSerieYMinMax(double& Min, double& Max) const +{ + if (m_iCurrentPoints==0) + return false; + + Min = m_dYMinVal; + Max = m_dYMaxVal; + return true; +} + +template +void CChartPointsArray::SetOrdering(PointsOrdering newOrdering) +{ + m_Ordering = newOrdering; + ReorderPoints(); +} + +template +bool CChartPointsArray::GetVisiblePoints(double dAxisMin, + double dAxisMax, + unsigned& uFirstPt, + unsigned& uLastPt) const +{ + if (m_iCurrentPoints == 0) + return false; + + if (m_Ordering == poNoOrdering) + { + uFirstPt = 0; + uLastPt = m_iCurrentPoints - 1; + return true; + } + + uFirstPt = BinarySearch(0,m_iCurrentPoints-1,dAxisMin); + uLastPt = BinarySearch(uFirstPt,m_iCurrentPoints-1,dAxisMax); + return true; +} + +template +void CChartPointsArray::ReorderPoints() +{ + switch (m_Ordering) + { + case poNoOrdering: + break; + case poXOrdering: + qsort(m_pPoints, m_iCurrentPoints, sizeof(T), + CChartPointsArray::ComparePointsOnX); + break; + case poYOrdering: + qsort(m_pPoints, m_iCurrentPoints, sizeof(T), + CChartPointsArray::ComparePointsOnY); + break; + } +} + +template +void CChartPointsArray::InsertNewPoint(const T& newPoint) +{ + if (m_iCurrentPoints == 0) + { + m_pPoints[0] = newPoint; + m_iCurrentPoints++; + return; + } + + if (m_Ordering == poXOrdering) + { + if (newPoint.GetX() >= m_pPoints[m_iCurrentPoints-1].GetX()) + m_pPoints[m_iCurrentPoints] = newPoint; + else + { + for (unsigned i=0; i= m_pPoints[m_iCurrentPoints-1].GetY()) + m_pPoints[m_iCurrentPoints] = newPoint; + else + { + for (unsigned i=0; i +void CChartPointsArray::InsertPointAtPos(const T& newPoint, int iPos) +{ + // Find the address of the insert point + T* pPointPos = m_pPoints + iPos; + // Move all remaining points one place to the right. + memmove(pPointPos+1,pPointPos,(m_iCurrentPoints-iPos)*sizeof(T)); + // Store the new point + *pPointPos = newPoint; +} + +template +int CChartPointsArray::ComparePointsOnX(void const* pA, void const* pB) +{ + T* pPointA = (T *) pA; + T* pPointB = (T *) pB; + + if (pPointA->GetX() < pPointB->GetX()) return -1; + if (pPointA->GetX() > pPointB->GetX()) return 1; + return 0; +} + +template +int CChartPointsArray::ComparePointsOnY(void const* pA, void const* pB) +{ + T* pPointA = (T *) pA; + T* pPointB = (T *) pB; + + if (pPointA->GetY() < pPointB->GetY()) return -1; + if (pPointA->GetY() > pPointB->GetY()) return 1; + return 0; +} + +template +void CChartPointsArray::RefreshMinMax() +{ + m_dXMinVal = m_pPoints[0].GetXMin(); + m_dXMaxVal = m_pPoints[0].GetXMax(); + m_dYMinVal = m_pPoints[0].GetYMin(); + m_dYMaxVal = m_pPoints[0].GetYMax(); + for (unsigned uIndex=0; uIndex m_dXMaxVal) + m_dXMaxVal = m_pPoints[uIndex].GetXMax(); + if (m_pPoints[uIndex].GetXMin() < m_dXMinVal) + m_dXMinVal = m_pPoints[uIndex].GetXMin(); + if (m_pPoints[uIndex].GetYMax() > m_dYMaxVal) + m_dYMaxVal = m_pPoints[uIndex].GetYMax(); + if (m_pPoints[uIndex].GetYMin() < m_dYMinVal) + m_dYMinVal = m_pPoints[uIndex].GetYMin(); + } +} + +template +int CChartPointsArray::BinarySearch(unsigned uLeft, + unsigned uRight, + double dFind) const +{ + unsigned middle = uLeft + ((uRight - uLeft) /2); + double midVal = 0; + if (m_Ordering == poXOrdering) + midVal = m_pPoints[middle].GetX(); + if (m_Ordering == poYOrdering) + midVal = m_pPoints[middle].GetY(); + + if(midVal > dFind) + { + if(uLeft < middle) + return BinarySearch(uLeft,middle-1,dFind); + else + return uLeft; + } + else if(middle < uRight) + return BinarySearch(middle+1,uRight,dFind); + else + return uRight; +} + + diff --git a/ChartDemo/ChartCtrl/ChartPointsSerie.cpp b/ChartDemo/ChartCtrl/ChartPointsSerie.cpp new file mode 100644 index 0000000..685420f --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartPointsSerie.cpp @@ -0,0 +1,335 @@ +/* + * + * ChartPointsSerie.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. + * + * + * History: + * - 07/07/2008: Last point of the series was not displayed. Fixed. + */ + +#include "stdafx.h" +#include "ChartPointsSerie.h" +#include "ChartCtrl.h" +#include "Math.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartPointsSerie::CChartPointsSerie(CChartCtrl* pParent) + : CChartXYSerie(pParent), m_iPointType(ptEllipse), m_iXPointSize(5), + m_iYPointSize(5), m_colBorder(RGB(0,0,0)) +{ +} + +CChartPointsSerie::~CChartPointsSerie() +{ + +} +void CChartPointsSerie::SetPointSize(int XSize, int YSize) +{ + m_iXPointSize = XSize; + m_iYPointSize = YSize; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartPointsSerie::SetPointType(PointType Type) +{ + m_iPointType = Type; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartPointsSerie::SetBorderColor(COLORREF Color) +{ + m_colBorder = Color; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartPointsSerie::Draw(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + CBrush NewBrush(m_SerieColor); + CPen BorderPen(PS_SOLID, 1, m_colBorder); + CBrush ShadowBrush(m_ShadowColor); + CPen ShadowPen(PS_SOLID, 1, m_ShadowColor); + CPen* pOldPen = pDC->SelectObject(&BorderPen); + CBrush* pOldBrush = pDC->SelectObject(&NewBrush); + + pDC->SetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + pDC->IntersectClipRect(m_PlottingRect); + + //Draw all points that haven't been drawn yet + for (m_uLastDrawnPoint;m_uLastDrawnPoint<(int)GetPointsCount();m_uLastDrawnPoint++) + { + SChartXYPoint Point = GetPoint(m_uLastDrawnPoint); + CPoint ScreenPoint; + ValueToScreen(Point.X, Point.Y, ScreenPoint); + + CRect PointRect; + PointRect.SetRect(ScreenPoint.x-m_iXPointSize/2,ScreenPoint.y-m_iYPointSize/2,ScreenPoint.x+m_iXPointSize/2,ScreenPoint.y+m_iYPointSize/2); + CRect ShadowRect = PointRect + CSize(m_iShadowDepth,m_iShadowDepth); + + switch(m_iPointType) + { + case ptEllipse: + if (m_bShadow) + { + pOldPen = pDC->SelectObject(&ShadowPen); + pDC->SelectObject(&ShadowBrush); + pDC->Ellipse(ShadowRect); + pDC->SelectObject(&NewBrush); + pDC->SelectObject(&BorderPen); + } + pDC->Ellipse(PointRect); + break; + + case ptRectangle: + if (m_bShadow) + { + pOldPen = pDC->SelectObject(&ShadowPen); + pDC->SelectObject(&ShadowBrush); + pDC->Rectangle(ShadowRect); + pDC->SelectObject(&NewBrush); + pDC->SelectObject(&BorderPen); + } + pDC->Rectangle(PointRect); + break; + + case ptTriangle: + { + CPoint TrPoints[3]; + TrPoints[0].x = PointRect.left; + TrPoints[0].y = PointRect.bottom; + TrPoints[1].x = PointRect.right; + TrPoints[1].y = PointRect.bottom; + TrPoints[2].x = PointRect.left + (int)fabs((PointRect.left-PointRect.right)/2.0); + TrPoints[2].y = PointRect.top; + + if (m_bShadow) + { + CPoint ShadowPoints[3]; + for (int i=0;i<3;i++) + { + ShadowPoints[i] = TrPoints[i] + CSize(m_iShadowDepth,m_iShadowDepth); + } + + pOldPen = pDC->SelectObject(&ShadowPen); + pDC->SelectObject(&ShadowBrush); + pDC->Polygon(ShadowPoints,3); + pDC->SelectObject(&NewBrush); + pDC->SelectObject(&BorderPen); + } + pDC->Polygon(TrPoints,3); + } + break; + } + + } + + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldPen); + pDC->SelectObject(pOldBrush); + DeleteObject(BorderPen); + DeleteObject(NewBrush); + DeleteObject(ShadowBrush); + DeleteObject(ShadowPen); +} + +void CChartPointsSerie::DrawAll(CDC *pDC) +{ + if (!m_bIsVisible) + return; + if (!pDC->GetSafeHdc()) + return; + + CBrush NewBrush(m_SerieColor); + CPen BorderPen(PS_SOLID, 1, m_colBorder); + CBrush ShadowBrush(m_ShadowColor); + CPen ShadowPen(PS_SOLID, 1, m_ShadowColor); + CPen* pOldPen = pDC->SelectObject(&BorderPen); + CBrush* pOldBrush = pDC->SelectObject(&NewBrush); + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + pDC->SetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + pDC->IntersectClipRect(m_PlottingRect); + + for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++) + { + SChartXYPoint Point = GetPoint(m_uLastDrawnPoint); + CPoint ScreenPoint; + ValueToScreen(Point.X, Point.Y, ScreenPoint); + + CRect PointRect; + PointRect.SetRect(ScreenPoint.x-m_iXPointSize/2,ScreenPoint.y-m_iYPointSize/2,ScreenPoint.x+m_iXPointSize/2,ScreenPoint.y+m_iYPointSize/2); + CRect ShadowRect = PointRect + CSize(m_iShadowDepth,m_iShadowDepth); + + switch(m_iPointType) + { + case ptEllipse: + if (m_bShadow) + { + pOldPen = pDC->SelectObject(&ShadowPen); + pDC->SelectObject(&ShadowBrush); + pDC->Ellipse(ShadowRect); + pDC->SelectObject(&NewBrush); + pDC->SelectObject(&BorderPen); + } + pDC->Ellipse(PointRect); + break; + + case ptRectangle: + if (m_bShadow) + { + pOldPen = pDC->SelectObject(&ShadowPen); + pDC->SelectObject(&ShadowBrush); + pDC->Rectangle(ShadowRect); + pDC->SelectObject(&NewBrush); + pDC->SelectObject(&BorderPen); + } + pDC->Rectangle(PointRect); + break; + + case ptTriangle: + { + CPoint TrPoints[3]; + TrPoints[0].x = PointRect.left; + TrPoints[0].y = PointRect.bottom; + TrPoints[1].x = PointRect.right; + TrPoints[1].y = PointRect.bottom; + TrPoints[2].x = PointRect.left + (int)fabs((PointRect.left-PointRect.right)/2.0); + TrPoints[2].y = PointRect.top; + + if (m_bShadow) + { + CPoint ShadowPoints[3]; + for (int i=0;i<3;i++) + { + ShadowPoints[i] = TrPoints[i] + CSize(m_iShadowDepth,m_iShadowDepth); + } + + pOldPen = pDC->SelectObject(&ShadowPen); + pDC->SelectObject(&ShadowBrush); + pDC->Polygon(ShadowPoints,3); + pDC->SelectObject(&NewBrush); + pDC->SelectObject(&BorderPen); + } + pDC->Polygon(TrPoints,3); + } + break; + } + } + + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldPen); + pDC->SelectObject(pOldBrush); + DeleteObject(BorderPen); + DeleteObject(NewBrush); + DeleteObject(ShadowBrush); + DeleteObject(ShadowPen); +} + +void CChartPointsSerie::DrawLegend(CDC *pDC, const CRect& rectBitmap) const +{ + if (m_strSerieName== _T("")) + return; + + CRect PointRect(0,0,m_iXPointSize,m_iYPointSize); + if ( (rectBitmap.Height()>m_iYPointSize) && (rectBitmap.Width()>m_iXPointSize) ) + { + int XOffset = rectBitmap.left + rectBitmap.Width()/2 - m_iXPointSize/2; + int YOffset = rectBitmap.top + rectBitmap.Height()/2 - m_iYPointSize/2; + PointRect.OffsetRect(XOffset,YOffset); + } + else + PointRect = rectBitmap; + + CBrush NewBrush(m_SerieColor); + CBrush* pOldBrush = pDC->SelectObject(&NewBrush); + + switch(m_iPointType) + { + case ptEllipse: + pDC->Ellipse(PointRect); + break; + + case ptRectangle: + pDC->Rectangle(PointRect); + break; + + case ptTriangle: + { + CPoint TrPoints[3]; + TrPoints[0].x = PointRect.left; + TrPoints[0].y = PointRect.bottom; + TrPoints[1].x = PointRect.right; + TrPoints[1].y = PointRect.bottom; + TrPoints[2].x = PointRect.left + (int)fabs((PointRect.left-PointRect.right)/2.0); + TrPoints[2].y = PointRect.top; + + pDC->Polygon(TrPoints,3); + } + break; + } + + pDC->SelectObject(pOldBrush); + DeleteObject(NewBrush); +} + +bool CChartPointsSerie::IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const +{ + uIndex = INVALID_POINT; + if (!m_bIsVisible) + return false; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst, uLast)) + return false; + + bool bResult = false; + for (unsigned i=uFirst ; i < uLast ; i++) + { + SChartXYPoint Point = GetPoint(i); + CPoint ValuePoint; + ValueToScreen(Point.X, Point.Y, ValuePoint); + + int xDist = abs(screenPoint.x - ValuePoint.x); + int yDist = abs(screenPoint.y - ValuePoint.y); + if (xDist<=5 && yDist<=5) + { + uIndex = i; + bResult = true; + break; + } + } + return bResult; +} + diff --git a/ChartDemo/ChartCtrl/ChartPointsSerie.h b/ChartDemo/ChartCtrl/ChartPointsSerie.h new file mode 100644 index 0000000..5faafef --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartPointsSerie.h @@ -0,0 +1,117 @@ +/* + * + * ChartPointsSerie.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTPOINTSSERIE_H__F66C180F_F04C_4E2D_878C_08BDBCE91863__INCLUDED_) +#define AFX_CHARTPOINTSSERIE_H__F66C180F_F04C_4E2D_878C_08BDBCE91863__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartXYSerie.h" + +//! Specialization of a CChartSerie to display a points series. +/** + The data points are simply displayed as independant points. +**/ +class CChartPointsSerie : public CChartXYSerie +{ +public: + //! The different point shapes + enum PointType + { + ptEllipse=0, + ptRectangle=1, + ptTriangle=2 + }; + + //! Sets the width and height of each points + void SetPointSize(int XSize, int YSize); + //! Retrieves the width and height of each points + void GetPointSize(int& XSize, int& YSize) const + { + XSize = m_iXPointSize; + YSize = m_iYPointSize; + } + //! Sets the points shape + void SetPointType(PointType Type); + //! Returns the points shape + PointType GetPointType() const { return m_iPointType; } + + //! Sets the border color of the points + void SetBorderColor(COLORREF Color); + //! Returns the border color of the points + COLORREF GetBorderColor() { return m_colBorder; } + + //! Constructor + CChartPointsSerie(CChartCtrl* pParent); + //! Destructor + virtual ~CChartPointsSerie(); + + //! Check whether a screen point is on the series. + /** + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const; + +private: + //! Draws the legend icon for the series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + void DrawLegend(CDC* pDC, const CRect& rectBitmap) const; + + //! Draws the most recent points of the series. + /** + This pure virtual function should be overriden by child classes. + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + void Draw(CDC* pDC); + //! Redraws the full series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + **/ + void DrawAll(CDC *pDC); + + //! Width of the points + int m_iXPointSize; + //! Height of the points + int m_iYPointSize; + //! Shape of the points + PointType m_iPointType; + //! The border color + COLORREF m_colBorder; +}; + +#endif // !defined(AFX_CHARTPOINTSSERIE_H__F66C180F_F04C_4E2D_878C_08BDBCE91863__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartScrollBar.cpp b/ChartDemo/ChartCtrl/ChartScrollBar.cpp new file mode 100644 index 0000000..f5d111c --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartScrollBar.cpp @@ -0,0 +1,222 @@ +/* + * + * ChartScrollBar.h + * + * 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 "ChartScrollBar.h" +#include "ChartAxis.h" +#include "ChartCtrl.h" +#include "math.h" + +CChartScrollBar::CChartScrollBar(CChartAxis* pParentAxis) + : CScrollBar(), m_pParentAxis(pParentAxis), m_bEnabled(false), + m_bAutoHide(true) +{ +} + +CChartScrollBar::~CChartScrollBar() +{ +} + +void CChartScrollBar::CreateScrollBar(const CRect& PlottingRect) +{ + CRect Temp = PlottingRect; + Temp.top++; Temp.left++; + + DWORD dwStyle = SBS_HORZ | WS_CHILD; + if (m_pParentAxis->IsHorizontal()) + { + if (m_pParentAxis->IsSecondary()) + dwStyle |= SBS_TOPALIGN; + else + dwStyle += SBS_BOTTOMALIGN; + } + else + { + if (m_pParentAxis->IsSecondary()) + dwStyle |= SBS_VERT | SBS_RIGHTALIGN; + else + dwStyle += SBS_VERT | SBS_LEFTALIGN; + } + CScrollBar::Create(dwStyle, Temp, m_pParentAxis->m_pParentCtrl,100); + SCROLLINFO info; + info.cbSize = sizeof(SCROLLINFO); + info.fMask = SIF_ALL; + info.nMin = 1; + info.nMax = 1; + info.nPage = 1; + info.nPos = 1; + CScrollBar::SetScrollInfo(&info); + +} + +bool CChartScrollBar::IsScrollInverted() const +{ + bool bInverted = false; + if (m_pParentAxis->IsInverted() && m_pParentAxis->IsHorizontal()) + bInverted = true; + if (!m_pParentAxis->IsInverted() && !m_pParentAxis->IsHorizontal()) + bInverted = true; + + return bInverted; +} + +void CChartScrollBar::Refresh() +{ + int iTotalSteps = 0; + int iCurrentStep = 0; + m_pParentAxis->GetScrollbarSteps(iTotalSteps,iCurrentStep); + + SCROLLINFO info; + info.cbSize = sizeof(SCROLLINFO); + info.fMask = SIF_ALL; + + info.nMin = 0; + info.nMax = iTotalSteps-1; + info.nPage = 10; + info.nPos = iCurrentStep; + + if (IsScrollInverted()) + info.nPos = iTotalSteps - 9 - iCurrentStep; + else + info.nPos = iCurrentStep; + CScrollBar::SetScrollInfo(&info); +} + +void CChartScrollBar::OnHScroll(UINT nSBCode, UINT nPos) +{ + int MinPos; + int MaxPos; + int PreviousPos = CScrollBar::GetScrollPos(); + CScrollBar::GetScrollRange(&MinPos, &MaxPos); + int CurPos = PreviousPos; + + bool bUpdate = true; + switch (nSBCode) + { + case SB_LEFT: + CurPos = 0; + break; + case SB_RIGHT: + CurPos = MaxPos; + break; + case SB_ENDSCROLL: + bUpdate = false; + break; + case SB_LINELEFT: + if (CurPos > MinPos) + CurPos--; + break; + case SB_LINERIGHT: + if (CurPos < MaxPos-9) + CurPos++; + break; + case SB_PAGELEFT: + if (CurPos > MinPos) + CurPos = max(MinPos, CurPos - 10); + break; + case SB_PAGERIGHT: + if (CurPos < MaxPos-9) + CurPos = min(MaxPos, CurPos + 10); + break; + case SB_THUMBPOSITION: + CurPos = nPos; + break; + case SB_THUMBTRACK: + CurPos = nPos; + break; + } + + if (bUpdate) + { + // Set the new position of the thumb (scroll box). + CScrollBar::SetScrollPos(CurPos); + MoveAxisToPos(PreviousPos,CurPos); + } +} + +void CChartScrollBar::OnVScroll(UINT nSBCode, UINT nPos) +{ + int MinPos; + int MaxPos; + int PreviousPos = CScrollBar::GetScrollPos(); + CScrollBar::GetScrollRange(&MinPos, &MaxPos); + int CurPos = PreviousPos; + bool bUpdate = true; + + switch (nSBCode) + { + case SB_BOTTOM: + CurPos = MaxPos; + break; + case SB_TOP: + CurPos = 0; + break; + case SB_ENDSCROLL: + bUpdate = false; + break; + case SB_LINEDOWN: + if (CurPos < MaxPos-9) + CurPos++; + break; + case SB_LINEUP: + if (CurPos > MinPos) + CurPos--; + break; + case SB_PAGEUP: + if (CurPos > MinPos) + CurPos = max(MinPos, CurPos - 10); + break; + case SB_PAGEDOWN: + if (CurPos < MaxPos-9) + CurPos = min(MaxPos, CurPos + 10); + break; + case SB_THUMBPOSITION: + CurPos = nPos; + break; + case SB_THUMBTRACK: + CurPos = nPos; + break; + } + + if (bUpdate) + { + // Set the new position of the thumb (scroll box). + CScrollBar::SetScrollPos(CurPos); + MoveAxisToPos(PreviousPos,CurPos); + } +} + +void CChartScrollBar::MoveAxisToPos(int PreviousPos, int CurPos) +{ + m_pParentAxis->SetAxisToScrollStep(PreviousPos,CurPos,IsScrollInverted()); +} + +void CChartScrollBar::OnMouseEnter() +{ + if (m_bEnabled && m_bAutoHide) + ShowWindow(SW_SHOW); +} + +void CChartScrollBar::OnMouseLeave() +{ + if (m_bEnabled && m_bAutoHide) + ShowWindow(SW_HIDE); +} diff --git a/ChartDemo/ChartCtrl/ChartScrollBar.h b/ChartDemo/ChartCtrl/ChartScrollBar.h new file mode 100644 index 0000000..b7425a1 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartScrollBar.h @@ -0,0 +1,75 @@ +/* + * + * ChartScrollBar.h + * + * 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. + * + * + */ + +#pragma once + +class CChartAxis; + +//! Class which manages the interaction with the axis scroll bar. +/** + This class is used internally by the CChartAxis class. +**/ +class CChartScrollBar : public CScrollBar +{ +friend CChartAxis; + +public: + //! Creates the scroll bar within a specified rectangle. + void CreateScrollBar(const CRect& PlottingRect); + + //! Called on horizontal scrolling. + void OnHScroll(UINT nSBCode, UINT nPos); + //! Called on vertical scrolling. + void OnVScroll(UINT nSBCode, UINT nPos); + //! Refreshes the scroll bar position. + void Refresh(); + + //! Enables/disables the scroll bar. + void SetEnabled(bool bEnabled) { m_bEnabled = bEnabled; } + //! Returns true if the scroll bar is enabled + bool GetEnabled() const { return m_bEnabled; } + //! Enables/disables the auto-hide mode. + /** + In auto-hide mode, the scroll bar is not visible unless the mouse + is over the region of the scroll bar. + **/ + void SetAutoHide(bool bAutoHide) { m_bAutoHide = bAutoHide; } + //! Returns true if the auto-hide mode is activated. + bool GetAutoHide() const { return m_bAutoHide; } + + //! Called when the mouse enters the scroll bar area. + void OnMouseEnter(); + //! Called when the mouse leaves the scroll bar area. + void OnMouseLeave(); + +private: + //! Constructor + CChartScrollBar(CChartAxis* pParentAxis); + //! Destructor + ~CChartScrollBar(); + + bool IsScrollInverted() const; + void MoveAxisToPos(int PreviousPos, int CurPos); + + CChartAxis* m_pParentAxis; + bool m_bEnabled; + bool m_bAutoHide; +}; diff --git a/ChartDemo/ChartCtrl/ChartSerie.cpp b/ChartDemo/ChartCtrl/ChartSerie.cpp new file mode 100644 index 0000000..eee56a9 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSerie.cpp @@ -0,0 +1,150 @@ +/* + * + * ChartSerie.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. + * + * History: + * - 11/08/2006: Management of the auto axis now done in the axis. Series Register + * Unregister themselves to their respective axes . + * - 29/02/2008: Taking into account that RefreshAutoAxis doesn't refresh the control. + * - 01/03/2008: RemovePointsFromBegin and RemovePointsFromEnd functions added. + * - 08/03/2008: AddPoints function added (thanks to Bruno Lavier). + * - 11/03/2008: Min and max values are now cached. + * - 14/03/2008: Series can be ordered. Speed improvement done in that case. + * - 13/08/2008: Bug fix: calling AddPoint was not drawing the new points. + * - 27/11/2008: Points are now stored into the CChartPointsArray class instead of + * std::vector for efficiency. + * + */ + +#include "stdafx.h" +#include "ChartCtrl.h" +#include "ChartSerie.h" +#include "ChartAxis.h" + +#include "Math.h" +#include + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +unsigned CChartSerie::m_uNextFreeId = 0; + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartSerie::CChartSerie(CChartCtrl* pParent) +{ + m_pParentCtrl = pParent; +// m_uLastDrawnPoint = 0; + m_strSerieName = _T(""); + + m_pHorizontalAxis = m_pVerticalAxis = NULL; + m_uSerieId = m_uNextFreeId; + m_uNextFreeId++; + + m_bIsVisible = true; + m_bShadow = false; + m_SerieColor = RGB(0, 0, 0); + m_ShadowColor = RGB(150,150,150); + m_iShadowDepth = 2; + + m_bMouseClickNotifications = true; + m_bMouseMoveNotifications = false; +} + +CChartSerie::~CChartSerie() +{ + m_pHorizontalAxis->UnregisterSeries(this); + m_pVerticalAxis->UnregisterSeries(this); +} + +//void CChartSerie::SetSeriesOrdering(CChartPointsArray::PointsOrdering newOrdering) +//{ +// m_vPoints.SetOrdering(newOrdering); +//} + +void CChartSerie::SetName(const TChartString& NewName) +{ + m_strSerieName = NewName; + m_pParentCtrl->RefreshCtrl(); +} + +double CChartSerie::XScreenToValue(long XScreenCoord) const +{ + return m_pHorizontalAxis->ScreenToValue(XScreenCoord); +} + +double CChartSerie::YScreenToValue(long YScreenCoord) const +{ + return m_pVerticalAxis->ScreenToValue(YScreenCoord); +} + +void CChartSerie::ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const +{ + ScreenPoint.x = m_pHorizontalAxis->ValueToScreen(XValue); + ScreenPoint.y = m_pVerticalAxis->ValueToScreen(YValue); +} + +void CChartSerie::SetVisible(bool bVisible) +{ + m_bIsVisible = bVisible; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSerie::SetColor(COLORREF NewColor) +{ + m_SerieColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSerie::SetShadowColor(COLORREF NewColor) +{ + m_ShadowColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSerie::EnableShadow(bool bEnable) +{ + m_bShadow = bEnable; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSerie::SetShadowDepth(int Depth) +{ + m_iShadowDepth = Depth; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSerie::EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled) +{ + m_bMouseClickNotifications = bClickEnabled; + m_bMouseMoveNotifications = bMoveEnabled; +} + +void CChartSerie::RefreshAutoAxes(bool bForceRefresh) +{ + m_pParentCtrl->EnableRefresh(false); + m_pHorizontalAxis->RefreshAutoAxis(); + m_pVerticalAxis->RefreshAutoAxis(); + if (bForceRefresh) + m_pParentCtrl->RefreshCtrl(); + m_pParentCtrl->EnableRefresh(true); +} diff --git a/ChartDemo/ChartCtrl/ChartSerie.h b/ChartDemo/ChartCtrl/ChartSerie.h new file mode 100644 index 0000000..a5ce223 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSerie.h @@ -0,0 +1,283 @@ +/* + * + * ChartSerie.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTSERIE_H__FFCF0E32_10E7_4A4D_9FF3_3C6177EDE4B1__INCLUDED_) +#define AFX_CHARTSERIE_H__FFCF0E32_10E7_4A4D_9FF3_3C6177EDE4B1__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +#define INVALID_POINT UINT_MAX + +#include "ChartAxis.h" +#include "ChartSeriesMouseListener.h" + +#include +#include "ChartString.h" + +class CChartLegend; +class CChartCtrl; + +#define INVALID_POINT UINT_MAX + +//! Abstract class that provides a common "interface" for all series in the control +/** + The class doesn't manipulate points (the type of point is unknown at this + level in the class hierarchy) but it provides all other functionalities + which are independant of the point type. + + The drawing of the series is made through pure virtual functions which + should be implemented by derived classes. + + Each series is identified by an Id. +**/ +class CChartSerie +{ + friend CChartCtrl; + friend CChartLegend; + +public: + //! Returns the number of points in the series. + virtual unsigned GetPointsCount() const = 0; + + //! Returns the screen coordinate of a specific point + virtual CPoint GetPointScreenCoord(unsigned uPointIndex) = 0; + + //! Retrieves the minimum and maxium Y values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + virtual bool GetSerieYMinMax(double& Min, double& Max) const = 0; + //! Retrieves the minimum and maxium X values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + virtual bool GetSerieXMinMax(double& Min, double& Max) const = 0; + //! Retrieves the minimum and maxium screen X values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + virtual bool GetSerieXScreenMinMax(double& Min, double& Max) const = 0; + //! Retrieves the minimum and maxium screen Y values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + virtual bool GetSerieYScreenMinMax(double& Min, double& Max) const = 0; + + //! Sets the name of the series, which is displayed in the legend. + void SetName(const TChartString& NewName); + //! Returns the name of the series. + TChartString GetName() const { return m_strSerieName; } + + //! Converts any data point into its relative screen point. + /** + @param XValue + The X value of the data point + @param YValue + The Y value of the data point + @param ScreenPoint + The screen point will be stored in the parameter + **/ + void ValueToScreen(double XValue, double YValue, CPoint& ScreenPoint) const; + //! Converts an Y screen value into its relative Y data value. + double YScreenToValue(long YScreenCoord) const; + //! Converts an Xscreen value into its relative X data value. + double XScreenToValue(long XScreenCoord) const; + + //! Constructor + CChartSerie(CChartCtrl* pParent); + //! Destructor + virtual ~CChartSerie(); + + //! Specifies if the series is visible or not. + /** + An invisible series won't affect automatic axis: it is considered + as if it was not in the control. + **/ + void SetVisible(bool bVisible); + //! Returns true if the series is visible. + bool IsVisible() const { return m_bIsVisible; } + + //! Returns the color of the series. + COLORREF GetColor() const { return m_SerieColor; } + //! Sets the color of the series. + void SetColor(COLORREF NewColor); + //! Returns the color of the shadow. + COLORREF GetShadowColor() const { return m_ShadowColor; } + //! Sets the color of the shadow. + void SetShadowColor(COLORREF NewColor); + //! Enables or disables the shadow for the series. + void EnableShadow(bool bEnable); + //! Sepcifies the depth (in pixels) of the shadow. + void SetShadowDepth(int Depth); + + //! Tests if a certain screen point is on the series. + /** + This function should be overidden by all child classes. + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + virtual bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const = 0; + + //! Returns the series Id. + unsigned GetSerieId() const { return m_uSerieId; } + //! Enables or disables certain mouse notifications on the series. + /** + Checking if a point is on the series could degrade performances if + it has to be done for each mouse event. This function allows to disable + certain notifications, in which case the test won't be done. By default + the series reacts on mouse clicks but not on mouse moves. + @param bClickEnabled + Specifies if the series reacts on mouse clicks. + @param bMoveEnabled + Specifies if the series reacts on mouse moves. + **/ + void EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled); + +protected: + //! Refreshes the automatic axes associated with this series + void RefreshAutoAxes(bool bForceRefresh); + //! Returns the first and last visible points of the series. + /** + This function only works if ordering is enabled. + @param uFirst + The index of the first visible point is stored in this argument + @param uLast + The index of the last visible point is stored in this argument + @return false if the series has no ordering or no data points. + **/ + virtual bool GetVisiblePoints(unsigned& uFirst, unsigned& uLast) const = 0; + + //! Draws the legend icon for the series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + virtual void DrawLegend(CDC* pDC, const CRect& rectBitmap) const =0; + + //! Draws the most recent points of the series. + /** + This pure virtual function should be overriden by child classes. + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + virtual void Draw(CDC* pDC) =0; + //! Redraws the full series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + **/ + virtual void DrawAll(CDC *pDC) =0; + //! Draws the labels of the series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + **/ + virtual void DrawLabels(CDC* pDC) =0; + + //! Called when a mouse event is detected on the chart + /** + This pure virtual function should be overriden by child classes. + @param mouseEvent + The event that occured on the control + @param screenPoint + The screen point on which the event occured + @return true if the event occured on the series. + **/ + virtual bool OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, + const CPoint& screenPoint) = 0; + + //! Returns true if the series reacts on mouse moves. + bool NotifyMouseMoveEnabled() { return m_bMouseMoveNotifications; } + //! Returns true if the series reacts on mouse clicks. + bool NotifyMouseClickEnabled() { return m_bMouseClickNotifications; } + + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + //! The related vertical axis. + CChartAxis* m_pVerticalAxis; + //! The related horizontal axis. + CChartAxis* m_pHorizontalAxis; + + //! The series name displayed in the legend. + TChartString m_strSerieName; + + //! Specifies if the series is visible. + bool m_bIsVisible; + //! Specifies if the series has shadow enabled. + bool m_bShadow; + //! Color of the series + COLORREF m_SerieColor; + //! Color of the shadow + COLORREF m_ShadowColor; + //! Depth (in pixels) of the shadow + int m_iShadowDepth; + //! The rectangle in which the series should be drawn. + CRect m_PlottingRect; + +private: + //! Sets the plotting rectangle. + void SetPlottingRect(const CRect& plottingRect) { m_PlottingRect = plottingRect; } + + //! The next available series Id + static unsigned m_uNextFreeId; + //! The series Id + unsigned m_uSerieId; + + //! Specifies if the series reacts on mouse clicks. + bool m_bMouseClickNotifications; + //! Specifies if the series reacts on mouse moves. + bool m_bMouseMoveNotifications; +}; + +#endif // !defined(AFX_CHARTSERIE_H__FFCF0E32_10E7_4A4D_9FF3_3C6177EDE4B1__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartSerieBase.h b/ChartDemo/ChartCtrl/ChartSerieBase.h new file mode 100644 index 0000000..af01f91 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSerieBase.h @@ -0,0 +1,231 @@ +/* + * + * ChartSerieBase.h + * + * 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. + * + * + */ + +#pragma once + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartSerie.h" +#include "ChartAxis.h" +#include "ChartPointsArray.h" +#include "ChartLabel.h" +#include "ChartBalloonLabel.h" +#include "ChartSeriesMouseListener.h" + +#include +#include "ChartString.h" +#include "PointsOrdering.h" + +class CChartLegend; + + +//! Base class for all series of the control +/** + This class inherits from CChartSeries and introduces the concept of + points through the template parameter. + + This class is much more than a simple base class. It already store + all the data points and provide utility functions to manipulate them. +**/ +template +class CChartSerieBase : public CChartSerie +{ + friend CChartCtrl; + friend CChartLegend; + +public: + //! Adds a single data point to the series. + void AddPoint(const T& newPoint); + //! Adds an array of points to the series. + /** + Points which were already present in the series are kept. + @param pPoints + Array of the new points + @param Count + Size of the array + **/ + void AddPoints(T* pPoints, unsigned Count); + //! Retrieves the point at the specified index. + /** + @param index + The index of the point to retrieve + **/ + const T& GetPoint(unsigned index) const; + //! Sets an array of points to the series. + /** + Points which were already present in the series are discarded. + @param pPoints + Array of the new points + @param Count + Size of the array + **/ + void SetPoints(T* pPoints, unsigned Count); + //! Removes a certain amount of points from the begining of the series. + void RemovePointsFromBegin(unsigned Count); + //! Removes a certain amount of points from the end of the series. + void RemovePointsFromEnd(unsigned Count); + //! Removes all points from the series. + void ClearSerie(); + + //! Returns the number of points in the series. + unsigned GetPointsCount() const { return m_vPoints.GetPointsCount(); } + + //! Retrieves the minimum and maxium Y values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + bool GetSerieYMinMax(double& Min, double& Max) const; + //! Retrieves the minimum and maxium X values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + bool GetSerieXMinMax(double& Min, double& Max) const; + //! Retrieves the minimum and maxium screen X values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + bool GetSerieXScreenMinMax(double& Min, double& Max) const; + //! Retrieves the minimum and maxium screen Y values of the series. + /** + @param Min + Minimum value will be stored in this parameter + @param Max + Maximum value will be stored in this parameter + @return + false if the series doesn't contain data or is invisible + **/ + bool GetSerieYScreenMinMax(double& Min, double& Max) const; + + //! Creates and attaches a balloon label on a point of the series. + /** + This functions specifies a static text to display in the label. + @param uPointIndex + The index of the point on which the label should be attached + @param strLabelText + The text of the label + @return the created CChartBalloonLabel + **/ + CChartBalloonLabel* CreateBalloonLabel(unsigned uPointIndex, const TChartString& strLabelText); + //! Creates and attaches a balloon label on a point of the series. + /** + This functions specifies a CChartLabelProvider object which is used to + supply the text of the label. This is useful if you want more flexibility + for the text of the label (display information about the point value for + instance). + @param uPointIndex + The index of the point on which the label should be attached + @param pLabelProvider + Object providing the text displayed on the label + @return the created CChartBalloonLabel + **/ + CChartBalloonLabel* CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider* pLabelProvider); + //! Attaches a custom label on a point of the series. + /** + @param uPointIndex + The index of the point on which the label should be attached + @param pLabel + The label to attach to the point + **/ + void AttachCustomLabel(unsigned uPointIndex, CChartLabel* pLabel); + + //! Constructor + CChartSerieBase(CChartCtrl* pParent); + //! Destructor + virtual ~CChartSerieBase(); + + //! Specifies how the points should be ordered in the series. + /** + This specifies if the points should be ordered on their X values, + on their Y values or not ordered (kept in order they are added to + the control). Ordering can improve performances a lot but makes it + impossible to draw some specific curves (for instance, drawing an + ellipse is only possible if no ordering is set). + **/ + virtual void SetSeriesOrdering(PointsOrdering newOrdering); + + //! Retrieves the screen point of a specific data point + /** + @param uPointIndex + The index of the point for which to retrieve the screen point + @return the screen point + **/ + CPoint GetPointScreenCoord(unsigned uPointIndex); + + //! Register a series mouse listener on this series + /** + @param pListener + The listener to register + **/ + void RegisterMouseListener(CChartSeriesMouseListener* pListener); + //! Unregister the series mouse listener for this series + void UnregisterMouseListener(); + +protected: + //! Returns the first and last visible points of the series. + /** + This function only works if ordering is enabled. + @param uFirst + The index of the first visible point is stored in this argument + @param uLast + The index of the last visible point is stored in this argument + @return false if the series has no ordering or no data points. + **/ + bool GetVisiblePoints(unsigned& uFirst, unsigned& uLast) const; + + //! Called by the control to check if an event occured on the series. + bool OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, + const CPoint& screenPoint); + + //! The helper class containing all the data points. + CChartPointsArray m_vPoints; + //! Index of the last point drawn + unsigned m_uLastDrawnPoint; + +private: + //! Draws the labels of the series. + void DrawLabels(CDC* pDC); + + typedef std::map*> TLabelMap; + //! Map containing the labels of the series. + TLabelMap m_mapLabels; + + CChartSeriesMouseListener* m_pMouseListener; +}; + +#include "ChartSerieBase.inl" + diff --git a/ChartDemo/ChartCtrl/ChartSerieBase.inl b/ChartDemo/ChartCtrl/ChartSerieBase.inl new file mode 100644 index 0000000..98aa017 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSerieBase.inl @@ -0,0 +1,340 @@ +/* + * + * ChartSerieBase.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 "ChartSerieBase.h" +#include "ChartAxis.h" +#include "ChartCtrl.h" +#include "ChartLabel.h" + +#include "Math.h" +#include + + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +template +CChartSerieBase::CChartSerieBase(CChartCtrl* pParent) : CChartSerie(pParent) +{ + m_uLastDrawnPoint = 0; + m_pMouseListener = NULL; +} + +template +CChartSerieBase::~CChartSerieBase() +{ + TLabelMap::iterator iter = m_mapLabels.begin(); + for (iter; iter!=m_mapLabels.end(); iter++) + { + delete iter->second; + } +} + +template +void CChartSerieBase::SetSeriesOrdering(PointsOrdering newOrdering) +{ + m_vPoints.SetOrdering(newOrdering); +} + + +template +void CChartSerieBase::AddPoint(const T& newPoint) +{ + m_vPoints.AddPoint(newPoint); + RefreshAutoAxes(false); + + CDC* pDC = m_pParentCtrl->GetDC(); + Draw(pDC); + m_pParentCtrl->Invalidate(); +} + +template +void CChartSerieBase::AddPoints(T* pPoints, unsigned Count) +{ + m_vPoints.AddPoints(pPoints, Count); + RefreshAutoAxes(false); + + CDC* pDC = m_pParentCtrl->GetDC(); + Draw(pDC); + m_pParentCtrl->Invalidate(); +} + +template +const T& CChartSerieBase::GetPoint(unsigned Index) const +{ + return m_vPoints[Index]; +} + +template +void CChartSerieBase::SetPoints(T* pPoints, unsigned Count) +{ + m_vPoints.SetPoints(pPoints, Count); + RefreshAutoAxes(true); +} + +template +void CChartSerieBase::RemovePointsFromBegin(unsigned Count) +{ + m_vPoints.RemovePointsFromBegin(Count); + // Remove all the labels associated with those points + for (unsigned i=0; i<=Count; i++) + { + TLabelMap::iterator iter = m_mapLabels.find(i); + if (iter != m_mapLabels.end()) + { + delete iter->second; + m_mapLabels.erase(iter); + } + } + + RefreshAutoAxes(true); +} + +template +void CChartSerieBase::RemovePointsFromEnd(unsigned Count) +{ + unsigned uPtsCount = m_vPoints.GetPointsCount(); + + m_vPoints.RemovePointsFromEnd(Count); + // Remove all the labels associated with those points + unsigned uStart = uPtsCount - Count; + for (unsigned i=0; i<=Count; i++) + { + TLabelMap::iterator iter = m_mapLabels.find(uStart + i); + if (iter != m_mapLabels.end()) + { + delete iter->second; + m_mapLabels.erase(iter); + } + } + + RefreshAutoAxes(true); +} + +template +void CChartSerieBase::ClearSerie() +{ + m_vPoints.Clear(); + TLabelMap::iterator iter = m_mapLabels.begin(); + for (iter; iter!=m_mapLabels.end(); iter++) + { + delete iter->second; + } + m_mapLabels.clear(); + m_uLastDrawnPoint = 0; + + RefreshAutoAxes(true); +} + +template +bool CChartSerieBase::GetSerieXMinMax(double &Min, double &Max) const +{ + if (!IsVisible()) + return false; + return m_vPoints.GetSerieXMinMax(Min, Max); +} + +template +bool CChartSerieBase::GetSerieYMinMax(double &Min, double &Max) const +{ + if (!IsVisible()) + return false; + return m_vPoints.GetSerieYMinMax(Min, Max); +} + +template +bool CChartSerieBase::GetSerieXScreenMinMax(double& Min, double& Max) const +{ + if (!IsVisible()) + return false; + if (m_vPoints.GetOrdering() != poYOrdering) + return false; + + unsigned first=0, last=0; + bool bRes = GetVisiblePoints(first, last); + if (!bRes) + return false; + + Min = m_vPoints[first].GetXMin(); + Max = m_vPoints[first].GetXMax(); + for (unsigned i=first; i Max) + Max = m_vPoints[i].GetXMax(); + } + return true; +} + +template +bool CChartSerieBase::GetSerieYScreenMinMax(double& Min, double& Max) const +{ + if (!IsVisible()) + return false; + if (m_vPoints.GetOrdering() != poXOrdering) + return false; + + unsigned first=0, last=0; + bool bRes = GetVisiblePoints(first, last); + if (!bRes) + return false; + + Min = m_vPoints[first].GetYMin(); + Max = m_vPoints[first].GetYMax(); + for (unsigned i=first; i Max) + Max = m_vPoints[i].GetYMax(); + } + return true; +} + +template +bool CChartSerieBase::GetVisiblePoints(unsigned& uFirst, unsigned& uLast) const +{ + if (m_vPoints.GetPointsCount() == 0) + return false; + + double Min=0, Max=0; + bool bResult = false; + switch (m_vPoints.GetOrdering()) + { + case poNoOrdering: + uFirst = 0; + uLast = GetPointsCount() - 1; + bResult = true; + break; + case poXOrdering: + m_pHorizontalAxis->GetMinMax(Min, Max); + bResult = m_vPoints.GetVisiblePoints(Min, Max, uFirst, uLast); + break; + case poYOrdering: + m_pVerticalAxis->GetMinMax(Min, Max); + bResult = m_vPoints.GetVisiblePoints(Min, Max, uFirst, uLast); + break; + } + + return bResult; +} + +template +CPoint CChartSerieBase::GetPointScreenCoord(unsigned uPointIndex) +{ + unsigned uCount = m_vPoints.GetPointsCount(); + ASSERT(uPointIndex +CChartBalloonLabel* CChartSerieBase::CreateBalloonLabel(unsigned uPointIndex, + const TChartString& strLabelText) +{ + ASSERT(uPointIndex* pToReturn = new CChartBalloonLabel(m_pParentCtrl, this); + pToReturn->SetLabelText(strLabelText); + AttachCustomLabel(uPointIndex, pToReturn); + return pToReturn; +} + +template +void CChartSerieBase::RegisterMouseListener(CChartSeriesMouseListener* pListener) +{ + m_pMouseListener = pListener; +} + +template +void CChartSerieBase::UnregisterMouseListener() +{ + m_pMouseListener = NULL; +} + +template +CChartBalloonLabel* CChartSerieBase::CreateBalloonLabel(unsigned uPointIndex, + CChartLabelProvider* pLabelProvider) +{ + ASSERT(uPointIndex* pToReturn = new CChartBalloonLabel(m_pParentCtrl, this); + pToReturn->SetLabelProvider(pLabelProvider); + AttachCustomLabel(uPointIndex, pToReturn); + return pToReturn; +} + +template +void CChartSerieBase::AttachCustomLabel(unsigned uPointIndex, CChartLabel* pLabel) +{ + ASSERT(uPointIndexsecond; + } + m_mapLabels[uPointIndex] = pLabel; +} + +template +void CChartSerieBase::DrawLabels(CDC* pDC) +{ + TLabelMap::iterator iter = m_mapLabels.begin(); + for (iter; iter!=m_mapLabels.end(); iter++) + { + iter->second->Draw(pDC,iter->first); + } +} + +template +bool CChartSerieBase::OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, + const CPoint& screenPoint) +{ + bool bHandled = false; + if (m_pMouseListener == NULL) + return bHandled; + + if ( (mouseEvent==CChartMouseListener::MouseMove) && + !NotifyMouseMoveEnabled()) + { + return bHandled; + } + if ( (mouseEvent!=CChartMouseListener::MouseMove) && + !NotifyMouseClickEnabled()) + { + return bHandled; + } + + unsigned uPtIndex = 0; + if (IsPointOnSerie(screenPoint,uPtIndex)) + { + m_pMouseListener->OnMouseEventSeries(mouseEvent,screenPoint,this,uPtIndex); + bHandled = true; + } + + return bHandled; +} diff --git a/ChartDemo/ChartCtrl/ChartSeriesMouseListener.h b/ChartDemo/ChartCtrl/ChartSeriesMouseListener.h new file mode 100644 index 0000000..658f86a --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSeriesMouseListener.h @@ -0,0 +1,65 @@ +/* + * + * ChartSeriesMouseListener.h + * + * 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. + * + * + */ + +#ifndef _CHARTSERIESMOUSELISTENER_H_ +#define _CHARTSERIESMOUSELISTENER_H_ + +#include "ChartMouseListener.h" + +//#pragma warning( disable : 4100 ) + +template +class CChartSerieBase; + +//! Listener for mouse events occuring on a series. +/** + This is an interface which must be implemented in order to receive + mouse notifications. You can then register your class with the chart + control by calling RegisterMouseListener. +**/ +template +class CChartSeriesMouseListener +{ +public: + //! Constructor + CChartSeriesMouseListener() { } + //! Destructor + virtual ~CChartSeriesMouseListener() { } + + //! Virtual function to implement in order to be notified when a mouse event occurs on a series. + /** + @param mouseEvent + The mouse event which occured + @param point + The screen point on which the event occured + @param pSerie + The series on which the event occured + @param uPointIndex + The index of the point on which the event occured. In case the event + did not occur on a specific point but on the series itself (e.g. clicking + between two points on a line series), INVALID_POINT is passed for this + parameter. + **/ + virtual void OnMouseEventSeries(CChartMouseListener::MouseEvent mouseEvent, CPoint point, + CChartSerieBase* pSerie, unsigned uPointIndex) { } +}; + +#endif // _CHARTSERIESMOUSELISTENER_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartStandardAxis.cpp b/ChartDemo/ChartCtrl/ChartStandardAxis.cpp new file mode 100644 index 0000000..765b81a --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartStandardAxis.cpp @@ -0,0 +1,197 @@ +/* + * + * 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 "ChartStandardAxis.h" +#include "ChartCtrl.h" +#include +#include +#include +#include + +using namespace std; + +CChartStandardAxis::CChartStandardAxis() + : CChartAxis(), m_dFirstTickValue(0), + m_dTickIncrement(1.0), m_uDecCount(0) +{ +} + +CChartStandardAxis::~CChartStandardAxis() +{ +} + + +void CChartStandardAxis::SetTickIncrement(bool bAuto, double newIncrement) +{ + m_bAutoTicks = bAuto; + if (!m_bAutoTicks) + { + m_dTickIncrement = newIncrement; + + int Zeros = (int)floor(log10(m_dTickIncrement)); + + int Digits = 0; + if (Zeros<0) + { + //We must set decimal places. In the other cases, Digits will be 0. + Digits = (int)fabs(Zeros*1.0); + } + SetDecimals(Digits); + } +} + +double CChartStandardAxis::GetFirstTickValue() const +{ + double dRetVal = m_dFirstTickValue; + if (m_bDiscrete) + { + dRetVal = m_dFirstTickValue - m_dTickIncrement; + } + return dRetVal; +} + +bool CChartStandardAxis::GetNextTickValue(double dCurrentTick, double& dNextTick) const +{ + if (m_dTickIncrement==0) + return false; + + dNextTick = dCurrentTick + m_dTickIncrement; + if (dNextTick <= m_MaxValue) + return true; + else + return false; +} + +long CChartStandardAxis::ValueToScreenDiscrete(double dValue) const +{ + // In discrete mode, all values between two ticks are "directed" + // to the middle of the interval. + double precision = 0.0000000001; + if (dValue < 0) + precision = -0.0000000001; + int tickNr = (int)((dValue+precision)/m_dTickIncrement); + dValue = tickNr * m_dTickIncrement; + + dValue += m_dTickIncrement/2.0; + return ValueToScreenStandard(dValue); +} + +long CChartStandardAxis::GetTickPos(double TickVal) const +{ + // The tick is always at the same position, + // even if the axis is discrete. + return ValueToScreenStandard(TickVal); +} + +TChartString CChartStandardAxis::GetTickLabel(double TickValue) const +{ + TChartStringStream ssLabel; + ssLabel << fixed << setprecision(m_uDecCount) << TickValue; + return ssLabel.str(); +} + +void CChartStandardAxis::RefreshTickIncrement() +{ + if (!m_bAutoTicks) + return; + + if (m_MaxValue == m_MinValue) + { + m_dTickIncrement = 0; + return; + } + + int PixelSpace; + if (m_bIsHorizontal) + PixelSpace = 30; + else + PixelSpace = 20; + + int MaxTickNumber = (int)fabs((m_EndPos-m_StartPos)/PixelSpace * 1.0); + + //Calculate the appropriate TickSpace (1 tick every 30 pixel +/-) + //Temporary tick increment + double TempTickIncrement = (m_MaxValue-m_MinValue)/MaxTickNumber; + + // Calculate appropriate tickSpace (not rounded on 'strange values' but + // on something like 1, 2 or 5*10^X where X is optimalized for showing the most + // significant digits) + int Zeros = (int)floor(log10(TempTickIncrement)); + double MinTickIncrement = pow(10.0,Zeros); + + int Digits = 0; + if (Zeros<0) + { + //We must set decimal places. In the other cases, Digits will be 0. + Digits = (int)fabs(Zeros*1.0); + } + + if (MinTickIncrement>=TempTickIncrement) + { + m_dTickIncrement = MinTickIncrement; + SetDecimals(Digits); + } + else if (MinTickIncrement*2>=TempTickIncrement) + { + m_dTickIncrement = MinTickIncrement*2; + SetDecimals(Digits); + } + else if (MinTickIncrement*5>=TempTickIncrement) + { + m_dTickIncrement = MinTickIncrement*5; + SetDecimals(Digits); + } + else if (MinTickIncrement*10>=TempTickIncrement) + { + m_dTickIncrement = MinTickIncrement*10; + if (Digits) + SetDecimals(Digits-1); + else + SetDecimals(Digits); + } +} + +void CChartStandardAxis::RefreshFirstTick() +{ + if (m_dTickIncrement!=0) + { + if (m_MinValue == 0) + m_dFirstTickValue = 0; + else if (m_MinValue>0) + { + m_dFirstTickValue = (int)(m_MinValue/m_dTickIncrement) * m_dTickIncrement; + while (m_dFirstTickValuem_MinValue) + m_dFirstTickValue -= m_dTickIncrement; + if (!(m_dFirstTickValue == m_MinValue)) + m_dFirstTickValue += m_dTickIncrement; + } + } + else // m_TickIncrement!=0 + { + m_dFirstTickValue = m_MinValue; + } +} diff --git a/ChartDemo/ChartCtrl/ChartStandardAxis.h b/ChartDemo/ChartCtrl/ChartStandardAxis.h new file mode 100644 index 0000000..2f9926d --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartStandardAxis.h @@ -0,0 +1,76 @@ +/* + * + * ChartStandardAxis.h + * + * 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. + * + * + */ + +#ifndef _CHARTSTANDARDAXIS_H_ +#define _CHARTSTANDARDAXIS_H_ + +#include "ChartAxis.h" + +//! Specialization of a CChartAxis class to display standard values. +class CChartStandardAxis : public CChartAxis +{ +friend CChartCtrl; + +public: + //! Sets the tick increment. + /** + The tick increment is the value between two adjacents + ticks on the axis. + @param bAuto + Specifies if the tick increment is automatically calculated. + @param newIncrement + The tick increment to use in manual mode. + **/ + void SetTickIncrement(bool bAuto, double newIncrement); + //! Gets the tick increment. + /** + The tick increment is the value between two adjacents + ticks on the axis. + **/ + double GetTickIncrement() const { return m_dTickIncrement; } + +private: + //! Default constructor + CChartStandardAxis(); + //! Default destructor + ~CChartStandardAxis(); + + double GetFirstTickValue() const; + bool GetNextTickValue(double dCurrentTick, double& dNextTick) const; + TChartString GetTickLabel(double TickValue) const; + long ValueToScreenDiscrete(double Value) const; + long GetTickPos(double TickVal) const; + + void RefreshTickIncrement(); + void RefreshFirstTick(); + + //! Sets the number of decimals points. + void SetDecimals(unsigned uDecimals) { m_uDecCount = uDecimals; } + + //! Caches the value of the first tick. + double m_dFirstTickValue; + //! Indicates the space between ticks (in axis value). + double m_dTickIncrement; + //! Number of decimals to display for tick labels. + unsigned int m_uDecCount; +}; + +#endif // _CHARTSTANDARDAXIS_H_ \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartString.h b/ChartDemo/ChartCtrl/ChartString.h new file mode 100644 index 0000000..7876266 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartString.h @@ -0,0 +1,33 @@ +/* + * + * ChartString.h + * + * 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. + * + * + */ + +#pragma once + +#include +#include + +#if defined _UNICODE || defined UNICODE + typedef std::wstring TChartString; + typedef std::wstringstream TChartStringStream; +#else + typedef std::string TChartString; + typedef std::stringstream TChartStringStream; +#endif \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartSurfaceSerie.cpp b/ChartDemo/ChartCtrl/ChartSurfaceSerie.cpp new file mode 100644 index 0000000..06cceeb --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSurfaceSerie.cpp @@ -0,0 +1,289 @@ +/* + * + * ChartSurfaceSerie.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 "ChartSurfaceSerie.h" +#include "ChartCtrl.h" + + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartSurfaceSerie::CChartSurfaceSerie(CChartCtrl* pParent) + : CChartXYSerie(pParent), m_FillStyle(fsHatchDownDiag), m_bHorizontal(true) +{ + +} + +CChartSurfaceSerie::~CChartSurfaceSerie() +{ + +} + +void CChartSurfaceSerie::Draw(CDC* pDC) +{ + DrawAll(pDC); +} + +void CChartSurfaceSerie::DrawAll(CDC* pDC) +{ + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return; + + if (uFirst>0) + uFirst--; + if (uLastSelectObject(&NewBrush); + + for (unsigned index=uFirst; index<=uLast; index++) + { + SChartXYPoint Point = GetPoint(index); + ValueToScreen(Point.X, Point.Y, pPoints[index-uFirst+1]); + } + + if (m_bHorizontal) + { + pPoints[0].x = pPoints[1].x; + pPoints[uCount+1].x = pPoints[uCount].x; + + double Position = m_pHorizontalAxis->GetPosition()/100.00; + int AxisPos = m_PlottingRect.top + (int)(Position * (m_PlottingRect.bottom-m_PlottingRect.top)); + + pPoints[0].y = AxisPos; + pPoints[uCount+1].y = AxisPos; + } + else + { + pPoints[0].y = pPoints[1].y; + pPoints[uCount+1].y = pPoints[uCount].y; + + double Position = m_pVerticalAxis->GetPosition()/100.00; + int AxisPos = m_PlottingRect.left + (int)(Position * (m_PlottingRect.right-m_PlottingRect.left)); + + pPoints[0].x = AxisPos; + pPoints[uCount+1].x = AxisPos; + } + + pDC->SetBkMode(TRANSPARENT); + //To have lines limited in the drawing rectangle : + CRect TempClipRect(m_PlottingRect); + TempClipRect.DeflateRect(1,1); + pDC->SetBkMode(TRANSPARENT); + pDC->IntersectClipRect(TempClipRect); + + pDC->Polygon(pPoints,uCount+2); + pDC->SelectClipRgn(NULL); + pDC->SelectObject(pOldBrush); + DeleteObject(NewBrush); + + delete[] pPoints; +} + +void CChartSurfaceSerie::DrawLegend(CDC* pDC, const CRect& rectBitmap) const +{ + if (m_strSerieName== _T("")) + return; + + // Draw the bitmap + CBrush NewBrush; + if (m_FillStyle == fsSolid) + NewBrush.CreateSolidBrush(m_SerieColor); + else + { + int nIndex = 0; + switch (m_FillStyle) + { + case fsHatchDownDiag: + nIndex = HS_FDIAGONAL; + break; + case fsHatchUpDiag: + nIndex = HS_BDIAGONAL; + break; + case fsHatchCross: + nIndex = HS_CROSS; + break; + case fsHatchDiagCross: + nIndex = HS_DIAGCROSS; + break; + case fsHatchHorizontal: + nIndex = HS_HORIZONTAL; + break; + case fsHatchVertical: + nIndex = HS_VERTICAL; + break; + } + NewBrush.CreateHatchBrush(nIndex,m_SerieColor); + } + + CBrush* pOldBrush = pDC->SelectObject(&NewBrush); + + pDC->Rectangle(rectBitmap); + + pDC->SelectObject(pOldBrush); + DeleteObject(NewBrush); +} + +void CChartSurfaceSerie::SetFillStyle(FillStyle NewStyle) +{ + m_FillStyle = NewStyle; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSurfaceSerie::SetHorizontal(bool bHoriz) +{ + m_bHorizontal = bHoriz; + if (m_bHorizontal) + m_vPoints.SetOrdering(poXOrdering); + else + m_vPoints.SetOrdering(poYOrdering); + m_pParentCtrl->RefreshCtrl(); +} + +void CChartSurfaceSerie::SetSeriesOrdering(PointsOrdering ) +{ + TRACE("Can't change the series ordering of a surface series."); +} + +bool CChartSurfaceSerie::IsPointOnSerie(const CPoint& screenPoint, + unsigned& uIndex) const +{ + uIndex = INVALID_POINT; + if (!m_bIsVisible) + return false; + + unsigned uFirst=0, uLast=0; + if (!GetVisiblePoints(uFirst,uLast)) + return false; + + if (uFirst>0) + uFirst--; + if (uLast point2.x)) + continue; + + int Position = m_pHorizontalAxis->GetPosition(); + if ( (Position==100) && (screenPoint.y > (screenPoint.x *lineSlope + lineOffset)) ) + bResult = true; + if ( (Position==0) && (screenPoint.y < (screenPoint.x *lineSlope + lineOffset)) ) + bResult = true; + + if (bResult) + { + // Check if the click is close to one of the two points. + int xDist = abs(screenPoint.x - point1.x); + int yDist = abs(screenPoint.y - point1.y); + if (xDist<=5 && yDist<=5) + uIndex = ptIndex; + xDist = abs(screenPoint.x - point2.x); + yDist = abs(screenPoint.y - point2.y); + if (xDist<=5 && yDist<=5) + uIndex = ptIndex+1; + break; + } + } + else + { + if ( (screenPoint.y > point1.y) || (screenPoint.y < point2.y)) + continue; + + int Position = m_pVerticalAxis->GetPosition(); + if ( (Position==0) && (screenPoint.x < (screenPoint.y-lineOffset)/lineSlope) ) + bResult = true; + if ( (Position==100) && (screenPoint.x > (screenPoint.y-lineOffset)/lineSlope) ) + bResult = true; + + if (bResult) + { + // Check if the click is close to one of the two points. + int xDist = abs(screenPoint.x - point1.x); + int yDist = abs(screenPoint.y - point1.y); + if (xDist<=5 && yDist<=5) + uIndex = ptIndex; + xDist = abs(screenPoint.x - point2.x); + yDist = abs(screenPoint.y - point2.y); + if (xDist<=5 && yDist<=5) + uIndex = ptIndex+1; + break; + } + } + } + + return bResult; +} diff --git a/ChartDemo/ChartCtrl/ChartSurfaceSerie.h b/ChartDemo/ChartCtrl/ChartSurfaceSerie.h new file mode 100644 index 0000000..c0090c7 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartSurfaceSerie.h @@ -0,0 +1,128 @@ +/* + * + * ChartSurfaceSerie.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTSURFACESERIE_H__28A77823_43BD_4502_9AA7_A2B227454035__INCLUDED_) +#define AFX_CHARTSURFACESERIE_H__28A77823_43BD_4502_9AA7_A2B227454035__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartXYSerie.h" + +//! Specialization of a CChartSerie to display a surface series. +/** + A surface can be horizontal (default) or vertical: this defines how + the filling of the surface is done. For a horizontal surface, the + filling is done between the points and the associated horizontal axis + and for a vertical surface, the filling is done between the points + and the associated vertical axis. + The series can be associated with a secondary axis. For example, if + the surface series is horizontal and is associated with the top axis + (secondary axis), the filling is done between the top axis and the points. +**/ +class CChartSurfaceSerie : public CChartXYSerie +{ +public: + //! Constructor + CChartSurfaceSerie(CChartCtrl* pParent); + //! Destructor + virtual ~CChartSurfaceSerie(); + + //! The different fill styles + enum FillStyle + { + fsSolid = 0, + fsHatchDownDiag, + fsHatchUpDiag, + fsHatchCross, + fsHatchDiagCross, + fsHatchHorizontal, + fsHatchVertical + }; + + //! Sets the fill style + void SetFillStyle(FillStyle NewStyle); + //! Returns the fill style + FillStyle GetFillStyle() const { return m_FillStyle; } + + //! Sets the series in horizontal or vertical mode + /** + If the series is in horizontal mode, the filling will be done between + the data points and the horizontal axis. + **/ + void SetHorizontal(bool bHoriz); + //! Returns true if the series is in horizontal mode + bool GetHorizontal() const { return m_bHorizontal; } + + //! Check whether a screen point is on the series. + /** + This function returns true if the screen point is on the surface. + If the screen point is also close to a specific point of the series, the + index of the point is stored in the uIndex parameter. Otherwise, this + parameter contains INVALID_POINT. + @param screenPoint + The screen point to test + @param uIndex + If the point is close to a specific point of the series, its index is stored here. + @return true if the point is on the series + **/ + bool IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const; + + void CChartSurfaceSerie::SetSeriesOrdering(PointsOrdering ); +private: + //! Override in order to avoid changing series ordering. +// void SetSeriesOrdering(CChartPointsArray::PointsOrdering); + + //! Draws the legend icon for the series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + @param rectBitmap + The rectangle in which to draw the legend icon + **/ + void DrawLegend(CDC* pDC, const CRect& rectBitmap) const; + + //! Draws the most recent points of the series. + /** + This pure virtual function should be overriden by child classes. + This function should only draw the points that were not previously + drawn. + @param pDC + The device context used to draw + **/ + void Draw(CDC* pDC); + //! Redraws the full series. + /** + This pure virtual function should be overriden by child classes. + @param pDC + The device context used to draw + **/ + void DrawAll(CDC *pDC); + + //! The brush style used to fill the surface + FillStyle m_FillStyle; + //! The horizontal/vertical mode + bool m_bHorizontal; +}; + +#endif // !defined(AFX_CHARTSURFACESERIE_H__28A77823_43BD_4502_9AA7_A2B227454035__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartTitle.cpp b/ChartDemo/ChartCtrl/ChartTitle.cpp new file mode 100644 index 0000000..43774ec --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartTitle.cpp @@ -0,0 +1,201 @@ +/* + * + * ChartTitle.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 "ChartTitle.h" +#include "ChartCtrl.h" +#include "Math.h" + +using namespace std; + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CChartTitle::CChartTitle(CChartCtrl* pParent) +{ + m_pParentCtrl = pParent; + m_bIsVisible = true; + m_TextColor = RGB(0,0,0); +} + +CChartTitle::~CChartTitle() +{ + +} + +void CChartTitle::SetFont(int iPointSize, const TChartString& strFaceName) +{ + m_DefaultFont.SetFont(strFaceName, iPointSize); + m_pParentCtrl->RefreshCtrl(); +} + +void CChartTitle::SetFont(const CChartFont& newFont) +{ + m_DefaultFont = newFont; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartTitle::SetColor(COLORREF NewColor) +{ + m_TextColor = NewColor; + m_pParentCtrl->RefreshCtrl(); +} + +void CChartTitle::SetLineFont(int iLineIndex, + int iPointSize, + const TChartString& strFaceName) +{ + CChartFont newFont(strFaceName,iPointSize); + m_mapLineFonts[iLineIndex] = newFont; +} + +void CChartTitle::SetLineFont(int iLineIndex, const CChartFont& newFont) +{ + m_mapLineFonts[iLineIndex] = newFont; +} + +void CChartTitle::AddString(const TChartString& NewString) +{ + m_StringArray.push_back(NewString); + m_pParentCtrl->RefreshCtrl(); +} + +size_t CChartTitle::GetStringCount() const +{ + return m_StringArray.size(); +} + +TChartString CChartTitle::GetString(size_t Index) const +{ + if ( (Index<0) || (Index>=m_StringArray.size()) ) + return _T(""); + return m_StringArray[Index]; +} + +void CChartTitle::RemoveAll() +{ + m_StringArray.clear(); + m_pParentCtrl->RefreshCtrl(); +} + +void CChartTitle::Draw(CDC *pDC) +{ + if (!pDC->GetSafeHdc()) + return; + if (!m_bIsVisible) + return; + + m_DefaultFont.SelectFont(pDC); + COLORREF OldColor = pDC->SetTextColor(m_TextColor); + int iPrevMode = pDC->SetBkMode(TRANSPARENT); + + //Draw all entries + int YPos = 4; + size_t TitleCount = m_StringArray.size(); + for (size_t i=0;i::iterator iter = m_mapLineFonts.find(i); + if (iter != m_mapLineFonts.end()) + iter->second.SelectFont(pDC); + + //Draw Text + int TextWidth = pDC->GetTextExtent(m_StringArray[i].c_str()).cx; + int TextHeigh = pDC->GetTextExtent(m_StringArray[i].c_str()).cy; + + int XPos = m_TitleRect.left + (int)fabs((m_TitleRect.left-m_TitleRect.right)/2.0) - TextWidth/2; + +/* if (m_bShadow) + { + pDC->SetTextColor(m_ShadowColor); + pDC->ExtTextOut(XPos+m_iShadowDepth,m_TitleRect.top+YPos+m_iShadowDepth, + ETO_CLIPPED,NULL,m_StringArray[i].c_str(),NULL); + pDC->SetTextColor(m_TextColor); + }*/ + pDC->ExtTextOut(XPos,m_TitleRect.top+YPos,ETO_CLIPPED,NULL,m_StringArray[i].c_str(),NULL); + + if (iter != m_mapLineFonts.end()) + iter->second.UnselectFont(pDC); + + YPos += TextHeigh + 2; + } + + m_DefaultFont.UnselectFont(pDC); + pDC->SetTextColor(OldColor); + pDC->SetBkMode(iPrevMode); +} + +CSize CChartTitle::GetSize(CDC *pDC) +{ + CSize TitleSize; + + if (!m_bIsVisible) + { + TitleSize.cx = TitleSize.cy = 0; + return TitleSize; + } + + int Height = 4; //Upper space + CSize TextSize = 0; + int MaxTextWidth = 0; + + size_t TitleCount = m_StringArray.size(); + if (TitleCount==0) + { + TitleSize.cx = TitleSize.cy = 0; + return TitleSize; + } + + m_DefaultFont.SelectFont(pDC); + for (size_t i=0;i::iterator iter = m_mapLineFonts.find(i); + if (iter != m_mapLineFonts.end()) + iter->second.SelectFont(pDC); + + TextSize = pDC->GetTextExtent(m_StringArray[i].c_str()); + Height += TextSize.cy + 2; + if (TextSize.cx > MaxTextWidth) + MaxTextWidth = TextSize.cx; + + if (iter != m_mapLineFonts.end()) + iter->second.UnselectFont(pDC); + } + + TitleSize.cx = MaxTextWidth + 2; + TitleSize.cy = Height; + + m_TitleRect.bottom = m_TitleRect.top + Height; + + m_DefaultFont.UnselectFont(pDC); + return TitleSize; +} + +BOOL CChartTitle::IsPointInside(const CPoint& screenPoint) const +{ + return m_TitleRect.PtInRect(screenPoint); +} diff --git a/ChartDemo/ChartCtrl/ChartTitle.h b/ChartDemo/ChartCtrl/ChartTitle.h new file mode 100644 index 0000000..29c2849 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartTitle.h @@ -0,0 +1,136 @@ +/* + * + * ChartTitle.h + * + * 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. + * + * + */ + +#if !defined(AFX_CHARTTITLE_H__49972787_6D28_4F81_A12F_420947456913__INCLUDED_) +#define AFX_CHARTTITLE_H__49972787_6D28_4F81_A12F_420947456913__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include +#include +#include "ChartString.h" +#include "ChartFont.h" + +class CChartCtrl; + +//! This class is responsible for the titles displayed on the control. +/** + Several lines can be displayed in the title, each one possibly with + its own font. It is retrieved by calling the GetTitle() function + from the CChartCtrl class. +**/ +class CChartTitle +{ + friend CChartCtrl; + +public: + //! Returns the number of lines in the title. + size_t GetStringCount() const; + //! Returns a specific line, specified by its index. + TChartString GetString(size_t Index) const; + //! Adds a new line to the title. + void AddString(const TChartString& NewString); + //! Removes all the lines displayed in the title. + void RemoveAll(); + + //! Sets the default font. + /** + @param iPointSize + The font point size. + @param strFaceName + The font face name ("Times New Roman", "Arial", ...) + **/ + void SetFont(int iPointSize, const TChartString& strFaceName); + //! Sets the default font. + /** + This function allows to set extended font style by passing + a CChartFont object. + @param newFont + The new font. + **/ + void SetFont(const CChartFont& newFont); + //! Sets the font for a specific line. + /** + @param iLineIndex + The index of the line to set the font. + @param iPointSize + The font point size. + @param strFaceName + The font face name ("Times New Roman", "Arial", ...) + **/ + void SetLineFont(int iLineIndex, int iPointSize, const TChartString& strFaceName); + //! Sets the font for a specific line. + /** + This function allows to set extended font style by passing + a CChartFont object. + @param iLineIndex + The index of the line to set the font. + @param newFont + The new font. + **/ + void SetLineFont(int iLineIndex, const CChartFont& newFont); + + //! Shows/hides the title. + void SetVisible(bool bVisible) { m_bIsVisible = bVisible; } + //! Returns true if the title is visible. + bool IsVisible() const { return m_bIsVisible; } + + //! Returns the text color. + COLORREF GetColor() const { return m_TextColor; } + //! Sets the text color. + void SetColor(COLORREF NewColor); + + //! Returns true if a screen point is in the region of the title. + BOOL IsPointInside(const CPoint& screenPoint) const; + +private: + //! Constructor + CChartTitle(CChartCtrl* pParent); + //! Destructor + virtual ~CChartTitle(); + + //! Sets the rectangle in which to display the title. + void SetTitleRect(const CRect& newRect) { m_TitleRect = newRect; } + //! Returns the size of the title lines. + CSize GetSize(CDC* pDC); + //! Draw the title. + void Draw(CDC *pDC); + + //! The parent charting control. + CChartCtrl* m_pParentCtrl; + //! Vector containing all strings to display. + std::vector m_StringArray; + //! Map containing all the fonts used for the title lines. + std::map m_mapLineFonts; + + //! Specifies if the title is visible. + bool m_bIsVisible; + //! The default font used to draw the titles. + CChartFont m_DefaultFont; + //! The text color. + COLORREF m_TextColor; + //! The rectangle in which to draw the titles. + CRect m_TitleRect; +}; + +#endif // !defined(AFX_CHARTTITLE_H__49972787_6D28_4F81_A12F_420947456913__INCLUDED_) diff --git a/ChartDemo/ChartCtrl/ChartXYSerie.cpp b/ChartDemo/ChartCtrl/ChartXYSerie.cpp new file mode 100644 index 0000000..3f4eaa1 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartXYSerie.cpp @@ -0,0 +1,186 @@ +/* + * + * ChartXYSerie.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 "ChartXYSerie.h" + +CChartXYSerie::CChartXYSerie(CChartCtrl* pParent) + : CChartSerieBase(pParent) +{ +} + +CChartXYSerie::~CChartXYSerie() +{ +} + +void CChartXYSerie::AddPoint(double X, double Y) +{ + SChartXYPoint newPoint(X, Y); + CChartSerieBase::AddPoint(newPoint); +} + +void CChartXYSerie::AddPoints(double* pX, double* pY, unsigned Count) +{ + SChartXYPoint* pPoints = new SChartXYPoint[Count]; + for (unsigned i=0; i::AddPoints(pPoints, Count); + delete pPoints; +} + +void CChartXYSerie::SetPoints(double* pX, double* pY, unsigned Count) +{ + SChartXYPoint* pPoints = new SChartXYPoint[Count]; + for (unsigned i=0; i::SetPoints(pPoints, Count); + delete pPoints; +} + +double CChartXYSerie::GetXPointValue(unsigned PointIndex) const +{ + return m_vPoints[PointIndex].GetX(); +} + +double CChartXYSerie::GetYPointValue(unsigned PointIndex) const +{ + return m_vPoints[PointIndex].GetY(); +} + +void CChartXYSerie::SetXPointValue(unsigned PointIndex, double NewVal) +{ + m_vPoints[PointIndex].X = NewVal; + m_vPoints.ReorderPoints(); + + RefreshAutoAxes(true); +} + +void CChartXYSerie::SetYPointValue(unsigned PointIndex, double NewVal) +{ + m_vPoints[PointIndex].Y = NewVal; + m_vPoints.ReorderPoints(); + + RefreshAutoAxes(true); +} + +#ifndef NO_USER_DATA +void CChartXYSerie::SetUserData(unsigned uPointIndex, void* pData) +{ + m_vPoints[uPointIndex].pUserData = pData; +} + +void* CChartXYSerie::GetUserData(unsigned uPointIndex) +{ + return m_vPoints[uPointIndex].pUserData; +} +#endif + +void CChartXYSerie::GetBezierControlPoints(unsigned uFirst, + unsigned uLast, + SChartXYPoint* &pKnots, + SChartXYPoint* &pFirstControlPoints, + SChartXYPoint* &pSecondControlPoints) const +{ + int Count = uLast - uFirst - 1; + if (Count < 1) + { + pFirstControlPoints = new SChartXYPoint[0]; + pSecondControlPoints = new SChartXYPoint[0]; + pKnots = new SChartXYPoint[0]; + return; + } + + pKnots = new SChartXYPoint[uLast-uFirst]; + SChartXYPoint* pPoints = m_vPoints.GetInternalBuffer(); + memcpy(pKnots, pPoints+uFirst, (uLast-uFirst)*sizeof(SChartXYPoint)); + + // Calculate first Bezier control points + // Right hand side vector + double* rhs = new double[Count]; + + // Set right hand side X values + int i=0; + for (i = 1; i < Count - 1; ++i) + rhs[i] = 4 * pKnots[i].X + 2 * pKnots[i + 1].X; + rhs[0] = pKnots[0].X + 2 * pKnots[1].X; + rhs[Count - 1] = 3 * pKnots[Count - 1].X; + // Get first control points X-values + double* pFirstX = GetFirstControlPoints(rhs, Count); + + // Set right hand side Y values + for (i = 1; i < Count - 1; ++i) + rhs[i] = 4 * pKnots[i].Y + 2 * pKnots[i + 1].Y; + rhs[0] = pKnots[0].Y + 2 * pKnots[1].Y; + rhs[Count - 1] = 3 * pKnots[Count - 1].Y; + // Get first control points Y-values + double* pFirstY = GetFirstControlPoints(rhs, Count); + + // Fill output arrays. + pFirstControlPoints = new SChartXYPoint[Count]; + pSecondControlPoints = new SChartXYPoint[Count]; + for (i = 0; i < Count; ++i) + { + // First control point + pFirstControlPoints[i].X = pFirstX[i]; + pFirstControlPoints[i].Y = pFirstY[i]; + // Second control point + if (i < Count - 1) + { + pSecondControlPoints[i].X = 2 * pKnots[i + 1].X - pFirstX[i + 1]; + pSecondControlPoints[i].Y = 2 * pKnots[i + 1].Y - pFirstY[i + 1]; + } + else + { + pSecondControlPoints[i].X = (pKnots[Count].X + pFirstX[Count - 1]) / 2; + pSecondControlPoints[i].Y = (pKnots[Count].Y + pFirstY[Count - 1]) / 2; + } + } + + delete[] rhs; + delete[] pFirstX; + delete[] pFirstY; +} + +double* CChartXYSerie::GetFirstControlPoints(double* rhs, int Count) const +{ + double* pPoints = new double[Count]; // Solution vector. + double* pTemp = new double[Count]; // Temp workspace. + + double b = 2.0; + pPoints[0] = rhs[0] / b; + int i =0; + for (i = 1; i < Count; i++) // Decomposition and forward substitution. + { + pTemp[i] = 1 / b; + b = (i < Count - 1 ? 4.0 : 2.0) - pTemp[i]; + pPoints[i] = (rhs[i] - pPoints[i - 1]) / b; + } + for (i = 1; i < Count; i++) + pPoints[Count - i - 1] -= pTemp[Count - i] * pPoints[Count - i]; // Backsubstitution. + delete[] pTemp; + return pPoints; +} \ No newline at end of file diff --git a/ChartDemo/ChartCtrl/ChartXYSerie.h b/ChartDemo/ChartCtrl/ChartXYSerie.h new file mode 100644 index 0000000..97af801 --- /dev/null +++ b/ChartDemo/ChartCtrl/ChartXYSerie.h @@ -0,0 +1,157 @@ +/* + * + * ChartXYSerie.h + * + * 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. + * + * + */ + +#pragma once +#include "ChartSerieBase.h" + +//! Structure containing a point data with X and Y values +struct SChartXYPoint +{ + SChartXYPoint() : X(0.0), Y(0.0) + { + #ifndef NO_USER_DATA + pUserData = NULL; + #endif + } + SChartXYPoint(double XVal, double YVal) : X(XVal), Y(YVal) + { + #ifndef NO_USER_DATA + pUserData = NULL; + #endif + } + + double GetX() const { return X; } + double GetY() const { return Y; } + double GetXMin() const { return X; } + double GetXMax() const { return X; } + double GetYMin() const { return Y; } + double GetYMax() const { return Y; } + + //! The point X value. + double X; + //! The point Y value. + double Y; + #ifndef NO_USER_DATA + //! Optional user data. + void *pUserData; + #endif +}; + +//! Specialization of a CChartSerieBase for series having data with an X and an Y value. +/** + This class is abstract and has to be implemented for specific series. It + already provides features which are common to all series with points having + an X and an Y value. Examples of such series are: point series, line series, + surface series and bar series. +**/ +class CChartXYSerie : public CChartSerieBase +{ +public: + //! Constructor + CChartXYSerie(CChartCtrl* pParent); + //! Destructor + virtual ~CChartXYSerie(); + + //! Adds a single data point to the series. + void AddPoint(double X, double Y); + //! Adds an array of points to the series. + /** + Points which were already present in the series are kept. + @param pX + Array of X values for the points + @param pY + Array of Y values for the points + @param Count + Size of each of both arrays (number of points to add) + **/ + void AddPoints(double* pX, double* pY, unsigned Count); + //! Sets an array of points to the series. + /** + Points which were already present in the series are discarded. + @param pX + Array of X values for the points + @param pY + Array of Y values for the points + @param Count + Size of each of both arrays (number of points to add) + **/ + void SetPoints(double* pX, double* pY, unsigned Count); + + //! Returns the Y value of a specific point in the series. + double GetYPointValue(unsigned PointIndex) const; + //! Returns the X value of a specific point in the series. + double GetXPointValue(unsigned PointIndex) const; + //! Sets the Y value of a specific point in the series. + /** + The control is refreshed to display the change. + @param PointIndex + The index of the points to change the Y value + @param NewVal + The new Y value of the point + **/ + void SetYPointValue(unsigned PointIndex, double NewVal); + //! Sets the X value of a specific point in the series. + /** + The control is refreshed to display the change. + @param PointIndex + The index of the points to change the Y value + @param NewVal + The new X value of the point + **/ + void SetXPointValue(unsigned PointIndex, double NewVal); + +#ifndef NO_USER_DATA + //! Sets user data for a specific point. + /** + User data can be disabled by adding the flag NO_USER_DATA in the preprocessor + definitions. This is usefull when you don't want to have an additional pointer + stored for each points in your series. + **/ + void SetUserData(unsigned uPointIndex, void* pData); + //! Retrieves user data for a specific point. + /** + User data can be disabled by adding the flag NO_USER_DATA in the preprocessor + definitions. This is usefull when you don't want to have an additional pointer + stored for each points in your series. + **/ + void* GetUserData(unsigned uPointIndex); +#endif + +protected: + //! Retrieves the control points of a bezier curve fitting the points stored in the array. + /** + @param uFirst + The index of the first point of the bezier curve + @param uLast + The index of the last point of the bezier curve + @param pKnots + This parameter will store the points data + @param pFirstControlPoints + This parameter will store the primary control points of the bezier curve + @param pSecondControlPoints + This parameter will store the secondary control points of the bezier curve + **/ + void GetBezierControlPoints(unsigned uFirst, unsigned uLast, SChartXYPoint* &pKnots, + SChartXYPoint* &pFirstControlPoints, SChartXYPoint* &pSecondControlPoints) const; + +private: + double* GetFirstControlPoints(double* rhs, int Count) const; +}; diff --git a/ChartDemo/ChartCtrl/PointsOrdering.h b/ChartDemo/ChartCtrl/PointsOrdering.h new file mode 100644 index 0000000..df6ee4c --- /dev/null +++ b/ChartDemo/ChartCtrl/PointsOrdering.h @@ -0,0 +1,33 @@ +/* + * + * PointOrdering.h + * + * 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. + * + * + */ + +#pragma once + +//! Enumeration listing the types of ordering. +enum PointsOrdering +{ + //! The points are not ordered + poNoOrdering, + //! The points are ordered by their X values + poXOrdering, + //! The points are ordered by their Y values + poYOrdering +}; diff --git a/ChartDemo/ChartDemo.cpp b/ChartDemo/ChartDemo.cpp new file mode 100644 index 0000000..322e4f3 --- /dev/null +++ b/ChartDemo/ChartDemo.cpp @@ -0,0 +1,76 @@ +// ChartDemo.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "ChartDemo.h" +#include "ChartDemoDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoApp + +BEGIN_MESSAGE_MAP(CChartDemoApp, CWinApp) + //{{AFX_MSG_MAP(CChartDemoApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoApp construction + +CChartDemoApp::CChartDemoApp() +{ + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CChartDemoApp object + +CChartDemoApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoApp initialization + +BOOL CChartDemoApp::InitInstance() +{ + AfxEnableControlContainer(); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#if _MFC_VER < 0x0700 + #ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL + #else + Enable3dControlsStatic(); // Call this when linking to MFC statically + #endif +#else + InitCommonControls(); + CWinApp::InitInstance(); +#endif + + CChartDemoDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + + } + else if (nResponse == IDCANCEL) + { + + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/ChartDemo/ChartDemo.dsp b/ChartDemo/ChartDemo.dsp new file mode 100644 index 0000000..2aeb5ee --- /dev/null +++ b/ChartDemo/ChartDemo.dsp @@ -0,0 +1,440 @@ +# Microsoft Developer Studio Project File - Name="ChartDemo" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=ChartDemo - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ChartDemo.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ChartDemo.mak" CFG="ChartDemo - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ChartDemo - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "ChartDemo - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ChartDemo - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "ChartCtrl" /I "ColourPicker" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c +# SUBTRACT CPP /Fr +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x40c /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x40c /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "ChartDemo - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "ChartCtrl" /I "ColourPicker" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x40c /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x40c /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "ChartDemo - Win32 Release" +# Name "ChartDemo - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\ChartDemo.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartDemoDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartSurfaceSerie.h +# End Source File +# Begin Source File + +SOURCE=.\LinePropDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\LinePropDialog.h +# End Source File +# Begin Source File + +SOURCE=.\PointsPropDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\PointsPropDialog.h +# End Source File +# Begin Source File + +SOURCE=.\SeriesPropDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\SurfacePropDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\SurfacePropDialog.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "rc2;rct;bin" +# Begin Group "Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\ChartDemo.ico +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ChartDemo.rc +# End Source File +# Begin Source File + +SOURCE=.\res\ChartDemo.rc2 +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\ChartDemo.h +# End Source File +# Begin Source File + +SOURCE=.\ChartDemoDlg.h +# End Source File +# Begin Source File + +SOURCE=.\SeriesPropDlg.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "ChartCtrl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\ChartCtrl\ChartAxis.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartAxis.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartAxisLabel.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartAxisLabel.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartBalloonLabel.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartBalloonLabel.inl +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartBarSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartBarSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCandlestickSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCandlestickSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCrossHairCursor.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCrossHairCursor.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCtrl.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCtrl.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCursor.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartCursor.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartDateTimeAxis.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartDateTimeAxis.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartDragLineCursor.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartDragLineCursor.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartFont.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartFont.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartGanttSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartGanttSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartGradient.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartGradient.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartGrid.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartGrid.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLabel.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLabel.inl +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLegend.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLegend.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLineSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLineSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLogarithmicAxis.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartLogarithmicAxis.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartMouseListener.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartPointsArray.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartPointsArray.inl +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartPointsSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartPointsSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartScrollBar.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartScrollBar.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSerieBase.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSerieBase.inl +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSeriesMouseListener.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartStandardAxis.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartStandardAxis.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartString.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSurfaceSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartSurfaceSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartTitle.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartTitle.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartXYSerie.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\ChartXYSerie.h +# End Source File +# Begin Source File + +SOURCE=.\ChartCtrl\PointsOrdering.h +# End Source File +# End Group +# Begin Group "ColourCtrl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\ColourPicker\ColourPicker.cpp +# End Source File +# Begin Source File + +SOURCE=.\ColourPicker\ColourPicker.h +# End Source File +# Begin Source File + +SOURCE=.\ColourPicker\ColourPopup.cpp +# End Source File +# Begin Source File + +SOURCE=.\ColourPicker\ColourPopup.h +# End Source File +# End Group +# End Target +# End Project diff --git a/ChartDemo/ChartDemo.dsw b/ChartDemo/ChartDemo.dsw new file mode 100644 index 0000000..a9346e3 --- /dev/null +++ b/ChartDemo/ChartDemo.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "ChartDemo"=".\ChartDemo.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/ChartDemo/ChartDemo.h b/ChartDemo/ChartDemo.h new file mode 100644 index 0000000..1e85e06 --- /dev/null +++ b/ChartDemo/ChartDemo.h @@ -0,0 +1,49 @@ +// ChartDemo.h : main header file for the CHARTDEMO application +// + +#if !defined(AFX_CHARTDEMO_H__B7735086_C0AE_4EB2_91AF_2AA128DA4EBD__INCLUDED_) +#define AFX_CHARTDEMO_H__B7735086_C0AE_4EB2_91AF_2AA128DA4EBD__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoApp: +// See ChartDemo.cpp for the implementation of this class +// + +class CChartDemoApp : public CWinApp +{ +public: + CChartDemoApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChartDemoApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CChartDemoApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHARTDEMO_H__B7735086_C0AE_4EB2_91AF_2AA128DA4EBD__INCLUDED_) diff --git a/ChartDemo/ChartDemo.rc b/ChartDemo/ChartDemo.rc new file mode 100644 index 0000000..504d47b --- /dev/null +++ b/ChartDemo/ChartDemo.rc @@ -0,0 +1,454 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Chinese (P.R.C.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "A propos de ChartDemo" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "ChartDemo version 1.0",IDC_STATIC,40,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2006",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP +END + +IDD_CHARTDEMO_DIALOG DIALOGEX 0, 0, 449, 543 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "ChartDemo" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "",IDC_CHARTCTRL,"ChartCtrl",WS_CLIPCHILDREN | + WS_TABSTOP,7,7,432,369 + GROUPBOX "Series",IDC_SERIES_GROUP,7,380,101,148 + LISTBOX IDC_SERIES_LIST,17,394,74,98,LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Add",IDC_ADDSERIES,17,500,37,14 + PUSHBUTTON "Delete",IDC_DELETESERIES,55,500,37,14 + GROUPBOX "General",IDC_GENERAL_GROUP,115,380,132,148 + LTEXT "Bkgnd color:",IDC_STATIC,123,397,41,8 + PUSHBUTTON "",IDC_BKGND_COLBTN,173,395,30,12 + CONTROL "Legend visible",IDC_LEGENDVIS_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,123,420,74,10 + LTEXT "Title:",IDC_STATIC,155,463,27,8 + EDITTEXT IDC_TITLE_EDIT,124,475,83,39,ES_CENTER | ES_MULTILINE | + ES_AUTOHSCROLL | ES_WANTRETURN + GROUPBOX "Axis",IDC_AXIS_GROUP,262,380,180,148 + CONTROL "Left",IDC_LEFTAXIS_RADIO,"Button",BS_AUTORADIOBUTTON, + 269,390,28,10 + CONTROL "Bottom",IDC_BOTTOMAXIS_RADIO,"Button", + BS_AUTORADIOBUTTON,308,390,38,10 + CONTROL "Right",IDC_RIGHTAXIS_RADIO,"Button",BS_AUTORADIOBUTTON, + 357,390,33,10 + CONTROL "Top",IDC_TOPAXIS_RADIO,"Button",BS_AUTORADIOBUTTON,401, + 390,29,10 + CONTROL "Visible",IDC_AXISVISIBLE_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,269,421,36,10 + CONTROL "Inverted",IDC_AXISINVERTED_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,320,421,50,10 + CONTROL "Automatic",IDC_AXISAUTOMATIC_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,377,421,53,10 + CONTROL "Grid",IDC_AXISGRIDVIS_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,269,441,29,10 + LTEXT "Axis min value:",IDC_AXISMINVAL_STATIC,280,462,63,8 + EDITTEXT IDC_AXISMINVAL_EDIT,355,460,40,14,ES_AUTOHSCROLL + LTEXT "Axis max value:",IDC_AXISMAXVAL_STATIC,278,481,63,8 + EDITTEXT IDC_AXISMAXVAL_EDIT,355,478,40,14,ES_AUTOHSCROLL + LTEXT "Label:",IDC_STATIC,286,502,25,8 + EDITTEXT IDC_AXISLABEL_EDIT,319,499,76,14,ES_AUTOHSCROLL + CONTROL "Pan",IDC_PAN_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,123,441,29,10 + CONTROL "Zoom",IDC_ZOOM_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,166,441,34,10 + CONTROL "ScrollBar",IDC_AXISSCROLLBAR_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,320,441,44,10 +END + +IDD_SERIESPROP_DLG DIALOG DISCARDABLE 0, 0, 449, 279 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Series properties" +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Series properties",IDC_STATIC,7,7,435,82 + LTEXT "Series type:",IDC_STATIC,45,25,66,8 + COMBOBOX IDC_SERIESTYPE_COMBO,123,23,62,54,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Series name:",IDC_STATIC,237,25,92,8 + EDITTEXT IDC_SERIESNAME_EDIT,341,22,63,14,ES_AUTOHSCROLL + LTEXT "Series colour:",IDC_STATIC,45,58,66,8 + PUSHBUTTON "",IDC_SERIESCOLOUR_BTN,123,55,38,14 + LTEXT "Associated vert axis:",IDC_STATIC,237,50,92,8 + COMBOBOX IDC_VERTICALAXIS_COMBO,341,48,48,49,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Associated horiz axis:",IDC_STATIC,237,67,92,8 + COMBOBOX IDC_HORIZONTALAXIS_COMBO,341,65,48,51,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Series Data",IDC_STATIC,7,102,435,139 + CONTROL "Line 一元一次方程",IDC_LINEDATA_RADIO,"Button", + BS_AUTORADIOBUTTON,50,119,88,10 + CONTROL "Sine wave 正弦曲线",IDC_SINEDATA_RADIO,"Button", + BS_AUTORADIOBUTTON,191,117,92,10 + CONTROL "Random data",IDC_RANDOMDATA_RADIO,"Button", + BS_AUTORADIOBUTTON,340,119,59,10 + RTEXT "Line Slope 斜率:",IDC_DATAPARAM1_TEXT,41,168,97,8 + EDITTEXT IDC_DATAPARAM1_EDIT,157,163,40,14,ES_AUTOHSCROLL + RTEXT "Line Offset 偏移量:",IDC_DATAPARAM2_TEXT,232,168,107,8 + EDITTEXT IDC_DATAPARAM2_EDIT,351,165,40,14,ES_AUTOHSCROLL + LTEXT "Number of points 点数量:",IDC_STATIC,41,205,97,8 + EDITTEXT IDC_POINTSNUMBER_EDIT,157,201,40,14,ES_AUTOHSCROLL | + ES_NUMBER + LTEXT "Minimum X value X的最小值:",IDC_STATIC,232,194,107,8 + EDITTEXT IDC_MINXVALUE_EDIT,351,191,29,14,ES_AUTOHSCROLL + LTEXT "Maximum X value X的最大值:",IDC_STATIC,232,215,107,8 + EDITTEXT IDC_MAXXVALUE_EDIT,351,212,29,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,7,258,50,14 + PUSHBUTTON "Cancel",IDCANCEL,392,258,50,14 +END + +IDD_LINEPROP_DLG DIALOG DISCARDABLE 0, 0, 216, 96 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Line series properties" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,82,75,50,14 + COMBOBOX IDC_PENSTYLE_COMBO,105,17,79,61,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Pen style:",IDC_STATIC,35,19,53,8 + LTEXT "Line width:",IDC_STATIC,35,41,53,8 + EDITTEXT IDC_LINEWIDTH_EDIT,105,38,40,14,ES_AUTOHSCROLL +END + +IDD_SURFACEPROP_DLG DIALOG DISCARDABLE 0, 0, 267, 98 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Surface series properties" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,108,77,50,14 + LTEXT "Fill style:",IDC_STATIC,39,20,69,8 + CONTROL "Horizontal surface",IDC_HORIZONTAL_RADIO,"Button", + BS_AUTORADIOBUTTON | WS_GROUP,30,46,92,10 + CONTROL "Vertical surface",IDC_RADIO2,"Button", + BS_AUTORADIOBUTTON,144,46,92,10 + COMBOBOX IDC_FILLSTYLE_COMBO,134,17,93,78,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP +END + +IDD_POINTPROP_DLG DIALOG DISCARDABLE 0, 0, 235, 101 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Points series properties" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,92,80,50,14 + LTEXT "Point type:",IDC_STATIC,34,16,53,8 + LTEXT "Point width:",IDC_STATIC,34,36,53,8 + LTEXT "Point height:",IDC_STATIC,34,56,53,8 + COMBOBOX IDC_POINTTYPE_COMBO,113,14,88,66,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_POINTWIDTH_EDIT,113,33,40,14,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_POINTHEIGHT_EDIT,113,53,40,14,ES_AUTOHSCROLL | + ES_NUMBER +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "Comments", "\0" + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Application MFC ChartDemo\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "ChartDemo\0" + VALUE "LegalCopyright", "Copyright (C) 2006\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "ChartDemo.EXE\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Application ChartDemo\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END + + IDD_CHARTDEMO_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 442 + TOPMARGIN, 7 + BOTTOMMARGIN, 536 + END + + IDD_SERIESPROP_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 442 + TOPMARGIN, 7 + BOTTOMMARGIN, 272 + END + + IDD_LINEPROP_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 209 + TOPMARGIN, 7 + BOTTOMMARGIN, 89 + END + + IDD_SURFACEPROP_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 260 + TOPMARGIN, 7 + BOTTOMMARGIN, 91 + END + + IDD_POINTPROP_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 94 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog Info +// + +IDD_SERIESPROP_DLG DLGINIT +BEGIN + IDC_SERIESTYPE_COMBO, 0x403, 5, 0 +0x694c, 0x656e, "\000" + IDC_SERIESTYPE_COMBO, 0x403, 7, 0 +0x6f50, 0x6e69, 0x7374, "\000" + IDC_SERIESTYPE_COMBO, 0x403, 8, 0 +0x7553, 0x6672, 0x6361, 0x0065, + IDC_VERTICALAXIS_COMBO, 0x403, 5, 0 +0x654c, 0x7466, "\000" + IDC_VERTICALAXIS_COMBO, 0x403, 6, 0 +0x6952, 0x6867, 0x0074, + IDC_HORIZONTALAXIS_COMBO, 0x403, 7, 0 +0x6f42, 0x7474, 0x6d6f, "\000" + IDC_HORIZONTALAXIS_COMBO, 0x403, 4, 0 +0x6f54, 0x0070, + 0 +END + +IDD_LINEPROP_DLG DLGINIT +BEGIN + IDC_PENSTYLE_COMBO, 0x403, 11, 0 +0x6f53, 0x696c, 0x2064, 0xb5ca, 0xdfcf, "\000" + IDC_PENSTYLE_COMBO, 0x403, 10, 0 +0x6144, 0x6873, 0xd020, 0xcfe9, 0x00df, + IDC_PENSTYLE_COMBO, 0x403, 9, 0 +0x6f44, 0x2074, 0xe3b5, 0xdfcf, "\000" + IDC_PENSTYLE_COMBO, 0x403, 16, 0 +0x6144, 0x6873, 0x442d, 0x746f, 0xb520, 0xbbe3, 0xcfae, 0x00df, + IDC_PENSTYLE_COMBO, 0x403, 20, 0 +0x6144, 0x6873, 0x442d, 0x746f, 0x442d, 0x746f, 0xb520, 0xbbe3, 0xcfae, +0x00df, + 0 +END + +IDD_SURFACEPROP_DLG DLGINIT +BEGIN + IDC_FILLSTYLE_COMBO, 0x403, 6, 0 +0x6f53, 0x696c, 0x0064, + IDC_FILLSTYLE_COMBO, 0x403, 20, 0 +0x6148, 0x6374, 0x2068, 0x6f64, 0x6e77, 0x6420, 0x6169, 0x6f67, 0x616e, +0x006c, + IDC_FILLSTYLE_COMBO, 0x403, 18, 0 +0x6148, 0x6374, 0x2068, 0x7075, 0x6420, 0x6169, 0x6f67, 0x616e, 0x006c, + + IDC_FILLSTYLE_COMBO, 0x403, 12, 0 +0x6148, 0x6374, 0x2068, 0x7263, 0x736f, 0x0073, + IDC_FILLSTYLE_COMBO, 0x403, 22, 0 +0x6148, 0x6374, 0x2068, 0x7263, 0x736f, 0x2073, 0x6964, 0x6761, 0x6e6f, +0x6c61, 0x0020, + IDC_FILLSTYLE_COMBO, 0x403, 17, 0 +0x6148, 0x6374, 0x2068, 0x6f68, 0x6972, 0x6f7a, 0x746e, 0x6c61, "\000" + IDC_FILLSTYLE_COMBO, 0x403, 15, 0 +0x6148, 0x6374, 0x2068, 0x6576, 0x7472, 0x6369, 0x6c61, "\000" + 0 +END + +IDD_POINTPROP_DLG DLGINIT +BEGIN + IDC_POINTTYPE_COMBO, 0x403, 8, 0 +0x6c45, 0x696c, 0x7370, 0x0065, + IDC_POINTTYPE_COMBO, 0x403, 10, 0 +0x6552, 0x7463, 0x6e61, 0x6c67, 0x0065, + IDC_POINTTYPE_COMBO, 0x403, 9, 0 +0x7254, 0x6169, 0x676e, 0x656c, "\000" + 0 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_ABOUTBOX "&A propos de ChartDemo..." +END + +#endif // Chinese (P.R.C.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE MOVEABLE PURE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE MOVEABLE PURE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE MOVEABLE PURE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 12, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\ChartDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""l.fra\\afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\ChartDemo.ico" +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE 12, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\ChartDemo.rc2" // non-Microsoft Visual C++ edited resources +#include "l.fra\afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ChartDemo/ChartDemo.sln b/ChartDemo/ChartDemo.sln new file mode 100644 index 0000000..956c631 --- /dev/null +++ b/ChartDemo/ChartDemo.sln @@ -0,0 +1,20 @@ +锘 +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChartDemo", "ChartDemo.vcproj", "{EFDCE8CF-7F5A-4BC4-A320-93563E1D0AF7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EFDCE8CF-7F5A-4BC4-A320-93563E1D0AF7}.Debug|Win32.ActiveCfg = Debug|Win32 + {EFDCE8CF-7F5A-4BC4-A320-93563E1D0AF7}.Debug|Win32.Build.0 = Debug|Win32 + {EFDCE8CF-7F5A-4BC4-A320-93563E1D0AF7}.Release|Win32.ActiveCfg = Release|Win32 + {EFDCE8CF-7F5A-4BC4-A320-93563E1D0AF7}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ChartDemo/ChartDemo.vcproj b/ChartDemo/ChartDemo.vcproj new file mode 100644 index 0000000..6e40d50 --- /dev/null +++ b/ChartDemo/ChartDemo.vcproj @@ -0,0 +1,656 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ChartDemo/ChartDemoDlg.cpp b/ChartDemo/ChartDemoDlg.cpp new file mode 100644 index 0000000..705de05 --- /dev/null +++ b/ChartDemo/ChartDemoDlg.cpp @@ -0,0 +1,751 @@ +// ChartDemoDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "ChartDemo.h" +#include "ChartDemoDlg.h" + +#include "ChartLineSerie.h" +#include "ChartPointsSerie.h" +#include "ChartSurfaceSerie.h" +#include "ChartGrid.h" + +#include "SeriesPropDlg.h" +#include "LinePropDialog.h" +#include "SurfacePropDialog.h" +#include "PointsPropDialog.h" + +#include "ChartBarSerie.h" +#include "ChartLabel.h" + +#include "ChartAxisLabel.h" +#include "ChartStandardAxis.h" +#include "ChartDateTimeAxis.h" + +#include "ChartCrossHairCursor.h" +#include "ChartDragLineCursor.h" + +#include +#include +#include +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +using namespace std; + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoDlg dialog + +CChartDemoDlg::CChartDemoDlg(CWnd* pParent /*=NULL*/) + : CDialog(CChartDemoDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CChartDemoDlg) + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void CChartDemoDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CChartDemoDlg) + DDX_Control(pDX, IDC_TITLE_EDIT, m_TitlesEdit); + DDX_Control(pDX, IDC_SERIES_LIST, m_SeriesList); + DDX_Control(pDX, IDC_AXISMINVAL_EDIT, m_AxisMinValEdit); + DDX_Control(pDX, IDC_AXISMAXVAL_EDIT, m_AxisMaxValEdit); + DDX_Control(pDX, IDC_LEGENDVIS_CHECK, m_LegendVisBtn); + DDX_Control(pDX, IDC_BKGND_COLBTN, m_BackgndColSel); + DDX_Control(pDX, IDC_CHARTCTRL, m_ChartCtrl); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CChartDemoDlg, CDialog) + //{{AFX_MSG_MAP(CChartDemoDlg) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_ADDSERIES, OnAddseries) + ON_BN_CLICKED(IDC_LEGENDVIS_CHECK, OnLegendVisible) + ON_BN_CLICKED(IDC_BOTTOMAXIS_RADIO, OnBottomAxisRadio) + ON_BN_CLICKED(IDC_LEFTAXIS_RADIO, OnLeftAxisRadio) + ON_BN_CLICKED(IDC_RIGHTAXIS_RADIO, OnRightAxisRadio) + ON_BN_CLICKED(IDC_TOPAXIS_RADIO, OnTopAxisRadio) + ON_BN_CLICKED(IDC_AXISAUTOMATIC_CHECK, OnAxisAutomaticCheck) + ON_BN_CLICKED(IDC_AXISGRIDVIS_CHECK, OnAxisGridVisCheck) + ON_BN_CLICKED(IDC_AXISVISIBLE_CHECK, OnAxisVisibleCheck) + ON_BN_CLICKED(IDC_AXISSCROLLBAR_CHECK, OnAxisScrollBarCheck) + ON_MESSAGE(CPN_SELENDOK, OnChangeBckCol) + ON_EN_KILLFOCUS(IDC_AXISMAXVAL_EDIT, OnChangeAxisMax) + ON_EN_KILLFOCUS(IDC_AXISMINVAL_EDIT, OnChangeAxisMin) + ON_BN_CLICKED(IDC_AXISINVERTED_CHECK, OnAxisInvertedCheck) + ON_EN_KILLFOCUS(IDC_AXISLABEL_EDIT, OnChangeAxisLabel) + ON_BN_CLICKED(IDC_DELETESERIES, OnDeleteSeries) + ON_EN_KILLFOCUS(IDC_TITLE_EDIT, OnChangeTitle) + ON_BN_CLICKED(IDC_PAN_CHECK, OnPanCheck) + ON_BN_CLICKED(IDC_ZOOM_CHECK, OnZoomCheck) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoDlg message handlers + +BOOL CChartDemoDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Add "About..." menu item to system menu. + + // IDM_ABOUTBOX must be in the system command range. + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != NULL) + { + CString strAboutMenu; + strAboutMenu.LoadString(IDS_ABOUTBOX); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + COLORREF BackColor = 0x00eeeeaf; + m_BackgndColSel.SetColour(BackColor); + m_ChartCtrl.SetBackColor(BackColor); + + ((CButton*)GetDlgItem(IDC_LEFTAXIS_RADIO))->SetCheck(1); + ((CButton*)GetDlgItem(IDC_PAN_CHECK))->SetCheck(1); + ((CButton*)GetDlgItem(IDC_ZOOM_CHECK))->SetCheck(1); + + CChartStandardAxis* pBottomAxis = + m_ChartCtrl.CreateStandardAxis(CChartCtrl::BottomAxis); + pBottomAxis->SetMinMax(0, 10); + CChartStandardAxis* pLeftAxis = + m_ChartCtrl.CreateStandardAxis(CChartCtrl::LeftAxis); + pLeftAxis->SetMinMax(0, 10); + CChartStandardAxis* pTopAxis = + m_ChartCtrl.CreateStandardAxis(CChartCtrl::TopAxis); + pTopAxis->SetMinMax(0, 10); + CChartStandardAxis* pRightAxis = + m_ChartCtrl.CreateStandardAxis(CChartCtrl::RightAxis); + pRightAxis->SetMinMax(0, 10); + + OnLeftAxisRadio(); + return TRUE; // return TRUE unless you set the focus to a control +} + +void CChartDemoDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialog::OnSysCommand(nID, lParam); + } +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void CChartDemoDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CChartDemoDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + + +void CChartDemoDlg::OnAddseries() +{ + CSeriesPropDlg PropertiesDlg; + if (PropertiesDlg.DoModal() == IDCANCEL) + return; + + int Type = PropertiesDlg.m_iSeriesType; + TChartString Name = PropertiesDlg.m_strSeriesName; + COLORREF Color = PropertiesDlg.m_SeriesColour; + + CChartXYSerie* pSeries = NULL; + INT_PTR nPropDlgRet = -1; + switch (Type) + { + // Line series + case 0: + { + bool bSecondHorizAxis = (PropertiesDlg.m_iHorizAxis == 1); + bool bSecondVertAxis = (PropertiesDlg.m_iVertAxis == 1); + CChartLineSerie* pLineSeries = m_ChartCtrl.CreateLineSerie(bSecondHorizAxis, bSecondVertAxis); + pSeries = pLineSeries; + + CLinePropDialog LinePropDlg; + nPropDlgRet = LinePropDlg.DoModal(); + + pLineSeries->SetWidth(LinePropDlg.m_iLineWidth); + pLineSeries->SetPenStyle(LinePropDlg.m_iPenStyle); + } + break; + + // Points series + case 1: + { + bool bSecondHorizAxis = (PropertiesDlg.m_iHorizAxis == 1); + bool bSecondVertAxis = (PropertiesDlg.m_iVertAxis == 1); + CChartPointsSerie* pPointsSeries = m_ChartCtrl.CreatePointsSerie(bSecondHorizAxis, bSecondVertAxis); + pSeries = pPointsSeries; + + CPointsPropDialog PointsPropDlg; + nPropDlgRet = PointsPropDlg.DoModal(); + + switch (PointsPropDlg.m_iPointsType) + { + case 0: + pPointsSeries->SetPointType(CChartPointsSerie::ptEllipse); + break; + + case 1: + pPointsSeries->SetPointType(CChartPointsSerie::ptRectangle); + break; + + case 2: + pPointsSeries->SetPointType(CChartPointsSerie::ptTriangle); + break; + } + + pPointsSeries->SetPointSize(PointsPropDlg.m_iPointsWidth,PointsPropDlg.m_iPointsHeight); + } + break; + + // Surface series + case 2: + { + bool bSecondHorizAxis = (PropertiesDlg.m_iHorizAxis == 1); + bool bSecondVertAxis = (PropertiesDlg.m_iVertAxis == 1); + CChartSurfaceSerie* pSurfSeries = m_ChartCtrl.CreateSurfaceSerie(bSecondHorizAxis, bSecondVertAxis); + pSeries = pSurfSeries; + + CSurfacePropDialog SurfPropDlg; + nPropDlgRet = SurfPropDlg.DoModal(); + + switch (SurfPropDlg.m_FillStyle) + { + case 0: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsSolid); + break; + case 1: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsHatchDownDiag); + break; + case 2: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsHatchUpDiag); + break; + case 3: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsHatchCross); + break; + case 4: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsHatchDiagCross); + break; + case 5: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsHatchHorizontal); + break; + case 6: + pSurfSeries->SetFillStyle(CChartSurfaceSerie::fsHatchVertical); + break; + } + + if (SurfPropDlg.m_iHorizSurf == 0) + pSurfSeries->SetHorizontal(true); + else + pSurfSeries->SetHorizontal(false); + } + break; + } + + if(nPropDlgRet ==IDCANCEL){ + return; + } + + pSeries->SetName(Name); + pSeries->SetColor(Color); + + int NumberPoints = PropertiesDlg.m_iPointsNumber; + double* XValues = new double[NumberPoints]; + double* YValues = new double[NumberPoints]; + float Step = (PropertiesDlg.m_fMaxXValue - PropertiesDlg.m_fMinXValue)/(NumberPoints - 1); + float XStart = PropertiesDlg.m_fMinXValue; + switch (PropertiesDlg.m_iDataType) + { + case 0: + { + float Slope = PropertiesDlg.m_fLineSlope; + float Offset = PropertiesDlg.m_fLineOffset; + + for (int i=0;iSetPoints(XValues,YValues,NumberPoints); + + } + break; + + case 1: + { + float Amplitude = PropertiesDlg.m_fSineAmplitude; + float Period = PropertiesDlg.m_fSinePeriod; + + for (int i=0;iSetPoints(XValues,YValues,NumberPoints); + } + break; + + case 2: + { + int Min = PropertiesDlg.m_iRandMinVal; + int Max = PropertiesDlg.m_iRandMaxVal; + srand((unsigned int)time(NULL)); + for (int i=0;iSetPoints(XValues,YValues,NumberPoints); + } + break; + } + + delete[] XValues; + delete[] YValues; + m_ChartCtrl.RefreshCtrl(); + int index = m_SeriesList.AddString(Name.c_str()); + m_SeriesList.SetItemData(index, pSeries->GetSerieId()); +} + +void CChartDemoDlg::OnLegendVisible() +{ + if (m_LegendVisBtn.GetCheck() == 1) + m_ChartCtrl.GetLegend()->SetVisible(true); + else + m_ChartCtrl.GetLegend()->SetVisible(false); + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnBottomAxisRadio() +{ + CChartAxis* pAxis = m_ChartCtrl.GetBottomAxis(); + if (pAxis->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(0); + if (pAxis->GetGrid()->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(0); + if (pAxis->IsAutomatic()) + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(0); + if (pAxis->IsInverted()) + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(0); + if (pAxis->ScrollBarEnabled()) + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(0); + + TChartString AxisLabel = pAxis->GetLabel()->GetText(); + GetDlgItem(IDC_AXISLABEL_EDIT)->SetWindowText(AxisLabel.c_str()); + + double Min=0, Max=0; + CString strBuff; + pAxis->GetMinMax(Min,Max); + strBuff.Format(_T("%.2f"),Min); + GetDlgItem(IDC_AXISMINVAL_EDIT)->SetWindowText(strBuff); + strBuff.Format(_T("%.2f"),Max); + GetDlgItem(IDC_AXISMAXVAL_EDIT)->SetWindowText(strBuff); +} + +void CChartDemoDlg::OnLeftAxisRadio() +{ + CChartAxis* pAxis = m_ChartCtrl.GetLeftAxis(); + if (pAxis->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(0); + if (pAxis->GetGrid()->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(0); + if (pAxis->IsAutomatic()) + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(0); + if (pAxis->IsInverted()) + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(0); + if (pAxis->ScrollBarEnabled()) + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(0); + + TChartString AxisLabel = pAxis->GetLabel()->GetText(); + GetDlgItem(IDC_AXISLABEL_EDIT)->SetWindowText(AxisLabel.c_str()); + + double Min=0, Max=0; + CString strBuff; + pAxis->GetMinMax(Min,Max); + strBuff.Format(_T("%.2f"),Min); + GetDlgItem(IDC_AXISMINVAL_EDIT)->SetWindowText(strBuff); + strBuff.Format(_T("%.2f"),Max); + GetDlgItem(IDC_AXISMAXVAL_EDIT)->SetWindowText(strBuff); +} + +void CChartDemoDlg::OnRightAxisRadio() +{ + CChartAxis* pAxis = m_ChartCtrl.GetRightAxis(); + if (pAxis->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(0); + if (pAxis->GetGrid()->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(0); + if (pAxis->IsAutomatic()) + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(0); + if (pAxis->IsInverted()) + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(0); + if (pAxis->ScrollBarEnabled()) + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(0); + + TChartString AxisLabel = pAxis->GetLabel()->GetText(); + GetDlgItem(IDC_AXISLABEL_EDIT)->SetWindowText(AxisLabel.c_str()); + + double Min=0, Max=0; + CString strBuff; + pAxis->GetMinMax(Min,Max); + strBuff.Format(_T("%.2f"),Min); + GetDlgItem(IDC_AXISMINVAL_EDIT)->SetWindowText(strBuff); + strBuff.Format(_T("%.2f"),Max); + GetDlgItem(IDC_AXISMAXVAL_EDIT)->SetWindowText(strBuff); +} + +void CChartDemoDlg::OnTopAxisRadio() +{ + CChartAxis* pAxis = m_ChartCtrl.GetTopAxis(); + if (pAxis->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(0); + if (pAxis->GetGrid()->IsVisible()) + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(0); + if (pAxis->IsAutomatic()) + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(0); + if (pAxis->IsInverted()) + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(0); + if (pAxis->ScrollBarEnabled()) + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(1); + else + ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(0); + + TChartString AxisLabel = pAxis->GetLabel()->GetText(); + GetDlgItem(IDC_AXISLABEL_EDIT)->SetWindowText(AxisLabel.c_str()); + + double Min=0, Max=0; + CString strBuff; + pAxis->GetMinMax(Min,Max); + strBuff.Format(_T("%.2f"),Min); + GetDlgItem(IDC_AXISMINVAL_EDIT)->SetWindowText(strBuff); + strBuff.Format(_T("%.2f"),Max); + GetDlgItem(IDC_AXISMAXVAL_EDIT)->SetWindowText(strBuff); +} + +void CChartDemoDlg::OnAxisAutomaticCheck() +{ + CChartAxis* pAxis = GetSelectedAxis(); + if ( ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->GetCheck() == 1) + pAxis->SetAutomatic(true); + else + { + TCHAR szBuffer[255]; + double MinVal=0, MaxVal=0; + m_AxisMinValEdit.GetWindowText(szBuffer,254); +// MinVal = _tstof(szBuffer); + MinVal = _tcstod(szBuffer, NULL); + m_AxisMaxValEdit.GetWindowText(szBuffer,254); +// MaxVal = _tstof(szBuffer); + MaxVal = _tcstod(szBuffer, NULL); + + if (MinVal > MaxVal) + { + MessageBox(_T("MinVal > MaxVal"),_T("Error"),MB_OK); + ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1); + return; + } + pAxis->SetAutomatic(false); + pAxis->SetMinMax(MinVal,MaxVal); + } + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnAxisGridVisCheck() +{ + CChartAxis* pAxis = GetSelectedAxis(); + if ( ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->GetCheck() == 1) + pAxis->GetGrid()->SetVisible(true); + else + pAxis->GetGrid()->SetVisible(false); + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnAxisVisibleCheck() +{ + CChartAxis* pAxis = GetSelectedAxis(); + if ( ((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->GetCheck() == 1) + pAxis->SetVisible(true); + else + pAxis->SetVisible(false); + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnAxisInvertedCheck() +{ + CChartAxis* pAxis = GetSelectedAxis(); + if ( ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->GetCheck() == 1) + pAxis->SetInverted(true); + else + pAxis->SetInverted(false); + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnAxisScrollBarCheck() +{ + CChartAxis* pAxis = GetSelectedAxis(); + bool bShow = ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->GetCheck() == 1; + pAxis->EnableScrollBar(bShow); +} + +CChartAxis* CChartDemoDlg::GetSelectedAxis() +{ + if ( ((CButton*)GetDlgItem(IDC_LEFTAXIS_RADIO))->GetCheck() == 1) + return m_ChartCtrl.GetLeftAxis(); + if ( ((CButton*)GetDlgItem(IDC_BOTTOMAXIS_RADIO))->GetCheck() == 1) + return m_ChartCtrl.GetBottomAxis(); + if ( ((CButton*)GetDlgItem(IDC_RIGHTAXIS_RADIO))->GetCheck() == 1) + return m_ChartCtrl.GetRightAxis(); + if ( ((CButton*)GetDlgItem(IDC_TOPAXIS_RADIO))->GetCheck() == 1) + return m_ChartCtrl.GetTopAxis(); + + return NULL; +} + +LONG CChartDemoDlg::OnChangeBckCol(UINT , LONG ) +{ + COLORREF BackColor = m_BackgndColSel.GetColour(); + m_ChartCtrl.SetBackColor(BackColor); + m_ChartCtrl.RefreshCtrl(); + return TRUE; +} + +void CChartDemoDlg::OnChangeAxisMax() +{ + CChartAxis* pAxis = GetSelectedAxis(); + TCHAR szBuffer[255]; + double MinVal=0, MaxVal=0; + m_AxisMinValEdit.GetWindowText(szBuffer,254); +// MinVal = _tstof(szBuffer); + MinVal = _tcstod(szBuffer, NULL); + m_AxisMaxValEdit.GetWindowText(szBuffer,254); +// MaxVal = _tstof(szBuffer); + MaxVal = _tcstod(szBuffer, NULL); + + if (MinVal > MaxVal) + { + MessageBox(_T("MinVal > MaxVal"),_T("Error"),MB_OK); + return; + } + pAxis->SetMinMax(MinVal,MaxVal); + + m_ChartCtrl.RefreshCtrl(); + +} + +void CChartDemoDlg::OnChangeAxisMin() +{ + CChartAxis* pAxis = GetSelectedAxis(); + TCHAR szBuffer[255]; + double MinVal=0, MaxVal=0; + m_AxisMinValEdit.GetWindowText(szBuffer,254); +// MinVal = _tstof(szBuffer); + MinVal = _tcstod(szBuffer, NULL); + m_AxisMaxValEdit.GetWindowText(szBuffer,254); +// MaxVal = _tstof(szBuffer); + MaxVal = _tcstod(szBuffer, NULL); + + if (MinVal > MaxVal) + { + MessageBox(_T("MinVal > MaxVal"),_T("Error"),MB_OK); + return; + } + pAxis->SetMinMax(MinVal,MaxVal); + + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnChangeAxisLabel() +{ + CChartAxis* pAxis = GetSelectedAxis(); + TCHAR szBuffer[255]; + GetDlgItem(IDC_AXISLABEL_EDIT)->GetWindowText(szBuffer,254); + pAxis->GetLabel()->SetText(szBuffer); + m_ChartCtrl.RefreshCtrl(); + +} + +void CChartDemoDlg::OnDeleteSeries() +{ + int Index = m_SeriesList.GetCurSel(); + if (Index == -1) + return; + unsigned seriesId = m_SeriesList.GetItemData(Index); + + m_ChartCtrl.RemoveSerie(seriesId); + m_SeriesList.DeleteString(Index); +} + +void CChartDemoDlg::OnChangeTitle() +{ + int Count = m_TitlesEdit.GetLineCount(); + CChartTitle* pTitle = m_ChartCtrl.GetTitle(); + pTitle->RemoveAll(); + + TCHAR szBuff[255]; + for (int i=0;iAddString(szBuff); + } + + m_ChartCtrl.RefreshCtrl(); +} + +void CChartDemoDlg::OnPanCheck() +{ + if ( ((CButton*)GetDlgItem(IDC_PAN_CHECK))->GetCheck() == 1) + m_ChartCtrl.SetPanEnabled(true); + else + m_ChartCtrl.SetPanEnabled(false); + +} + +void CChartDemoDlg::OnZoomCheck() +{ + if ( ((CButton*)GetDlgItem(IDC_ZOOM_CHECK))->GetCheck() == 1) + m_ChartCtrl.SetZoomEnabled(true); + else + m_ChartCtrl.SetZoomEnabled(false); +} \ No newline at end of file diff --git a/ChartDemo/ChartDemoDlg.h b/ChartDemo/ChartDemoDlg.h new file mode 100644 index 0000000..6b67596 --- /dev/null +++ b/ChartDemo/ChartDemoDlg.h @@ -0,0 +1,82 @@ +// ChartDemoDlg.h : header file +// + +#if !defined(AFX_CHARTDEMODLG_H__1C3B17D7_0821_47FC_B873_9D9337728F79__INCLUDED_) +#define AFX_CHARTDEMODLG_H__1C3B17D7_0821_47FC_B873_9D9337728F79__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChartCtrl.h" +#include "ColourPicker.h" +#include "ChartLineSerie.h" + +///////////////////////////////////////////////////////////////////////////// +// CChartDemoDlg dialog + +class CChartDemoDlg : public CDialog +{ +// Construction +public: + CChartDemoDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CChartDemoDlg) + enum { IDD = IDD_CHARTDEMO_DIALOG }; + CEdit m_TitlesEdit; + CListBox m_SeriesList; + CEdit m_AxisMinValEdit; + CEdit m_AxisMaxValEdit; + CButton m_LegendVisBtn; + CColourPicker m_BackgndColSel; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChartDemoDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + HICON m_hIcon; + + // Generated message map functions + //{{AFX_MSG(CChartDemoDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnAddseries(); + afx_msg void OnLegendVisible(); + afx_msg void OnBottomAxisRadio(); + afx_msg void OnLeftAxisRadio(); + afx_msg void OnRightAxisRadio(); + afx_msg void OnTopAxisRadio(); + afx_msg void OnAxisAutomaticCheck(); + afx_msg void OnAxisGridVisCheck(); + afx_msg void OnAxisVisibleCheck(); + afx_msg void OnAxisScrollBarCheck(); + afx_msg LONG OnChangeBckCol(UINT lParam, LONG wParam); + afx_msg void OnChangeAxisMax(); + afx_msg void OnChangeAxisMin(); + afx_msg void OnAxisInvertedCheck(); + afx_msg void OnChangeAxisLabel(); + afx_msg void OnDeleteSeries(); + afx_msg void OnChangeTitle(); + afx_msg void OnPanCheck(); + afx_msg void OnZoomCheck(); + afx_msg void OnSaveImage(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + CChartAxis* GetSelectedAxis(); + + CChartCtrl m_ChartCtrl; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHARTDEMODLG_H__1C3B17D7_0821_47FC_B873_9D9337728F79__INCLUDED_) diff --git a/ChartDemo/ColourPicker/ColourPicker.cpp b/ChartDemo/ColourPicker/ColourPicker.cpp new file mode 100644 index 0000000..35a7ce7 --- /dev/null +++ b/ChartDemo/ColourPicker/ColourPicker.cpp @@ -0,0 +1,309 @@ +// ColourPicker.cpp : implementation file +// +// ColourPicker is a drop-in colour picker control. Check out the +// header file or the accompanying HTML doc file for details. +// +// Written by Chris Maunder (chrismaunder@codeguru.com) +// Extended by Alexander Bischofberger (bischofb@informatik.tu-muenchen.de) +// Copyright (c) 1998. +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name is included. If +// the source code in this file is used in any commercial application +// then a simple email would be nice. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability if it causes any damage to your +// computer, causes your pet cat to fall ill, increases baldness or +// makes you car start emitting strange noises when you start it up. +// +// Expect bugs. +// +// Please use and enjoy. Please let me know of any bugs/mods/improvements +// that you have found/implemented and I will fix/incorporate them into this +// file. +// +// Updated 16 May 1998 +// 31 May 1998 - added Default text (CJM) +// 9 Jan 1999 - minor vis update + +#include "stdafx.h" +#include "ColourPopup.h" +#include "ColourPicker.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +void AFXAPI DDX_ColourPicker(CDataExchange *pDX, int nIDC, COLORREF& crColour) +{ + HWND hWndCtrl = pDX->PrepareCtrl(nIDC); + ASSERT (hWndCtrl != NULL); + + CColourPicker* pColourPicker = (CColourPicker*) CWnd::FromHandle(hWndCtrl); + if (pDX->m_bSaveAndValidate) + { + crColour = pColourPicker->GetColour(); + } + else // initializing + { + pColourPicker->SetColour(crColour); + } +} + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker + +CColourPicker::CColourPicker() +{ + SetBkColour(GetSysColor(COLOR_3DFACE)); + SetTextColour(GetSysColor(COLOR_BTNTEXT)); + + m_bTrackSelection = FALSE; + m_nSelectionMode = CP_MODE_BK; + m_bActive = FALSE; + + m_strDefaultText = _T("Automatic"); + m_strCustomText = _T("More Colours..."); +} + +CColourPicker::~CColourPicker() +{ +} + +IMPLEMENT_DYNCREATE(CColourPicker, CButton) + +BEGIN_MESSAGE_MAP(CColourPicker, CButton) + //{{AFX_MSG_MAP(CColourPicker) + ON_CONTROL_REFLECT_EX(BN_CLICKED, OnClicked) + ON_WM_CREATE() + //}}AFX_MSG_MAP + ON_MESSAGE(CPN_SELENDOK, OnSelEndOK) + ON_MESSAGE(CPN_SELENDCANCEL, OnSelEndCancel) + ON_MESSAGE(CPN_SELCHANGE, OnSelChange) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker message handlers + +LONG CColourPicker::OnSelEndOK(UINT lParam, LONG /*wParam*/) +{ + COLORREF crNewColour = (COLORREF) lParam; + m_bActive = FALSE; + SetColour(crNewColour); + + CWnd *pParent = GetParent(); + if (pParent) { + pParent->SendMessage(CPN_CLOSEUP, lParam, (WPARAM) GetDlgCtrlID()); + pParent->SendMessage(CPN_SELENDOK, lParam, (WPARAM) GetDlgCtrlID()); + } + + if (crNewColour != GetColour()) + if (pParent) pParent->SendMessage(CPN_SELCHANGE, lParam, (WPARAM) GetDlgCtrlID()); + + return TRUE; +} + +LONG CColourPicker::OnSelEndCancel(UINT lParam, LONG /*wParam*/) +{ + m_bActive = FALSE; + SetColour((COLORREF) lParam); + + CWnd *pParent = GetParent(); + if (pParent) { + pParent->SendMessage(CPN_CLOSEUP, lParam, (WPARAM) GetDlgCtrlID()); + pParent->SendMessage(CPN_SELENDCANCEL, lParam, (WPARAM) GetDlgCtrlID()); + } + + return TRUE; +} + +LONG CColourPicker::OnSelChange(UINT lParam, LONG /*wParam*/) +{ + if (m_bTrackSelection) SetColour((COLORREF) lParam); + + CWnd *pParent = GetParent(); + if (pParent) pParent->SendMessage(CPN_SELCHANGE, lParam, (WPARAM) GetDlgCtrlID()); + + return TRUE; +} + +int CColourPicker::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CButton::OnCreate(lpCreateStruct) == -1) + return -1; + + SetWindowSize(); // resize appropriately + return 0; +} + +// On mouse click, create and show a CColourPopup window for colour selection +BOOL CColourPicker::OnClicked() +{ + m_bActive = TRUE; + CRect rect; + GetWindowRect(rect); + new CColourPopup(CPoint(rect.left, rect.bottom), // Point to display popup + GetColour(), // Selected colour + this, // parent + m_strDefaultText, // "Default" text area + m_strCustomText); // Custom Text + + CWnd *pParent = GetParent(); + if (pParent) + pParent->SendMessage(CPN_DROPDOWN, (LPARAM)GetColour(), (WPARAM) GetDlgCtrlID()); + + // Docs say I should return FALSE to stop the parent also getting the message. + // HA! What a joke. + + return TRUE; +} + +void CColourPicker::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + ASSERT(lpDrawItemStruct); + + CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + CRect rect = lpDrawItemStruct->rcItem; + UINT state = lpDrawItemStruct->itemState; + CString m_strText; + + CSize Margins(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE)); + + // Draw arrow + if (m_bActive) state |= ODS_SELECTED; + pDC->DrawFrameControl(&m_ArrowRect, DFC_SCROLL, DFCS_SCROLLDOWN | + ((state & ODS_SELECTED) ? DFCS_PUSHED : 0) | + ((state & ODS_DISABLED) ? DFCS_INACTIVE : 0)); + + pDC->DrawEdge(rect, EDGE_SUNKEN, BF_RECT); + + // Must reduce the size of the "client" area of the button due to edge thickness. + rect.DeflateRect(Margins.cx, Margins.cy); + + // Fill remaining area with colour + rect.right -= m_ArrowRect.Width(); + + CBrush brush( ((state & ODS_DISABLED) || m_crColourBk == CLR_DEFAULT)? + ::GetSysColor(COLOR_3DFACE) : m_crColourBk); + CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush); + pDC->SelectStockObject(NULL_PEN); + pDC->Rectangle(rect); + pDC->SelectObject(pOldBrush); + + // Draw the window text (if any) + GetWindowText(m_strText); + if (m_strText.GetLength()) + { + pDC->SetBkMode(TRANSPARENT); + if (state & ODS_DISABLED) + { + rect.OffsetRect(1,1); + pDC->SetTextColor(::GetSysColor(COLOR_3DHILIGHT)); + pDC->DrawText(m_strText, rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER); + rect.OffsetRect(-1,-1); + pDC->SetTextColor(::GetSysColor(COLOR_3DSHADOW)); + pDC->DrawText(m_strText, rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER); + } + else + { + pDC->SetTextColor((m_crColourText == CLR_DEFAULT)? 0 : m_crColourText); + pDC->DrawText(m_strText, rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER); + } + } + + // Draw focus rect + if (state & ODS_FOCUS) + { + rect.DeflateRect(1,1); + pDC->DrawFocusRect(rect); + } +} + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker overrides + +void CColourPicker::PreSubclassWindow() +{ + ModifyStyle(0, BS_OWNERDRAW); // Make it owner drawn + CButton::PreSubclassWindow(); + SetWindowSize(); // resize appropriately +} + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker attributes + +COLORREF CColourPicker::GetColour() +{ + return (m_nSelectionMode == CP_MODE_TEXT)? + GetTextColour(): GetBkColour(); +} + +void CColourPicker::SetColour(COLORREF crColour) +{ + (m_nSelectionMode == CP_MODE_TEXT)? + SetTextColour(crColour): SetBkColour(crColour); +} + +void CColourPicker::SetBkColour(COLORREF crColourBk) +{ + m_crColourBk = crColourBk; + if (IsWindow(m_hWnd)) + RedrawWindow(); +} + +void CColourPicker::SetTextColour(COLORREF crColourText) +{ + m_crColourText = crColourText; + if (IsWindow(m_hWnd)) + RedrawWindow(); +} + +void CColourPicker::SetDefaultText(LPCTSTR szDefaultText) +{ + m_strDefaultText = (szDefaultText)? szDefaultText : _T(""); +} + +void CColourPicker::SetCustomText(LPCTSTR szCustomText) +{ + m_strCustomText = (szCustomText)? szCustomText : _T(""); +} + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker implementation + +void CColourPicker::SetWindowSize() +{ + // Get size dimensions of edges + CSize MarginSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE)); + + // Get size of dropdown arrow + int nArrowWidth = max(::GetSystemMetrics(SM_CXHTHUMB), 5*MarginSize.cx); + int nArrowHeight = max(::GetSystemMetrics(SM_CYVTHUMB), 5*MarginSize.cy); + CSize ArrowSize(max(nArrowWidth, nArrowHeight), max(nArrowWidth, nArrowHeight)); + + // Get window size + CRect rect; + GetWindowRect(rect); + + CWnd* pParent = GetParent(); + if (pParent) + pParent->ScreenToClient(rect); + + // Set window size at least as wide as 2 arrows, and as high as arrow + margins + int nWidth = max(rect.Width(), 2*ArrowSize.cx + 2*MarginSize.cx); + MoveWindow(rect.left, rect.top, nWidth, ArrowSize.cy+2*MarginSize.cy, TRUE); + + // Get the new coords of this window + GetWindowRect(rect); + ScreenToClient(rect); + + // Get the rect where the arrow goes, and convert to client coords. + m_ArrowRect.SetRect(rect.right - ArrowSize.cx - MarginSize.cx, + rect.top + MarginSize.cy, rect.right - MarginSize.cx, + rect.bottom - MarginSize.cy); +} diff --git a/ChartDemo/ColourPicker/ColourPicker.h b/ChartDemo/ColourPicker/ColourPicker.h new file mode 100644 index 0000000..0c2d7ac --- /dev/null +++ b/ChartDemo/ColourPicker/ColourPicker.h @@ -0,0 +1,113 @@ +#if !defined(AFX_COLOURPICKER_H__D0B75901_9830_11D1_9C0F_00A0243D1382__INCLUDED_) +#define AFX_COLOURPICKER_H__D0B75901_9830_11D1_9C0F_00A0243D1382__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +// ColourPicker.h : header file +// +// Written by Chris Maunder (chrismaunder@codeguru.com) +// Extended by Alexander Bischofberger (bischofb@informatik.tu-muenchen.de) +// Copyright (c) 1998. +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name is included. If +// the source code in this file is used in any commercial application +// then a simple email would be nice. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability if it causes any damage whatsoever. +// It's free - so you get what you pay for. + +#include "ColourPopup.h" + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker window + +void AFXAPI DDX_ColourPicker(CDataExchange *pDX, int nIDC, COLORREF& crColour); + +///////////////////////////////////////////////////////////////////////////// +// CColourPicker window + +#define CP_MODE_TEXT 1 // edit text colour +#define CP_MODE_BK 2 // edit background colour (default) + +class CColourPicker : public CButton +{ +// Construction +public: + CColourPicker(); + DECLARE_DYNCREATE(CColourPicker); + +// Attributes +public: + COLORREF GetColour(); + void SetColour(COLORREF crColour); + + void SetDefaultText(LPCTSTR szDefaultText); + void SetCustomText(LPCTSTR szCustomText); + + void SetTrackSelection(BOOL bTracking = TRUE) { m_bTrackSelection = bTracking; } + BOOL GetTrackSelection() { return m_bTrackSelection; } + + void SetSelectionMode(UINT nMode) { m_nSelectionMode = nMode; } + UINT GetSelectionMode() { return m_nSelectionMode; }; + + void SetBkColour(COLORREF crColourBk); + COLORREF GetBkColour() { return m_crColourBk; } + + void SetTextColour(COLORREF crColourText); + COLORREF GetTextColour() { return m_crColourText;} + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CColourPicker) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CColourPicker(); + +protected: + void SetWindowSize(); + +// protected attributes +protected: + BOOL m_bActive, // Is the dropdown active? + m_bTrackSelection; // track colour changes? + COLORREF m_crColourBk; + COLORREF m_crColourText; + UINT m_nSelectionMode; + CRect m_ArrowRect; + CString m_strDefaultText; + CString m_strCustomText; + + // Generated message map functions +protected: + //{{AFX_MSG(CColourPicker) + afx_msg BOOL OnClicked(); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + //}}AFX_MSG + afx_msg LONG OnSelEndOK(UINT lParam, LONG wParam); + afx_msg LONG OnSelEndCancel(UINT lParam, LONG wParam); + afx_msg LONG OnSelChange(UINT lParam, LONG wParam); + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COLOURPICKER_H__D0B75901_9830_11D1_9C0F_00A0243D1382__INCLUDED_) diff --git a/ChartDemo/ColourPicker/ColourPopup.cpp b/ChartDemo/ColourPicker/ColourPopup.cpp new file mode 100644 index 0000000..9a9c06f --- /dev/null +++ b/ChartDemo/ColourPicker/ColourPopup.cpp @@ -0,0 +1,917 @@ +// ColourPopup.cpp : implementation file +// +// Written by Chris Maunder (chrismaunder@codeguru.com) +// Extended by Alexander Bischofberger (bischofb@informatik.tu-muenchen.de) +// Copyright (c) 1998. +// +// Updated 30 May 1998 to allow any number of colours, and to +// make the appearance closer to Office 97. +// Also added "Default" text area. (CJM) +// +// 13 June 1998 Fixed change of focus bug (CJM) +// 30 June 1998 Fixed bug caused by focus bug fix (D'oh!!) +// Solution suggested by Paul Wilkerson. +// +// ColourPopup is a helper class for the colour picker control +// CColourPicker. Check out the header file or the accompanying +// HTML doc file for details. +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name is included. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability if it causes any damage to you or your +// computer whatsoever. It's free, so don't hassle me about it. +// +// Expect bugs. +// +// Please use and enjoy. Please let me know of any bugs/mods/improvements +// that you have found/implemented and I will fix/incorporate them into this +// file. + +#include "stdafx.h" +#include +#include "ColourPicker.h" +#include "ColourPopup.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define DEFAULT_BOX_VALUE -3 +#define CUSTOM_BOX_VALUE -2 +#define INVALID_COLOUR -1 + +#define MAX_COLOURS 100 + + +ColourTableEntry CColourPopup::m_crColours[] = +{ + { RGB(0x00, 0x00, 0x00), _T("Black") }, + { RGB(0xA5, 0x2A, 0x00), _T("Brown") }, + { RGB(0x00, 0x40, 0x40), _T("Dark Olive Green") }, + { RGB(0x00, 0x55, 0x00), _T("Dark Green") }, + { RGB(0x00, 0x00, 0x5E), _T("Dark Teal") }, + { RGB(0x00, 0x00, 0x8B), _T("Dark blue") }, + { RGB(0x4B, 0x00, 0x82), _T("Indigo") }, + { RGB(0x28, 0x28, 0x28), _T("Dark grey") }, + + { RGB(0x8B, 0x00, 0x00), _T("Dark red") }, + { RGB(0xFF, 0x68, 0x20), _T("Orange") }, + { RGB(0x8B, 0x8B, 0x00), _T("Dark yellow") }, + { RGB(0x00, 0x93, 0x00), _T("Green") }, + { RGB(0x38, 0x8E, 0x8E), _T("Teal") }, + { RGB(0x00, 0x00, 0xFF), _T("Blue") }, + { RGB(0x7B, 0x7B, 0xC0), _T("Blue-grey") }, + { RGB(0x66, 0x66, 0x66), _T("Grey - 40") }, + + { RGB(0xFF, 0x00, 0x00), _T("Red") }, + { RGB(0xFF, 0xAD, 0x5B), _T("Light orange") }, + { RGB(0x32, 0xCD, 0x32), _T("Lime") }, + { RGB(0x3C, 0xB3, 0x71), _T("Sea green") }, + { RGB(0x7F, 0xFF, 0xD4), _T("Aqua") }, + { RGB(0x7D, 0x9E, 0xC0), _T("Light blue") }, + { RGB(0x80, 0x00, 0x80), _T("Violet") }, + { RGB(0x7F, 0x7F, 0x7F), _T("Grey - 50") }, + + { RGB(0xFF, 0xC0, 0xCB), _T("Pink") }, + { RGB(0xFF, 0xD7, 0x00), _T("Gold") }, + { RGB(0xFF, 0xFF, 0x00), _T("Yellow") }, + { RGB(0x00, 0xFF, 0x00), _T("Bright green") }, + { RGB(0x40, 0xE0, 0xD0), _T("Turquoise") }, + { RGB(0xC0, 0xFF, 0xFF), _T("Skyblue") }, + { RGB(0x48, 0x00, 0x48), _T("Plum") }, + { RGB(0xC0, 0xC0, 0xC0), _T("Light grey") }, + + { RGB(0xFF, 0xE4, 0xE1), _T("Rose") }, + { RGB(0xD2, 0xB4, 0x8C), _T("Tan") }, + { RGB(0xFF, 0xFF, 0xE0), _T("Light yellow") }, + { RGB(0x98, 0xFB, 0x98), _T("Pale green ") }, + { RGB(0xAF, 0xEE, 0xEE), _T("Pale turquoise") }, + { RGB(0x68, 0x83, 0x8B), _T("Pale blue") }, + { RGB(0xE6, 0xE6, 0xFA), _T("Lavender") }, + { RGB(0xFF, 0xFF, 0xFF), _T("White") } +}; + +///////////////////////////////////////////////////////////////////////////// +// CColourPopup + +CColourPopup::CColourPopup() +{ + Initialise(); +} + +CColourPopup::CColourPopup(CPoint p, COLORREF crColour, CWnd* pParentWnd, + LPCTSTR szDefaultText /* = NULL */, + LPCTSTR szCustomText /* = NULL */) +{ + Initialise(); + + m_crColour = m_crInitialColour = crColour; + m_pParent = pParentWnd; + m_strDefaultText = (szDefaultText)? szDefaultText : _T(""); + m_strCustomText = (szCustomText)? szCustomText : _T(""); + + CColourPopup::Create(p, crColour, pParentWnd, szDefaultText, szCustomText); +} + +void CColourPopup::Initialise() +{ + m_nNumColours = sizeof(m_crColours)/sizeof(ColourTableEntry); + ASSERT(m_nNumColours <= MAX_COLOURS); + if (m_nNumColours > MAX_COLOURS) + m_nNumColours = MAX_COLOURS; + + m_nNumColumns = 0; + m_nNumRows = 0; + m_nBoxSize = 18; + m_nMargin = ::GetSystemMetrics(SM_CXEDGE); + m_nCurrentSel = INVALID_COLOUR; + m_nChosenColourSel = INVALID_COLOUR; + m_pParent = NULL; + m_crColour = m_crInitialColour = RGB(0,0,0); + + m_bChildWindowVisible = FALSE; + + // Idiot check: Make sure the colour square is at least 5 x 5; + if (m_nBoxSize - 2*m_nMargin - 2 < 5) m_nBoxSize = 5 + 2*m_nMargin + 2; + + // Create the font + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)); + m_Font.CreateFontIndirect(&(ncm.lfMessageFont)); + + // Create the palette + struct { + LOGPALETTE LogPalette; + PALETTEENTRY PalEntry[MAX_COLOURS]; + } pal; + + LOGPALETTE* pLogPalette = (LOGPALETTE*) &pal; + pLogPalette->palVersion = 0x300; + pLogPalette->palNumEntries = (WORD) m_nNumColours; + + for (int i = 0; i < m_nNumColours; i++) + { + pLogPalette->palPalEntry[i].peRed = GetRValue(m_crColours[i].crColour); + pLogPalette->palPalEntry[i].peGreen = GetGValue(m_crColours[i].crColour); + pLogPalette->palPalEntry[i].peBlue = GetBValue(m_crColours[i].crColour); + pLogPalette->palPalEntry[i].peFlags = 0; + } + + m_Palette.CreatePalette(pLogPalette); +} + +CColourPopup::~CColourPopup() +{ + m_Font.DeleteObject(); + m_Palette.DeleteObject(); +} + +BOOL CColourPopup::Create(CPoint p, COLORREF crColour, CWnd* pParentWnd, + LPCTSTR szDefaultText /* = NULL */, + LPCTSTR szCustomText /* = NULL */) +{ + ASSERT(pParentWnd && ::IsWindow(pParentWnd->GetSafeHwnd())); + ASSERT(pParentWnd->IsKindOf(RUNTIME_CLASS(CColourPicker))); + + m_pParent = pParentWnd; + m_crColour = m_crInitialColour = crColour; + + // Get the class name and create the window + CString szClassName = AfxRegisterWndClass(CS_CLASSDC|CS_SAVEBITS|CS_HREDRAW|CS_VREDRAW, + 0, + (HBRUSH) (COLOR_BTNFACE+1), + 0); + + if (!CWnd::CreateEx(0, szClassName, _T(""), WS_VISIBLE|WS_POPUP, + p.x, p.y, 100, 100, // size updated soon + pParentWnd->GetSafeHwnd(), 0, NULL)) + return FALSE; + + // Store the Custom text + if (szCustomText != NULL) + m_strCustomText = szCustomText; + + // Store the Default Area text + if (szDefaultText != NULL) + m_strDefaultText = szDefaultText; + + // Set the window size + SetWindowSize(); + + // Create the tooltips + CreateToolTips(); + + // Find which cell (if any) corresponds to the initial colour + FindCellFromColour(crColour); + + // Capture all mouse events for the life of this window + SetCapture(); + + return TRUE; +} + +BEGIN_MESSAGE_MAP(CColourPopup, CWnd) + //{{AFX_MSG_MAP(CColourPopup) + ON_WM_NCDESTROY() + ON_WM_LBUTTONUP() + ON_WM_PAINT() + ON_WM_MOUSEMOVE() + ON_WM_KEYDOWN() + ON_WM_QUERYNEWPALETTE() + ON_WM_PALETTECHANGED() + ON_WM_KILLFOCUS() + ON_WM_ACTIVATEAPP() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CColourPopup message handlers + +// For tooltips +BOOL CColourPopup::PreTranslateMessage(MSG* pMsg) +{ + m_ToolTip.RelayEvent(pMsg); + + // Fix (Adrian Roman): Sometimes if the picker loses focus it is never destroyed + if (GetCapture()->GetSafeHwnd() != m_hWnd) + SetCapture(); + + return CWnd::PreTranslateMessage(pMsg); +} + +// If an arrow key is pressed, then move the selection +void CColourPopup::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + int row = GetRow(m_nCurrentSel), + col = GetColumn(m_nCurrentSel); + + if (nChar == VK_DOWN) + { + if (row == DEFAULT_BOX_VALUE) + row = col = 0; + else if (row == CUSTOM_BOX_VALUE) + { + if (m_strDefaultText.GetLength()) + row = col = DEFAULT_BOX_VALUE; + else + row = col = 0; + } + else + { + row++; + if (GetIndex(row,col) < 0) + { + if (m_strCustomText.GetLength()) + row = col = CUSTOM_BOX_VALUE; + else if (m_strDefaultText.GetLength()) + row = col = DEFAULT_BOX_VALUE; + else + row = col = 0; + } + } + ChangeSelection(GetIndex(row, col)); + } + + if (nChar == VK_UP) + { + if (row == DEFAULT_BOX_VALUE) + { + if (m_strCustomText.GetLength()) + row = col = CUSTOM_BOX_VALUE; + else + { + row = GetRow(m_nNumColours-1); + col = GetColumn(m_nNumColours-1); + } + } + else if (row == CUSTOM_BOX_VALUE) + { + row = GetRow(m_nNumColours-1); + col = GetColumn(m_nNumColours-1); + } + else if (row > 0) row--; + else /* row == 0 */ + { + if (m_strDefaultText.GetLength()) + row = col = DEFAULT_BOX_VALUE; + else if (m_strCustomText.GetLength()) + row = col = CUSTOM_BOX_VALUE; + else + { + row = GetRow(m_nNumColours-1); + col = GetColumn(m_nNumColours-1); + } + } + ChangeSelection(GetIndex(row, col)); + } + + if (nChar == VK_RIGHT) + { + if (row == DEFAULT_BOX_VALUE) + row = col = 0; + else if (row == CUSTOM_BOX_VALUE) + { + if (m_strDefaultText.GetLength()) + row = col = DEFAULT_BOX_VALUE; + else + row = col = 0; + } + else if (col < m_nNumColumns-1) + col++; + else + { + col = 0; row++; + } + + if (GetIndex(row,col) == INVALID_COLOUR) + { + if (m_strCustomText.GetLength()) + row = col = CUSTOM_BOX_VALUE; + else if (m_strDefaultText.GetLength()) + row = col = DEFAULT_BOX_VALUE; + else + row = col = 0; + } + + ChangeSelection(GetIndex(row, col)); + } + + if (nChar == VK_LEFT) + { + if (row == DEFAULT_BOX_VALUE) + { + if (m_strCustomText.GetLength()) + row = col = CUSTOM_BOX_VALUE; + else + { + row = GetRow(m_nNumColours-1); + col = GetColumn(m_nNumColours-1); + } + } + else if (row == CUSTOM_BOX_VALUE) + { + row = GetRow(m_nNumColours-1); + col = GetColumn(m_nNumColours-1); + } + else if (col > 0) col--; + else /* col == 0 */ + { + if (row > 0) { row--; col = m_nNumColumns-1; } + else + { + if (m_strDefaultText.GetLength()) + row = col = DEFAULT_BOX_VALUE; + else if (m_strCustomText.GetLength()) + row = col = CUSTOM_BOX_VALUE; + else + { + row = GetRow(m_nNumColours-1); + col = GetColumn(m_nNumColours-1); + } + } + } + ChangeSelection(GetIndex(row, col)); + } + + if (nChar == VK_ESCAPE) + { + m_crColour = m_crInitialColour; + EndSelection(CPN_SELENDCANCEL); + return; + } + + if (nChar == VK_RETURN || nChar == VK_SPACE) + { + EndSelection(CPN_SELENDOK); + return; + } + + CWnd::OnKeyDown(nChar, nRepCnt, nFlags); +} + +// auto-deletion +void CColourPopup::OnNcDestroy() +{ + CWnd::OnNcDestroy(); + delete this; +} + +void CColourPopup::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + // Draw the Default Area text + if (m_strDefaultText.GetLength()) + DrawCell(&dc, DEFAULT_BOX_VALUE); + + // Draw colour cells + for (int i = 0; i < m_nNumColours; i++) + DrawCell(&dc, i); + + // Draw custom text + if (m_strCustomText.GetLength()) + DrawCell(&dc, CUSTOM_BOX_VALUE); + + // Draw raised window edge (ex-window style WS_EX_WINDOWEDGE is sposed to do this, + // but for some reason isn't + CRect rect; + GetClientRect(rect); + dc.DrawEdge(rect, EDGE_RAISED, BF_RECT); +} + +void CColourPopup::OnMouseMove(UINT nFlags, CPoint point) +{ + int nNewSelection = INVALID_COLOUR; + + // Translate points to be relative raised window edge + point.x -= m_nMargin; + point.y -= m_nMargin; + + // First check we aren't in text box + if (m_strCustomText.GetLength() && m_CustomTextRect.PtInRect(point)) + nNewSelection = CUSTOM_BOX_VALUE; + else if (m_strDefaultText.GetLength() && m_DefaultTextRect.PtInRect(point)) + nNewSelection = DEFAULT_BOX_VALUE; + else + { + // Take into account text box + if (m_strDefaultText.GetLength()) + point.y -= m_DefaultTextRect.Height(); + + // Get the row and column + nNewSelection = GetIndex(point.y / m_nBoxSize, point.x / m_nBoxSize); + + // In range? If not, default and exit + if (nNewSelection < 0 || nNewSelection >= m_nNumColours) + { + CWnd::OnMouseMove(nFlags, point); + return; + } + } + + // OK - we have the row and column of the current selection (may be CUSTOM_BOX_VALUE) + // Has the row/col selection changed? If yes, then redraw old and new cells. + if (nNewSelection != m_nCurrentSel) + ChangeSelection(nNewSelection); + + CWnd::OnMouseMove(nFlags, point); +} + +// End selection on LButtonUp +void CColourPopup::OnLButtonUp(UINT nFlags, CPoint point) +{ + CWnd::OnLButtonUp(nFlags, point); + + DWORD pos = GetMessagePos(); + point = CPoint(LOWORD(pos), HIWORD(pos)); + + if (m_WindowRect.PtInRect(point)) + EndSelection(CPN_SELENDOK); + else + EndSelection(CPN_SELENDCANCEL); +} + +///////////////////////////////////////////////////////////////////////////// +// CColourPopup implementation + +int CColourPopup::GetIndex(int row, int col) const +{ + if ((row == CUSTOM_BOX_VALUE || col == CUSTOM_BOX_VALUE) && m_strCustomText.GetLength()) + return CUSTOM_BOX_VALUE; + else if ((row == DEFAULT_BOX_VALUE || col == DEFAULT_BOX_VALUE) && m_strDefaultText.GetLength()) + return DEFAULT_BOX_VALUE; + else if (row < 0 || col < 0 || row >= m_nNumRows || col >= m_nNumColumns) + return INVALID_COLOUR; + else + { + if (row*m_nNumColumns + col >= m_nNumColours) + return INVALID_COLOUR; + else + return row*m_nNumColumns + col; + } +} + +int CColourPopup::GetRow(int nIndex) const +{ + if (nIndex == CUSTOM_BOX_VALUE && m_strCustomText.GetLength()) + return CUSTOM_BOX_VALUE; + else if (nIndex == DEFAULT_BOX_VALUE && m_strDefaultText.GetLength()) + return DEFAULT_BOX_VALUE; + else if (nIndex < 0 || nIndex >= m_nNumColours) + return INVALID_COLOUR; + else + return nIndex / m_nNumColumns; +} + +int CColourPopup::GetColumn(int nIndex) const +{ + if (nIndex == CUSTOM_BOX_VALUE && m_strCustomText.GetLength()) + return CUSTOM_BOX_VALUE; + else if (nIndex == DEFAULT_BOX_VALUE && m_strDefaultText.GetLength()) + return DEFAULT_BOX_VALUE; + else if (nIndex < 0 || nIndex >= m_nNumColours) + return INVALID_COLOUR; + else + return nIndex % m_nNumColumns; +} + +void CColourPopup::FindCellFromColour(COLORREF crColour) +{ + if (crColour == CLR_DEFAULT && m_strDefaultText.GetLength()) + { + m_nChosenColourSel = DEFAULT_BOX_VALUE; + return; + } + + for (int i = 0; i < m_nNumColours; i++) + { + if (GetColour(i) == crColour) + { + m_nChosenColourSel = i; + return; + } + } + + if (m_strCustomText.GetLength()) + m_nChosenColourSel = CUSTOM_BOX_VALUE; + else + m_nChosenColourSel = INVALID_COLOUR; +} + +// Gets the dimensions of the colour cell given by (row,col) +BOOL CColourPopup::GetCellRect(int nIndex, const LPRECT& rect) +{ + if (nIndex == CUSTOM_BOX_VALUE) + { + ::SetRect(rect, + m_CustomTextRect.left, m_CustomTextRect.top, + m_CustomTextRect.right, m_CustomTextRect.bottom); + return TRUE; + } + else if (nIndex == DEFAULT_BOX_VALUE) + { + ::SetRect(rect, + m_DefaultTextRect.left, m_DefaultTextRect.top, + m_DefaultTextRect.right, m_DefaultTextRect.bottom); + return TRUE; + } + + if (nIndex < 0 || nIndex >= m_nNumColours) + return FALSE; + + rect->left = GetColumn(nIndex) * m_nBoxSize + m_nMargin; + rect->top = GetRow(nIndex) * m_nBoxSize + m_nMargin; + + // Move everything down if we are displaying a default text area + if (m_strDefaultText.GetLength()) + rect->top += (m_nMargin + m_DefaultTextRect.Height()); + + rect->right = rect->left + m_nBoxSize; + rect->bottom = rect->top + m_nBoxSize; + + return TRUE; +} + +// Works out an appropriate size and position of this window +void CColourPopup::SetWindowSize() +{ + CSize TextSize; + + // If we are showing a custom or default text area, get the font and text size. + if (m_strCustomText.GetLength() || m_strDefaultText.GetLength()) + { + CClientDC dc(this); + CFont* pOldFont = (CFont*) dc.SelectObject(&m_Font); + + // Get the size of the custom text (if there IS custom text) + TextSize = CSize(0,0); + if (m_strCustomText.GetLength()) + TextSize = dc.GetTextExtent(m_strCustomText); + + // Get the size of the default text (if there IS default text) + if (m_strDefaultText.GetLength()) + { + CSize DefaultSize = dc.GetTextExtent(m_strDefaultText); + if (DefaultSize.cx > TextSize.cx) TextSize.cx = DefaultSize.cx; + if (DefaultSize.cy > TextSize.cy) TextSize.cy = DefaultSize.cy; + } + + dc.SelectObject(pOldFont); + TextSize += CSize(2*m_nMargin,2*m_nMargin); + + // Add even more space to draw the horizontal line + TextSize.cy += 2*m_nMargin + 2; + } + + // Get the number of columns and rows + //m_nNumColumns = (int) sqrt((double)m_nNumColours); // for a square window (yuk) + m_nNumColumns = 8; + m_nNumRows = m_nNumColours / m_nNumColumns; + if (m_nNumColours % m_nNumColumns) m_nNumRows++; + + // Get the current window position, and set the new size + CRect rect; + GetWindowRect(rect); + + m_WindowRect.SetRect(rect.left, rect.top, + rect.left + m_nNumColumns*m_nBoxSize + 2*m_nMargin, + rect.top + m_nNumRows*m_nBoxSize + 2*m_nMargin); + + // if custom text, then expand window if necessary, and set text width as + // window width + if (m_strDefaultText.GetLength()) + { + if (TextSize.cx > m_WindowRect.Width()) + m_WindowRect.right = m_WindowRect.left + TextSize.cx; + TextSize.cx = m_WindowRect.Width()-2*m_nMargin; + + // Work out the text area + m_DefaultTextRect.SetRect(m_nMargin, m_nMargin, + m_nMargin+TextSize.cx, 2*m_nMargin+TextSize.cy); + m_WindowRect.bottom += m_DefaultTextRect.Height() + 2*m_nMargin; + } + + // if custom text, then expand window if necessary, and set text width as + // window width + if (m_strCustomText.GetLength()) + { + if (TextSize.cx > m_WindowRect.Width()) + m_WindowRect.right = m_WindowRect.left + TextSize.cx; + TextSize.cx = m_WindowRect.Width()-2*m_nMargin; + + // Work out the text area + m_CustomTextRect.SetRect(m_nMargin, m_WindowRect.Height(), + m_nMargin+TextSize.cx, + m_WindowRect.Height()+m_nMargin+TextSize.cy); + m_WindowRect.bottom += m_CustomTextRect.Height() + 2*m_nMargin; + } + + // Need to check it'll fit on screen: Too far right? + CSize ScreenSize(::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN)); + if (m_WindowRect.right > ScreenSize.cx) + m_WindowRect.OffsetRect(-(m_WindowRect.right - ScreenSize.cx), 0); + + // Too far left? + if (m_WindowRect.left < 0) + m_WindowRect.OffsetRect( -m_WindowRect.left, 0); + + // Bottom falling out of screen? + if (m_WindowRect.bottom > ScreenSize.cy) + { + CRect ParentRect; + m_pParent->GetWindowRect(ParentRect); + m_WindowRect.OffsetRect(0, -(ParentRect.Height() + m_WindowRect.Height())); + } + + // Set the window size and position + MoveWindow(m_WindowRect, TRUE); +} + +void CColourPopup::CreateToolTips() +{ + // Create the tool tip + if (!m_ToolTip.Create(this)) return; + + // Add a tool for each cell + for (int i = 0; i < m_nNumColours; i++) + { + CRect rect; + if (!GetCellRect(i, rect)) continue; + m_ToolTip.AddTool(this, GetColourName(i), rect, 1); + } +} + +void CColourPopup::ChangeSelection(int nIndex) +{ + CClientDC dc(this); // device context for drawing + + if (nIndex > m_nNumColours) + nIndex = CUSTOM_BOX_VALUE; + + if ((m_nCurrentSel >= 0 && m_nCurrentSel < m_nNumColours) || + m_nCurrentSel == CUSTOM_BOX_VALUE || m_nCurrentSel == DEFAULT_BOX_VALUE) + { + // Set Current selection as invalid and redraw old selection (this way + // the old selection will be drawn unselected) + int OldSel = m_nCurrentSel; + m_nCurrentSel = INVALID_COLOUR; + DrawCell(&dc, OldSel); + } + + // Set the current selection as row/col and draw (it will be drawn selected) + m_nCurrentSel = nIndex; + DrawCell(&dc, m_nCurrentSel); + + // Store the current colour + if (m_nCurrentSel == CUSTOM_BOX_VALUE) + m_pParent->SendMessage(CPN_SELCHANGE, (WPARAM) m_crInitialColour, 0); + else if (m_nCurrentSel == DEFAULT_BOX_VALUE) + { + m_crColour = CLR_DEFAULT; + m_pParent->SendMessage(CPN_SELCHANGE, (WPARAM) CLR_DEFAULT, 0); + } + else + { + m_crColour = GetColour(m_nCurrentSel); + m_pParent->SendMessage(CPN_SELCHANGE, (WPARAM) m_crColour, 0); + } +} + +void CColourPopup::EndSelection(int nMessage) +{ + ReleaseCapture(); + + // If custom text selected, perform a custom colour selection + if (nMessage != CPN_SELENDCANCEL && m_nCurrentSel == CUSTOM_BOX_VALUE) + { + m_bChildWindowVisible = TRUE; + + CColorDialog dlg(m_crInitialColour, CC_FULLOPEN | CC_ANYCOLOR, this); + + if (dlg.DoModal() == IDOK) + m_crColour = dlg.GetColor(); + else + nMessage = CPN_SELENDCANCEL; + + m_bChildWindowVisible = FALSE; + } + + if (nMessage == CPN_SELENDCANCEL) + m_crColour = m_crInitialColour; + + m_pParent->SendMessage(nMessage, (WPARAM) m_crColour, 0); + + // Kill focus bug fixed by Martin Wawrusch + if (!m_bChildWindowVisible) + DestroyWindow(); +} + +void CColourPopup::DrawCell(CDC* pDC, int nIndex) +{ + // For the Custom Text area + if (m_strCustomText.GetLength() && nIndex == CUSTOM_BOX_VALUE) + { + // The extent of the actual text button + CRect TextButtonRect = m_CustomTextRect; + TextButtonRect.top += 2*m_nMargin; + + // Fill background + pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DFACE)); + + // Draw horizontal line + pDC->FillSolidRect(m_CustomTextRect.left+2*m_nMargin, m_CustomTextRect.top, + m_CustomTextRect.Width()-4*m_nMargin, 1, ::GetSysColor(COLOR_3DSHADOW)); + pDC->FillSolidRect(m_CustomTextRect.left+2*m_nMargin, m_CustomTextRect.top+1, + m_CustomTextRect.Width()-4*m_nMargin, 1, ::GetSysColor(COLOR_3DHILIGHT)); + + TextButtonRect.DeflateRect(1,1); + + // fill background + if (m_nChosenColourSel == nIndex && m_nCurrentSel != nIndex) + pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DLIGHT)); + else + pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DFACE)); + + // Draw button + if (m_nCurrentSel == nIndex) + pDC->DrawEdge(TextButtonRect, BDR_RAISEDINNER, BF_RECT); + else if (m_nChosenColourSel == nIndex) + pDC->DrawEdge(TextButtonRect, BDR_SUNKENOUTER, BF_RECT); + + // Draw custom text + CFont *pOldFont = (CFont*) pDC->SelectObject(&m_Font); + pDC->SetBkMode(TRANSPARENT); + pDC->DrawText(m_strCustomText, TextButtonRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); + pDC->SelectObject(pOldFont); + + return; + } + + // For the Default Text area + if (m_strDefaultText.GetLength() && nIndex == DEFAULT_BOX_VALUE) + { + // Fill background + pDC->FillSolidRect(m_DefaultTextRect, ::GetSysColor(COLOR_3DFACE)); + + // The extent of the actual text button + CRect TextButtonRect = m_DefaultTextRect; + TextButtonRect.DeflateRect(1,1); + + // fill background + if (m_nChosenColourSel == nIndex && m_nCurrentSel != nIndex) + pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DLIGHT)); + else + pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DFACE)); + + // Draw thin line around text + CRect LineRect = TextButtonRect; + LineRect.DeflateRect(2*m_nMargin,2*m_nMargin); + CPen pen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); + CPen* pOldPen = pDC->SelectObject(&pen); + pDC->SelectStockObject(NULL_BRUSH); + pDC->Rectangle(LineRect); + pDC->SelectObject(pOldPen); + + // Draw button + if (m_nCurrentSel == nIndex) + pDC->DrawEdge(TextButtonRect, BDR_RAISEDINNER, BF_RECT); + else if (m_nChosenColourSel == nIndex) + pDC->DrawEdge(TextButtonRect, BDR_SUNKENOUTER, BF_RECT); + + // Draw custom text + CFont *pOldFont = (CFont*) pDC->SelectObject(&m_Font); + pDC->SetBkMode(TRANSPARENT); + pDC->DrawText(m_strDefaultText, TextButtonRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); + pDC->SelectObject(pOldFont); + + return; + } + + CRect rect; + if (!GetCellRect(nIndex, rect)) return; + + // Select and realize the palette + CPalette* pOldPalette = NULL; + if (pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE) + { + pOldPalette = pDC->SelectPalette(&m_Palette, FALSE); + pDC->RealizePalette(); + } + + // fill background + if (m_nChosenColourSel == nIndex && m_nCurrentSel != nIndex) + pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DHILIGHT)); + else + pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE)); + + // Draw button + if (m_nCurrentSel == nIndex) + pDC->DrawEdge(rect, BDR_RAISEDINNER, BF_RECT); + else if (m_nChosenColourSel == nIndex) + pDC->DrawEdge(rect, BDR_SUNKENOUTER, BF_RECT); + + CBrush brush(PALETTERGB(GetRValue(GetColour(nIndex)), + GetGValue(GetColour(nIndex)), + GetBValue(GetColour(nIndex)) )); + CPen pen; + pen.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); + + CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush); + CPen* pOldPen = (CPen*) pDC->SelectObject(&pen); + + // Draw the cell colour + rect.DeflateRect(m_nMargin+1, m_nMargin+1); + pDC->Rectangle(rect); + + // restore DC and cleanup + pDC->SelectObject(pOldBrush); + pDC->SelectObject(pOldPen); + brush.DeleteObject(); + pen.DeleteObject(); + + if (pOldPalette && pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE) + pDC->SelectPalette(pOldPalette, FALSE); +} + +BOOL CColourPopup::OnQueryNewPalette() +{ + Invalidate(); + return CWnd::OnQueryNewPalette(); +} + +void CColourPopup::OnPaletteChanged(CWnd* pFocusWnd) +{ + CWnd::OnPaletteChanged(pFocusWnd); + + if (pFocusWnd->GetSafeHwnd() != GetSafeHwnd()) + Invalidate(); +} + +void CColourPopup::OnKillFocus(CWnd* pNewWnd) +{ + CWnd::OnKillFocus(pNewWnd); + + ReleaseCapture(); + //DestroyWindow(); - causes crash when Custom colour dialog appears. +} + +// KillFocus problem fix suggested by Paul Wilkerson. +#if _MFC_VER < 0x0700 + void CColourPopup::OnActivateApp(BOOL bActive, HTASK hTask) +#else + void CColourPopup::OnActivateApp(BOOL bActive, DWORD hTask) +#endif +{ + CWnd::OnActivateApp(bActive, hTask); + + // If Deactivating App, cancel this selection + if (!bActive) + EndSelection(CPN_SELENDCANCEL); +} diff --git a/ChartDemo/ColourPicker/ColourPopup.h b/ChartDemo/ColourPicker/ColourPopup.h new file mode 100644 index 0000000..3d738a5 --- /dev/null +++ b/ChartDemo/ColourPicker/ColourPopup.h @@ -0,0 +1,132 @@ +#if !defined(AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_) +#define AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +// ColourPopup.h : header file +// +// Written by Chris Maunder (chrismaunder@codeguru.com) +// Extended by Alexander Bischofberger (bischofb@informatik.tu-muenchen.de) +// Copyright (c) 1998. +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name is included. If +// the source code in this file is used in any commercial application +// then a simple email would be nice. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability if it causes any damage whatsoever. +// It's free - so you get what you pay for. + + +// CColourPopup messages +#define CPN_SELCHANGE WM_USER + 1001 // Colour Picker Selection change +#define CPN_DROPDOWN WM_USER + 1002 // Colour Picker drop down +#define CPN_CLOSEUP WM_USER + 1003 // Colour Picker close up +#define CPN_SELENDOK WM_USER + 1004 // Colour Picker end OK +#define CPN_SELENDCANCEL WM_USER + 1005 // Colour Picker end (cancelled) + +// forward declaration +class CColourPicker; + +// To hold the colours and their names +typedef struct { + COLORREF crColour; + TCHAR *szName; +} ColourTableEntry; + +///////////////////////////////////////////////////////////////////////////// +// CColourPopup window + +class CColourPopup : public CWnd +{ +// Construction +public: + CColourPopup(); + CColourPopup(CPoint p, COLORREF crColour, CWnd* pParentWnd, + LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL); + void Initialise(); + +// Attributes +public: + +// Operations +public: + BOOL Create(CPoint p, COLORREF crColour, CWnd* pParentWnd, + LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CColourPopup) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CColourPopup(); + +protected: + BOOL GetCellRect(int nIndex, const LPRECT& rect); + void FindCellFromColour(COLORREF crColour); + void SetWindowSize(); + void CreateToolTips(); + void ChangeSelection(int nIndex); + void EndSelection(int nMessage); + void DrawCell(CDC* pDC, int nIndex); + + COLORREF GetColour(int nIndex) { return m_crColours[nIndex].crColour; } + LPCTSTR GetColourName(int nIndex) { return m_crColours[nIndex].szName; } + int GetIndex(int row, int col) const; + int GetRow(int nIndex) const; + int GetColumn(int nIndex) const; + +// protected attributes +protected: + static ColourTableEntry m_crColours[]; + int m_nNumColours; + int m_nNumColumns, m_nNumRows; + int m_nBoxSize, m_nMargin; + int m_nCurrentSel; + int m_nChosenColourSel; + CString m_strDefaultText; + CString m_strCustomText; + CRect m_CustomTextRect, m_DefaultTextRect, m_WindowRect; + CFont m_Font; + CPalette m_Palette; + COLORREF m_crInitialColour, m_crColour; + CToolTipCtrl m_ToolTip; + CWnd* m_pParent; + + BOOL m_bChildWindowVisible; + + // Generated message map functions +protected: + //{{AFX_MSG(CColourPopup) + afx_msg void OnNcDestroy(); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnPaint(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg BOOL OnQueryNewPalette(); + afx_msg void OnPaletteChanged(CWnd* pFocusWnd); + afx_msg void OnKillFocus(CWnd* pNewWnd); + #if _MFC_VER < 0x0700 + afx_msg void OnActivateApp(BOOL bActive, HTASK hTask); + #else + afx_msg void OnActivateApp(BOOL bActive, DWORD hTask); + #endif + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_) diff --git a/ChartDemo/Doc/html/_chart_axis_8h-source.html b/ChartDemo/Doc/html/_chart_axis_8h-source.html new file mode 100644 index 0000000..8575be8 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_axis_8h-source.html @@ -0,0 +1,265 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxis.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_axis_label_8h-source.html b/ChartDemo/Doc/html/_chart_axis_label_8h-source.html new file mode 100644 index 0000000..7a5dfa2 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_axis_label_8h-source.html @@ -0,0 +1,104 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxisLabel.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_axis_old_8h-source.html b/ChartDemo/Doc/html/_chart_axis_old_8h-source.html new file mode 100644 index 0000000..bac0169 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_axis_old_8h-source.html @@ -0,0 +1,239 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartAxisOld.h Source File + + + + + +
Generated on Sun Feb 1 14:21:48 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_balloon_label_8h-source.html b/ChartDemo/Doc/html/_chart_balloon_label_8h-source.html new file mode 100644 index 0000000..940289d --- /dev/null +++ b/ChartDemo/Doc/html/_chart_balloon_label_8h-source.html @@ -0,0 +1,95 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartBalloonLabel.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_bar_serie_8h-source.html b/ChartDemo/Doc/html/_chart_bar_serie_8h-source.html new file mode 100644 index 0000000..2d26b5b --- /dev/null +++ b/ChartDemo/Doc/html/_chart_bar_serie_8h-source.html @@ -0,0 +1,148 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartBarSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_candlestick_serie_8h-source.html b/ChartDemo/Doc/html/_chart_candlestick_serie_8h-source.html new file mode 100644 index 0000000..1c5488d --- /dev/null +++ b/ChartDemo/Doc/html/_chart_candlestick_serie_8h-source.html @@ -0,0 +1,110 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartCandlestickSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_cross_hair_cursor_8h-source.html b/ChartDemo/Doc/html/_chart_cross_hair_cursor_8h-source.html new file mode 100644 index 0000000..a69b835 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_cross_hair_cursor_8h-source.html @@ -0,0 +1,77 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartCrossHairCursor.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_ctrl_8h-source.html b/ChartDemo/Doc/html/_chart_ctrl_8h-source.html new file mode 100644 index 0000000..14188e7 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_ctrl_8h-source.html @@ -0,0 +1,305 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartCtrl.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_cursor_8h-source.html b/ChartDemo/Doc/html/_chart_cursor_8h-source.html new file mode 100644 index 0000000..4e156fe --- /dev/null +++ b/ChartDemo/Doc/html/_chart_cursor_8h-source.html @@ -0,0 +1,105 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartCursor.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_date_time_axis_8h-source.html b/ChartDemo/Doc/html/_chart_date_time_axis_8h-source.html new file mode 100644 index 0000000..256154b --- /dev/null +++ b/ChartDemo/Doc/html/_chart_date_time_axis_8h-source.html @@ -0,0 +1,109 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartDateTimeAxis.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_demo_8h-source.html b/ChartDemo/Doc/html/_chart_demo_8h-source.html new file mode 100644 index 0000000..e2a9ca7 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_demo_8h-source.html @@ -0,0 +1,72 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartDemo.h Source File + + + + + +
Generated on Sat Mar 7 11:33:23 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_demo_dlg_8h-source.html b/ChartDemo/Doc/html/_chart_demo_dlg_8h-source.html new file mode 100644 index 0000000..4b0adae --- /dev/null +++ b/ChartDemo/Doc/html/_chart_demo_dlg_8h-source.html @@ -0,0 +1,108 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartDemoDlg.h Source File + + + + + +
Generated on Sat Mar 7 11:33:23 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_drag_line_cursor_8h-source.html b/ChartDemo/Doc/html/_chart_drag_line_cursor_8h-source.html new file mode 100644 index 0000000..d136a6b --- /dev/null +++ b/ChartDemo/Doc/html/_chart_drag_line_cursor_8h-source.html @@ -0,0 +1,81 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartDragLineCursor.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_font_8h-source.html b/ChartDemo/Doc/html/_chart_font_8h-source.html new file mode 100644 index 0000000..5e8349f --- /dev/null +++ b/ChartDemo/Doc/html/_chart_font_8h-source.html @@ -0,0 +1,94 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartFont.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_gantt_serie_8h-source.html b/ChartDemo/Doc/html/_chart_gantt_serie_8h-source.html new file mode 100644 index 0000000..db723e7 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_gantt_serie_8h-source.html @@ -0,0 +1,116 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartGanttSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_gradient_8h-source.html b/ChartDemo/Doc/html/_chart_gradient_8h-source.html new file mode 100644 index 0000000..8b22145 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_gradient_8h-source.html @@ -0,0 +1,69 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartGradient.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_grid_8h-source.html b/ChartDemo/Doc/html/_chart_grid_8h-source.html new file mode 100644 index 0000000..44e2735 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_grid_8h-source.html @@ -0,0 +1,93 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartGrid.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_label_8h-source.html b/ChartDemo/Doc/html/_chart_label_8h-source.html new file mode 100644 index 0000000..0b54b09 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_label_8h-source.html @@ -0,0 +1,104 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartLabel.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_legend_8h-source.html b/ChartDemo/Doc/html/_chart_legend_8h-source.html new file mode 100644 index 0000000..4b4d7e5 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_legend_8h-source.html @@ -0,0 +1,130 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartLegend.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_line_serie_8h-source.html b/ChartDemo/Doc/html/_chart_line_serie_8h-source.html new file mode 100644 index 0000000..729db12 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_line_serie_8h-source.html @@ -0,0 +1,95 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartLineSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_logarithmic_axis_8h-source.html b/ChartDemo/Doc/html/_chart_logarithmic_axis_8h-source.html new file mode 100644 index 0000000..95d897a --- /dev/null +++ b/ChartDemo/Doc/html/_chart_logarithmic_axis_8h-source.html @@ -0,0 +1,82 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartLogarithmicAxis.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_mouse_listener_8h-source.html b/ChartDemo/Doc/html/_chart_mouse_listener_8h-source.html new file mode 100644 index 0000000..b5b6f6a --- /dev/null +++ b/ChartDemo/Doc/html/_chart_mouse_listener_8h-source.html @@ -0,0 +1,83 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartMouseListener.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_object_8h-source.html b/ChartDemo/Doc/html/_chart_object_8h-source.html new file mode 100644 index 0000000..bedcba8 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_object_8h-source.html @@ -0,0 +1,126 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartObject.h Source File + + + + + +
Generated on Sun Feb 1 14:25:46 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_point_label_8h-source.html b/ChartDemo/Doc/html/_chart_point_label_8h-source.html new file mode 100644 index 0000000..fb8cc2d --- /dev/null +++ b/ChartDemo/Doc/html/_chart_point_label_8h-source.html @@ -0,0 +1,107 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartPointLabel.h Source File + + + + + +
Generated on Mon Feb 23 20:14:50 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_points_array_8h-source.html b/ChartDemo/Doc/html/_chart_points_array_8h-source.html new file mode 100644 index 0000000..143e7d1 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_points_array_8h-source.html @@ -0,0 +1,112 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsArray.h Source File + + + + + +
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_points_serie_8h-source.html b/ChartDemo/Doc/html/_chart_points_serie_8h-source.html new file mode 100644 index 0000000..b6d1908 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_points_serie_8h-source.html @@ -0,0 +1,102 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_scroll_bar_8h-source.html b/ChartDemo/Doc/html/_chart_scroll_bar_8h-source.html new file mode 100644 index 0000000..d96dca6 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_scroll_bar_8h-source.html @@ -0,0 +1,84 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartScrollBar.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_serie_8h-source.html b/ChartDemo/Doc/html/_chart_serie_8h-source.html new file mode 100644 index 0000000..5735ff8 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_serie_8h-source.html @@ -0,0 +1,164 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_serie_base_8h-source.html b/ChartDemo/Doc/html/_chart_serie_base_8h-source.html new file mode 100644 index 0000000..72ee6f6 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_serie_base_8h-source.html @@ -0,0 +1,139 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerieBase.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_series_mouse_listener_8h-source.html b/ChartDemo/Doc/html/_chart_series_mouse_listener_8h-source.html new file mode 100644 index 0000000..a2fcfb7 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_series_mouse_listener_8h-source.html @@ -0,0 +1,72 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartSeriesMouseListener.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_standard_axis_8h-source.html b/ChartDemo/Doc/html/_chart_standard_axis_8h-source.html new file mode 100644 index 0000000..f9b7d2d --- /dev/null +++ b/ChartDemo/Doc/html/_chart_standard_axis_8h-source.html @@ -0,0 +1,84 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartStandardAxis.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_string_8h-source.html b/ChartDemo/Doc/html/_chart_string_8h-source.html new file mode 100644 index 0000000..b4910b1 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_string_8h-source.html @@ -0,0 +1,60 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartString.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_surface_serie_8h-source.html b/ChartDemo/Doc/html/_chart_surface_serie_8h-source.html new file mode 100644 index 0000000..7bf336f --- /dev/null +++ b/ChartDemo/Doc/html/_chart_surface_serie_8h-source.html @@ -0,0 +1,102 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartSurfaceSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_title_8h-source.html b/ChartDemo/Doc/html/_chart_title_8h-source.html new file mode 100644 index 0000000..9bdc5e6 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_title_8h-source.html @@ -0,0 +1,109 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartTitle.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_chart_x_y_serie_8h-source.html b/ChartDemo/Doc/html/_chart_x_y_serie_8h-source.html new file mode 100644 index 0000000..2e68657 --- /dev/null +++ b/ChartDemo/Doc/html/_chart_x_y_serie_8h-source.html @@ -0,0 +1,115 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartXYSerie.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_colour_picker_8h-source.html b/ChartDemo/Doc/html/_colour_picker_8h-source.html new file mode 100644 index 0000000..ea4b0f4 --- /dev/null +++ b/ChartDemo/Doc/html/_colour_picker_8h-source.html @@ -0,0 +1,136 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ColourPicker.h Source File + + + + + +
Generated on Thu Mar 5 21:28:19 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_colour_popup_8h-source.html b/ChartDemo/Doc/html/_colour_popup_8h-source.html new file mode 100644 index 0000000..28e9736 --- /dev/null +++ b/ChartDemo/Doc/html/_colour_popup_8h-source.html @@ -0,0 +1,156 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ColourPopup.h Source File + + + + + +
Generated on Thu Mar 5 21:28:19 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_line_prop_dialog_8h-source.html b/ChartDemo/Doc/html/_line_prop_dialog_8h-source.html new file mode 100644 index 0000000..4dce7a6 --- /dev/null +++ b/ChartDemo/Doc/html/_line_prop_dialog_8h-source.html @@ -0,0 +1,72 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/LinePropDialog.h Source File + + + + + +
Generated on Sat Mar 7 11:33:23 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_points_ordering_8h-source.html b/ChartDemo/Doc/html/_points_ordering_8h-source.html new file mode 100644 index 0000000..4d01559 --- /dev/null +++ b/ChartDemo/Doc/html/_points_ordering_8h-source.html @@ -0,0 +1,56 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/PointsOrdering.h Source File + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_points_prop_dialog_8h-source.html b/ChartDemo/Doc/html/_points_prop_dialog_8h-source.html new file mode 100644 index 0000000..7f5f6ec --- /dev/null +++ b/ChartDemo/Doc/html/_points_prop_dialog_8h-source.html @@ -0,0 +1,74 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/PointsPropDialog.h Source File + + + + + +
Generated on Sat Mar 7 11:33:24 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_series_prop_dlg_8h-source.html b/ChartDemo/Doc/html/_series_prop_dlg_8h-source.html new file mode 100644 index 0000000..7c6117b --- /dev/null +++ b/ChartDemo/Doc/html/_series_prop_dlg_8h-source.html @@ -0,0 +1,109 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/SeriesPropDlg.h Source File + + + + + +
Generated on Sat Mar 7 11:33:24 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_std_afx_8h-source.html b/ChartDemo/Doc/html/_std_afx_8h-source.html new file mode 100644 index 0000000..8037869 --- /dev/null +++ b/ChartDemo/Doc/html/_std_afx_8h-source.html @@ -0,0 +1,53 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/StdAfx.h Source File + + + + + +
Generated on Sat Mar 7 11:33:24 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/_surface_prop_dialog_8h-source.html b/ChartDemo/Doc/html/_surface_prop_dialog_8h-source.html new file mode 100644 index 0000000..db462e9 --- /dev/null +++ b/ChartDemo/Doc/html/_surface_prop_dialog_8h-source.html @@ -0,0 +1,72 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/SurfacePropDialog.h Source File + + + + + +
Generated on Sat Mar 7 11:33:24 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/annotated.html b/ChartDemo/Doc/html/annotated.html new file mode 100644 index 0000000..d0dab58 --- /dev/null +++ b/ChartDemo/Doc/html/annotated.html @@ -0,0 +1,67 @@ + + +ChartDemo: Class List + + + + + +
+

Class List

Here are the classes, structs, unions and interfaces with brief descriptions: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CChartAxisBase class that takes care of the management of a chart axis
CChartAxisLabelDraws the label of an axis
CChartBalloonLabel< PointType >Specialization of the CChartLabel to display a balloon label
CChartBarSerieSpecialization of a CChartSerie to display a bars series
CChartCandlestickSerieSpecialization of a CChartSerieBase to display a candlestick series
CChartCrossHairCursorSpecialization of a CChartCursor class for a cross-hair cursor
CChartCtrlThe main chart control class
CChartCursorBase class for cursors which can be added to the chart control
CChartCursorListenerInterface to implement in order to be notified about a cursor movement
CChartDateTimeAxisA specialization of the CChartAxis class for displaying date and time data
CChartDragLineCursorSpecialization of a CChartCursor class for a dragline cursor
CChartFontWrapper class for fonts with advanced properties (italic, bold or underlined)
CChartGanttSerieSpecialization of a CChartSerieBase to display a gantt series
CChartGradientHelper class to draw gradient
CChartGridClass which draws the grid associated with a specific axis
CChartLabel< PointType >Draws a label containing some text which is attached to a point of a series
CChartLabelProvider< PointType >Interface which should be implemented in order to provide text to a label
CChartLegendThis class is responsible for the legend displayed on the control
CChartLineSerieSpecialization of a CChartSerie to display a line series
CChartLogarithmicAxisSpecialization of a CChartAxis to display a logarithmic scale
CChartMouseListenerListener for mouse events occuring on the chart control
CChartPointsArray< T >Manages an array of points which supports fast resizing
CChartPointsSerieSpecialization of a CChartSerie to display a points series
CChartScrollBarClass which manages the interaction with the axis scroll bar
CChartSerieAbstract class that provides a common "interface" for all series in the control
CChartSerieBase< T >Base class for all series of the control
CChartSeriesMouseListener< PointType >Listener for mouse events occuring on a series
CChartStandardAxisSpecialization of a CChartAxis class to display standard values
CChartSurfaceSerieSpecialization of a CChartSerie to display a surface series
CChartTitleThis class is responsible for the titles displayed on the control
CChartXYSerieSpecialization of a CChartSerieBase for series having data with an X and an Y value
SChartCandlestickPointPoint structure used as template parameter for candlestick series
SChartGanttPointPoint structure used as template parameter for gantt series
SChartXYPointStructure containing a point data with X and Y values
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_axis-members.html b/ChartDemo/Doc/html/class_c_chart_axis-members.html new file mode 100644 index 0000000..39190dc --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_axis-members.html @@ -0,0 +1,98 @@ + + +ChartDemo: Member List + + + + + +
+

CChartAxis Member List

This is the complete list of members for CChartAxis, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CChartAxis()CChartAxis
EAxisAutoModes enum nameCChartAxis
EnableScrollBar(bool bEnabled)CChartAxis
FullAutomatic enum valueCChartAxis
GetAutoHideScrollBar() const CChartAxis
GetAutomaticMode() const CChartAxis [inline]
GetAxisLenght() const CChartAxis [protected]
GetFirstTickValue() const =0CChartAxis [protected, pure virtual]
GetGrid() const CChartAxis [inline]
GetLabel() const CChartAxis [inline]
GetMinMax(double &Minimum, double &Maximum) const CChartAxis [inline]
GetNextTickValue(double dCurrentTick, double &dNextTick) const =0CChartAxis [protected, pure virtual]
GetPosition()CChartAxis
GetScrollbarSteps(int &iTotalSteps, int &iCurrentStep)CChartAxis [protected, virtual]
GetSeriesMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetSeriesScreenMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetTextColor() const CChartAxis [inline]
GetTickLabel(double TickValue) const =0CChartAxis [protected, pure virtual]
GetTickPos(double Value) const =0CChartAxis [protected, pure virtual]
IsAutomatic() const CChartAxis [inline]
IsHorizontal() const CChartAxis [inline]
IsInverted() const CChartAxis [inline]
IsPointInside(const CPoint &screenPoint) const CChartAxis
IsVisible() const CChartAxis [inline]
m_AutoModeCChartAxis [protected]
m_AxisRectCChartAxis [protected]
m_bAutoTicksCChartAxis [protected]
m_bDiscreteCChartAxis [protected]
m_bIsHorizontalCChartAxis [protected]
m_bIsInvertedCChartAxis [protected]
m_bIsSecondaryCChartAxis [protected]
m_bIsVisibleCChartAxis [protected]
m_EndPosCChartAxis [protected]
m_MaxValueCChartAxis [protected]
m_MinValueCChartAxis [protected]
m_pParentCtrlCChartAxis [protected]
m_StartPosCChartAxis [protected]
m_UnzoomMaxCChartAxis [protected]
m_UnzoomMinCChartAxis [protected]
NotAutomatic enum valueCChartAxis
PanAxis(long PanStart, long PanEnd)CChartAxis [protected, virtual]
RefreshFirstTick()=0CChartAxis [protected, pure virtual]
RefreshTickIncrement()=0CChartAxis [protected, pure virtual]
ScreenAutomatic enum valueCChartAxis
ScreenToValue(long ScreenVal) const CChartAxis [virtual]
ScrollBarEnabled() const CChartAxis [inline]
SetAutoHideScrollBar(bool bAutoHide)CChartAxis
SetAutomatic(bool bAutomatic)CChartAxis
SetAutomaticMode(EAxisAutoModes AutoMode)CChartAxis
SetAxisColor(COLORREF NewColor)CChartAxis
SetAxisToScrollStep(int iPreviousStep, int iCurrentStep, bool bScrollInverted)CChartAxis [protected, virtual]
SetDiscrete(bool bDiscrete)CChartAxis [virtual]
SetFont(int nPointSize, const TChartString &strFaceName)CChartAxis
SetInverted(bool bInverted)CChartAxis
SetMarginSize(bool bAuto, int iNewSize)CChartAxis
SetMinMax(double Minimum, double Maximum)CChartAxis
SetPanZoomEnabled(bool bEnabled)CChartAxis [inline]
SetTextColor(COLORREF NewColor)CChartAxis
SetVisible(bool bVisible)CChartAxis
SetZoomLimit(double dLimit)CChartAxis [inline]
SetZoomMinMax(double Minimum, double Maximum)CChartAxis [protected, virtual]
UndoZoom()CChartAxis [protected]
ValueToScreen(double Value) const CChartAxis
ValueToScreenDiscrete(double Value) const =0CChartAxis [protected, pure virtual]
ValueToScreenStandard(double Value) const CChartAxis [protected, virtual]
~CChartAxis()CChartAxis [virtual]

+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_axis.html b/ChartDemo/Doc/html/class_c_chart_axis.html new file mode 100644 index 0000000..b489650 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_axis.html @@ -0,0 +1,964 @@ + + +ChartDemo: CChartAxis Class Reference + + + + + +
+

CChartAxis Class Reference

Base class that takes care of the management of a chart axis. +More... +

+#include <ChartAxis.h> +

+

+Inheritance diagram for CChartAxis:
+
+ +

+ +CChartDateTimeAxis +CChartLogarithmicAxis +CChartStandardAxis + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  EAxisAutoModes { NotAutomatic, +FullAutomatic, +ScreenAutomatic + }
 The different modes of automatic modes for an axis. More...

Public Member Functions

CChartAxis ()
 Default constructor.
+virtual ~CChartAxis ()
 Default destructor.
+int GetPosition ()
 Retrieves the position (in %) of the axis.
void SetInverted (bool bInverted)
 Sets the axis in reverse.
+bool IsInverted () const
 Retrieves if the axis is inverted or not.
void SetAutomatic (bool bAutomatic)
 Sets the axis in automatic or manual mode.
bool IsAutomatic () const
 Returns true if an automatic mode has been set on this axis.
+void SetAutomaticMode (EAxisAutoModes AutoMode)
 Sets the automatic mode of the axis.
+EAxisAutoModes GetAutomaticMode () const
 Gets the automatic type of the axis.
+void SetVisible (bool bVisible)
 Sets the axis visible/invisible.
+bool IsVisible () const
 Retrieves the axis automatic mode.
void SetMinMax (double Minimum, double Maximum)
 Sets the axis min and max values.
+void GetMinMax (double &Minimum, double &Maximum) const
 Gets the min anx max values of the axis.
+void SetAxisColor (COLORREF NewColor)
 Sets the axis color.
+void SetTextColor (COLORREF NewColor)
 Sets the tick labels color.
+COLORREF GetTextColor () const
 Gets the tick labels color.
void SetFont (int nPointSize, const TChartString &strFaceName)
 Sets the tick labels font.
+CChartAxisLabelGetLabel () const
 Retrieves the chart axis label object.
+CChartGridGetGrid () const
 Retrieves the chart axis grid object.
void SetMarginSize (bool bAuto, int iNewSize)
 Sets the margin size.
+void SetPanZoomEnabled (bool bEnabled)
 Enable the pan and zoom for this axis.
void SetZoomLimit (double dLimit)
 Sets the zoom limit.
+void EnableScrollBar (bool bEnabled)
 Enables/disables the scroll bar.
+bool ScrollBarEnabled () const
 Retrieves if the scroll bar is enabled or not.
void SetAutoHideScrollBar (bool bAutoHide)
 Specifies if the scroll bar is in auto-hide mode.
+bool GetAutoHideScrollBar () const
 Retrieves if the scroll bar is in auto-hide mode.
virtual void SetDiscrete (bool bDiscrete)
 Sets the axis in discrete mode.
long ValueToScreen (double Value) const
 Converts a value on the axis to a screen position.
virtual double ScreenToValue (long ScreenVal) const
 Converts a screen position to a value on the axis.
+bool IsHorizontal () const
 Returns true if the axis is horizontal.
+BOOL IsPointInside (const CPoint &screenPoint) const
 Returns true if a screen point is in the region of the axis.

Protected Member Functions

virtual double GetFirstTickValue () const =0
 Returns the first tick value.
virtual bool GetNextTickValue (double dCurrentTick, double &dNextTick) const =0
 Retrieves the next tick value after a given tick.
virtual long GetTickPos (double Value) const =0
 Retrieves the screen position of a certain tick.
virtual long ValueToScreenDiscrete (double Value) const =0
 Converts a value on the axis to a screen position.
virtual long ValueToScreenStandard (double Value) const
 Converts a value on the axis to a screen position.
virtual TChartString GetTickLabel (double TickValue) const =0
 Retrieves the label for a specific tick.
+virtual void RefreshTickIncrement ()=0
 Forces a recalculation of the tick increment.
+virtual void RefreshFirstTick ()=0
 Forces a recalculation of the first tick value.
virtual void GetScrollbarSteps (int &iTotalSteps, int &iCurrentStep)
 Retrieves the step information related to the scrollbar.
virtual void SetAxisToScrollStep (int iPreviousStep, int iCurrentStep, bool bScrollInverted)
 Sets the axis to the specified scrollbar step.
virtual void PanAxis (long PanStart, long PanEnd)
 Pan the axis.
+virtual void SetZoomMinMax (double Minimum, double Maximum)
 Sets the min and max values of the axis due to a zoom operation.
+void UndoZoom ()
 Reverts the zoom and pan settings.
+long GetAxisLenght () const
 Retrieves the lenght (in pixels) of the axis.
+void GetSeriesMinMax (double &Minimum, double &Maximum)
 Retrieves the min and max values for all the series related to this axis.
+void GetSeriesScreenMinMax (double &Minimum, double &Maximum)
 Retrieves the screen min and max values for all the series related to this axis.

Protected Attributes

+CChartCtrlm_pParentCtrl
 The parent chart control.
+bool m_bIsHorizontal
 Indicates if this is an horizontal or vertical axis.
+bool m_bIsInverted
 Indicates if the axis is inverted.
EAxisAutoModes m_AutoMode
 Indicates if the axis is automatic.
+bool m_bIsVisible
 Indicates if the axis is visible or not.
bool m_bIsSecondary
 Specifies if the axis is secondary.
+double m_MaxValue
 The axis max value.
+double m_MinValue
 The axis min value.
+double m_UnzoomMin
 Min value of the axis before it has been zoomed.
+double m_UnzoomMax
 Max value of the axis before it has been zoomed.
+bool m_bAutoTicks
 Specify if the tick increment is manual or automatic.
+bool m_bDiscrete
 Specify if the axis has to be in discrete mode or not.
+int m_StartPos
 Start position of the axis (in pixels).
+int m_EndPos
 End position of the axis (in pixels).
+CRect m_AxisRect
 The rectangle in which the axis is contained.
+


Detailed Description

+Base class that takes care of the management of a chart axis. +

+This class cannot be instanciated but should be overriden in order to provide the required functionality (this is already done for standard axis, date/time axis and logarithmic axis).
+ The class provides already a lot of functionalities but delegate the ticks positioning and labeling to the child classes.
+ By default, the class manages a continues range of double values (which is the case for standard axis and date/time axis) but in some cases, this is not valid (for instance, a logarithmic scale). In that case, you should in addition override some specific functions (e.g. those handling the scrollbar). Take a look at the CChartLogarithmicAxis class for more details.


Member Enumeration Documentation

+ +
+
+ + + + +
enum CChartAxis::EAxisAutoModes
+
+
+ +

+The different modes of automatic modes for an axis. +

+

Enumerator:
+ + + + +
NotAutomatic  +The axis min and max values are set manually.
FullAutomatic  +The axis min and max values of the axis are the min and max values of all series associated with this axis. This corresponds to the "standard" automatic mode that was implemented before version 3.0.
ScreenAutomatic  +The axis min and max values of the axis are the visible min and max values of all series associated with this axis. The end result will then depends on how the other axes are configured.
+
+ +
+

+


Member Function Documentation

+ +
+
+ + + + + + + + +
virtual double CChartAxis::GetFirstTickValue (  )  const [protected, pure virtual]
+
+
+ +

+Returns the first tick value. +

+This pure virtual function must be implemented for specific axes type. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartAxis::GetNextTickValue (double  dCurrentTick,
double &  dNextTick 
) const [protected, pure virtual]
+
+
+ +

+Retrieves the next tick value after a given tick. +

+This pure virtual function must be implemented for specific axes type.

Parameters:
+ + + +
dCurrentTick The value of the current tick
dNextTick The value of the next tick will be stored in this parameter
+
+
Returns:
true if there is a next or false when the current tick is the last one.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartAxis::GetScrollbarSteps (int &  iTotalSteps,
int &  iCurrentStep 
) [protected, virtual]
+
+
+ +

+Retrieves the step information related to the scrollbar. +

+This function can be implemented for specific axis types which should provide a behavior different than the standard behavior (for instance log axis).

Parameters:
+ + + +
iTotalSteps Stores the total number of steps for the scrollbar
iCurrentStep Stores the current step index for the scrollbar
+
+ +
+

+ +

+
+ + + + + + + + + +
virtual TChartString CChartAxis::GetTickLabel (double  TickValue  )  const [protected, pure virtual]
+
+
+ +

+Retrieves the label for a specific tick. +

+This pure virtual function must be implemented for specific axes type.

Parameters:
+ + +
TickValue The tick value for which we need to get the label.
+
+
Returns:
A TChartString containing the label for the tick.
+ +
+

+ +

+
+ + + + + + + + + +
virtual long CChartAxis::GetTickPos (double  Value  )  const [protected, pure virtual]
+
+
+ +

+Retrieves the screen position of a certain tick. +

+This pure virtual function must be implemented for specific axes type.

Parameters:
+ + +
Value The value of the tick for which we want to retrieve the position
+
+
Returns:
the screen position of the tick
+ +
+

+ +

+
+ + + + + + + + +
bool CChartAxis::IsAutomatic (  )  const [inline]
+
+
+ +

+Returns true if an automatic mode has been set on this axis. +

+

Deprecated:
You should use the GetAutomaticType instead.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartAxis::PanAxis (long  PanStart,
long  PanEnd 
) [protected, virtual]
+
+
+ +

+Pan the axis. +

+This function can be overriden in case the axis doesn't display a continuous range of values (e.g. log axis).

Parameters:
+ + + +
PanStart The position of the start of the pan
PanEnd The position of the end of the pan
+
+ +
+

+ +

+
+ + + + + + + + + +
double CChartAxis::ScreenToValue (long  ScreenVal  )  const [virtual]
+
+
+ +

+Converts a screen position to a value on the axis. +

+The function is implemented for an axis with a standard behavior (the axis shows a continuous range of doubles). It is the case for standard axis and date/time axis (date are converted to doubles internally). Axis that needs a different behavior should override this function (e.g. a logarithmic axis). The function does not take care of the discrete mode.

Parameters:
+ + +
ScreenVal The screen value to convert
+
+
Returns:
the double value
+ +
+

+ +

+
+ + + + + + + + + +
void CChartAxis::SetAutoHideScrollBar (bool  bAutoHide  ) 
+
+
+ +

+Specifies if the scroll bar is in auto-hide mode. +

+In auto-hide mode, the scroll bar will be hidden until you hover the mouse over it. +

+

+ +

+
+ + + + + + + + + +
void CChartAxis::SetAutomatic (bool  bAutomatic  ) 
+
+
+ +

+Sets the axis in automatic or manual mode. +

+In automatic mode, the axis min and max will be updated depending on the series related to this axis.

Parameters:
+ + +
bAutomatic true if the axis should be automatic.
+
+
Deprecated:
You should use the SetAutomaticType instead.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartAxis::SetAxisToScrollStep (int  iPreviousStep,
int  iCurrentStep,
bool  bScrollInverted 
) [protected, virtual]
+
+
+ +

+Sets the axis to the specified scrollbar step. +

+This function can be implemented for specific axis types which should provide a behavior different than the standard behavior (for instance log axis).

Parameters:
+ + + + +
iPreviousStep The previous scroll step.
iCurrentStep The current scroll step to which the axis should be moved.
bScrollInverted Specifies if the scroll is inverted or not.
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartAxis::SetDiscrete (bool  bDiscrete  )  [virtual]
+
+
+ +

+Sets the axis in discrete mode. +

+

Parameters:
+ + +
bDiscrete true if the axis has to be discrete, false otherwise. In discrete mode, the axis doesn't have a continuous range of values but only steps which are defined by the tick interval. In this mode, you won't be able to plot points at a different location that in the middle of two ticks. For instance, if you have a tick interval of 1.0, trying to plot a value of 0.9 will display the point at the same position as if the value was 0.3: it will be displayed in the middle of tick 0.0 and tick 1.0.
+It is mainly used to display the tick label in the middle of two ticks. This is for instance nice with date/time axis.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartAxis::SetFont (int  nPointSize,
const TChartString &  strFaceName 
)
+
+
+ +

+Sets the tick labels font. +

+

Parameters:
+ + + +
nPointSize The font point size
strFaceName The font face name
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartAxis::SetInverted (bool  bInverted  ) 
+
+
+ +

+Sets the axis in reverse. +

+For an inverted axis, the values on the axis are in decreasing order.

Parameters:
+ + +
bInverted true if the axis has to be inverted.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartAxis::SetMarginSize (bool  bAuto,
int  iNewSize 
)
+
+
+ +

+Sets the margin size. +

+

Parameters:
+ + + +
bAuto Specifies if the margin size is automatic or not. In automatic mode, the iNewSize parameter is ignored and the margin size is calculated automatically.
iNewSize The new size of the margin, in manual mode.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartAxis::SetMinMax (double  Minimum,
double  Maximum 
)
+
+
+ +

+Sets the axis min and max values. +

+This doesn't take into account the real type of the axis, so double values should be provided.

Parameters:
+ + + +
Minimum The min value of the axis
Maximum The max value of the axis.
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartAxis::SetZoomLimit (double  dLimit  )  [inline]
+
+
+ +

+Sets the zoom limit. +

+The zoom limit is the minimum lenght (in values) of the axis. +

+

+ +

+
+ + + + + + + + + +
long CChartAxis::ValueToScreen (double  Value  )  const
+
+
+ +

+Converts a value on the axis to a screen position. +

+The functions takes care of the discrete mode (internally, it calls ValueToScreenStandard or ValueToScreenDiscrete depending on the discrete mode).

Parameters:
+ + +
Value The value to convert
+
+
Returns:
the screen position of the value
+ +
+

+ +

+
+ + + + + + + + + +
virtual long CChartAxis::ValueToScreenDiscrete (double  Value  )  const [protected, pure virtual]
+
+
+ +

+Converts a value on the axis to a screen position. +

+This function is called internally only when the axis is in discrete mode. This pure virtual function must be implemented for specific axes type.

Parameters:
+ + +
Value The value to convert
+
+
Returns:
the screen position of the value
+ +
+

+ +

+
+ + + + + + + + + +
long CChartAxis::ValueToScreenStandard (double  Value  )  const [protected, virtual]
+
+
+ +

+Converts a value on the axis to a screen position. +

+This function is called internally only when the axis is in standard mode. This virtual function can be overriden when the axis doesn't display a continuous range of values (e.g. log axis).

Parameters:
+ + +
Value The value to convert
+
+
Returns:
the screen position of the value
+ +
+

+


Member Data Documentation

+ +
+
+ + + + +
EAxisAutoModes CChartAxis::m_AutoMode [protected]
+
+
+ +

+Indicates if the axis is automatic. +

+Indicates the automatic mode of the axis +

+

+ +

+
+ + + + +
bool CChartAxis::m_bIsSecondary [protected]
+
+
+ +

+Specifies if the axis is secondary. +

+The secondary axis is either on the top (for horizontal axis) or on the right (for vertical axis) of the chart. +

+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxis.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxis.cpp
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_axis.png b/ChartDemo/Doc/html/class_c_chart_axis.png new file mode 100644 index 0000000..02904ce Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_axis.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_axis_label-members.html b/ChartDemo/Doc/html/class_c_chart_axis_label-members.html new file mode 100644 index 0000000..72b7c1f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_axis_label-members.html @@ -0,0 +1,40 @@ + + +ChartDemo: Member List + + + + + +
+

CChartAxisLabel Member List

This is the complete list of members for CChartAxisLabel, including all inherited members.

+ + + + + + + + +
GetColor() const CChartAxisLabel [inline]
GetText() const CChartAxisLabel [inline]
IsVisible() const CChartAxisLabel [inline]
SetColor(COLORREF NewColor)CChartAxisLabel
SetFont(int nPointSize, const TChartString &strFaceName)CChartAxisLabel
SetFont(const CChartFont &newFont)CChartAxisLabel
SetText(const TChartString &NewText)CChartAxisLabel
SetVisible(bool bVisible)CChartAxisLabel

+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_axis_label.html b/ChartDemo/Doc/html/class_c_chart_axis_label.html new file mode 100644 index 0000000..f6941bf --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_axis_label.html @@ -0,0 +1,142 @@ + + +ChartDemo: CChartAxisLabel Class Reference + + + + + +
+

CChartAxisLabel Class Reference

Draws the label of an axis. +More... +

+#include <ChartAxisLabel.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void SetText (const TChartString &NewText)
 Sets the text of the axis label.
+TChartString GetText () const
 Retrieves the text of the axis label.
void SetFont (int nPointSize, const TChartString &strFaceName)
 Sets the font of the text.
void SetFont (const CChartFont &newFont)
 Sets the font of the text.
+void SetVisible (bool bVisible)
 Shows/hides the title.
+bool IsVisible () const
 Returns true if the title is visible.
+COLORREF GetColor () const
 Retrieves the text color.
+void SetColor (COLORREF NewColor)
 Sets the text color.
+


Detailed Description

+Draws the label of an axis. +

+The label axis is displayed under or next to the tick values. The label is retrieved by calling CChartAxis::GetAxisLabel.


Member Function Documentation

+ +
+
+ + + + + + + + + +
void CChartAxisLabel::SetFont (const CChartFont newFont  ) 
+
+
+ +

+Sets the font of the text. +

+This function allows to set extended font style by passing a CChartFont object.

Parameters:
+ + +
newFont The new font.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartAxisLabel::SetFont (int  nPointSize,
const TChartString &  strFaceName 
)
+
+
+ +

+Sets the font of the text. +

+

Parameters:
+ + + +
nPointSize The font point size.
strFaceName The font face name ("Times New Roman", "Arial", ...)
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxisLabel.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxisLabel.cpp
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_balloon_label-members.html b/ChartDemo/Doc/html/class_c_chart_balloon_label-members.html new file mode 100644 index 0000000..a82cf33 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_balloon_label-members.html @@ -0,0 +1,57 @@ + + +ChartDemo: Member List + + + + + +
+

CChartBalloonLabel< PointType > Member List

This is the complete list of members for CChartBalloonLabel< PointType >, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
CChartBalloonLabel(CChartCtrl *pParentCtrl, CChartSerieBase< PointType > *pParentSeries)CChartBalloonLabel< PointType > [inline]
CChartLabel(CChartCtrl *pParentCtrl, CChartSerieBase< PointType > *pParentSeries)CChartLabel< PointType > [inline, protected]
Draw(CDC *pDC, unsigned uPointIndex)CChartBalloonLabel< PointType > [inline, protected, virtual]
GetBackgroundColor() const CChartBalloonLabel< PointType > [inline]
GetBorderColor() const CChartBalloonLabel< PointType > [inline]
GetLineColor() const CChartBalloonLabel< PointType > [inline]
GetRoundedRect() const CChartBalloonLabel< PointType > [inline]
m_bIsVisibleCChartLabel< PointType > [protected]
m_iFontSizeCChartLabel< PointType > [protected]
m_pLabelProviderCChartLabel< PointType > [protected]
m_pParentCtrlCChartLabel< PointType > [protected]
m_pParentSeriesCChartLabel< PointType > [protected]
m_strFontNameCChartLabel< PointType > [protected]
m_strLabelTextCChartLabel< PointType > [protected]
SetBackgroundColor(COLORREF colBackground)CChartBalloonLabel< PointType > [inline]
SetBorderColor(COLORREF colBorder)CChartBalloonLabel< PointType > [inline]
SetFont(int nPointSize, const TChartString &strFaceName)CChartBalloonLabel< PointType > [inline]
SetFont(const CChartFont &newFont)CChartBalloonLabel< PointType > [inline]
SetLabelProvider(CChartLabelProvider< PointType > *pProvider)CChartLabel< PointType > [inline]
SetLabelText(const TChartString &strText)CChartLabel< PointType > [inline]
SetLineColor(COLORREF colArrow)CChartBalloonLabel< PointType > [inline]
SetRoundedRect(bool bRounded)CChartBalloonLabel< PointType > [inline]
SetVisisble(bool bVisible)CChartLabel< PointType > [inline]
~CChartBalloonLabel()CChartBalloonLabel< PointType > [inline]
~CChartLabel()CChartLabel< PointType > [inline, protected, virtual]

+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_balloon_label.html b/ChartDemo/Doc/html/class_c_chart_balloon_label.html new file mode 100644 index 0000000..037ee8b --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_balloon_label.html @@ -0,0 +1,181 @@ + + +ChartDemo: CChartBalloonLabel< PointType > Class Template Reference + + + + + +
+

CChartBalloonLabel< PointType > Class Template Reference

Specialization of the CChartLabel to display a balloon label. +More... +

+#include <ChartBalloonLabel.h> +

+

+Inheritance diagram for CChartBalloonLabel< PointType >:
+
+ +

+ +CChartLabel< PointType > + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void SetBackgroundColor (COLORREF colBackground)
 Sets the background color of the text area.
+COLORREF GetBackgroundColor () const
 Retrieves the background color of the text area.
+void SetLineColor (COLORREF colArrow)
 Sets the color of the line connecting the point to the text area.
+COLORREF GetLineColor () const
 Retrieves the color of the line connecting the point to the text area.
+void SetBorderColor (COLORREF colBorder)
 Sets the color of border's text area.
+COLORREF GetBorderColor () const
 Retrieves the color of border's text area.
+void SetRoundedRect (bool bRounded)
 Specifies if the text area is rounded or not.
+bool GetRoundedRect () const
 Returns true if the text area is rounded.
void SetFont (int nPointSize, const TChartString &strFaceName)
 Sets the font of the text.
void SetFont (const CChartFont &newFont)
 Sets the font of the text.
CChartBalloonLabel (CChartCtrl *pParentCtrl, CChartSerieBase< PointType > *pParentSeries)
 Constructor.
~CChartBalloonLabel ()
 Destructor.

Protected Member Functions

+void Draw (CDC *pDC, unsigned uPointIndex)
 Draw the label.
+


Detailed Description

+

template<class PointType>
+ class CChartBalloonLabel< PointType >

+ +Specialization of the CChartLabel to display a balloon label. +

+A balloon label is a label with a rounded rectangle area in which the text is displayed and which is connected with a line to the point to which it is attached.


Member Function Documentation

+ +
+
+
+template<class PointType >
+ + + + + + + + + +
void CChartBalloonLabel< PointType >::SetFont (const CChartFont newFont  )  [inline]
+
+
+ +

+Sets the font of the text. +

+This function allows to set extended font style by passing a CChartFont object.

Parameters:
+ + +
newFont The new font.
+
+ +
+

+ +

+
+
+template<class PointType >
+ + + + + + + + + + + + + + + + + + +
void CChartBalloonLabel< PointType >::SetFont (int  nPointSize,
const TChartString &  strFaceName 
) [inline]
+
+
+ +

+Sets the font of the text. +

+

Parameters:
+ + + +
nPointSize The font point size.
strFaceName The font face name ("Times New Roman", "Arial", ...)
+
+ +

Reimplemented from CChartLabel< PointType >.

+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartBalloonLabel.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartBalloonLabel.inl
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_balloon_label.png b/ChartDemo/Doc/html/class_c_chart_balloon_label.png new file mode 100644 index 0000000..b1c0500 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_balloon_label.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_bar_serie-members.html b/ChartDemo/Doc/html/class_c_chart_bar_serie-members.html new file mode 100644 index 0000000..b644e1e --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_bar_serie-members.html @@ -0,0 +1,119 @@ + + +ChartDemo: Member List + + + + + +
+

CChartBarSerie Member List

This is the complete list of members for CChartBarSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double X, double Y)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoint(const SChartXYPoint &newPoint)CChartSerieBase< SChartXYPoint >
AddPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartXYPoint > *pLabel)CChartSerieBase< SChartXYPoint >
CChartBarSerie(CChartCtrl *pParent)CChartBarSerie
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartXYPoint >
CChartXYSerie(CChartCtrl *pParent)CChartXYSerie
ClearSerie()CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartXYPoint > *pLabelProvider)CChartSerieBase< SChartXYPoint >
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetBarWidth() const CChartBarSerie [inline]
GetBezierControlPoints(unsigned uFirst, unsigned uLast, SChartXYPoint *&pKnots, SChartXYPoint *&pFirstControlPoints, SChartXYPoint *&pSecondControlPoints) const CChartXYSerie [protected]
GetBorderColor() const CChartBarSerie [inline]
GetBorderWidth() const CChartBarSerie [inline]
GetColor() const CChartSerie [inline]
GetGroupId() const CChartBarSerie [inline]
GetHorizontal() const CChartBarSerie [inline]
GetInterSpace()CChartBarSerie [inline, static]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartXYPoint >
GetPointsCount() constCChartSerieBase< SChartXYPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartXYPoint > [virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetUserData(unsigned uPointIndex)CChartXYSerie
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartXYPoint > [protected, virtual]
GetXPointValue(unsigned PointIndex) const CChartXYSerie
GetYPointValue(unsigned PointIndex) const CChartXYSerie
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const CChartBarSerie [virtual]
IsStacked()CChartBarSerie
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartXYPoint > [protected]
m_vPointsCChartSerieBase< SChartXYPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartXYPoint > [protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartXYPoint > *pListener)CChartSerieBase< SChartXYPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartXYPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartXYPoint >
SetBarWidth(int Width)CChartBarSerie
SetBaseLine(bool bAutomatic, double dBaseLine)CChartBarSerie [inline]
SetBorderColor(COLORREF BorderColor)CChartBarSerie
SetBorderWidth(int Width)CChartBarSerie
SetColor(COLORREF NewColor)CChartSerie
SetGradient(COLORREF GradientColor, EGradientType GradientType)CChartBarSerie
SetGroupId(unsigned GroupId)CChartBarSerie
SetHorizontal(bool bHorizontal)CChartBarSerie
SetInterSpace(int Space)CChartBarSerie [inline, static]
SetName(const TChartString &NewName)CChartSerie
SetPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::SetPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< SChartXYPoint > [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetStacked(bool bStacked)CChartBarSerie
SetUserData(unsigned uPointIndex, void *pData)CChartXYSerie
SetVisible(bool bVisible)CChartSerie
SetXPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
SetYPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
ShowGradient(bool bShow)CChartBarSerie
UnregisterMouseListener()CChartSerieBase< SChartXYPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartBarSerie()CChartBarSerie
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartXYPoint > [virtual]
~CChartXYSerie()CChartXYSerie [virtual]

+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_bar_serie.html b/ChartDemo/Doc/html/class_c_chart_bar_serie.html new file mode 100644 index 0000000..08f2715 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_bar_serie.html @@ -0,0 +1,293 @@ + + +ChartDemo: CChartBarSerie Class Reference + + + + + +
+

CChartBarSerie Class Reference

Specialization of a CChartSerie to display a bars series. +More... +

+#include <ChartBarSerie.h> +

+

+Inheritance diagram for CChartBarSerie:
+
+ +

+ +CChartXYSerie +CChartSerieBase< SChartXYPoint > +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

CChartBarSerie (CChartCtrl *pParent)
 Constructor.
~CChartBarSerie ()
 Destructor.
+void SetHorizontal (bool bHorizontal)
 Specifies if the bars are vertical or horizontal.
+bool GetHorizontal () const
 Returns true if bars are horizontal, false otherwise.
+void SetBorderColor (COLORREF BorderColor)
 Sets the bars border color.
+COLORREF GetBorderColor () const
 Returns the bars border color.
+void SetBorderWidth (int Width)
 Sets the bars border width.
+int GetBorderWidth () const
 Returns the bars border width.
+void SetBarWidth (int Width)
 Sets the bars width (in pixels).
+int GetBarWidth () const
 Returns the bars width (in pixels).
void SetGroupId (unsigned GroupId)
 Set the group Id of the series.
+unsigned GetGroupId () const
 Returns the group Id of the series.
void SetStacked (bool bStacked)
 Specifies if the series is stacked with other bar series.
+bool IsStacked ()
 Returns true if the series is stacked.
+void ShowGradient (bool bShow)
 Specifies if a gradient is applied to the bars.
void SetGradient (COLORREF GradientColor, EGradientType GradientType)
 Sets the gradient style.
void SetBaseLine (bool bAutomatic, double dBaseLine)
 Specifies a base line for the bars.
bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const
 Check whether a screen point is on the series.

Static Public Member Functions

+static void SetInterSpace (int Space)
 Static function used to specify the space (in pixels) between series of the same group.
+static int GetInterSpace ()
 Static function returning the space between series of the same group.
+


Detailed Description

+Specialization of a CChartSerie to display a bars series. +

+This class is a specialized series class used to display vertical (default) or horizontal bars. Each bar in the series is centered around its X value (for vertical bars) or Y value (for horizontal bars). Bars can be grouped together, so that they do not overlap but are stacked next to each other (or on top of each other). This is done by specifying a group Id: bar series with the same group Id will be grouped together (stacked). Series with different group Id will be independant (they will be drawn as if they were the only one, meaning that the different series will probably overlap).


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool CChartBarSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [virtual]
+
+
+ +

+Check whether a screen point is on the series. +

+This function returns true if the screen point is on one of the bars of the series. In that case, the index of the point is stored in the uIndex parameter.

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartBarSerie::SetBaseLine (bool  bAutomatic,
double  dBaseLine 
) [inline]
+
+
+ +

+Specifies a base line for the bars. +

+If a baseline is specified, the bars will be drawn between that value and the point value, instead of being drawn between the axis ans the point value.

Parameters:
+ + + +
bAutomatic If true, the bars are drawn between the axis and the point value.
dBaseLine The value of the baseline. This parameter is ignored if bAutomatic is true.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartBarSerie::SetGradient (COLORREF  GradientColor,
EGradientType  GradientType 
)
+
+
+ +

+Sets the gradient style. +

+

Parameters:
+ + + +
GradientColor The second color used for the gradient (the first one being the original series color).
GradientType The type of gradient used between the two colors (vertical, horizontal, ...)
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartBarSerie::SetGroupId (unsigned  GroupId  ) 
+
+
+ +

+Set the group Id of the series. +

+The group Id allows to stack series next to each other (or on top of each other). +

+

+ +

+
+ + + + + + + + + +
void CChartBarSerie::SetStacked (bool  bStacked  ) 
+
+
+ +

+Specifies if the series is stacked with other bar series. +

+All bar series with the same group Id and with the stacked flag to true will be drawn on top of each other (for vertical bars). +

+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartBarSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartBarSerie.cpp
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_bar_serie.png b/ChartDemo/Doc/html/class_c_chart_bar_serie.png new file mode 100644 index 0000000..40f17a2 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_bar_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_candlestick_serie-members.html b/ChartDemo/Doc/html/class_c_chart_candlestick_serie-members.html new file mode 100644 index 0000000..c2c9284 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_candlestick_serie-members.html @@ -0,0 +1,96 @@ + + +ChartDemo: Member List + + + + + +
+

CChartCandlestickSerie Member List

This is the complete list of members for CChartCandlestickSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double XVal, double Low, double High, double Open, double Close)CChartCandlestickSerie
CChartSerieBase< SChartCandlestickPoint >::AddPoint(const SChartCandlestickPoint &newPoint)CChartSerieBase< SChartCandlestickPoint >
AddPoints(SChartCandlestickPoint *pPoints, unsigned Count)CChartSerieBase< SChartCandlestickPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartCandlestickPoint > *pLabel)CChartSerieBase< SChartCandlestickPoint >
CChartCandlestickSerie(CChartCtrl *pParent)CChartCandlestickSerie
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartCandlestickPoint >
ClearSerie()CChartSerieBase< SChartCandlestickPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartCandlestickPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartCandlestickPoint > *pLabelProvider)CChartSerieBase< SChartCandlestickPoint >
Draw(CDC *pDC)CChartCandlestickSerie [protected, virtual]
DrawAll(CDC *pDC)CChartCandlestickSerie [protected, virtual]
DrawLegend(CDC *pDC, const CRect &rectBitmap) const CChartCandlestickSerie [protected, virtual]
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartCandlestickPoint >
GetPointsCount() constCChartSerieBase< SChartCandlestickPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartCandlestickPoint > [virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartCandlestickPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartCandlestickPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartCandlestickPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartCandlestickPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartCandlestickPoint > [protected, virtual]
GetWidth()CChartCandlestickSerie [inline]
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const CChartCandlestickSerie [virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartCandlestickPoint > [protected]
m_vPointsCChartSerieBase< SChartCandlestickPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartCandlestickPoint > [protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartCandlestickPoint > *pListener)CChartSerieBase< SChartCandlestickPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartCandlestickPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartCandlestickPoint >
SetColor(COLORREF NewColor)CChartSerie
SetName(const TChartString &NewName)CChartSerie
SetPoints(SChartCandlestickPoint *pPoints, unsigned Count)CChartSerieBase< SChartCandlestickPoint >
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< SChartCandlestickPoint > [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetVisible(bool bVisible)CChartSerie
SetWidth(int Width)CChartCandlestickSerie
UnregisterMouseListener()CChartSerieBase< SChartCandlestickPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartCandlestickSerie()CChartCandlestickSerie
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartCandlestickPoint > [virtual]

+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_candlestick_serie.html b/ChartDemo/Doc/html/class_c_chart_candlestick_serie.html new file mode 100644 index 0000000..6e689e3 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_candlestick_serie.html @@ -0,0 +1,285 @@ + + +ChartDemo: CChartCandlestickSerie Class Reference + + + + + +
+

CChartCandlestickSerie Class Reference

Specialization of a CChartSerieBase to display a candlestick series. +More... +

+#include <ChartCandlestickSerie.h> +

+

+Inheritance diagram for CChartCandlestickSerie:
+
+ +

+ +CChartSerieBase< SChartCandlestickPoint > +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

CChartCandlestickSerie (CChartCtrl *pParent)
 Constructor.
~CChartCandlestickSerie ()
 Destructor.
bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const
 Tests if a certain screen point is on the series.
void AddPoint (double XVal, double Low, double High, double Open, double Close)
 Adds a new point in the series.
+void SetWidth (int Width)
 Sets the width (in pixels) of all candlestick points in the series.
+int GetWidth ()
 Returns the width (in pixels) of a point in the series.

Protected Member Functions

void DrawLegend (CDC *pDC, const CRect &rectBitmap) const
 Draws the legend icon for the series.
void Draw (CDC *pDC)
 Draws the most recent points of the series.
void DrawAll (CDC *pDC)
 Redraws the full series.
+


Detailed Description

+Specialization of a CChartSerieBase to display a candlestick series. +

+Each point in the series has an X value (the time), a high value (the highest market price), a low value (the lowest market price), an open value (the market price at the opening) and a close value (the market price at the closing).


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void CChartCandlestickSerie::AddPoint (double  XVal,
double  Low,
double  High,
double  Open,
double  Close 
)
+
+
+ +

+Adds a new point in the series. +

+

Parameters:
+ + + + + + +
XVal The X value of the point (the time)
Low The lowest market price
High The highest market price
Open The market price at the opening
Close The market price at the closing
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartCandlestickSerie::Draw (CDC *  pDC  )  [protected, virtual]
+
+
+ +

+Draws the most recent points of the series. +

+This function should only draw the points that were not previously drawn.

Parameters:
+ + +
pDC The device context used to draw
+
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + +
void CChartCandlestickSerie::DrawAll (CDC *  pDC  )  [protected, virtual]
+
+
+ +

+Redraws the full series. +

+

Parameters:
+ + +
pDC The device context used to draw
+
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartCandlestickSerie::DrawLegend (CDC *  pDC,
const CRect &  rectBitmap 
) const [protected, virtual]
+
+
+ +

+Draws the legend icon for the series. +

+

Parameters:
+ + + +
pDC The device context used to draw
rectBitmap The rectangle in which to draw the legend icon
+
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
bool CChartCandlestickSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [virtual]
+
+
+ +

+Tests if a certain screen point is on the series. +

+

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implements CChartSerie.

+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCandlestickSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCandlestickSerie.cpp
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_candlestick_serie.png b/ChartDemo/Doc/html/class_c_chart_candlestick_serie.png new file mode 100644 index 0000000..2b2edcf Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_candlestick_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor-members.html b/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor-members.html new file mode 100644 index 0000000..7c73e1f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor-members.html @@ -0,0 +1,48 @@ + + +ChartDemo: Member List + + + + + +
+

CChartCrossHairCursor Member List

This is the complete list of members for CChartCrossHairCursor, including all inherited members.

+ + + + + + + + + + + + + + + + +
CChartCursor(CChartCtrl *pParent)CChartCursor [protected]
CursorMoved(double newXValue, double newYValue)CChartCursor [protected]
Draw(CDC *pDC)CChartCrossHairCursor [protected, virtual]
GetCursorId() const CChartCursor [inline]
m_colCursorCChartCursor [protected]
m_lstListenersCChartCursor [protected]
m_pParentCtrlCChartCursor [protected]
m_uCursorIdCChartCursor [protected]
m_uNextFreeIdCChartCursor [protected, static]
OnMouseButtonDown(CPoint)CChartCursor [inline, protected, virtual]
OnMouseButtonUp(CPoint)CChartCursor [inline, protected, virtual]
OnMouseMove(CPoint mousePoint)CChartCrossHairCursor [protected, virtual]
RegisterListener(CChartCursorListener *pListener)CChartCursor
SetColor(COLORREF cursorColor)CChartCursor
TListenerList typedef (defined in CChartCursor)CChartCursor [protected]
~CChartCursor()CChartCursor [protected, virtual]

+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor.html b/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor.html new file mode 100644 index 0000000..1e4c495 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor.html @@ -0,0 +1,65 @@ + + +ChartDemo: CChartCrossHairCursor Class Reference + + + + + +
+

CChartCrossHairCursor Class Reference

Specialization of a CChartCursor class for a cross-hair cursor. +More... +

+#include <ChartCrossHairCursor.h> +

+

+Inheritance diagram for CChartCrossHairCursor:
+
+ +

+ +CChartCursor + +
+ +

+List of all members. + + + + + + + + +

Protected Member Functions

+void OnMouseMove (CPoint mousePoint)
 Called when the mouse is moved over the plot area.
+void Draw (CDC *pDC)
 Draws the cursor.
+


Detailed Description

+Specialization of a CChartCursor class for a cross-hair cursor. +

+A cross-hair cursor is a simple cross displayed in the plotting area. The cursor moves along with the mouse (but stay within the bounds of the plot area).
+ To create a cross-hair cursor, call the CreateCrossHairCursor from the CChartCtrl class.


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCrossHairCursor.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCrossHairCursor.cpp
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor.png b/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor.png new file mode 100644 index 0000000..c28da37 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_cross_hair_cursor.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_ctrl-members.html b/ChartDemo/Doc/html/class_c_chart_ctrl-members.html new file mode 100644 index 0000000..39d5ffd --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_ctrl-members.html @@ -0,0 +1,109 @@ + + +ChartDemo: Member List + + + + + +
+

CChartCtrl Member List

This is the complete list of members for CChartCtrl, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttachCustomAxis(CChartAxis *pAxis, EAxisPos axisPos)CChartCtrl
AttachCustomCursor(CChartCursor *pCursor)CChartCtrl
AttachCustomSerie(CChartSerie *pNewSeries, bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
BottomAxis enum value (defined in CChartCtrl)CChartCtrl
CChartCtrl()CChartCtrl
Create(CWnd *pParentWnd, const RECT &rect, UINT nID, DWORD dwStyle=WS_VISIBLE)CChartCtrl
CreateBarSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
CreateCandlestickSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
CreateCrossHairCursor(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
CreateDateTimeAxis(EAxisPos axisPos)CChartCtrl
CreateDragLineCursor(EAxisPos relatedAxis)CChartCtrl
CreateGanttSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
CreateLineSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
CreateLogarithmicAxis(EAxisPos axisPos)CChartCtrl
CreatePointsSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
CreateStandardAxis(EAxisPos axisPos)CChartCtrl
CreateSurfaceSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)CChartCtrl
DateToValue(const COleDateTime &Date)CChartCtrl [static]
DrawBackground(CDC *pDC, CRect ChartRect) (defined in CChartCtrl)CChartCtrl [protected, virtual]
DrawChart(CDC *pDC, CRect ChartRect) (defined in CChartCtrl)CChartCtrl [protected, virtual]
EAxisPos enum nameCChartCtrl
EnableRefresh(bool bEnable)CChartCtrl
GetAxis(EAxisPos axisPos) const CChartCtrl [inline]
GetBackColor() const CChartCtrl [inline]
GetBorderColor() const CChartCtrl [inline]
GetBottomAxis() const (defined in CChartCtrl)CChartCtrl
GetDC()CChartCtrl
GetEdgeType() const CChartCtrl [inline]
GetLeftAxis() const (defined in CChartCtrl)CChartCtrl
GetLegend() const CChartCtrl [inline]
GetNextSerie()CChartCtrl
GetPanEnabled() const CChartCtrl [inline]
GetPlottingRect() const CChartCtrl [inline]
GetRightAxis() const (defined in CChartCtrl)CChartCtrl
GetSerie(unsigned uSerieId) const CChartCtrl
GetSeriesCount() const CChartCtrl
GetTitle() const CChartCtrl [inline]
GetTopAxis() const (defined in CChartCtrl)CChartCtrl
GetZoomEnabled() const CChartCtrl [inline]
GetZoomRectColor() const CChartCtrl [inline]
GoToFirstSerie()CChartCtrl
LeftAxis enum value (defined in CChartCtrl)CChartCtrl
OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) (defined in CChartCtrl)CChartCtrl [protected, virtual]
OnEndPrinting(CDC *pDC, CPrintInfo *pInfo) (defined in CChartCtrl)CChartCtrl [protected, virtual]
OnEraseBkgnd(CDC *pDC) (defined in CChartCtrl)CChartCtrl [protected]
OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) (defined in CChartCtrl)CChartCtrl [protected]
OnLButtonDblClk(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnLButtonDown(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnLButtonUp(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnMouseMove(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnPaint() (defined in CChartCtrl)CChartCtrl [protected]
OnPrint(CDC *pDC, CPrintInfo *pInfo) (defined in CChartCtrl)CChartCtrl [protected, virtual]
OnRButtonDblClk(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnRButtonDown(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnRButtonUp(UINT nFlags, CPoint point) (defined in CChartCtrl)CChartCtrl [protected]
OnSize(UINT nType, int cx, int cy) (defined in CChartCtrl)CChartCtrl [protected]
OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) (defined in CChartCtrl)CChartCtrl [protected]
Print(const TChartString &strTitle, CPrintDialog *pPrntDialog=NULL)CChartCtrl [virtual]
RefreshCtrl()CChartCtrl
RefreshScreenAutoAxes()CChartCtrl
RegisterMouseListener(CChartMouseListener *pMouseListener)CChartCtrl [inline]
RemoveAllSeries()CChartCtrl
RemoveCursor(unsigned cursorId)CChartCtrl
RemoveSerie(unsigned uSerieId)CChartCtrl
RightAxis enum value (defined in CChartCtrl)CChartCtrl
SetBackColor(COLORREF NewCol)CChartCtrl [inline]
SetBackGradient(COLORREF Col1, COLORREF Col2, EGradientType GradientType)CChartCtrl
SetBorderColor(COLORREF NewCol)CChartCtrl [inline]
SetEdgeType(UINT NewEdge)CChartCtrl [inline]
SetPanEnabled(bool bEnabled)CChartCtrl [inline]
SetZoomEnabled(bool bEnabled)CChartCtrl [inline]
SetZoomRectColor(COLORREF NewCol)CChartCtrl [inline]
ShowMouseCursor(bool bShow)CChartCtrl
TopAxis enum value (defined in CChartCtrl)CChartCtrl
UndoPanZoom()CChartCtrl
ValueToDate(double Value)CChartCtrl [static]
~CChartCtrl()CChartCtrl [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_ctrl.html b/ChartDemo/Doc/html/class_c_chart_ctrl.html new file mode 100644 index 0000000..976aa8f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_ctrl.html @@ -0,0 +1,1206 @@ + + +ChartDemo: CChartCtrl Class Reference + + + + + +
+

CChartCtrl Class Reference

The main chart control class. +More... +

+#include <ChartCtrl.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  EAxisPos { LeftAxis = 0, +BottomAxis, +RightAxis, +TopAxis + }
 An enumeration of the different axis positions.

Public Member Functions

CDC * GetDC ()
 Retrieves de device context.
+CRect GetPlottingRect () const
 Retrieves the plotting rectangle.
+CChartLegendGetLegend () const
 Returns a pointer to the legend object.
+CChartTitleGetTitle () const
 Returns a pointer to the title object.
CChartStandardAxisCreateStandardAxis (EAxisPos axisPos)
 Create and attach a standard axis to the control.
CChartLogarithmicAxisCreateLogarithmicAxis (EAxisPos axisPos)
 Create and attach a logarithmic axis to the control.
CChartDateTimeAxisCreateDateTimeAxis (EAxisPos axisPos)
 Create and attach a date/time axis to the control.
void AttachCustomAxis (CChartAxis *pAxis, EAxisPos axisPos)
 Attach a custom axis to the control.
CChartPointsSerieCreatePointsSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a point series to the control.
CChartLineSerieCreateLineSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a line series to the control.
CChartSurfaceSerieCreateSurfaceSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a surface series to the control.
CChartBarSerieCreateBarSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a bar series to the control.
CChartCandlestickSerieCreateCandlestickSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a candlestick series to the control.
CChartGanttSerieCreateGanttSerie (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a gantt series to the control.
void AttachCustomSerie (CChartSerie *pNewSeries, bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Attaches a custom series to the chart.
CChartSerieGetSerie (unsigned uSerieId) const
 Retrieves a specific series from the chart.
void RemoveSerie (unsigned uSerieId)
 Removes a specific series from the chart.
+void RemoveAllSeries ()
 Removes all the series from the chart.
+size_t GetSeriesCount () const
 Returns the number of series in the chart.
CChartCrossHairCursorCreateCrossHairCursor (bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false)
 Create and attach a cross-hair cursor to the control.
CChartDragLineCursorCreateDragLineCursor (EAxisPos relatedAxis)
 Create and attach a drag-line cursor to the control.
void AttachCustomCursor (CChartCursor *pCursor)
 Attach a custom cursor to the control.
void RemoveCursor (unsigned cursorId)
 Removes a cursor with a specific Id from the control.
+void ShowMouseCursor (bool bShow)
 Shows/hides the mouse cursor when it is over the plotting area.
+CChartAxisGetBottomAxis () const
+CChartAxisGetLeftAxis () const
+CChartAxisGetTopAxis () const
+CChartAxisGetRightAxis () const
CChartAxisGetAxis (EAxisPos axisPos) const
 Returns a specific axis attached to the control.
+UINT GetEdgeType () const
 Returns the type of the edge used as border.
void SetEdgeType (UINT NewEdge)
 Sets the edge type.
+COLORREF GetBackColor () const
 Returns the background color.
+void SetBackColor (COLORREF NewCol)
 Sets the background color.
+COLORREF GetBorderColor () const
 Returns the color of the plotting area's border.
+void SetBorderColor (COLORREF NewCol)
 Sets the color of the plotting area's border.
+COLORREF GetZoomRectColor () const
 Returns the color of the zoom rectangle.
+void SetZoomRectColor (COLORREF NewCol)
 Sets the color of the zoom rectangle.
void SetBackGradient (COLORREF Col1, COLORREF Col2, EGradientType GradientType)
 Sets a gradient background.
+void SetPanEnabled (bool bEnabled)
 Enables/disables the pan feature.
+bool GetPanEnabled () const
 Returns true if the pan feature is enabled.
+void SetZoomEnabled (bool bEnabled)
 Enables/disables the zoom feature.
+bool GetZoomEnabled () const
 Returns true if the zoom feature is enabled.
+void UndoPanZoom ()
 Undo all pan and zoom operations that were done on the chart.
void RefreshCtrl ()
 Forces a refresh of the control.
void EnableRefresh (bool bEnable)
 Enables/disables the refresh of the control.
int Create (CWnd *pParentWnd, const RECT &rect, UINT nID, DWORD dwStyle=WS_VISIBLE)
 Creates the control dynamically.
virtual void Print (const TChartString &strTitle, CPrintDialog *pPrntDialog=NULL)
 Print the chart.
CChartCtrl ()
 Default constructor.
+virtual ~CChartCtrl ()
 Default destructor.
void RegisterMouseListener (CChartMouseListener *pMouseListener)
 Register a mouse listener with the control.
void GoToFirstSerie ()
 Tell the control to set the current series to the first series.
CChartSerieGetNextSerie ()
 Returns the next series in the control.
+void RefreshScreenAutoAxes ()
 Refreshes all the axes which are automatic for the screen.

Static Public Member Functions

+static double DateToValue (const COleDateTime &Date)
 Helper function to convert a date to a double value.
+static COleDateTime ValueToDate (double Value)
 Helper function to convert a double value to a date.

Protected Member Functions

+afx_msg void OnPaint ()
+afx_msg BOOL OnEraseBkgnd (CDC *pDC)
+afx_msg void OnSize (UINT nType, int cx, int cy)
+afx_msg void OnMouseMove (UINT nFlags, CPoint point)
+afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
+afx_msg void OnLButtonUp (UINT nFlags, CPoint point)
+afx_msg void OnLButtonDblClk (UINT nFlags, CPoint point)
+afx_msg void OnRButtonDown (UINT nFlags, CPoint point)
+afx_msg void OnRButtonUp (UINT nFlags, CPoint point)
+afx_msg void OnRButtonDblClk (UINT nFlags, CPoint point)
+afx_msg void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
+afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
+virtual void OnBeginPrinting (CDC *pDC, CPrintInfo *pInfo)
+virtual void OnPrint (CDC *pDC, CPrintInfo *pInfo)
+virtual void OnEndPrinting (CDC *pDC, CPrintInfo *pInfo)
+virtual void DrawChart (CDC *pDC, CRect ChartRect)
+virtual void DrawBackground (CDC *pDC, CRect ChartRect)
+


Detailed Description

+The main chart control class.

Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
void CChartCtrl::AttachCustomAxis (CChartAxis pAxis,
EAxisPos  axisPos 
)
+
+
+ +

+Attach a custom axis to the control. +

+This function takes ownership of the axis pointer, so you must not destroy it. If the axis is alread attached to a chart control (even this one), the function will fail with an assertion. This function should be used only when you want to provide a custom axis to the control, otherwise you should use the AttachStandardAxis, AttachLogarithmicAxis and AttachDateTimeAxis instead.

Parameters:
+ + + +
pAxis The axis to attach to the control.
axisPos The position of the axis. This value can be:
    +
  • LeftAxis
  • BottomAxis
  • RightAxis
  • TopAxis
+
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartCtrl::AttachCustomCursor (CChartCursor pCursor  ) 
+
+
+ +

+Attach a custom cursor to the control. +

+You should only use this function if you want to attach a custom cursor to the control. Otherwise, you should use the CreateXXXCursor helper functions.

Parameters:
+ + +
pCursor The custom cursor to be attached to the control.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartCtrl::AttachCustomSerie (CChartSerie pNewSeries,
bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Attaches a custom series to the chart. +

+You should only use this function if you want to attach a custom series to the control. Otherwise, you should use the CreateXXXSerie helper functions. The function will assert if the associated axes are not attached to the control.

Parameters:
+ + + + +
pNewSeries The new series to be added. The control will take ownership of the pointer, so dont't delete it yourself.
bSecondaryHorizAxis Specifies if the associated horizontal axis is secondary or not. If this value is false, the associated horizontal axis is the bottom axis, otherwise it is the top axis.
bSecondaryVertAxis Specifies if the associated vertical axis is secondary or not. If this value is false, the associated vertical axis is the left axis, otherwise it is the right axis.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
int CChartCtrl::Create (CWnd *  pParentWnd,
const RECT &  rect,
UINT  nID,
DWORD  dwStyle = WS_VISIBLE 
)
+
+
+ +

+Creates the control dynamically. +

+

Parameters:
+ + + + + +
pParentWnd Parent window of the control
rect Position of the control
nID ID of the control
dwStyle Style of the control
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartBarSerie * CChartCtrl::CreateBarSerie (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a bar series to the control. +

+

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created chart bar series.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+
See also:
AttachCustomSerie for more info about the parameters of the function.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartCandlestickSerie * CChartCtrl::CreateCandlestickSerie (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a candlestick series to the control. +

+

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created chart candlestick series.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+
See also:
AttachCustomSerie for more info about the parameters of the function.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartCrossHairCursor * CChartCtrl::CreateCrossHairCursor (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a cross-hair cursor to the control. +

+A cross-hair cursor display a cross on the control and move accordingly to the mouse. It is attached to an horizontal and a vertical axis.

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created cross-hair cursor.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+ +
+

+ +

+
+ + + + + + + + + +
CChartDateTimeAxis * CChartCtrl::CreateDateTimeAxis (EAxisPos  axisPos  ) 
+
+
+ +

+Create and attach a date/time axis to the control. +

+

Parameters:
+ + +
axisPos The position of the axis.
+
+
Returns:
The created date/time axis.
+ +
+

+ +

+
+ + + + + + + + + +
CChartDragLineCursor * CChartCtrl::CreateDragLineCursor (EAxisPos  relatedAxis  ) 
+
+
+ +

+Create and attach a drag-line cursor to the control. +

+A drag-line cursor is a simple line (horizontal or vertical) that can be dragged with the mouse by clicking on it. It is attached to a specific axis.

Parameters:
+ + +
relatedAxis The axis position to which the cursor is attached to.
+
+
Returns:
The created drag-line cursor.
+
Remarks:
The function will assert if the associated axis is not attached to the control.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartGanttSerie * CChartCtrl::CreateGanttSerie (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a gantt series to the control. +

+

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created chart gantt series.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+
See also:
AttachCustomSerie for more info about the parameters of the function.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartLineSerie * CChartCtrl::CreateLineSerie (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a line series to the control. +

+The function will assert if the associated axes are not attached to the control.

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created chart line series.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+
See also:
AttachCustomSerie for more info about the parameters of the function.
+ +
+

+ +

+
+ + + + + + + + + +
CChartLogarithmicAxis * CChartCtrl::CreateLogarithmicAxis (EAxisPos  axisPos  ) 
+
+
+ +

+Create and attach a logarithmic axis to the control. +

+

Parameters:
+ + +
axisPos The position of the axis.
+
+
Returns:
The created logarithmic axis.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartPointsSerie * CChartCtrl::CreatePointsSerie (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a point series to the control. +

+

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created chart point series.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+
See also:
AttachCustomSerie for more info about the parameters of the function.
+ +
+

+ +

+
+ + + + + + + + + +
CChartStandardAxis * CChartCtrl::CreateStandardAxis (EAxisPos  axisPos  ) 
+
+
+ +

+Create and attach a standard axis to the control. +

+

Parameters:
+ + +
axisPos The position of the axis.
+
+
Returns:
The created standard axis.
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
CChartSurfaceSerie * CChartCtrl::CreateSurfaceSerie (bool  bSecondaryHorizAxis = false,
bool  bSecondaryVertAxis = false 
)
+
+
+ +

+Create and attach a surface series to the control. +

+The function will assert if the associated axes are not attached to the control.

Parameters:
+ + + +
bSecondaryHorizAxis Specifies if the horizontal axis is the secondary axis or not.
bSecondaryVertAxis Specifies if the vertical axis is the secondary axis or not.
+
+
Returns:
The created chart surface series.
+
Remarks:
The function will assert if the associated axes are not attached to the control.
+
See also:
AttachCustomSerie for more info about the parameters of the function.
+ +
+

+ +

+
+ + + + + + + + + +
void CChartCtrl::EnableRefresh (bool  bEnable  ) 
+
+
+ +

+Enables/disables the refresh of the control. +

+This function is used when several settings have to be changed at the same time on the control. This way we can avoid refreshing the control when it is not needed.

Parameters:
+ + +
bEnable false to disable the refresh and true to re-enable the refresh.
+
+ +
+

+ +

+
+ + + + + + + + + +
CChartAxis* CChartCtrl::GetAxis (EAxisPos  axisPos  )  const [inline]
+
+
+ +

+Returns a specific axis attached to the control. +

+If the specified axis does not exist, NULL is returned.

Parameters:
+ + +
axisPos The axis position (left, bottom, right or top).
+
+ +
+

+ +

+
+ + + + + + + + +
CDC * CChartCtrl::GetDC (  ) 
+
+
+ +

+Retrieves de device context. +

+This function is used for internal purposes only. +

+

+ +

+
+ + + + + + + + +
CChartSerie * CChartCtrl::GetNextSerie (  ) 
+
+
+ +

+Returns the next series in the control. +

+This function is used with the GoToFirstSerie to iterate over all series in the control. First call GoToFirstSerie and then call this function until it returns NULL to iterate over all series. Warning: calling this function without calling GoToFirstSerie before might lead to unpredicted results. The same if you add or remove series between the call to GetFirstSerie and the call to GetNextSerie.

Returns:
the next series or NULL if we already are at the last series.
+ +
+

+ +

+
+ + + + + + + + + +
CChartSerie* CChartCtrl::GetSerie (unsigned  uSerieId  )  const
+
+
+ +

+Retrieves a specific series from the chart. +

+

Parameters:
+ + +
uSerieId The Id of the series to retrieve
+
+
Returns:
The series or NULL if uSerieId is not attributed.
+ +
+

+ +

+
+ + + + + + + + +
void CChartCtrl::GoToFirstSerie (  ) 
+
+
+ +

+Tell the control to set the current series to the first series. +

+This function is used with the GetNextSerie to iterate over all series in the control. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartCtrl::Print (const TChartString &  strTitle,
CPrintDialog *  pPrntDialog = NULL 
) [virtual]
+
+
+ +

+Print the chart. +

+

Parameters:
+ + + +
strTitle The title of the print document.
pPrntDialog A pointer to a CPrintDialog. If NULL is passed, the default print dialog will be displayed.
+
+ +
+

+ +

+
+ + + + + + + + +
void CChartCtrl::RefreshCtrl (  ) 
+
+
+ +

+Forces a refresh of the control. +

+This function is used for internal purposes. +

+

+ +

+
+ + + + + + + + + +
void CChartCtrl::RegisterMouseListener (CChartMouseListener pMouseListener  )  [inline]
+
+
+ +

+Register a mouse listener with the control. +

+This listener will be notified each time a mouse event occurs on the control.

Parameters:
+ + +
pMouseListener The mouse listener to register with this control.
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartCtrl::RemoveCursor (unsigned  cursorId  ) 
+
+
+ +

+Removes a cursor with a specific Id from the control. +

+The cursor Id can be retrieved on through the CChartCursor::GetCursorId function.

Parameters:
+ + +
cursorId The Id of the cursor to remove from the control.
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartCtrl::RemoveSerie (unsigned  uSerieId  ) 
+
+
+ +

+Removes a specific series from the chart. +

+

Parameters:
+ + +
uSerieId The Id of the series to be removed.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartCtrl::SetBackGradient (COLORREF  Col1,
COLORREF  Col2,
EGradientType  GradientType 
)
+
+
+ +

+Sets a gradient background. +

+

Parameters:
+ + + + +
Col1 The first gradient color
Col2 The second gradient color
GradientType The type of gradient used from Col1 to Col2. It can take the following values:
    +
  • gtHorizontal: a simple left-to-right gradient, from Col1 to Col2.
  • gtVertical: a simple top-to-bottom gradient, from Col1 to Col2.
  • gtHorizontalDouble: a left-to-middle-to-right gradient, with Col2 in the middle.
  • gtVerticalDouble: a top-to-middle-to-bottom gradient, with Col2 in the middle.
+
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartCtrl::SetEdgeType (UINT  NewEdge  )  [inline]
+
+
+ +

+Sets the edge type. +

+

Parameters:
+ + +
NewEdge The type of the edge. See the DrawEdge function in MSDN for a list of the different types.
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCtrl.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCtrl.cpp
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_cursor-members.html b/ChartDemo/Doc/html/class_c_chart_cursor-members.html new file mode 100644 index 0000000..4996412 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_cursor-members.html @@ -0,0 +1,48 @@ + + +ChartDemo: Member List + + + + + +
+

CChartCursor Member List

This is the complete list of members for CChartCursor, including all inherited members.

+ + + + + + + + + + + + + + + + +
CChartCursor(CChartCtrl *pParent)CChartCursor [protected]
CursorMoved(double newXValue, double newYValue)CChartCursor [protected]
Draw(CDC *pDC)=0CChartCursor [protected, pure virtual]
GetCursorId() const CChartCursor [inline]
m_colCursorCChartCursor [protected]
m_lstListenersCChartCursor [protected]
m_pParentCtrlCChartCursor [protected]
m_uCursorIdCChartCursor [protected]
m_uNextFreeIdCChartCursor [protected, static]
OnMouseButtonDown(CPoint)CChartCursor [inline, protected, virtual]
OnMouseButtonUp(CPoint)CChartCursor [inline, protected, virtual]
OnMouseMove(CPoint mousePoint)=0CChartCursor [protected, pure virtual]
RegisterListener(CChartCursorListener *pListener)CChartCursor
SetColor(COLORREF cursorColor)CChartCursor
TListenerList typedef (defined in CChartCursor)CChartCursor [protected]
~CChartCursor()CChartCursor [protected, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_cursor.html b/ChartDemo/Doc/html/class_c_chart_cursor.html new file mode 100644 index 0000000..0746e40 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_cursor.html @@ -0,0 +1,225 @@ + + +ChartDemo: CChartCursor Class Reference + + + + + +
+

CChartCursor Class Reference

Base class for cursors which can be added to the chart control. +More... +

+#include <ChartCursor.h> +

+

+Inheritance diagram for CChartCursor:
+
+ +

+ +CChartCrossHairCursor +CChartDragLineCursor + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void SetColor (COLORREF cursorColor)
 Sets the cursor color.
+unsigned GetCursorId () const
 Retrieves the cursor Id.
+void RegisterListener (CChartCursorListener *pListener)
 Registers a cursor listener with this cursor.

Protected Types

+typedef std::list
+< CChartCursorListener * > 
TListenerList

Protected Member Functions

CChartCursor (CChartCtrl *pParent)
 Default constructor.
+virtual ~CChartCursor ()
 Default destructor.
virtual void OnMouseMove (CPoint mousePoint)=0
 Pure virtual function that is called when the mouse moved on the plot area.
virtual void OnMouseButtonDown (CPoint)
 Virtual function that is called when the left mouse button is pressed.
virtual void OnMouseButtonUp (CPoint)
 Virtual function that is called when the left mouse button is released.
+virtual void Draw (CDC *pDC)=0
 Pure virtual function that draws the cursor.
void CursorMoved (double newXValue, double newYValue)
 Function that is called by the child classes when the cursor has been moved.

Protected Attributes

+COLORREF m_colCursor
 The color of the cursor.
+CChartCtrlm_pParentCtrl
 The parent charting control.
+unsigned m_uCursorId
 The Id of this curosr.
+TListenerList m_lstListeners
 List of all listeners registered with this cursor.

Static Protected Attributes

+static unsigned m_uNextFreeId = 0
 Static variable holding the next free cursor Id.
+


Detailed Description

+Base class for cursors which can be added to the chart control. +

+This class must be overriden for specific cursor types. This is already done for a cross-hair cursor and a dragline cursor. Each cursor is assigned an Id when it is added to the control.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
void CChartCursor::CursorMoved (double  newXValue,
double  newYValue 
) [protected]
+
+
+ +

+Function that is called by the child classes when the cursor has been moved. +

+This will notify all the listeners registered with the cursor. +

+

+ +

+
+ + + + + + + + + +
virtual void CChartCursor::OnMouseButtonDown (CPoint   )  [inline, protected, virtual]
+
+
+ +

+Virtual function that is called when the left mouse button is pressed. +

+This function can be overriden by child classes to take appropriate actions on the mouse click event. +

Reimplemented in CChartDragLineCursor.

+ +
+

+ +

+
+ + + + + + + + + +
virtual void CChartCursor::OnMouseButtonUp (CPoint   )  [inline, protected, virtual]
+
+
+ +

+Virtual function that is called when the left mouse button is released. +

+This function can be overriden by child classes to take appropriate actions on the mouse click event. +

Reimplemented in CChartDragLineCursor.

+ +
+

+ +

+
+ + + + + + + + + +
virtual void CChartCursor::OnMouseMove (CPoint  mousePoint  )  [protected, pure virtual]
+
+
+ +

+Pure virtual function that is called when the mouse moved on the plot area. +

+This function must be overriden by child classes to take appropriate actions on the mouse move event. +

Implemented in CChartCrossHairCursor, and CChartDragLineCursor.

+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCursor.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartCursor.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_cursor.png b/ChartDemo/Doc/html/class_c_chart_cursor.png new file mode 100644 index 0000000..9ffcbdb Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_cursor.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_cursor_listener-members.html b/ChartDemo/Doc/html/class_c_chart_cursor_listener-members.html new file mode 100644 index 0000000..8066ef1 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_cursor_listener-members.html @@ -0,0 +1,35 @@ + + +ChartDemo: Member List + + + + + +
+

CChartCursorListener Member List

This is the complete list of members for CChartCursorListener, including all inherited members.

+ + + +
CChartCursorListener()CChartCursorListener
OnCursorMoved(CChartCursor *pCursor, double xValue, double yValue)=0CChartCursorListener [pure virtual]
~CChartCursorListener()CChartCursorListener [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_cursor_listener.html b/ChartDemo/Doc/html/class_c_chart_cursor_listener.html new file mode 100644 index 0000000..6c62bfb --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_cursor_listener.html @@ -0,0 +1,103 @@ + + +ChartDemo: CChartCursorListener Class Reference + + + + + +
+

CChartCursorListener Class Reference

Interface to implement in order to be notified about a cursor movement. +More... +

+#include <ChartCursor.h> +

+ +

+List of all members. + + + + + + + + + + + +

Public Member Functions

CChartCursorListener ()
 Default constructor.
+virtual ~CChartCursorListener ()
 Destructor.
virtual void OnCursorMoved (CChartCursor *pCursor, double xValue, double yValue)=0
 Pure virtual function to implement in order to be notified about a cursor movement.
+


Detailed Description

+Interface to implement in order to be notified about a cursor movement. +

+This class must be overriden and registered with a CChartCursor by calling RegisterListener.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
virtual void CChartCursorListener::OnCursorMoved (CChartCursor pCursor,
double  xValue,
double  yValue 
) [pure virtual]
+
+
+ +

+Pure virtual function to implement in order to be notified about a cursor movement. +

+Note that not all cursor types have an X and a Y value, in which case, only the relevant information is passed, the other value will be 0.

Parameters:
+ + + + +
pCursor The cursor which was moved
xValue The cursor xValue
yValue The cursor yValue
+
+ +
+

+


The documentation for this class was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_date_time_axis-members.html b/ChartDemo/Doc/html/class_c_chart_date_time_axis-members.html new file mode 100644 index 0000000..59b14bd --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_date_time_axis-members.html @@ -0,0 +1,101 @@ + + +ChartDemo: Member List + + + + + +
+

CChartDateTimeAxis Member List

This is the complete list of members for CChartDateTimeAxis, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CChartAxis()CChartAxis
EAxisAutoModes enum nameCChartAxis
EnableScrollBar(bool bEnabled)CChartAxis
FullAutomatic enum valueCChartAxis
GetAutoHideScrollBar() const CChartAxis
GetAutomaticMode() const CChartAxis [inline]
GetAxisLenght() const CChartAxis [protected]
GetGrid() const CChartAxis [inline]
GetLabel() const CChartAxis [inline]
GetMinMax(double &Minimum, double &Maximum) const CChartAxis [inline]
GetPosition()CChartAxis
GetScrollbarSteps(int &iTotalSteps, int &iCurrentStep)CChartAxis [protected, virtual]
GetSeriesMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetSeriesScreenMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetTextColor() const CChartAxis [inline]
IsAutomatic() const CChartAxis [inline]
IsHorizontal() const CChartAxis [inline]
IsInverted() const CChartAxis [inline]
IsPointInside(const CPoint &screenPoint) const CChartAxis
IsVisible() const CChartAxis [inline]
m_AutoModeCChartAxis [protected]
m_AxisRectCChartAxis [protected]
m_bAutoTicksCChartAxis [protected]
m_bDiscreteCChartAxis [protected]
m_bIsHorizontalCChartAxis [protected]
m_bIsInvertedCChartAxis [protected]
m_bIsSecondaryCChartAxis [protected]
m_bIsVisibleCChartAxis [protected]
m_EndPosCChartAxis [protected]
m_MaxValueCChartAxis [protected]
m_MinValueCChartAxis [protected]
m_pParentCtrlCChartAxis [protected]
m_StartPosCChartAxis [protected]
m_UnzoomMaxCChartAxis [protected]
m_UnzoomMinCChartAxis [protected]
NotAutomatic enum valueCChartAxis
PanAxis(long PanStart, long PanEnd)CChartAxis [protected, virtual]
ScreenAutomatic enum valueCChartAxis
ScreenToValue(long ScreenVal) const CChartAxis [virtual]
ScrollBarEnabled() const CChartAxis [inline]
SetAutoHideScrollBar(bool bAutoHide)CChartAxis
SetAutomatic(bool bAutomatic)CChartAxis
SetAutomaticMode(EAxisAutoModes AutoMode)CChartAxis
SetAxisColor(COLORREF NewColor)CChartAxis
SetAxisToScrollStep(int iPreviousStep, int iCurrentStep, bool bScrollInverted)CChartAxis [protected, virtual]
SetDiscrete(bool bDiscrete)CChartAxis [virtual]
SetFont(int nPointSize, const TChartString &strFaceName)CChartAxis
SetInverted(bool bInverted)CChartAxis
SetMarginSize(bool bAuto, int iNewSize)CChartAxis
SetMinMax(double Minimum, double Maximum)CChartAxis
SetPanZoomEnabled(bool bEnabled)CChartAxis [inline]
SetReferenceTick(COleDateTime referenceTick)CChartDateTimeAxis
SetTextColor(COLORREF NewColor)CChartAxis
SetTickIncrement(bool bAuto, TimeInterval Interval, int Multiplier)CChartDateTimeAxis
SetTickLabelFormat(bool bAutomatic, const TChartString &strFormat)CChartDateTimeAxis
SetVisible(bool bVisible)CChartAxis
SetZoomLimit(double dLimit)CChartAxis [inline]
SetZoomMinMax(double Minimum, double Maximum)CChartAxis [protected, virtual]
tiDay enum value (defined in CChartDateTimeAxis)CChartDateTimeAxis
tiHour enum value (defined in CChartDateTimeAxis)CChartDateTimeAxis
TimeInterval enum nameCChartDateTimeAxis
tiMinute enum value (defined in CChartDateTimeAxis)CChartDateTimeAxis
tiMonth enum value (defined in CChartDateTimeAxis)CChartDateTimeAxis
tiSecond enum value (defined in CChartDateTimeAxis)CChartDateTimeAxis
tiYear enum value (defined in CChartDateTimeAxis)CChartDateTimeAxis
UndoZoom()CChartAxis [protected]
ValueToScreen(double Value) const CChartAxis
ValueToScreenStandard(double Value) const CChartAxis [protected, virtual]
~CChartAxis()CChartAxis [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_date_time_axis.html b/ChartDemo/Doc/html/class_c_chart_date_time_axis.html new file mode 100644 index 0000000..9349e7c --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_date_time_axis.html @@ -0,0 +1,181 @@ + + +ChartDemo: CChartDateTimeAxis Class Reference + + + + + +
+

CChartDateTimeAxis Class Reference

A specialization of the CChartAxis class for displaying date and time data. +More... +

+#include <ChartDateTimeAxis.h> +

+

+Inheritance diagram for CChartDateTimeAxis:
+
+ +

+ +CChartAxis + +
+ +

+List of all members. + + + + + + + + + + + + + + + +

Public Types

enum  TimeInterval {
+  tiSecond, +tiMinute, +tiHour, +tiDay, +
+  tiMonth, +tiYear +
+ }
 Enum listing the different base intervals.

Public Member Functions

void SetTickIncrement (bool bAuto, TimeInterval Interval, int Multiplier)
 Sets the tick increment.
void SetTickLabelFormat (bool bAutomatic, const TChartString &strFormat)
 Sets the format of the tick labels.
void SetReferenceTick (COleDateTime referenceTick)
 Sets the reference tick.
+


Detailed Description

+A specialization of the CChartAxis class for displaying date and time data.

Member Function Documentation

+ +
+
+ + + + + + + + + +
void CChartDateTimeAxis::SetReferenceTick (COleDateTime  referenceTick  ) 
+
+
+ +

+Sets the reference tick. +

+The reference tick is a date/time which specifies a tick which should always be displayed on the axis. This is needed when the tick interval multiplier is not 1 (e.g. the interval between two ticks is 3 months). In that specific case, there is no way for the control to know which ticks should be displayed (in our example, the chart doesn't know if the first tick will be january, february or march). This is particularly annoying when the axis is panned (in that case, if we always take the first month on the axis as first tick, the ticks will always switch from one month to another). By having a refence tick, this forces the control to calculate all tick intervals based on this reference. It is set to January 1st 2000 by default. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartDateTimeAxis::SetTickIncrement (bool  bAuto,
TimeInterval  Interval,
int  Multiplier 
)
+
+
+ +

+Sets the tick increment. +

+The tick increment is the value between two adjacents ticks on the axis. In case of a date time axis, the interval is specified by a time period because this interval might not be constant (for instance, if a tick interval of one month is specified, the distance between two adjacents ticks is not constant: it depends on the number of days in the month). The full tick interval is made of a base interval (day, month, hour, ...) and a multiplier, that is applied to this base interval. So, for an interval of three months between two ticks, you have to specify tiMonth for the interval and 3 for the multiplier.

Parameters:
+ + + + +
bAuto Specifies if the tick increment is automatically calculated.
Interval The base interval.
Multiplier The multiplier applied to the base interval.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartDateTimeAxis::SetTickLabelFormat (bool  bAutomatic,
const TChartString &  strFormat 
)
+
+
+ +

+Sets the format of the tick labels. +

+

Parameters:
+ + + +
bAutomatic Specifies if the format is calculated automatically.
strFormat The format to apply to the tick label if bAutomatic is false.
+Check the documentation of the COleDateTime::Format function on MSDN for more information about the format string.
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartDateTimeAxis.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartDateTimeAxis.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_date_time_axis.png b/ChartDemo/Doc/html/class_c_chart_date_time_axis.png new file mode 100644 index 0000000..b3dc87d Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_date_time_axis.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_drag_line_cursor-members.html b/ChartDemo/Doc/html/class_c_chart_drag_line_cursor-members.html new file mode 100644 index 0000000..4963c6a --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_drag_line_cursor-members.html @@ -0,0 +1,49 @@ + + +ChartDemo: Member List + + + + + +
+

CChartDragLineCursor Member List

This is the complete list of members for CChartDragLineCursor, including all inherited members.

+ + + + + + + + + + + + + + + + + +
CChartCursor(CChartCtrl *pParent)CChartCursor [protected]
CursorMoved(double newXValue, double newYValue)CChartCursor [protected]
Draw(CDC *pDC)CChartDragLineCursor [protected, virtual]
GetCursorId() const CChartCursor [inline]
m_colCursorCChartCursor [protected]
m_lstListenersCChartCursor [protected]
m_pParentCtrlCChartCursor [protected]
m_uCursorIdCChartCursor [protected]
m_uNextFreeIdCChartCursor [protected, static]
OnMouseButtonDown(CPoint mousePoint)CChartDragLineCursor [protected, virtual]
OnMouseButtonUp(CPoint mousePoint)CChartDragLineCursor [protected, virtual]
OnMouseMove(CPoint mousePoint)CChartDragLineCursor [protected, virtual]
RegisterListener(CChartCursorListener *pListener)CChartCursor
SetColor(COLORREF cursorColor)CChartCursor
SetPosition(double dPosition)CChartDragLineCursor
TListenerList typedef (defined in CChartCursor)CChartCursor [protected]
~CChartCursor()CChartCursor [protected, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_drag_line_cursor.html b/ChartDemo/Doc/html/class_c_chart_drag_line_cursor.html new file mode 100644 index 0000000..02bbaa1 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_drag_line_cursor.html @@ -0,0 +1,78 @@ + + +ChartDemo: CChartDragLineCursor Class Reference + + + + + +
+

CChartDragLineCursor Class Reference

Specialization of a CChartCursor class for a dragline cursor. +More... +

+#include <ChartDragLineCursor.h> +

+

+Inheritance diagram for CChartDragLineCursor:
+
+ +

+ +CChartCursor + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void SetPosition (double dPosition)
 Sets the position (by value) of the cursor.

Protected Member Functions

+void OnMouseMove (CPoint mousePoint)
 Called when the mouse is moved over the plot area.
+void OnMouseButtonDown (CPoint mousePoint)
 Called when the mouse button is pressed over the plot area.
+void OnMouseButtonUp (CPoint mousePoint)
 Called when the mouse button is released over the plot area.
+void Draw (CDC *pDC)
 Draw the cursor.
+


Detailed Description

+Specialization of a CChartCursor class for a dragline cursor. +

+A dragline cursor is a simple vertical or horizontal line associated with a specific axis. The line can be moved if the user clicks on the line (and keeps the button pressed) and moves the mouse. Once the mouse button is released, the line doesn't move anymore.
+ To create a dragline cursor, call the CreateDragLineCursor from the CChartCtrl class.


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartDragLineCursor.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartDragLineCursor.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_drag_line_cursor.png b/ChartDemo/Doc/html/class_c_chart_drag_line_cursor.png new file mode 100644 index 0000000..b7dc717 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_drag_line_cursor.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_font-members.html b/ChartDemo/Doc/html/class_c_chart_font-members.html new file mode 100644 index 0000000..0d6f527 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_font-members.html @@ -0,0 +1,41 @@ + + +ChartDemo: Member List + + + + + +
+

CChartFont Member List

This is the complete list of members for CChartFont, including all inherited members.

+ + + + + + + + + +
CChartFont(const CChartFont &copy)CChartFont
CChartFont(const TChartString &strFaceName, int iPointSize)CChartFont
CChartFont()CChartFont
operator=(const CChartFont &objectSrc)CChartFont
SelectFont(CDC *pDC) const CChartFont
SetFont(const TChartString &strFaceName, int iPointSize, bool bItalic=false, bool bBold=false, bool bUnderline=false)CChartFont
SetVertical(bool bVertical)CChartFont
UnselectFont(CDC *pDC) const CChartFont
~CChartFont()CChartFont

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_font.html b/ChartDemo/Doc/html/class_c_chart_font.html new file mode 100644 index 0000000..71c2326 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_font.html @@ -0,0 +1,238 @@ + + +ChartDemo: CChartFont Class Reference + + + + + +
+

CChartFont Class Reference

Wrapper class for fonts with advanced properties (italic, bold or underlined). +More... +

+#include <ChartFont.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

CChartFont (const CChartFont &copy)
 Copy constructor.
 CChartFont (const TChartString &strFaceName, int iPointSize)
 Constructor.
 CChartFont ()
 Default constructor.
~CChartFont ()
 Destructor.
void SetFont (const TChartString &strFaceName, int iPointSize, bool bItalic=false, bool bBold=false, bool bUnderline=false)
 Sets the font with extended properties.
void SelectFont (CDC *pDC) const
 Select this font in the device context passed in argument.
+void UnselectFont (CDC *pDC) const
 Reset the font to its original in the device context.
void SetVertical (bool bVertical)
 Sets the text in vertical mode.
+void operator= (const CChartFont &objectSrc)
 Assignement operator.
+


Detailed Description

+Wrapper class for fonts with advanced properties (italic, bold or underlined).

Constructor & Destructor Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
CChartFont::CChartFont (const TChartString &  strFaceName,
int  iPointSize 
)
+
+
+ +

+Constructor. +

+

Parameters:
+ + + +
strFaceName The font face name
iPointSize The font point size
+
+ +
+

+ +

+
+ + + + + + + + +
CChartFont::CChartFont (  ) 
+
+
+ +

+Default constructor. +

+Construct a font with the "Microsoft Sans Serif" face name and with a point size of 100. +

+

+


Member Function Documentation

+ +
+
+ + + + + + + + + +
void CChartFont::SelectFont (CDC *  pDC  )  const
+
+
+ +

+Select this font in the device context passed in argument. +

+This function stores the current font selected in the DC to set it back when calling UnselectFont. This function is mainly used internally. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void CChartFont::SetFont (const TChartString &  strFaceName,
int  iPointSize,
bool  bItalic = false,
bool  bBold = false,
bool  bUnderline = false 
)
+
+
+ +

+Sets the font with extended properties. +

+

Parameters:
+ + + + + + +
strFaceName The font face name
iPointSize The font point size
bItalic Specifies if the text is in italic
bBold Specifies if the text is in bold
bUnderline Specifies if the text is underlined
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartFont::SetVertical (bool  bVertical  ) 
+
+
+ +

+Sets the text in vertical mode. +

+This function is mainly used internally. +

+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartFont.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartFont.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_gantt_serie-members.html b/ChartDemo/Doc/html/class_c_chart_gantt_serie-members.html new file mode 100644 index 0000000..61640aa --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_gantt_serie-members.html @@ -0,0 +1,102 @@ + + +ChartDemo: Member List + + + + + +
+

CChartGanttSerie Member List

This is the complete list of members for CChartGanttSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double StartTime, double EndTime, double YValue)CChartGanttSerie
CChartSerieBase< SChartGanttPoint >::AddPoint(const SChartGanttPoint &newPoint)CChartSerieBase< SChartGanttPoint >
AddPoints(SChartGanttPoint *pPoints, unsigned Count)CChartSerieBase< SChartGanttPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartGanttPoint > *pLabel)CChartSerieBase< SChartGanttPoint >
CChartGanttSerie(CChartCtrl *pParent)CChartGanttSerie
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartGanttPoint >
ClearSerie()CChartSerieBase< SChartGanttPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartGanttPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartGanttPoint > *pLabelProvider)CChartSerieBase< SChartGanttPoint >
Draw(CDC *pDC)CChartGanttSerie [protected, virtual]
DrawAll(CDC *pDC)CChartGanttSerie [protected, virtual]
DrawLegend(CDC *pDC, const CRect &rectBitmap) const CChartGanttSerie [protected, virtual]
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetBarWidth() const CChartGanttSerie [inline]
GetBorderColor() const CChartGanttSerie [inline]
GetBorderWidth() const CChartGanttSerie [inline]
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartGanttPoint >
GetPointsCount() constCChartSerieBase< SChartGanttPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartGanttPoint > [virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartGanttPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartGanttPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartGanttPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartGanttPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartGanttPoint > [protected, virtual]
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const CChartGanttSerie [virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartGanttPoint > [protected]
m_vPointsCChartSerieBase< SChartGanttPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartGanttPoint > [protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartGanttPoint > *pListener)CChartSerieBase< SChartGanttPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartGanttPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartGanttPoint >
SetBarWidth(int Width)CChartGanttSerie
SetBorderColor(COLORREF BorderColor)CChartGanttSerie
SetBorderWidth(int Width)CChartGanttSerie
SetColor(COLORREF NewColor)CChartSerie
SetGradient(COLORREF GradientColor, EGradientType GradientType)CChartGanttSerie
SetName(const TChartString &NewName)CChartSerie
SetPoints(SChartGanttPoint *pPoints, unsigned Count)CChartSerieBase< SChartGanttPoint >
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< SChartGanttPoint > [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetVisible(bool bVisible)CChartSerie
ShowGradient(bool bShow)CChartGanttSerie
UnregisterMouseListener()CChartSerieBase< SChartGanttPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartGanttSerie()CChartGanttSerie
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartGanttPoint > [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_gantt_serie.html b/ChartDemo/Doc/html/class_c_chart_gantt_serie.html new file mode 100644 index 0000000..ef20bf8 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_gantt_serie.html @@ -0,0 +1,331 @@ + + +ChartDemo: CChartGanttSerie Class Reference + + + + + +
+

CChartGanttSerie Class Reference

Specialization of a CChartSerieBase to display a gantt series. +More... +

+#include <ChartGanttSerie.h> +

+

+Inheritance diagram for CChartGanttSerie:
+
+ +

+ +CChartSerieBase< SChartGanttPoint > +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

CChartGanttSerie (CChartCtrl *pParent)
 Constructor.
~CChartGanttSerie ()
 Destructor.
void AddPoint (double StartTime, double EndTime, double YValue)
 Adds a new point to the series.
bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const
 Tests if a certain screen point is on the series.
+void SetBorderColor (COLORREF BorderColor)
 Sets the bars border color.
+COLORREF GetBorderColor () const
 Returns the bars border color.
+void SetBorderWidth (int Width)
 Sets the bars border width.
+int GetBorderWidth () const
 Returns the bars border width.
+void SetBarWidth (int Width)
 Sets the bars width (in pixels).
+int GetBarWidth () const
 Returns the bars width (in pixels).
+void ShowGradient (bool bShow)
 Specifies if a gradient is applied to the bars.
void SetGradient (COLORREF GradientColor, EGradientType GradientType)
 Sets the gradient style.

Protected Member Functions

void DrawLegend (CDC *pDC, const CRect &rectBitmap) const
 Draws the legend icon for the series.
void Draw (CDC *pDC)
 Draws the most recent points of the series.
void DrawAll (CDC *pDC)
 Redraws the full series.
+


Detailed Description

+Specialization of a CChartSerieBase to display a gantt series. +

+Each point in a gantt series is amde of three values: a start and end time and an Y value. The points are displayed as horizontal bars that are positionned on the Y axis depending on their Y value and which starts at the start time and end at the end time along the X axis.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartGanttSerie::AddPoint (double  StartTime,
double  EndTime,
double  YValue 
)
+
+
+ +

+Adds a new point to the series. +

+

Parameters:
+ + + + +
StartTime The start time of the Gantt bar
EndTime The end time of the Gantt bar
YValue The YValue of the Gantt bar
+
+ +
+

+ +

+
+ + + + + + + + + +
void CChartGanttSerie::Draw (CDC *  pDC  )  [protected, virtual]
+
+
+ +

+Draws the most recent points of the series. +

+This function should only draw the points that were not previously drawn.

Parameters:
+ + +
pDC The device context used to draw
+
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + +
void CChartGanttSerie::DrawAll (CDC *  pDC  )  [protected, virtual]
+
+
+ +

+Redraws the full series. +

+

Parameters:
+ + +
pDC The device context used to draw
+
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartGanttSerie::DrawLegend (CDC *  pDC,
const CRect &  rectBitmap 
) const [protected, virtual]
+
+
+ +

+Draws the legend icon for the series. +

+

Parameters:
+ + + +
pDC The device context used to draw
rectBitmap The rectangle in which to draw the legend icon
+
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
bool CChartGanttSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [virtual]
+
+
+ +

+Tests if a certain screen point is on the series. +

+

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartGanttSerie::SetGradient (COLORREF  GradientColor,
EGradientType  GradientType 
)
+
+
+ +

+Sets the gradient style. +

+

Parameters:
+ + + +
GradientColor The second color used for the gradient (the first one being the original series color).
GradientType The type of gradient used between the two colors (vertical, horizontal, ...)
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartGanttSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartGanttSerie.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_gantt_serie.png b/ChartDemo/Doc/html/class_c_chart_gantt_serie.png new file mode 100644 index 0000000..477b41f Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_gantt_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_gradient-members.html b/ChartDemo/Doc/html/class_c_chart_gradient-members.html new file mode 100644 index 0000000..3311992 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_gradient-members.html @@ -0,0 +1,35 @@ + + +ChartDemo: Member List + + + + + +
+

CChartGradient Member List

This is the complete list of members for CChartGradient, including all inherited members.

+ + + +
CChartGradient()CChartGradient
DrawGradient(CDC *pDC, const CRect &GradientRect, COLORREF Color1, COLORREF Color2, EGradientType GradientType)CChartGradient [static]
~CChartGradient()CChartGradient

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_gradient.html b/ChartDemo/Doc/html/class_c_chart_gradient.html new file mode 100644 index 0000000..6b76843 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_gradient.html @@ -0,0 +1,118 @@ + + +ChartDemo: CChartGradient Class Reference + + + + + +
+

CChartGradient Class Reference

Helper class to draw gradient. +More... +

+#include <ChartGradient.h> +

+ +

+List of all members. + + + + + + + + + + + + +

Public Member Functions

CChartGradient ()
 Constructor.
~CChartGradient ()
 Destructor.

Static Public Member Functions

static void DrawGradient (CDC *pDC, const CRect &GradientRect, COLORREF Color1, COLORREF Color2, EGradientType GradientType)
 Draws a gradient between two colors inside a rectangle.
+


Detailed Description

+Helper class to draw gradient. +

+It only contains a static function to draw the gradient. This is mainly used internally.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void CChartGradient::DrawGradient (CDC *  pDC,
const CRect &  GradientRect,
COLORREF  Color1,
COLORREF  Color2,
EGradientType  GradientType 
) [static]
+
+
+ +

+Draws a gradient between two colors inside a rectangle. +

+

Parameters:
+ + + + + + +
pDC The device context with which to draw.
GradientRect The rectangle in which to draw the gradient
Color1 The first gradient color
Color2 The second gradient color
GradientType The type of gradient to use in the rectangle
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartGradient.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartGradient.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_grid-members.html b/ChartDemo/Doc/html/class_c_chart_grid-members.html new file mode 100644 index 0000000..a334629 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_grid-members.html @@ -0,0 +1,36 @@ + + +ChartDemo: Member List + + + + + +
+

CChartGrid Member List

This is the complete list of members for CChartGrid, including all inherited members.

+ + + + +
GetColor() const CChartGrid [inline]
IsVisible() const CChartGrid [inline]
SetColor(COLORREF NewColor)CChartGrid
SetVisible(bool bVisible)CChartGrid

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_grid.html b/ChartDemo/Doc/html/class_c_chart_grid.html new file mode 100644 index 0000000..0fc7f0b --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_grid.html @@ -0,0 +1,63 @@ + + +ChartDemo: CChartGrid Class Reference + + + + + +
+

CChartGrid Class Reference

Class which draws the grid associated with a specific axis. +More... +

+#include <ChartGrid.h> +

+ +

+List of all members. + + + + + + + + + + + + + + +

Public Member Functions

+void SetVisible (bool bVisible)
 Shows/hides the grid.
+bool IsVisible () const
 Returns true if the grid is visible.
+void SetColor (COLORREF NewColor)
 Sets the color of the grid.
+COLORREF GetColor () const
 Returns the grid color.
+


Detailed Description

+Class which draws the grid associated with a specific axis. +

+This object is retrieved through the CChartAxis::GetGrid function.


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartGrid.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartGrid.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_label-members.html b/ChartDemo/Doc/html/class_c_chart_label-members.html new file mode 100644 index 0000000..bdd2f80 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_label-members.html @@ -0,0 +1,46 @@ + + +ChartDemo: Member List + + + + + +
+

CChartLabel< PointType > Member List

This is the complete list of members for CChartLabel< PointType >, including all inherited members.

+ + + + + + + + + + + + + + +
CChartLabel(CChartCtrl *pParentCtrl, CChartSerieBase< PointType > *pParentSeries)CChartLabel< PointType > [protected]
Draw(CDC *pDC, unsigned uPointIndex)=0CChartLabel< PointType > [protected, pure virtual]
m_bIsVisibleCChartLabel< PointType > [protected]
m_iFontSizeCChartLabel< PointType > [protected]
m_pLabelProviderCChartLabel< PointType > [protected]
m_pParentCtrlCChartLabel< PointType > [protected]
m_pParentSeriesCChartLabel< PointType > [protected]
m_strFontNameCChartLabel< PointType > [protected]
m_strLabelTextCChartLabel< PointType > [protected]
SetFont(int nPointSize, const TChartString &strFaceName)CChartLabel< PointType >
SetLabelProvider(CChartLabelProvider< PointType > *pProvider)CChartLabel< PointType > [inline]
SetLabelText(const TChartString &strText)CChartLabel< PointType >
SetVisisble(bool bVisible)CChartLabel< PointType >
~CChartLabel()CChartLabel< PointType > [protected, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_label.html b/ChartDemo/Doc/html/class_c_chart_label.html new file mode 100644 index 0000000..69792ff --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_label.html @@ -0,0 +1,183 @@ + + +ChartDemo: CChartLabel< PointType > Class Template Reference + + + + + +
+

CChartLabel< PointType > Class Template Reference

Draws a label containing some text which is attached to a point of a series. +More... +

+#include <ChartLabel.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void SetLabelText (const TChartString &strText)
 Sets a static text to be displayed in the label.
void SetFont (int nPointSize, const TChartString &strFaceName)
 Sets the font of the text label.
+void SetVisisble (bool bVisible)
 Shows/hides the label.
+void SetLabelProvider (CChartLabelProvider< PointType > *pProvider)
 Sets a label provider for more flexibility in how the text is supplied.

Protected Member Functions

CChartLabel (CChartCtrl *pParentCtrl, CChartSerieBase< PointType > *pParentSeries)
 Constructor.
+virtual ~CChartLabel ()
 Destructor.
virtual void Draw (CDC *pDC, unsigned uPointIndex)=0
 Draws the label.

Protected Attributes

+bool m_bIsVisible
 Specifies if the label is visible or not.
+int m_iFontSize
 The text font size.
+TChartString m_strFontName
 The text font face name.
+TChartString m_strLabelText
 The static text of the label.
+CChartLabelProvider< PointType > * m_pLabelProvider
 The text provider.
+CChartCtrlm_pParentCtrl
 The parent charting control.
+CChartSerieBase< PointType > * m_pParentSeries
 The parent series.
+


Detailed Description

+

template<class PointType>
+ class CChartLabel< PointType >

+ +Draws a label containing some text which is attached to a point of a series. +

+This is a base class which should be overriden for specific label types.


Member Function Documentation

+ +
+
+
+template<class PointType>
+ + + + + + + + + + + + + + + + + + +
virtual void CChartLabel< PointType >::Draw (CDC *  pDC,
unsigned  uPointIndex 
) [protected, pure virtual]
+
+
+ +

+Draws the label. +

+This pure virtual function must be overriden by all child classes. +

Implemented in CChartBalloonLabel< PointType >.

+ +
+

+ +

+
+
+template<class PointType>
+ + + + + + + + + + + + + + + + + + +
void CChartLabel< PointType >::SetFont (int  nPointSize,
const TChartString &  strFaceName 
)
+
+
+ +

+Sets the font of the text label. +

+

Parameters:
+ + + +
nPointSize The font point size
strFaceName The font face name
+
+ +

Reimplemented in CChartBalloonLabel< PointType >.

+ +
+

+


The documentation for this class was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_label.png b/ChartDemo/Doc/html/class_c_chart_label.png new file mode 100644 index 0000000..ab89b66 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_label.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_label_provider-members.html b/ChartDemo/Doc/html/class_c_chart_label_provider-members.html new file mode 100644 index 0000000..5f20229 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_label_provider-members.html @@ -0,0 +1,35 @@ + + +ChartDemo: Member List + + + + + +
+

CChartLabelProvider< PointType > Member List

This is the complete list of members for CChartLabelProvider< PointType >, including all inherited members.

+ + + +
CChartLabelProvider()CChartLabelProvider< PointType > [inline]
GetText(CChartSerieBase< PointType > *pSerie, unsigned PointIndex)=0CChartLabelProvider< PointType > [pure virtual]
~CChartLabelProvider()CChartLabelProvider< PointType > [inline, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_label_provider.html b/ChartDemo/Doc/html/class_c_chart_label_provider.html new file mode 100644 index 0000000..3555863 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_label_provider.html @@ -0,0 +1,103 @@ + + +ChartDemo: CChartLabelProvider< PointType > Class Template Reference + + + + + +
+

CChartLabelProvider< PointType > Class Template Reference

Interface which should be implemented in order to provide text to a label. +More... +

+#include <ChartLabel.h> +

+ +

+List of all members. + + + + + + + + + + + +

Public Member Functions

CChartLabelProvider ()
 Constructor.
+virtual ~CChartLabelProvider ()
 Destructor.
virtual TChartString GetText (CChartSerieBase< PointType > *pSerie, unsigned PointIndex)=0
 Method to override in order to provide the text of the label.
+


Detailed Description

+

template<class PointType>
+ class CChartLabelProvider< PointType >

+ +Interface which should be implemented in order to provide text to a label. +

+This class is a template class with the template parameter being the point type of the series to which the label is attached.

+Using a CChartLabelProvider provides more flexibility in the way to supply text to the label. You can for instance embedd in the string some information about the point (XValue, YValue, index, ...). In that case, a single CChartLabelProvider object can be provided for all labels. Changing the displayed text of all labels becomes also easier: you only have to adapt the string returned by this object and refresh the control and all labels will be updated.


Member Function Documentation

+ +
+
+
+template<class PointType>
+ + + + + + + + + + + + + + + + + + +
virtual TChartString CChartLabelProvider< PointType >::GetText (CChartSerieBase< PointType > *  pSerie,
unsigned  PointIndex 
) [pure virtual]
+
+
+ +

+Method to override in order to provide the text of the label. +

+

Parameters:
+ + + +
pSerie The series to which the label is attached
uPtIndex The index of the point in the series to which the label is attached
+
+
Returns:
a string which will be the text displayed in the label.
+ +
+

+


The documentation for this class was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_legend-members.html b/ChartDemo/Doc/html/class_c_chart_legend-members.html new file mode 100644 index 0000000..066c37b --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_legend-members.html @@ -0,0 +1,51 @@ + + +ChartDemo: Member List + + + + + +
+

CChartLegend Member List

This is the complete list of members for CChartLegend, including all inherited members.

+ + + + + + + + + + + + + + + + + + + +
DockLegend(DockSide dsSide)CChartLegend
DockSide enum nameCChartLegend
dsDockBottom enum value (defined in CChartLegend)CChartLegend
dsDockLeft enum value (defined in CChartLegend)CChartLegend
dsDockRight enum value (defined in CChartLegend)CChartLegend
dsDockTop enum value (defined in CChartLegend)CChartLegend
EnableShadow(bool bEnable)CChartLegend
GetBackColor() const CChartLegend [inline]
GetShadowColor() const CChartLegend [inline]
IsPointInside(const CPoint &screenPoint) const CChartLegend
IsVisible() const CChartLegend [inline]
SetBackColor(COLORREF NewColor)CChartLegend
SetFont(int iPointSize, const TChartString &strFaceName)CChartLegend
SetHorizontalMode(bool bHorizontal)CChartLegend
SetShadowColor(COLORREF NewColor)CChartLegend
SetShadowDepth(int Depth)CChartLegend
SetTransparent(bool bTransparent)CChartLegend
SetVisible(bool bVisible)CChartLegend
UndockLegend(int iLeftPos, int iTopPos)CChartLegend

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_legend.html b/ChartDemo/Doc/html/class_c_chart_legend.html new file mode 100644 index 0000000..23ece9c --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_legend.html @@ -0,0 +1,169 @@ + + +ChartDemo: CChartLegend Class Reference + + + + + +
+

CChartLegend Class Reference

This class is responsible for the legend displayed on the control. +More... +

+#include <ChartLegend.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  DockSide { dsDockRight, +dsDockLeft, +dsDockTop, +dsDockBottom + }
 Enumeration specifying on which side of the control the legend is docked.

Public Member Functions

+void SetFont (int iPointSize, const TChartString &strFaceName)
 Sets the font used to display the series names.
+void DockLegend (DockSide dsSide)
 Dock the legend on a specific side of the control. Default is right.
void UndockLegend (int iLeftPos, int iTopPos)
 Undock the legend.
+void SetTransparent (bool bTransparent)
 Sets the background of the legend transparent.
void SetHorizontalMode (bool bHorizontal)
 Sets the legend in horizontal/vertical mode.
+void SetVisible (bool bVisible)
 Sets the legend visible/invisible.
+bool IsVisible () const
 Returns true if the legend is visible.
+COLORREF GetBackColor () const
 Returns the back color of the legend.
+void SetBackColor (COLORREF NewColor)
 Sets the back color of the legend.
+COLORREF GetShadowColor () const
 Returns the shadow color.
+void SetShadowColor (COLORREF NewColor)
 Sets the shadow color.
+void EnableShadow (bool bEnable)
 Enables/disables the shadow.
+void SetShadowDepth (int Depth)
 Sets the shadow depth (in pixels).
+BOOL IsPointInside (const CPoint &screenPoint) const
 Returns true if the screen point is on the legend region.
+


Detailed Description

+This class is responsible for the legend displayed on the control. +

+Series which are named will be displayed in the legend. The legend object is retrieved by calling the GetLegend() function on the CChartCtrl class.


Member Function Documentation

+ +
+
+ + + + + + + + + +
void CChartLegend::SetHorizontalMode (bool  bHorizontal  ) 
+
+
+ +

+Sets the legend in horizontal/vertical mode. +

+In horizontal mode, the names are drawn next to each other instead of on top of each other. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartLegend::UndockLegend (int  iLeftPos,
int  iTopPos 
)
+
+
+ +

+Undock the legend. +

+When the legend is undocked (floating), it doesn't take any margin size but is drawn on top of the control at the specified location (it can be above the plotting area for instance).

Parameters:
+ + + +
iLeftPos The left position of the legend, in pixels (from the left of the control)
iTopPos The top position of the legend, in pixels (from the top of the control)
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartLegend.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartLegend.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_line_serie-members.html b/ChartDemo/Doc/html/class_c_chart_line_serie-members.html new file mode 100644 index 0000000..03016a5 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_line_serie-members.html @@ -0,0 +1,107 @@ + + +ChartDemo: Member List + + + + + +
+

CChartLineSerie Member List

This is the complete list of members for CChartLineSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double X, double Y)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoint(const SChartXYPoint &newPoint)CChartSerieBase< SChartXYPoint >
AddPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartXYPoint > *pLabel)CChartSerieBase< SChartXYPoint >
CChartLineSerie(CChartCtrl *pParent)CChartLineSerie
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartXYPoint >
CChartXYSerie(CChartCtrl *pParent)CChartXYSerie
ClearSerie()CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartXYPoint > *pLabelProvider)CChartSerieBase< SChartXYPoint >
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetBezierControlPoints(unsigned uFirst, unsigned uLast, SChartXYPoint *&pKnots, SChartXYPoint *&pFirstControlPoints, SChartXYPoint *&pSecondControlPoints) const CChartXYSerie [protected]
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPenStyle() const CChartLineSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartXYPoint >
GetPointsCount() constCChartSerieBase< SChartXYPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartXYPoint > [virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetUserData(unsigned uPointIndex)CChartXYSerie
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartXYPoint > [protected, virtual]
GetWidth() const CChartLineSerie [inline]
GetXPointValue(unsigned PointIndex) const CChartXYSerie
GetYPointValue(unsigned PointIndex) const CChartXYSerie
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const CChartLineSerie [virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartXYPoint > [protected]
m_vPointsCChartSerieBase< SChartXYPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartXYPoint > [protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartXYPoint > *pListener)CChartSerieBase< SChartXYPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartXYPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartXYPoint >
SetColor(COLORREF NewColor)CChartSerie
SetName(const TChartString &NewName)CChartSerie
SetPenStyle(int NewStyle)CChartLineSerie
SetPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::SetPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< SChartXYPoint > [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetSmooth(bool bSmooth)CChartLineSerie
SetUserData(unsigned uPointIndex, void *pData)CChartXYSerie
SetVisible(bool bVisible)CChartSerie
SetWidth(int PenWidth)CChartLineSerie
SetXPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
SetYPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
UnregisterMouseListener()CChartSerieBase< SChartXYPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartLineSerie()CChartLineSerie [virtual]
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartXYPoint > [virtual]
~CChartXYSerie()CChartXYSerie [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_line_serie.html b/ChartDemo/Doc/html/class_c_chart_line_serie.html new file mode 100644 index 0000000..f131797 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_line_serie.html @@ -0,0 +1,171 @@ + + +ChartDemo: CChartLineSerie Class Reference + + + + + +
+

CChartLineSerie Class Reference

Specialization of a CChartSerie to display a line series. +More... +

+#include <ChartLineSerie.h> +

+

+Inheritance diagram for CChartLineSerie:
+
+ +

+ +CChartXYSerie +CChartSerieBase< SChartXYPoint > +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

int GetPenStyle () const
 Returns the pen style (plain, dashed, dotted, ...).
void SetPenStyle (int NewStyle)
 Sets the pen style (plain, dashed, dotted, ...).
+int GetWidth () const
 Returns the pen width.
+void SetWidth (int PenWidth)
 Sets the pen width.
+void SetSmooth (bool bSmooth)
 Enables the smoothing of the curve (slower).
CChartLineSerie (CChartCtrl *pParent)
 Constructor.
+virtual ~CChartLineSerie ()
 Destructor.
bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const
 Check whether a screen point is on the series.
+


Detailed Description

+Specialization of a CChartSerie to display a line series. +

+The data points are connected by line segments. The curve can also be smoothed.


Member Function Documentation

+ +
+
+ + + + + + + + +
int CChartLineSerie::GetPenStyle (  )  const [inline]
+
+
+ +

+Returns the pen style (plain, dashed, dotted, ...). +

+For a list of pen styles available, see the CreatePen function in MSDN. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + +
bool CChartLineSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [virtual]
+
+
+ +

+Check whether a screen point is on the series. +

+This function returns true if the screen point is close to a line segment. If the screen point is also close to a specific point of the series, the index of the point is stored in the uIndex parameter. Otherwise, this parameter contains INVALID_POINT.

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + +
void CChartLineSerie::SetPenStyle (int  NewStyle  ) 
+
+
+ +

+Sets the pen style (plain, dashed, dotted, ...). +

+For a list of pen styles available, see the CreatePen function in MSDN. +

+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartLineSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartLineSerie.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_line_serie.png b/ChartDemo/Doc/html/class_c_chart_line_serie.png new file mode 100644 index 0000000..af2aa05 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_line_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_logarithmic_axis-members.html b/ChartDemo/Doc/html/class_c_chart_logarithmic_axis-members.html new file mode 100644 index 0000000..bcb981a --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_logarithmic_axis-members.html @@ -0,0 +1,86 @@ + + +ChartDemo: Member List + + + + + +
+

CChartLogarithmicAxis Member List

This is the complete list of members for CChartLogarithmicAxis, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CChartAxis()CChartAxis
EAxisAutoModes enum nameCChartAxis
EnableScrollBar(bool bEnabled)CChartAxis
FullAutomatic enum valueCChartAxis
GetAutoHideScrollBar() const CChartAxis
GetAutomaticMode() const CChartAxis [inline]
GetAxisLenght() const CChartAxis [protected]
GetGrid() const CChartAxis [inline]
GetLabel() const CChartAxis [inline]
GetMinMax(double &Minimum, double &Maximum) const CChartAxis [inline]
GetPosition()CChartAxis
GetSeriesMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetSeriesScreenMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetTextColor() const CChartAxis [inline]
IsAutomatic() const CChartAxis [inline]
IsHorizontal() const CChartAxis [inline]
IsInverted() const CChartAxis [inline]
IsPointInside(const CPoint &screenPoint) const CChartAxis
IsVisible() const CChartAxis [inline]
m_AutoModeCChartAxis [protected]
m_AxisRectCChartAxis [protected]
m_bAutoTicksCChartAxis [protected]
m_bDiscreteCChartAxis [protected]
m_bIsHorizontalCChartAxis [protected]
m_bIsInvertedCChartAxis [protected]
m_bIsSecondaryCChartAxis [protected]
m_bIsVisibleCChartAxis [protected]
m_EndPosCChartAxis [protected]
m_MaxValueCChartAxis [protected]
m_MinValueCChartAxis [protected]
m_pParentCtrlCChartAxis [protected]
m_StartPosCChartAxis [protected]
m_UnzoomMaxCChartAxis [protected]
m_UnzoomMinCChartAxis [protected]
NotAutomatic enum valueCChartAxis
ScreenAutomatic enum valueCChartAxis
ScrollBarEnabled() const CChartAxis [inline]
SetAutoHideScrollBar(bool bAutoHide)CChartAxis
SetAutomatic(bool bAutomatic)CChartAxis
SetAutomaticMode(EAxisAutoModes AutoMode)CChartAxis
SetAxisColor(COLORREF NewColor)CChartAxis
SetDiscrete(bool bDiscrete)CChartAxis [virtual]
SetFont(int nPointSize, const TChartString &strFaceName)CChartAxis
SetInverted(bool bInverted)CChartAxis
SetMarginSize(bool bAuto, int iNewSize)CChartAxis
SetMinMax(double Minimum, double Maximum)CChartAxis
SetPanZoomEnabled(bool bEnabled)CChartAxis [inline]
SetTextColor(COLORREF NewColor)CChartAxis
SetVisible(bool bVisible)CChartAxis
SetZoomLimit(double dLimit)CChartAxis [inline]
SetZoomMinMax(double Minimum, double Maximum)CChartAxis [protected, virtual]
UndoZoom()CChartAxis [protected]
ValueToScreen(double Value) const CChartAxis
~CChartAxis()CChartAxis [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_logarithmic_axis.html b/ChartDemo/Doc/html/class_c_chart_logarithmic_axis.html new file mode 100644 index 0000000..675a2a8 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_logarithmic_axis.html @@ -0,0 +1,55 @@ + + +ChartDemo: CChartLogarithmicAxis Class Reference + + + + + +
+

CChartLogarithmicAxis Class Reference

Specialization of a CChartAxis to display a logarithmic scale. +More... +

+#include <ChartLogarithmicAxis.h> +

+

+Inheritance diagram for CChartLogarithmicAxis:
+
+ +

+ +CChartAxis + +
+ +

+List of all members. + +
+


Detailed Description

+Specialization of a CChartAxis to display a logarithmic scale. +

+Currently this class only allows to have a logarithmic axis with a base of 10.


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartLogarithmicAxis.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartLogarithmicAxis.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_logarithmic_axis.png b/ChartDemo/Doc/html/class_c_chart_logarithmic_axis.png new file mode 100644 index 0000000..d7c9698 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_logarithmic_axis.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_mouse_listener-members.html b/ChartDemo/Doc/html/class_c_chart_mouse_listener-members.html new file mode 100644 index 0000000..3a5673c --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_mouse_listener-members.html @@ -0,0 +1,46 @@ + + +ChartDemo: Member List + + + + + +
+

CChartMouseListener Member List

This is the complete list of members for CChartMouseListener, including all inherited members.

+ + + + + + + + + + + + + + +
CChartMouseListener()CChartMouseListener [inline]
LButtonDoubleClick enum value (defined in CChartMouseListener)CChartMouseListener
LButtonDown enum value (defined in CChartMouseListener)CChartMouseListener
LButtonUp enum value (defined in CChartMouseListener)CChartMouseListener
MouseEvent enum nameCChartMouseListener
MouseMove enum value (defined in CChartMouseListener)CChartMouseListener
OnMouseEventAxis(MouseEvent mouseEvent, CPoint point, CChartAxis *pAxisClicked)CChartMouseListener [inline, virtual]
OnMouseEventLegend(MouseEvent mouseEvent, CPoint point)CChartMouseListener [inline, virtual]
OnMouseEventPlotArea(MouseEvent mouseEvent, CPoint point)CChartMouseListener [inline, virtual]
OnMouseEventTitle(MouseEvent mouseEvent, CPoint point)CChartMouseListener [inline, virtual]
RButtonDoubleClick enum value (defined in CChartMouseListener)CChartMouseListener
RButtonDown enum value (defined in CChartMouseListener)CChartMouseListener
RButtonUp enum value (defined in CChartMouseListener)CChartMouseListener
~CChartMouseListener()CChartMouseListener [inline, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_mouse_listener.html b/ChartDemo/Doc/html/class_c_chart_mouse_listener.html new file mode 100644 index 0000000..10e243f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_mouse_listener.html @@ -0,0 +1,237 @@ + + +ChartDemo: CChartMouseListener Class Reference + + + + + +
+

CChartMouseListener Class Reference

Listener for mouse events occuring on the chart control. +More... +

+#include <ChartMouseListener.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  MouseEvent {
+  MouseMove, +LButtonUp, +LButtonDown, +LButtonDoubleClick, +
+  RButtonUp, +RButtonDown, +RButtonDoubleClick +
+ }
 Enumeration listing the type of mouse events.

Public Member Functions

CChartMouseListener ()
 Constructor.
+virtual ~CChartMouseListener ()
 Destructor.
virtual void OnMouseEventTitle (MouseEvent mouseEvent, CPoint point)
 Virtual function to implement in order to be notified when the title is clicked.
virtual void OnMouseEventAxis (MouseEvent mouseEvent, CPoint point, CChartAxis *pAxisClicked)
 Virtual function to implement in order to be notified when an axis is clicked.
virtual void OnMouseEventLegend (MouseEvent mouseEvent, CPoint point)
 Virtual function to implement in order to be notified when the legend is clicked.
virtual void OnMouseEventPlotArea (MouseEvent mouseEvent, CPoint point)
 Virtual function to implement in order to be notified when the plotting area is clicked.
+


Detailed Description

+Listener for mouse events occuring on the chart control. +

+This is an interface which must be implemented in order to receive mouse notifications. You can then register your class with the chart control by calling RegisterMouseListener.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
virtual void CChartMouseListener::OnMouseEventAxis (MouseEvent  mouseEvent,
CPoint  point,
CChartAxis pAxisClicked 
) [inline, virtual]
+
+
+ +

+Virtual function to implement in order to be notified when an axis is clicked. +

+

Parameters:
+ + + + +
mouseEvent The mouse event which occured
point The screen point on which the event occured
pAxisClicked The axis on which the event occured
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual void CChartMouseListener::OnMouseEventLegend (MouseEvent  mouseEvent,
CPoint  point 
) [inline, virtual]
+
+
+ +

+Virtual function to implement in order to be notified when the legend is clicked. +

+

Parameters:
+ + + +
mouseEvent The mouse event which occured
point The screen point on which the event occured
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual void CChartMouseListener::OnMouseEventPlotArea (MouseEvent  mouseEvent,
CPoint  point 
) [inline, virtual]
+
+
+ +

+Virtual function to implement in order to be notified when the plotting area is clicked. +

+

Parameters:
+ + + +
mouseEvent The mouse event which occured
point The screen point on which the event occured
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual void CChartMouseListener::OnMouseEventTitle (MouseEvent  mouseEvent,
CPoint  point 
) [inline, virtual]
+
+
+ +

+Virtual function to implement in order to be notified when the title is clicked. +

+

Parameters:
+ + + +
mouseEvent The mouse event which occured
point The screen point on which the event occured
+
+ +
+

+


The documentation for this class was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_points_array-members.html b/ChartDemo/Doc/html/class_c_chart_points_array-members.html new file mode 100644 index 0000000..1c6d7b7 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_points_array-members.html @@ -0,0 +1,51 @@ + + +ChartDemo: Member List + + + + + +
+

CChartPointsArray< T > Member List

This is the complete list of members for CChartPointsArray< T >, including all inherited members.

+ + + + + + + + + + + + + + + + + + + +
AddPoint(const T &newPoint)CChartPointsArray< T > [inline]
AddPoints(T *pPoints, unsigned uCount)CChartPointsArray< T > [inline]
CChartPointsArray(unsigned iResize=1000)CChartPointsArray< T > [inline]
Clear()CChartPointsArray< T > [inline]
GetInternalBuffer() const CChartPointsArray< T > [inline]
GetOrdering() const CChartPointsArray< T > [inline]
GetPointsCount() const CChartPointsArray< T > [inline]
GetSerieXMinMax(double &Min, double &Max) const CChartPointsArray< T > [inline]
GetSerieYMinMax(double &Min, double &Max) const CChartPointsArray< T > [inline]
GetVisiblePoints(double dAxisMin, double dAxisMax, unsigned &uFirstPt, unsigned &uLastPt) const CChartPointsArray< T > [inline]
operator[](unsigned Index)CChartPointsArray< T > [inline]
operator[](unsigned Index) const CChartPointsArray< T > [inline]
RemovePointsFromBegin(unsigned Count)CChartPointsArray< T > [inline]
RemovePointsFromEnd(unsigned Count)CChartPointsArray< T > [inline]
ReorderPoints()CChartPointsArray< T > [inline]
SetOrdering(PointsOrdering newOrdering)CChartPointsArray< T > [inline]
SetPoints(T *pPoints, unsigned uCount)CChartPointsArray< T > [inline]
SetResize(int iResize)CChartPointsArray< T > [inline]
~CChartPointsArray()CChartPointsArray< T > [inline]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_points_array.html b/ChartDemo/Doc/html/class_c_chart_points_array.html new file mode 100644 index 0000000..b099b72 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_points_array.html @@ -0,0 +1,351 @@ + + +ChartDemo: CChartPointsArray< T > Class Template Reference + + + + + +
+

CChartPointsArray< T > Class Template Reference

Manages an array of points which supports fast resizing. +More... +

+#include <ChartPointsArray.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

 CChartPointsArray (unsigned iResize=1000)
 Constructor.
~CChartPointsArray ()
 Destructor.
+unsigned GetPointsCount () const
 Returns the number of points currently stored.
+void SetResize (int iResize)
 Sets the size by which the internal buffer is increased when reallocation occurs.
void AddPoint (const T &newPoint)
 Adds a new point in the array.
void AddPoints (T *pPoints, unsigned uCount)
 Adds multiple points in the array.
void SetPoints (T *pPoints, unsigned uCount)
 Sets multiple points in the array.
+void Clear ()
 Removes all the points from the array.
+void RemovePointsFromBegin (unsigned Count)
 Removes a certain amount of points from the begining of the series.
+void RemovePointsFromEnd (unsigned Count)
 Removes a certain amount of points from the end of the series.
+T & operator[] (unsigned Index)
 Retrieves the points at the specified index.
+const T & operator[] (unsigned Index) const
 Retrieves the points at the specified index.
+bool GetSerieXMinMax (double &Min, double &Max) const
 Retrieves the minimum and maximum X values of the points stored in the array.
+bool GetSerieYMinMax (double &Min, double &Max) const
 Retrieves the minimum and maximum Y values of the points stored in the array.
void SetOrdering (PointsOrdering newOrdering)
 Specifies how the points should be ordered in the array.
+PointsOrdering GetOrdering () const
 Retrieves the ordering of the points in the array.
+void ReorderPoints ()
 Refreshes the point ordering.
bool GetVisiblePoints (double dAxisMin, double dAxisMax, unsigned &uFirstPt, unsigned &uLastPt) const
 Retrieves the index of the points which are between two given values.
+T * GetInternalBuffer () const
 Returns the internal buffer of the array.
+


Detailed Description

+

template<class T>
+ class CChartPointsArray< T >

+ +Manages an array of points which supports fast resizing. +

+This class is used internally to store the data for all the points. The data is stored in a C-style array. The internal buffer can grow dynamically depending on the needs.

+The class is a template class with the template parameter being the type of the points to be stored. The points have to provide the following methods:

    +
  • +double GetXMin()
  • +
  • +double GetX()
  • +
  • +double GetXMax()
  • +
  • +double GetYMin()
  • +
  • +double GetY()
  • +
  • +double GetYMax()
  • +
+

Constructor & Destructor Documentation

+ +
+
+
+template<class T >
+ + + + + + + + + +
CChartPointsArray< T >::CChartPointsArray (unsigned  iResize = 1000  )  [inline]
+
+
+ +

+Constructor. +

+

Parameters:
+ + +
iResize The size by which the internal buffer is increased when reallocation occurs
+
+ +
+

+


Member Function Documentation

+ +
+
+
+template<class T>
+ + + + + + + + + +
void CChartPointsArray< T >::AddPoint (const T &  newPoint  )  [inline]
+
+
+ +

+Adds a new point in the array. +

+

Parameters:
+ + +
newPoint The new point to add
+
+ +
+

+ +

+
+
+template<class T>
+ + + + + + + + + + + + + + + + + + +
void CChartPointsArray< T >::AddPoints (T *  pPoints,
unsigned  uCount 
) [inline]
+
+
+ +

+Adds multiple points in the array. +

+The points are added to the ones currently stored in the array.

Parameters:
+ + + +
pPoints Array containing the points
uCount The number of points to add
+
+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool CChartPointsArray< T >::GetVisiblePoints (double  dAxisMin,
double  dAxisMax,
unsigned &  uFirstPt,
unsigned &  uLastPt 
) const [inline]
+
+
+ +

+Retrieves the index of the points which are between two given values. +

+If the points are not ordered, uFirstPt will contain 0 and uLastPt will contain the index of the last point in the array.

Parameters:
+ + + + + +
dAxisMin The minimum value to retrieve the first visible point
dAxisMax The maximum value to retrieve the last visible point
uFirstPt This parameter will store the index of the first visible point
uLastPt This parameter will store the index of the last visible point
+
+
Returns:
false if no points are in the array.
+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + +
void CChartPointsArray< T >::SetOrdering (PointsOrdering  newOrdering  )  [inline]
+
+
+ +

+Specifies how the points should be ordered in the array. +

+This specifies if the points should be ordered on their X values, on their Y values or not ordered (kept in order they are added to the control). Ordering can improve performances a lot but makes it impossible to draw some specific curves (for instance, drawing an ellipse is only possible if no ordering is set). +

+

+ +

+
+
+template<class T>
+ + + + + + + + + + + + + + + + + + +
void CChartPointsArray< T >::SetPoints (T *  pPoints,
unsigned  uCount 
) [inline]
+
+
+ +

+Sets multiple points in the array. +

+The points currently stored in the array are first removed before adding the new points.

Parameters:
+ + + +
pPoints Array containing the new points
uCount The number of points to add
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsArray.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsArray.inl
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_points_serie-members.html b/ChartDemo/Doc/html/class_c_chart_points_serie-members.html new file mode 100644 index 0000000..6774c81 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_points_serie-members.html @@ -0,0 +1,112 @@ + + +ChartDemo: Member List + + + + + +
+

CChartPointsSerie Member List

This is the complete list of members for CChartPointsSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double X, double Y)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoint(const SChartXYPoint &newPoint)CChartSerieBase< SChartXYPoint >
AddPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartXYPoint > *pLabel)CChartSerieBase< SChartXYPoint >
CChartPointsSerie(CChartCtrl *pParent)CChartPointsSerie
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartXYPoint >
CChartXYSerie(CChartCtrl *pParent)CChartXYSerie
ClearSerie()CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartXYPoint > *pLabelProvider)CChartSerieBase< SChartXYPoint >
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetBezierControlPoints(unsigned uFirst, unsigned uLast, SChartXYPoint *&pKnots, SChartXYPoint *&pFirstControlPoints, SChartXYPoint *&pSecondControlPoints) const CChartXYSerie [protected]
GetBorderColor()CChartPointsSerie [inline]
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartXYPoint >
GetPointsCount() constCChartSerieBase< SChartXYPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartXYPoint > [virtual]
GetPointSize(int &XSize, int &YSize) const CChartPointsSerie [inline]
GetPointType() const CChartPointsSerie [inline]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetUserData(unsigned uPointIndex)CChartXYSerie
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartXYPoint > [protected, virtual]
GetXPointValue(unsigned PointIndex) const CChartXYSerie
GetYPointValue(unsigned PointIndex) const CChartXYSerie
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const CChartPointsSerie [virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartXYPoint > [protected]
m_vPointsCChartSerieBase< SChartXYPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartXYPoint > [protected, virtual]
PointType enum nameCChartPointsSerie
ptEllipse enum value (defined in CChartPointsSerie)CChartPointsSerie
ptRectangle enum value (defined in CChartPointsSerie)CChartPointsSerie
ptTriangle enum value (defined in CChartPointsSerie)CChartPointsSerie
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartXYPoint > *pListener)CChartSerieBase< SChartXYPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartXYPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartXYPoint >
SetBorderColor(COLORREF Color)CChartPointsSerie
SetColor(COLORREF NewColor)CChartSerie
SetName(const TChartString &NewName)CChartSerie
SetPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::SetPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
SetPointSize(int XSize, int YSize)CChartPointsSerie
SetPointType(PointType Type)CChartPointsSerie
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< SChartXYPoint > [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetUserData(unsigned uPointIndex, void *pData)CChartXYSerie
SetVisible(bool bVisible)CChartSerie
SetXPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
SetYPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
UnregisterMouseListener()CChartSerieBase< SChartXYPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartPointsSerie()CChartPointsSerie [virtual]
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartXYPoint > [virtual]
~CChartXYSerie()CChartXYSerie [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_points_serie.html b/ChartDemo/Doc/html/class_c_chart_points_serie.html new file mode 100644 index 0000000..ad52b02 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_points_serie.html @@ -0,0 +1,141 @@ + + +ChartDemo: CChartPointsSerie Class Reference + + + + + +
+

CChartPointsSerie Class Reference

Specialization of a CChartSerie to display a points series. +More... +

+#include <ChartPointsSerie.h> +

+

+Inheritance diagram for CChartPointsSerie:
+
+ +

+ +CChartXYSerie +CChartSerieBase< SChartXYPoint > +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  PointType { ptEllipse = 0, +ptRectangle = 1, +ptTriangle = 2 + }
 The different point shapes.

Public Member Functions

+void SetPointSize (int XSize, int YSize)
 Sets the width and height of each points.
+void GetPointSize (int &XSize, int &YSize) const
 Retrieves the width and height of each points.
+void SetPointType (PointType Type)
 Sets the points shape.
+PointType GetPointType () const
 Returns the points shape.
+void SetBorderColor (COLORREF Color)
 Sets the border color of the points.
+COLORREF GetBorderColor ()
 Returns the border color of the points.
CChartPointsSerie (CChartCtrl *pParent)
 Constructor.
+virtual ~CChartPointsSerie ()
 Destructor.
bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const
 Check whether a screen point is on the series.
+


Detailed Description

+Specialization of a CChartSerie to display a points series. +

+The data points are simply displayed as independant points.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool CChartPointsSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [virtual]
+
+
+ +

+Check whether a screen point is on the series. +

+

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implements CChartSerie.

+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsSerie.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_points_serie.png b/ChartDemo/Doc/html/class_c_chart_points_serie.png new file mode 100644 index 0000000..0ae49ea Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_points_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_scroll_bar-members.html b/ChartDemo/Doc/html/class_c_chart_scroll_bar-members.html new file mode 100644 index 0000000..cf4e141 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_scroll_bar-members.html @@ -0,0 +1,42 @@ + + +ChartDemo: Member List + + + + + +
+

CChartScrollBar Member List

This is the complete list of members for CChartScrollBar, including all inherited members.

+ + + + + + + + + + +
CreateScrollBar(const CRect &PlottingRect)CChartScrollBar
GetAutoHide() const CChartScrollBar [inline]
GetEnabled() const CChartScrollBar [inline]
OnHScroll(UINT nSBCode, UINT nPos)CChartScrollBar
OnMouseEnter()CChartScrollBar
OnMouseLeave()CChartScrollBar
OnVScroll(UINT nSBCode, UINT nPos)CChartScrollBar
Refresh()CChartScrollBar
SetAutoHide(bool bAutoHide)CChartScrollBar [inline]
SetEnabled(bool bEnabled)CChartScrollBar [inline]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_scroll_bar.html b/ChartDemo/Doc/html/class_c_chart_scroll_bar.html new file mode 100644 index 0000000..56cc4a9 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_scroll_bar.html @@ -0,0 +1,109 @@ + + +ChartDemo: CChartScrollBar Class Reference + + + + + +
+

CChartScrollBar Class Reference

Class which manages the interaction with the axis scroll bar. +More... +

+#include <ChartScrollBar.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void CreateScrollBar (const CRect &PlottingRect)
 Creates the scroll bar within a specified rectangle.
+void OnHScroll (UINT nSBCode, UINT nPos)
 Called on horizontal scrolling.
+void OnVScroll (UINT nSBCode, UINT nPos)
 Called on vertical scrolling.
+void Refresh ()
 Refreshes the scroll bar position.
+void SetEnabled (bool bEnabled)
 Enables/disables the scroll bar.
+bool GetEnabled () const
 Returns true if the scroll bar is enabled.
void SetAutoHide (bool bAutoHide)
 Enables/disables the auto-hide mode.
+bool GetAutoHide () const
 Returns true if the auto-hide mode is activated.
+void OnMouseEnter ()
 Called when the mouse enters the scroll bar area.
+void OnMouseLeave ()
 Called when the mouse leaves the scroll bar area.
+


Detailed Description

+Class which manages the interaction with the axis scroll bar. +

+This class is used internally by the CChartAxis class.


Member Function Documentation

+ +
+
+ + + + + + + + + +
void CChartScrollBar::SetAutoHide (bool  bAutoHide  )  [inline]
+
+
+ +

+Enables/disables the auto-hide mode. +

+In auto-hide mode, the scroll bar is not visible unless the mouse is over the region of the scroll bar. +

+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartScrollBar.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartScrollBar.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_serie-members.html b/ChartDemo/Doc/html/class_c_chart_serie-members.html new file mode 100644 index 0000000..eb6507e --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_serie-members.html @@ -0,0 +1,75 @@ + + +ChartDemo: Member List + + + + + +
+

CChartSerie Member List

This is the complete list of members for CChartSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CChartSerie(CChartCtrl *pParent)CChartSerie
Draw(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawAll(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawLabels(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawLegend(CDC *pDC, const CRect &rectBitmap) const =0CChartSerie [protected, pure virtual]
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPointsCount() const =0CChartSerie [pure virtual]
GetPointScreenCoord(unsigned uPointIndex)=0CChartSerie [pure virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) const =0CChartSerie [pure virtual]
GetSerieXScreenMinMax(double &Min, double &Max) const =0CChartSerie [pure virtual]
GetSerieYMinMax(double &Min, double &Max) const =0CChartSerie [pure virtual]
GetSerieYScreenMinMax(double &Min, double &Max) const =0CChartSerie [pure virtual]
GetShadowColor() const CChartSerie [inline]
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) const =0CChartSerie [protected, pure virtual]
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const =0CChartSerie [pure virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)=0CChartSerie [protected, pure virtual]
RefreshAutoAxes()CChartSerie [protected]
SetColor(COLORREF NewColor)CChartSerie
SetName(const TChartString &NewName)CChartSerie
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetVisible(bool bVisible)CChartSerie
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartSerie()CChartSerie [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_serie.html b/ChartDemo/Doc/html/class_c_chart_serie.html new file mode 100644 index 0000000..d5b5b0f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_serie.html @@ -0,0 +1,737 @@ + + +ChartDemo: CChartSerie Class Reference + + + + + +
+

CChartSerie Class Reference

Abstract class that provides a common "interface" for all series in the control. +More... +

+#include <ChartSerie.h> +

+

+Inheritance diagram for CChartSerie:
+
+ +

+ +CChartSerieBase< T > +CChartSerieBase< PointType > +CChartSerieBase< SChartCandlestickPoint > +CChartSerieBase< SChartGanttPoint > +CChartSerieBase< SChartXYPoint > +CChartCandlestickSerie +CChartGanttSerie +CChartXYSerie +CChartBarSerie +CChartLineSerie +CChartPointsSerie +CChartSurfaceSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+virtual unsigned GetPointsCount () const =0
 Returns the number of points in the series.
+virtual CPoint GetPointScreenCoord (unsigned uPointIndex)=0
 Returns the screen coordinate of a specific point.
virtual bool GetSerieYMinMax (double &Min, double &Max) const =0
 Retrieves the minimum and maxium Y values of the series.
virtual bool GetSerieXMinMax (double &Min, double &Max) const =0
 Retrieves the minimum and maxium X values of the series.
virtual bool GetSerieXScreenMinMax (double &Min, double &Max) const =0
 Retrieves the minimum and maxium screen X values of the series.
virtual bool GetSerieYScreenMinMax (double &Min, double &Max) const =0
 Retrieves the minimum and maxium screen Y values of the series.
+void SetName (const TChartString &NewName)
 Sets the name of the series, which is displayed in the legend.
+TChartString GetName () const
 Returns the name of the series.
void ValueToScreen (double XValue, double YValue, CPoint &ScreenPoint) const
 Converts any data point into its relative screen point.
+double YScreenToValue (long YScreenCoord) const
 Converts an Y screen value into its relative Y data value.
+double XScreenToValue (long XScreenCoord) const
 Converts an Xscreen value into its relative X data value.
CChartSerie (CChartCtrl *pParent)
 Constructor.
+virtual ~CChartSerie ()
 Destructor.
void SetVisible (bool bVisible)
 Specifies if the series is visible or not.
+bool IsVisible () const
 Returns true if the series is visible.
+COLORREF GetColor () const
 Returns the color of the series.
+void SetColor (COLORREF NewColor)
 Sets the color of the series.
+COLORREF GetShadowColor () const
 Returns the color of the shadow.
+void SetShadowColor (COLORREF NewColor)
 Sets the color of the shadow.
+void EnableShadow (bool bEnable)
 Enables or disables the shadow for the series.
+void SetShadowDepth (int Depth)
 Sepcifies the depth (in pixels) of the shadow.
virtual bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const =0
 Tests if a certain screen point is on the series.
+unsigned GetSerieId () const
 Returns the series Id.
void EnableMouseNotifications (bool bClickEnabled, bool bMoveEnabled)
 Enables or disables certain mouse notifications on the series.

Protected Member Functions

+void RefreshAutoAxes ()
 Refreshes the automatic axes associated with this series.
virtual bool GetVisiblePoints (unsigned &uFirst, unsigned &uLast) const =0
 Returns the first and last visible points of the series.
virtual void DrawLegend (CDC *pDC, const CRect &rectBitmap) const =0
 Draws the legend icon for the series.
virtual void Draw (CDC *pDC)=0
 Draws the most recent points of the series.
virtual void DrawAll (CDC *pDC)=0
 Redraws the full series.
virtual void DrawLabels (CDC *pDC)=0
 Draws the labels of the series.
virtual bool OnMouseEvent (CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)=0
 Called when a mouse event is detected on the chart.
+bool NotifyMouseMoveEnabled ()
 Returns true if the series reacts on mouse moves.
+bool NotifyMouseClickEnabled ()
 Returns true if the series reacts on mouse clicks.

Protected Attributes

+CChartCtrlm_pParentCtrl
 The parent charting control.
+CChartAxism_pVerticalAxis
 The related vertical axis.
+CChartAxism_pHorizontalAxis
 The related horizontal axis.
+TChartString m_strSerieName
 The series name displayed in the legend.
+bool m_bIsVisible
 Specifies if the series is visible.
+bool m_bShadow
 Specifies if the series has shadow enabled.
+COLORREF m_SerieColor
 Color of the series.
+COLORREF m_ShadowColor
 Color of the shadow.
+int m_iShadowDepth
 Depth (in pixels) of the shadow.
+CRect m_PlottingRect
 The rectangle in which the series should be drawn.
+


Detailed Description

+Abstract class that provides a common "interface" for all series in the control. +

+The class doesn't manipulate points (the type of point is unknown at this level in the class hierarchy) but it provides all other functionalities which are independant of the point type.

+The drawing of the series is made through pure virtual functions which should be implemented by derived classes.

+Each series is identified by an Id.


Member Function Documentation

+ +
+
+ + + + + + + + + +
virtual void CChartSerie::Draw (CDC *  pDC  )  [protected, pure virtual]
+
+
+ +

+Draws the most recent points of the series. +

+This pure virtual function should be overriden by child classes. This function should only draw the points that were not previously drawn.

Parameters:
+ + +
pDC The device context used to draw
+
+ +

Implemented in CChartCandlestickSerie, and CChartGanttSerie.

+ +
+

+ +

+
+ + + + + + + + + +
virtual void CChartSerie::DrawAll (CDC *  pDC  )  [protected, pure virtual]
+
+
+ +

+Redraws the full series. +

+This pure virtual function should be overriden by child classes.

Parameters:
+ + +
pDC The device context used to draw
+
+ +

Implemented in CChartCandlestickSerie, and CChartGanttSerie.

+ +
+

+ +

+
+ + + + + + + + + +
virtual void CChartSerie::DrawLabels (CDC *  pDC  )  [protected, pure virtual]
+
+
+ +

+Draws the labels of the series. +

+This pure virtual function should be overriden by child classes.

Parameters:
+ + +
pDC The device context used to draw
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual void CChartSerie::DrawLegend (CDC *  pDC,
const CRect &  rectBitmap 
) const [protected, pure virtual]
+
+
+ +

+Draws the legend icon for the series. +

+This pure virtual function should be overriden by child classes.

Parameters:
+ + + +
pDC The device context used to draw
rectBitmap The rectangle in which to draw the legend icon
+
+ +

Implemented in CChartCandlestickSerie, and CChartGanttSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartSerie::EnableMouseNotifications (bool  bClickEnabled,
bool  bMoveEnabled 
)
+
+
+ +

+Enables or disables certain mouse notifications on the series. +

+Checking if a point is on the series could degrade performances if it has to be done for each mouse event. This function allows to disable certain notifications, in which case the test won't be done. By default the series reacts on mouse clicks but not on mouse moves.

Parameters:
+ + + +
bClickEnabled Specifies if the series reacts on mouse clicks.
bMoveEnabled Specifies if the series reacts on mouse moves.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::GetSerieXMinMax (double &  Min,
double &  Max 
) const [pure virtual]
+
+
+ +

+Retrieves the minimum and maxium X values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implemented in CChartSerieBase< T >, CChartSerieBase< SChartCandlestickPoint >, CChartSerieBase< SChartXYPoint >, CChartSerieBase< SChartGanttPoint >, and CChartSerieBase< PointType >.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::GetSerieXScreenMinMax (double &  Min,
double &  Max 
) const [pure virtual]
+
+
+ +

+Retrieves the minimum and maxium screen X values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implemented in CChartSerieBase< T >, CChartSerieBase< SChartCandlestickPoint >, CChartSerieBase< SChartXYPoint >, CChartSerieBase< SChartGanttPoint >, and CChartSerieBase< PointType >.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::GetSerieYMinMax (double &  Min,
double &  Max 
) const [pure virtual]
+
+
+ +

+Retrieves the minimum and maxium Y values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implemented in CChartSerieBase< T >, CChartSerieBase< SChartCandlestickPoint >, CChartSerieBase< SChartXYPoint >, CChartSerieBase< SChartGanttPoint >, and CChartSerieBase< PointType >.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::GetSerieYScreenMinMax (double &  Min,
double &  Max 
) const [pure virtual]
+
+
+ +

+Retrieves the minimum and maxium screen Y values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implemented in CChartSerieBase< T >, CChartSerieBase< SChartCandlestickPoint >, CChartSerieBase< SChartXYPoint >, CChartSerieBase< SChartGanttPoint >, and CChartSerieBase< PointType >.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::GetVisiblePoints (unsigned &  uFirst,
unsigned &  uLast 
) const [protected, pure virtual]
+
+
+ +

+Returns the first and last visible points of the series. +

+This function only works if ordering is enabled.

Parameters:
+ + + +
uFirst The index of the first visible point is stored in this argument
uLast The index of the last visible point is stored in this argument
+
+
Returns:
false if the series has no ordering or no data points.
+ +

Implemented in CChartSerieBase< T >, CChartSerieBase< SChartCandlestickPoint >, CChartSerieBase< SChartXYPoint >, CChartSerieBase< SChartGanttPoint >, and CChartSerieBase< PointType >.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [pure virtual]
+
+
+ +

+Tests if a certain screen point is on the series. +

+This function should be overidden by all child classes.

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implemented in CChartBarSerie, CChartCandlestickSerie, CChartGanttSerie, CChartLineSerie, CChartPointsSerie, and CChartSurfaceSerie.

+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
virtual bool CChartSerie::OnMouseEvent (CChartMouseListener::MouseEvent  mouseEvent,
const CPoint &  screenPoint 
) [protected, pure virtual]
+
+
+ +

+Called when a mouse event is detected on the chart. +

+This pure virtual function should be overriden by child classes.

Parameters:
+ + + +
mouseEvent The event that occured on the control
screenPoint The screen point on which the event occured
+
+
Returns:
true if the event occured on the series.
+ +

Implemented in CChartSerieBase< T >, CChartSerieBase< SChartCandlestickPoint >, CChartSerieBase< SChartXYPoint >, CChartSerieBase< SChartGanttPoint >, and CChartSerieBase< PointType >.

+ +
+

+ +

+
+ + + + + + + + + +
void CChartSerie::SetVisible (bool  bVisible  ) 
+
+
+ +

+Specifies if the series is visible or not. +

+An invisible series won't affect automatic axis: it is considered as if it was not in the control. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartSerie::ValueToScreen (double  XValue,
double  YValue,
CPoint &  ScreenPoint 
) const
+
+
+ +

+Converts any data point into its relative screen point. +

+

Parameters:
+ + + + +
XValue The X value of the data point
YValue The Y value of the data point
ScreenPoint The screen point will be stored in the parameter
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerie.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_serie.png b/ChartDemo/Doc/html/class_c_chart_serie.png new file mode 100644 index 0000000..26316de Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_serie_base-members.html b/ChartDemo/Doc/html/class_c_chart_serie_base-members.html new file mode 100644 index 0000000..ad07650 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_serie_base-members.html @@ -0,0 +1,91 @@ + + +ChartDemo: Member List + + + + + +
+

CChartSerieBase< T > Member List

This is the complete list of members for CChartSerieBase< T >, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(const T &newPoint)CChartSerieBase< T > [inline]
AddPoints(T *pPoints, unsigned Count)CChartSerieBase< T > [inline]
AttachCustomLabel(unsigned uPointIndex, CChartLabel< T > *pLabel)CChartSerieBase< T > [inline]
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< T > [inline]
ClearSerie()CChartSerieBase< T > [inline]
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< T > [inline]
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< T > *pLabelProvider)CChartSerieBase< T > [inline]
Draw(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawAll(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawLegend(CDC *pDC, const CRect &rectBitmap) const =0CChartSerie [protected, pure virtual]
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) const CChartSerieBase< T > [inline]
GetPointsCount() const CChartSerieBase< T > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< T > [inline, virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) const CChartSerieBase< T > [inline, virtual]
GetSerieXScreenMinMax(double &Min, double &Max) const CChartSerieBase< T > [inline, virtual]
GetSerieYMinMax(double &Min, double &Max) const CChartSerieBase< T > [inline, virtual]
GetSerieYScreenMinMax(double &Min, double &Max) const CChartSerieBase< T > [inline, virtual]
GetShadowColor() const CChartSerie [inline]
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) const CChartSerieBase< T > [inline, protected, virtual]
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const =0CChartSerie [pure virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< T > [protected]
m_vPointsCChartSerieBase< T > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< T > [inline, protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< T > *pListener)CChartSerieBase< T > [inline]
RemovePointsFromBegin(unsigned Count)CChartSerieBase< T > [inline]
RemovePointsFromEnd(unsigned Count)CChartSerieBase< T > [inline]
SetColor(COLORREF NewColor)CChartSerie
SetName(const TChartString &NewName)CChartSerie
SetPoints(T *pPoints, unsigned Count)CChartSerieBase< T > [inline]
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< T > [inline, virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetVisible(bool bVisible)CChartSerie
UnregisterMouseListener()CChartSerieBase< T > [inline]
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< T > [inline, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_serie_base.html b/ChartDemo/Doc/html/class_c_chart_serie_base.html new file mode 100644 index 0000000..465daa5 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_serie_base.html @@ -0,0 +1,672 @@ + + +ChartDemo: CChartSerieBase< T > Class Template Reference + + + + + +
+

CChartSerieBase< T > Class Template Reference

Base class for all series of the control. +More... +

+#include <ChartSerieBase.h> +

+

+Inheritance diagram for CChartSerieBase< T >:
+
+ +

+ +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+void AddPoint (const T &newPoint)
 Adds a single data point to the series.
void AddPoints (T *pPoints, unsigned Count)
 Adds an array of points to the series.
const T & GetPoint (unsigned index) const
 Retrieves the point at the specified index.
void SetPoints (T *pPoints, unsigned Count)
 Sets an array of points to the series.
+void RemovePointsFromBegin (unsigned Count)
 Removes a certain amount of points from the begining of the series.
+void RemovePointsFromEnd (unsigned Count)
 Removes a certain amount of points from the end of the series.
+void ClearSerie ()
 Removes all points from the series.
+unsigned GetPointsCount () const
 Returns the number of points in the series.
bool GetSerieYMinMax (double &Min, double &Max) const
 Retrieves the minimum and maxium Y values of the series.
bool GetSerieXMinMax (double &Min, double &Max) const
 Retrieves the minimum and maxium X values of the series.
bool GetSerieXScreenMinMax (double &Min, double &Max) const
 Retrieves the minimum and maxium screen X values of the series.
bool GetSerieYScreenMinMax (double &Min, double &Max) const
 Retrieves the minimum and maxium screen Y values of the series.
CChartBalloonLabel< T > * CreateBalloonLabel (unsigned uPointIndex, const TChartString &strLabelText)
 Creates and attaches a balloon label on a point of the series.
CChartBalloonLabel< T > * CreateBalloonLabel (unsigned uPointIndex, CChartLabelProvider< T > *pLabelProvider)
 Creates and attaches a balloon label on a point of the series.
void AttachCustomLabel (unsigned uPointIndex, CChartLabel< T > *pLabel)
 Attaches a custom label on a point of the series.
CChartSerieBase (CChartCtrl *pParent)
 Constructor.
+virtual ~CChartSerieBase ()
 Destructor.
virtual void SetSeriesOrdering (PointsOrdering newOrdering)
 Specifies how the points should be ordered in the series.
CPoint GetPointScreenCoord (unsigned uPointIndex)
 Retrieves the screen point of a specific data point.
void RegisterMouseListener (CChartSeriesMouseListener< T > *pListener)
 Register a series mouse listener on this series.
+void UnregisterMouseListener ()
 Unregister the series mouse listener for this series.

Protected Member Functions

bool GetVisiblePoints (unsigned &uFirst, unsigned &uLast) const
 Returns the first and last visible points of the series.
+bool OnMouseEvent (CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)
 Called by the control to check if an event occured on the series.

Protected Attributes

+CChartPointsArray< T > m_vPoints
 The helper class containing all the data points.
+unsigned m_uLastDrawnPoint
 Index of the last point drawn.
+


Detailed Description

+

template<class T>
+ class CChartSerieBase< T >

+ +Base class for all series of the control. +

+This class inherits from CChartSeries and introduces the concept of points through the template parameter.

+This class is much more than a simple base class. It already store all the data points and provide utility functions to manipulate them.


Member Function Documentation

+ +
+
+
+template<class T>
+ + + + + + + + + + + + + + + + + + +
void CChartSerieBase< T >::AddPoints (T *  pPoints,
unsigned  Count 
) [inline]
+
+
+ +

+Adds an array of points to the series. +

+Points which were already present in the series are kept.

Parameters:
+ + + +
pPoints Array of the new points
Count Size of the array
+
+ +
+

+ +

+
+
+template<class T>
+ + + + + + + + + + + + + + + + + + +
void CChartSerieBase< T >::AttachCustomLabel (unsigned  uPointIndex,
CChartLabel< T > *  pLabel 
) [inline]
+
+
+ +

+Attaches a custom label on a point of the series. +

+

Parameters:
+ + + +
uPointIndex The index of the point on which the label should be attached
pLabel The label to attach to the point
+
+ +
+

+ +

+
+
+template<class T>
+ + + + + + + + + + + + + + + + + + +
CChartBalloonLabel< T > * CChartSerieBase< T >::CreateBalloonLabel (unsigned  uPointIndex,
CChartLabelProvider< T > *  pLabelProvider 
) [inline]
+
+
+ +

+Creates and attaches a balloon label on a point of the series. +

+This functions specifies a CChartLabelProvider object which is used to supply the text of the label. This is useful if you want more flexibility for the text of the label (display information about the point value for instance).

Parameters:
+ + + +
uPointIndex The index of the point on which the label should be attached
pLabelProvider Object providing the text displayed on the label
+
+
Returns:
the created CChartBalloonLabel
+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + +
CChartBalloonLabel< T > * CChartSerieBase< T >::CreateBalloonLabel (unsigned  uPointIndex,
const TChartString &  strLabelText 
) [inline]
+
+
+ +

+Creates and attaches a balloon label on a point of the series. +

+This functions specifies a static text to display in the label.

Parameters:
+ + + +
uPointIndex The index of the point on which the label should be attached
strLabelText The text of the label
+
+
Returns:
the created CChartBalloonLabel
+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + +
const T & CChartSerieBase< T >::GetPoint (unsigned  index  )  const [inline]
+
+
+ +

+Retrieves the point at the specified index. +

+

Parameters:
+ + +
index The index of the point to retrieve
+
+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + +
CPoint CChartSerieBase< T >::GetPointScreenCoord (unsigned  uPointIndex  )  [inline, virtual]
+
+
+ +

+Retrieves the screen point of a specific data point. +

+

Parameters:
+ + +
uPointIndex The index of the point for which to retrieve the screen point
+
+
Returns:
the screen point
+ +

Implements CChartSerie.

+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + +
bool CChartSerieBase< T >::GetSerieXMinMax (double &  Min,
double &  Max 
) const [inline, virtual]
+
+
+ +

+Retrieves the minimum and maxium X values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implements CChartSerie.

+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + +
bool CChartSerieBase< T >::GetSerieXScreenMinMax (double &  Min,
double &  Max 
) const [inline, virtual]
+
+
+ +

+Retrieves the minimum and maxium screen X values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implements CChartSerie.

+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + +
bool CChartSerieBase< T >::GetSerieYMinMax (double &  Min,
double &  Max 
) const [inline, virtual]
+
+
+ +

+Retrieves the minimum and maxium Y values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implements CChartSerie.

+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + +
bool CChartSerieBase< T >::GetSerieYScreenMinMax (double &  Min,
double &  Max 
) const [inline, virtual]
+
+
+ +

+Retrieves the minimum and maxium screen Y values of the series. +

+

Parameters:
+ + + +
Min Minimum value will be stored in this parameter
Max Maximum value will be stored in this parameter
+
+
Returns:
false if the series doesn't contain data or is invisible
+ +

Implements CChartSerie.

+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + + + + + + + + + + +
bool CChartSerieBase< T >::GetVisiblePoints (unsigned &  uFirst,
unsigned &  uLast 
) const [inline, protected, virtual]
+
+
+ +

+Returns the first and last visible points of the series. +

+This function only works if ordering is enabled.

Parameters:
+ + + +
uFirst The index of the first visible point is stored in this argument
uLast The index of the last visible point is stored in this argument
+
+
Returns:
false if the series has no ordering or no data points.
+ +

Implements CChartSerie.

+ +
+

+ +

+
+
+template<class T>
+ + + + + + + + + +
void CChartSerieBase< T >::RegisterMouseListener (CChartSeriesMouseListener< T > *  pListener  )  [inline]
+
+
+ +

+Register a series mouse listener on this series. +

+

Parameters:
+ + +
pListener The listener to register
+
+ +
+

+ +

+
+
+template<class T>
+ + + + + + + + + + + + + + + + + + +
void CChartSerieBase< T >::SetPoints (T *  pPoints,
unsigned  Count 
) [inline]
+
+
+ +

+Sets an array of points to the series. +

+Points which were already present in the series are discarded.

Parameters:
+ + + +
pPoints Array of the new points
Count Size of the array
+
+ +
+

+ +

+
+
+template<class T >
+ + + + + + + + + +
void CChartSerieBase< T >::SetSeriesOrdering (PointsOrdering  newOrdering  )  [inline, virtual]
+
+
+ +

+Specifies how the points should be ordered in the series. +

+This specifies if the points should be ordered on their X values, on their Y values or not ordered (kept in order they are added to the control). Ordering can improve performances a lot but makes it impossible to draw some specific curves (for instance, drawing an ellipse is only possible if no ordering is set). +

Reimplemented in CChartSurfaceSerie.

+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerieBase.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerieBase.inl
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_serie_base.png b/ChartDemo/Doc/html/class_c_chart_serie_base.png new file mode 100644 index 0000000..ab84c51 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_serie_base.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_series_mouse_listener-members.html b/ChartDemo/Doc/html/class_c_chart_series_mouse_listener-members.html new file mode 100644 index 0000000..1b36486 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_series_mouse_listener-members.html @@ -0,0 +1,35 @@ + + +ChartDemo: Member List + + + + + +
+

CChartSeriesMouseListener< PointType > Member List

This is the complete list of members for CChartSeriesMouseListener< PointType >, including all inherited members.

+ + + +
CChartSeriesMouseListener()CChartSeriesMouseListener< PointType > [inline]
OnMouseEventSeries(CChartMouseListener::MouseEvent mouseEvent, CPoint point, CChartSerieBase< PointType > *pSerie, unsigned uPointIndex)CChartSeriesMouseListener< PointType > [inline, virtual]
~CChartSeriesMouseListener()CChartSeriesMouseListener< PointType > [inline, virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_series_mouse_listener.html b/ChartDemo/Doc/html/class_c_chart_series_mouse_listener.html new file mode 100644 index 0000000..4be984f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_series_mouse_listener.html @@ -0,0 +1,115 @@ + + +ChartDemo: CChartSeriesMouseListener< PointType > Class Template Reference + + + + + +
+

CChartSeriesMouseListener< PointType > Class Template Reference

Listener for mouse events occuring on a series. +More... +

+#include <ChartSeriesMouseListener.h> +

+ +

+List of all members. + + + + + + + + + + + +

Public Member Functions

CChartSeriesMouseListener ()
 Constructor.
+virtual ~CChartSeriesMouseListener ()
 Destructor.
virtual void OnMouseEventSeries (CChartMouseListener::MouseEvent mouseEvent, CPoint point, CChartSerieBase< PointType > *pSerie, unsigned uPointIndex)
 Virtual function to implement in order to be notified when a mouse event occurs on a series.
+


Detailed Description

+

template<class PointType>
+ class CChartSeriesMouseListener< PointType >

+ +Listener for mouse events occuring on a series. +

+This is an interface which must be implemented in order to receive mouse notifications. You can then register your class with the chart control by calling RegisterMouseListener.


Member Function Documentation

+ +
+
+
+template<class PointType>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
virtual void CChartSeriesMouseListener< PointType >::OnMouseEventSeries (CChartMouseListener::MouseEvent  mouseEvent,
CPoint  point,
CChartSerieBase< PointType > *  pSerie,
unsigned  uPointIndex 
) [inline, virtual]
+
+
+ +

+Virtual function to implement in order to be notified when a mouse event occurs on a series. +

+

Parameters:
+ + + + + +
mouseEvent The mouse event which occured
point The screen point on which the event occured
pSerie The series on which the event occured
uPointIndex The index of the point on which the event occured. In case the event did not occur on a specific point but on the series itself (e.g. clicking between two points on a line series), INVALID_POINT is passed for this parameter.
+
+ +
+

+


The documentation for this class was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_standard_axis-members.html b/ChartDemo/Doc/html/class_c_chart_standard_axis-members.html new file mode 100644 index 0000000..9749166 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_standard_axis-members.html @@ -0,0 +1,93 @@ + + +ChartDemo: Member List + + + + + +
+

CChartStandardAxis Member List

This is the complete list of members for CChartStandardAxis, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CChartAxis()CChartAxis
EAxisAutoModes enum nameCChartAxis
EnableScrollBar(bool bEnabled)CChartAxis
FullAutomatic enum valueCChartAxis
GetAutoHideScrollBar() const CChartAxis
GetAutomaticMode() const CChartAxis [inline]
GetAxisLenght() const CChartAxis [protected]
GetGrid() const CChartAxis [inline]
GetLabel() const CChartAxis [inline]
GetMinMax(double &Minimum, double &Maximum) const CChartAxis [inline]
GetPosition()CChartAxis
GetScrollbarSteps(int &iTotalSteps, int &iCurrentStep)CChartAxis [protected, virtual]
GetSeriesMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetSeriesScreenMinMax(double &Minimum, double &Maximum)CChartAxis [protected]
GetTextColor() const CChartAxis [inline]
GetTickIncrement() const CChartStandardAxis [inline]
IsAutomatic() const CChartAxis [inline]
IsHorizontal() const CChartAxis [inline]
IsInverted() const CChartAxis [inline]
IsPointInside(const CPoint &screenPoint) const CChartAxis
IsVisible() const CChartAxis [inline]
m_AutoModeCChartAxis [protected]
m_AxisRectCChartAxis [protected]
m_bAutoTicksCChartAxis [protected]
m_bDiscreteCChartAxis [protected]
m_bIsHorizontalCChartAxis [protected]
m_bIsInvertedCChartAxis [protected]
m_bIsSecondaryCChartAxis [protected]
m_bIsVisibleCChartAxis [protected]
m_EndPosCChartAxis [protected]
m_MaxValueCChartAxis [protected]
m_MinValueCChartAxis [protected]
m_pParentCtrlCChartAxis [protected]
m_StartPosCChartAxis [protected]
m_UnzoomMaxCChartAxis [protected]
m_UnzoomMinCChartAxis [protected]
NotAutomatic enum valueCChartAxis
PanAxis(long PanStart, long PanEnd)CChartAxis [protected, virtual]
ScreenAutomatic enum valueCChartAxis
ScreenToValue(long ScreenVal) const CChartAxis [virtual]
ScrollBarEnabled() const CChartAxis [inline]
SetAutoHideScrollBar(bool bAutoHide)CChartAxis
SetAutomatic(bool bAutomatic)CChartAxis
SetAutomaticMode(EAxisAutoModes AutoMode)CChartAxis
SetAxisColor(COLORREF NewColor)CChartAxis
SetAxisToScrollStep(int iPreviousStep, int iCurrentStep, bool bScrollInverted)CChartAxis [protected, virtual]
SetDiscrete(bool bDiscrete)CChartAxis [virtual]
SetFont(int nPointSize, const TChartString &strFaceName)CChartAxis
SetInverted(bool bInverted)CChartAxis
SetMarginSize(bool bAuto, int iNewSize)CChartAxis
SetMinMax(double Minimum, double Maximum)CChartAxis
SetPanZoomEnabled(bool bEnabled)CChartAxis [inline]
SetTextColor(COLORREF NewColor)CChartAxis
SetTickIncrement(bool bAuto, double newIncrement)CChartStandardAxis
SetVisible(bool bVisible)CChartAxis
SetZoomLimit(double dLimit)CChartAxis [inline]
SetZoomMinMax(double Minimum, double Maximum)CChartAxis [protected, virtual]
UndoZoom()CChartAxis [protected]
ValueToScreen(double Value) const CChartAxis
ValueToScreenStandard(double Value) const CChartAxis [protected, virtual]
~CChartAxis()CChartAxis [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_standard_axis.html b/ChartDemo/Doc/html/class_c_chart_standard_axis.html new file mode 100644 index 0000000..7b1a4b5 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_standard_axis.html @@ -0,0 +1,119 @@ + + +ChartDemo: CChartStandardAxis Class Reference + + + + + +
+

CChartStandardAxis Class Reference

Specialization of a CChartAxis class to display standard values. +More... +

+#include <ChartStandardAxis.h> +

+

+Inheritance diagram for CChartStandardAxis:
+
+ +

+ +CChartAxis + +
+ +

+List of all members. + + + + + + + + +

Public Member Functions

void SetTickIncrement (bool bAuto, double newIncrement)
 Sets the tick increment.
double GetTickIncrement () const
 Gets the tick increment.
+


Detailed Description

+Specialization of a CChartAxis class to display standard values.

Member Function Documentation

+ +
+
+ + + + + + + + +
double CChartStandardAxis::GetTickIncrement (  )  const [inline]
+
+
+ +

+Gets the tick increment. +

+The tick increment is the value between two adjacents ticks on the axis. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartStandardAxis::SetTickIncrement (bool  bAuto,
double  newIncrement 
)
+
+
+ +

+Sets the tick increment. +

+The tick increment is the value between two adjacents ticks on the axis.

Parameters:
+ + + +
bAuto Specifies if the tick increment is automatically calculated.
newIncrement The tick increment to use in manual mode.
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartStandardAxis.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartStandardAxis.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_standard_axis.png b/ChartDemo/Doc/html/class_c_chart_standard_axis.png new file mode 100644 index 0000000..56b202a Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_standard_axis.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_surface_serie-members.html b/ChartDemo/Doc/html/class_c_chart_surface_serie-members.html new file mode 100644 index 0000000..42f07c8 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_surface_serie-members.html @@ -0,0 +1,114 @@ + + +ChartDemo: Member List + + + + + +
+

CChartSurfaceSerie Member List

This is the complete list of members for CChartSurfaceSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double X, double Y)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoint(const SChartXYPoint &newPoint)CChartSerieBase< SChartXYPoint >
AddPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartXYPoint > *pLabel)CChartSerieBase< SChartXYPoint >
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartXYPoint >
CChartSurfaceSerie(CChartCtrl *pParent)CChartSurfaceSerie
CChartXYSerie(CChartCtrl *pParent)CChartXYSerie
ClearSerie()CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartXYPoint > *pLabelProvider)CChartSerieBase< SChartXYPoint >
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
FillStyle enum nameCChartSurfaceSerie
fsHatchCross enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
fsHatchDiagCross enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
fsHatchDownDiag enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
fsHatchHorizontal enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
fsHatchUpDiag enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
fsHatchVertical enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
fsSolid enum value (defined in CChartSurfaceSerie)CChartSurfaceSerie
GetBezierControlPoints(unsigned uFirst, unsigned uLast, SChartXYPoint *&pKnots, SChartXYPoint *&pFirstControlPoints, SChartXYPoint *&pSecondControlPoints) const CChartXYSerie [protected]
GetColor() const CChartSerie [inline]
GetFillStyle() const CChartSurfaceSerie [inline]
GetHorizontal() const CChartSurfaceSerie [inline]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartXYPoint >
GetPointsCount() constCChartSerieBase< SChartXYPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartXYPoint > [virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetUserData(unsigned uPointIndex)CChartXYSerie
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartXYPoint > [protected, virtual]
GetXPointValue(unsigned PointIndex) const CChartXYSerie
GetYPointValue(unsigned PointIndex) const CChartXYSerie
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const CChartSurfaceSerie [virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartXYPoint > [protected]
m_vPointsCChartSerieBase< SChartXYPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartXYPoint > [protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartXYPoint > *pListener)CChartSerieBase< SChartXYPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartXYPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartXYPoint >
SetColor(COLORREF NewColor)CChartSerie
SetFillStyle(FillStyle NewStyle)CChartSurfaceSerie
SetHorizontal(bool bHoriz)CChartSurfaceSerie
SetName(const TChartString &NewName)CChartSerie
SetPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::SetPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
SetSeriesOrdering(PointsOrdering)CChartSurfaceSerie [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetUserData(unsigned uPointIndex, void *pData)CChartXYSerie
SetVisible(bool bVisible)CChartSerie
SetXPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
SetYPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
UnregisterMouseListener()CChartSerieBase< SChartXYPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartXYPoint > [virtual]
~CChartSurfaceSerie()CChartSurfaceSerie [virtual]
~CChartXYSerie()CChartXYSerie [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_surface_serie.html b/ChartDemo/Doc/html/class_c_chart_surface_serie.html new file mode 100644 index 0000000..e6104a5 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_surface_serie.html @@ -0,0 +1,188 @@ + + +ChartDemo: CChartSurfaceSerie Class Reference + + + + + +
+

CChartSurfaceSerie Class Reference

Specialization of a CChartSerie to display a surface series. +More... +

+#include <ChartSurfaceSerie.h> +

+

+Inheritance diagram for CChartSurfaceSerie:
+
+ +

+ +CChartXYSerie +CChartSerieBase< SChartXYPoint > +CChartSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

enum  FillStyle {
+  fsSolid = 0, +fsHatchDownDiag, +fsHatchUpDiag, +fsHatchCross, +
+  fsHatchDiagCross, +fsHatchHorizontal, +fsHatchVertical +
+ }
 The different fill styles.

Public Member Functions

CChartSurfaceSerie (CChartCtrl *pParent)
 Constructor.
+virtual ~CChartSurfaceSerie ()
 Destructor.
+void SetFillStyle (FillStyle NewStyle)
 Sets the fill style.
+FillStyle GetFillStyle () const
 Returns the fill style.
void SetHorizontal (bool bHoriz)
 Sets the series in horizontal or vertical mode.
+bool GetHorizontal () const
 Returns true if the series is in horizontal mode.
bool IsPointOnSerie (const CPoint &screenPoint, unsigned &uIndex) const
 Check whether a screen point is on the series.
void SetSeriesOrdering (PointsOrdering)
 Specifies how the points should be ordered in the series.
+


Detailed Description

+Specialization of a CChartSerie to display a surface series. +

+A surface can be horizontal (default) or vertical: this defines how the filling of the surface is done. For a horizontal surface, the filling is done between the points and the associated horizontal axis and for a vertical surface, the filling is done between the points and the associated vertical axis. The series can be associated with a secondary axis. For example, if the surface series is horizontal and is associated with the top axis (secondary axis), the filling is done between the top axis and the points.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool CChartSurfaceSerie::IsPointOnSerie (const CPoint &  screenPoint,
unsigned &  uIndex 
) const [virtual]
+
+
+ +

+Check whether a screen point is on the series. +

+This function returns true if the screen point is on the surface. If the screen point is also close to a specific point of the series, the index of the point is stored in the uIndex parameter. Otherwise, this parameter contains INVALID_POINT.

Parameters:
+ + + +
screenPoint The screen point to test
uIndex If the point is close to a specific point of the series, its index is stored here.
+
+
Returns:
true if the point is on the series
+ +

Implements CChartSerie.

+ +
+

+ +

+
+ + + + + + + + + +
void CChartSurfaceSerie::SetHorizontal (bool  bHoriz  ) 
+
+
+ +

+Sets the series in horizontal or vertical mode. +

+If the series is in horizontal mode, the filling will be done between the data points and the horizontal axis. +

+

+ +

+
+ + + + + + + + + +
void CChartSurfaceSerie::SetSeriesOrdering (PointsOrdering  newOrdering  )  [virtual]
+
+
+ +

+Specifies how the points should be ordered in the series. +

+This specifies if the points should be ordered on their X values, on their Y values or not ordered (kept in order they are added to the control). Ordering can improve performances a lot but makes it impossible to draw some specific curves (for instance, drawing an ellipse is only possible if no ordering is set). +

Reimplemented from CChartSerieBase< SChartXYPoint >.

+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartSurfaceSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartSurfaceSerie.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_surface_serie.png b/ChartDemo/Doc/html/class_c_chart_surface_serie.png new file mode 100644 index 0000000..da63a13 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_surface_serie.png differ diff --git a/ChartDemo/Doc/html/class_c_chart_title-members.html b/ChartDemo/Doc/html/class_c_chart_title-members.html new file mode 100644 index 0000000..bf3eb61 --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_title-members.html @@ -0,0 +1,45 @@ + + +ChartDemo: Member List + + + + + +
+

CChartTitle Member List

This is the complete list of members for CChartTitle, including all inherited members.

+ + + + + + + + + + + + + +
AddString(const TChartString &NewString)CChartTitle
GetColor() const CChartTitle [inline]
GetString(size_t Index) const CChartTitle
GetStringCount() const CChartTitle
IsPointInside(const CPoint &screenPoint) const CChartTitle
IsVisible() const CChartTitle [inline]
RemoveAll()CChartTitle
SetColor(COLORREF NewColor)CChartTitle
SetFont(int iPointSize, const TChartString &strFaceName)CChartTitle
SetFont(const CChartFont &newFont)CChartTitle
SetLineFont(int iLineIndex, int iPointSize, const TChartString &strFaceName)CChartTitle
SetLineFont(int iLineIndex, const CChartFont &newFont)CChartTitle
SetVisible(bool bVisible)CChartTitle [inline]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_title.html b/ChartDemo/Doc/html/class_c_chart_title.html new file mode 100644 index 0000000..2797a9e --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_title.html @@ -0,0 +1,241 @@ + + +ChartDemo: CChartTitle Class Reference + + + + + +
+

CChartTitle Class Reference

This class is responsible for the titles displayed on the control. +More... +

+#include <ChartTitle.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

+size_t GetStringCount () const
 Returns the number of lines in the title.
+TChartString GetString (size_t Index) const
 Returns a specific line, specified by its index.
+void AddString (const TChartString &NewString)
 Adds a new line to the title.
+void RemoveAll ()
 Removes all the lines displayed in the title.
void SetFont (int iPointSize, const TChartString &strFaceName)
 Sets the default font.
void SetFont (const CChartFont &newFont)
 Sets the default font.
void SetLineFont (int iLineIndex, int iPointSize, const TChartString &strFaceName)
 Sets the font for a specific line.
void SetLineFont (int iLineIndex, const CChartFont &newFont)
 Sets the font for a specific line.
+void SetVisible (bool bVisible)
 Shows/hides the title.
+bool IsVisible () const
 Returns true if the title is visible.
+COLORREF GetColor () const
 Returns the text color.
+void SetColor (COLORREF NewColor)
 Sets the text color.
+BOOL IsPointInside (const CPoint &screenPoint) const
 Returns true if a screen point is in the region of the title.
+


Detailed Description

+This class is responsible for the titles displayed on the control. +

+Several lines can be displayed in the title, each one possibly with its own font. It is retrieved by calling the GetTitle() function from the CChartCtrl class.


Member Function Documentation

+ +
+
+ + + + + + + + + +
void CChartTitle::SetFont (const CChartFont newFont  ) 
+
+
+ +

+Sets the default font. +

+This function allows to set extended font style by passing a CChartFont object.

Parameters:
+ + +
newFont The new font.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartTitle::SetFont (int  iPointSize,
const TChartString &  strFaceName 
)
+
+
+ +

+Sets the default font. +

+

Parameters:
+ + + +
iPointSize The font point size.
strFaceName The font face name ("Times New Roman", "Arial", ...)
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartTitle::SetLineFont (int  iLineIndex,
const CChartFont newFont 
)
+
+
+ +

+Sets the font for a specific line. +

+This function allows to set extended font style by passing a CChartFont object.

Parameters:
+ + + +
iLineIndex The index of the line to set the font.
newFont The new font.
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartTitle::SetLineFont (int  iLineIndex,
int  iPointSize,
const TChartString &  strFaceName 
)
+
+
+ +

+Sets the font for a specific line. +

+

Parameters:
+ + + + +
iLineIndex The index of the line to set the font.
iPointSize The font point size.
strFaceName The font face name ("Times New Roman", "Arial", ...)
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartTitle.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartTitle.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_x_y_serie-members.html b/ChartDemo/Doc/html/class_c_chart_x_y_serie-members.html new file mode 100644 index 0000000..ca582bb --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_x_y_serie-members.html @@ -0,0 +1,103 @@ + + +ChartDemo: Member List + + + + + +
+

CChartXYSerie Member List

This is the complete list of members for CChartXYSerie, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddPoint(double X, double Y)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoint(const SChartXYPoint &newPoint)CChartSerieBase< SChartXYPoint >
AddPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::AddPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
AttachCustomLabel(unsigned uPointIndex, CChartLabel< SChartXYPoint > *pLabel)CChartSerieBase< SChartXYPoint >
CChartSerie(CChartCtrl *pParent)CChartSerie
CChartSerieBase(CChartCtrl *pParent)CChartSerieBase< SChartXYPoint >
CChartXYSerie(CChartCtrl *pParent)CChartXYSerie
ClearSerie()CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, const TChartString &strLabelText)CChartSerieBase< SChartXYPoint >
CreateBalloonLabel(unsigned uPointIndex, CChartLabelProvider< SChartXYPoint > *pLabelProvider)CChartSerieBase< SChartXYPoint >
Draw(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawAll(CDC *pDC)=0CChartSerie [protected, pure virtual]
DrawLegend(CDC *pDC, const CRect &rectBitmap) const =0CChartSerie [protected, pure virtual]
EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)CChartSerie
EnableShadow(bool bEnable)CChartSerie
GetBezierControlPoints(unsigned uFirst, unsigned uLast, SChartXYPoint *&pKnots, SChartXYPoint *&pFirstControlPoints, SChartXYPoint *&pSecondControlPoints) const CChartXYSerie [protected]
GetColor() const CChartSerie [inline]
GetName() const CChartSerie [inline]
GetPoint(unsigned index) constCChartSerieBase< SChartXYPoint >
GetPointsCount() constCChartSerieBase< SChartXYPoint > [inline, virtual]
GetPointScreenCoord(unsigned uPointIndex)CChartSerieBase< SChartXYPoint > [virtual]
GetSerieId() const CChartSerie [inline]
GetSerieXMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieXScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetSerieYScreenMinMax(double &Min, double &Max) constCChartSerieBase< SChartXYPoint > [virtual]
GetShadowColor() const CChartSerie [inline]
GetUserData(unsigned uPointIndex)CChartXYSerie
GetVisiblePoints(unsigned &uFirst, unsigned &uLast) constCChartSerieBase< SChartXYPoint > [protected, virtual]
GetXPointValue(unsigned PointIndex) const CChartXYSerie
GetYPointValue(unsigned PointIndex) const CChartXYSerie
IsPointOnSerie(const CPoint &screenPoint, unsigned &uIndex) const =0CChartSerie [pure virtual]
IsVisible() const CChartSerie [inline]
m_bIsVisibleCChartSerie [protected]
m_bShadowCChartSerie [protected]
m_iShadowDepthCChartSerie [protected]
m_pHorizontalAxisCChartSerie [protected]
m_PlottingRectCChartSerie [protected]
m_pParentCtrlCChartSerie [protected]
m_pVerticalAxisCChartSerie [protected]
m_SerieColorCChartSerie [protected]
m_ShadowColorCChartSerie [protected]
m_strSerieNameCChartSerie [protected]
m_uLastDrawnPointCChartSerieBase< SChartXYPoint > [protected]
m_vPointsCChartSerieBase< SChartXYPoint > [protected]
NotifyMouseClickEnabled()CChartSerie [inline, protected]
NotifyMouseMoveEnabled()CChartSerie [inline, protected]
OnMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint &screenPoint)CChartSerieBase< SChartXYPoint > [protected, virtual]
RefreshAutoAxes()CChartSerie [protected]
RegisterMouseListener(CChartSeriesMouseListener< SChartXYPoint > *pListener)CChartSerieBase< SChartXYPoint >
RemovePointsFromBegin(unsigned Count)CChartSerieBase< SChartXYPoint >
RemovePointsFromEnd(unsigned Count)CChartSerieBase< SChartXYPoint >
SetColor(COLORREF NewColor)CChartSerie
SetName(const TChartString &NewName)CChartSerie
SetPoints(double *pX, double *pY, unsigned Count)CChartXYSerie
CChartSerieBase< SChartXYPoint >::SetPoints(SChartXYPoint *pPoints, unsigned Count)CChartSerieBase< SChartXYPoint >
SetSeriesOrdering(PointsOrdering newOrdering)CChartSerieBase< SChartXYPoint > [virtual]
SetShadowColor(COLORREF NewColor)CChartSerie
SetShadowDepth(int Depth)CChartSerie
SetUserData(unsigned uPointIndex, void *pData)CChartXYSerie
SetVisible(bool bVisible)CChartSerie
SetXPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
SetYPointValue(unsigned PointIndex, double NewVal)CChartXYSerie
UnregisterMouseListener()CChartSerieBase< SChartXYPoint >
ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const CChartSerie
XScreenToValue(long XScreenCoord) const CChartSerie
YScreenToValue(long YScreenCoord) const CChartSerie
~CChartSerie()CChartSerie [virtual]
~CChartSerieBase()CChartSerieBase< SChartXYPoint > [virtual]
~CChartXYSerie()CChartXYSerie [virtual]

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_x_y_serie.html b/ChartDemo/Doc/html/class_c_chart_x_y_serie.html new file mode 100644 index 0000000..149bd7f --- /dev/null +++ b/ChartDemo/Doc/html/class_c_chart_x_y_serie.html @@ -0,0 +1,377 @@ + + +ChartDemo: CChartXYSerie Class Reference + + + + + +
+

CChartXYSerie Class Reference

Specialization of a CChartSerieBase for series having data with an X and an Y value. +More... +

+#include <ChartXYSerie.h> +

+

+Inheritance diagram for CChartXYSerie:
+
+ +

+ +CChartSerieBase< SChartXYPoint > +CChartSerie +CChartBarSerie +CChartLineSerie +CChartPointsSerie +CChartSurfaceSerie + +
+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

CChartXYSerie (CChartCtrl *pParent)
 Constructor.
+virtual ~CChartXYSerie ()
 Destructor.
+void AddPoint (double X, double Y)
 Adds a single data point to the series.
void AddPoints (double *pX, double *pY, unsigned Count)
 Adds an array of points to the series.
void SetPoints (double *pX, double *pY, unsigned Count)
 Sets an array of points to the series.
+double GetYPointValue (unsigned PointIndex) const
 Returns the Y value of a specific point in the series.
+double GetXPointValue (unsigned PointIndex) const
 Returns the X value of a specific point in the series.
void SetYPointValue (unsigned PointIndex, double NewVal)
 Sets the Y value of a specific point in the series.
void SetXPointValue (unsigned PointIndex, double NewVal)
 Sets the X value of a specific point in the series.
void SetUserData (unsigned uPointIndex, void *pData)
 Sets user data for a specific point.
void * GetUserData (unsigned uPointIndex)
 Retrieves user data for a specific point.

Protected Member Functions

void GetBezierControlPoints (unsigned uFirst, unsigned uLast, SChartXYPoint *&pKnots, SChartXYPoint *&pFirstControlPoints, SChartXYPoint *&pSecondControlPoints) const
 Retrieves the control points of a bezier curve fitting the points stored in the array.
+


Detailed Description

+Specialization of a CChartSerieBase for series having data with an X and an Y value. +

+This class is abstract and has to be implemented for specific series. It already provides features which are common to all series with points having an X and an Y value. Examples of such series are: point series, line series, surface series and bar series.


Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartXYSerie::AddPoints (double *  pX,
double *  pY,
unsigned  Count 
)
+
+
+ +

+Adds an array of points to the series. +

+Points which were already present in the series are kept.

Parameters:
+ + + + +
pX Array of X values for the points
pY Array of Y values for the points
Count Size of each of both arrays (number of points to add)
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void CChartXYSerie::GetBezierControlPoints (unsigned  uFirst,
unsigned  uLast,
SChartXYPoint *&  pKnots,
SChartXYPoint *&  pFirstControlPoints,
SChartXYPoint *&  pSecondControlPoints 
) const [protected]
+
+
+ +

+Retrieves the control points of a bezier curve fitting the points stored in the array. +

+

Parameters:
+ + + + + + +
uFirst The index of the first point of the bezier curve
uLast The index of the last point of the bezier curve
pKnots This parameter will store the points data
pFirstControlPoints This parameter will store the primary control points of the bezier curve
pSecondControlPoints This parameter will store the secondary control points of the bezier curve
+
+ +
+

+ +

+
+ + + + + + + + + +
void * CChartXYSerie::GetUserData (unsigned  uPointIndex  ) 
+
+
+ +

+Retrieves user data for a specific point. +

+User data can be disabled by adding the flag NO_USER_DATA in the preprocessor definitions. This is usefull when you don't want to have an additional pointer stored for each points in your series. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void CChartXYSerie::SetPoints (double *  pX,
double *  pY,
unsigned  Count 
)
+
+
+ +

+Sets an array of points to the series. +

+Points which were already present in the series are discarded.

Parameters:
+ + + + +
pX Array of X values for the points
pY Array of Y values for the points
Count Size of each of both arrays (number of points to add)
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartXYSerie::SetUserData (unsigned  uPointIndex,
void *  pData 
)
+
+
+ +

+Sets user data for a specific point. +

+User data can be disabled by adding the flag NO_USER_DATA in the preprocessor definitions. This is usefull when you don't want to have an additional pointer stored for each points in your series. +

+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartXYSerie::SetXPointValue (unsigned  PointIndex,
double  NewVal 
)
+
+
+ +

+Sets the X value of a specific point in the series. +

+The control is refreshed to display the change.

Parameters:
+ + + +
PointIndex The index of the points to change the Y value
NewVal The new X value of the point
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
void CChartXYSerie::SetYPointValue (unsigned  PointIndex,
double  NewVal 
)
+
+
+ +

+Sets the Y value of a specific point in the series. +

+The control is refreshed to display the change.

Parameters:
+ + + +
PointIndex The index of the points to change the Y value
NewVal The new Y value of the point
+
+ +
+

+


The documentation for this class was generated from the following files:
    +
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartXYSerie.h
  • E:/Sources Misc/ChartDemo/ChartCtrl/ChartXYSerie.cpp
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/class_c_chart_x_y_serie.png b/ChartDemo/Doc/html/class_c_chart_x_y_serie.png new file mode 100644 index 0000000..0cb5121 Binary files /dev/null and b/ChartDemo/Doc/html/class_c_chart_x_y_serie.png differ diff --git a/ChartDemo/Doc/html/classes.html b/ChartDemo/Doc/html/classes.html new file mode 100644 index 0000000..6f6c2d1 --- /dev/null +++ b/ChartDemo/Doc/html/classes.html @@ -0,0 +1,36 @@ + + +ChartDemo: Alphabetical List + + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/deprecated.html b/ChartDemo/Doc/html/deprecated.html new file mode 100644 index 0000000..8a4bbb8 --- /dev/null +++ b/ChartDemo/Doc/html/deprecated.html @@ -0,0 +1,33 @@ + + +ChartDemo: Deprecated List + + + + + +
+

Deprecated List

+
Member CChartAxis::IsAutomatic () const
+
You should use the GetAutomaticType instead.
+
+

+

+
Member CChartAxis::SetAutomatic (bool bAutomatic)
+
You should use the SetAutomaticType instead.
+
+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/doxygen.css b/ChartDemo/Doc/html/doxygen.css new file mode 100644 index 0000000..3767dc9 --- /dev/null +++ b/ChartDemo/Doc/html/doxygen.css @@ -0,0 +1,441 @@ +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; +} + +/* @group Heading Levels */ + +h1 { + text-align: center; + font-size: 150%; +} + +h2 { + font-size: 120%; +} + +h3 { + font-size: 100%; +} + +/* @end */ + +caption { + font-weight: bold; +} + +div.qindex, div.navtab{ + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + padding: 2px; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #153788; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #1b77c5; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #6666cc; + color: #ffffff; + border: 1px double #9295C2; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code { +} + +a.codeRef { +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +.fragment { + font-family: monospace, fixed; + font-size: 105%; +} + +pre.fragment { + border: 1px solid #CCCCCC; + background-color: #f5f5f5; + padding: 4px 6px; + margin: 4px 8px 4px 2px; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background: white; + color: black; + margin-right: 20px; + margin-left: 20px; +} + +td.indexkey { + background-color: #e8eef2; + font-weight: bold; + border: 1px solid #CCCCCC; + margin: 2px 0px 2px 0; + padding: 2px 10px; +} + +td.indexvalue { + background-color: #e8eef2; + border: 1px solid #CCCCCC; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #f0f0f0; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +/* @end */ + +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #84b0c7; +} + +th.dirtab { + background: #e8eef2; + font-weight: bold; +} + +hr { + height: 0; + border: none; + border-top: 1px solid #666; +} + +/* @group Member Descriptions */ + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #FAFAFA; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #ccc; +} + +.memTemplParams { + color: #606060; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #606060; + font-weight: normal; + margin-left: 3px; +} + +.memnav { + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.memitem { + padding: 0; +} + +.memname { + white-space: nowrap; + font-weight: bold; +} + +.memproto, .memdoc { + border: 1px solid #84b0c7; +} + +.memproto { + padding: 0; + background-color: #d5e1e8; + font-weight: bold; + -webkit-border-top-left-radius: 8px; + -webkit-border-top-right-radius: 8px; + -moz-border-radius-topleft: 8px; + -moz-border-radius-topright: 8px; +} + +.memdoc { + padding: 2px 5px; + background-color: #eef3f5; + border-top-width: 0; + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0.5em; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +address { + font-style: normal; + color: #333; +} diff --git a/ChartDemo/Doc/html/doxygen.png b/ChartDemo/Doc/html/doxygen.png new file mode 100644 index 0000000..f0a274b Binary files /dev/null and b/ChartDemo/Doc/html/doxygen.png differ diff --git a/ChartDemo/Doc/html/files.html b/ChartDemo/Doc/html/files.html new file mode 100644 index 0000000..b32d3ce --- /dev/null +++ b/ChartDemo/Doc/html/files.html @@ -0,0 +1,62 @@ + + +ChartDemo: File Index + + + + + +
+

File List

Here is a list of all documented files with brief descriptions: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxis.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartAxisLabel.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartBalloonLabel.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartBarSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartCandlestickSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartCrossHairCursor.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartCtrl.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartCursor.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartDateTimeAxis.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartDragLineCursor.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartFont.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartGanttSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartGradient.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartGrid.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartLabel.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartLegend.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartLineSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartLogarithmicAxis.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartMouseListener.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsArray.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartPointsSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartScrollBar.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartSerieBase.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartSeriesMouseListener.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartStandardAxis.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartString.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartSurfaceSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartTitle.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/ChartXYSerie.h [code]
E:/Sources Misc/ChartDemo/ChartCtrl/PointsOrdering.h [code]
+
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions.html b/ChartDemo/Doc/html/functions.html new file mode 100644 index 0000000..93d8c9f --- /dev/null +++ b/ChartDemo/Doc/html/functions.html @@ -0,0 +1,89 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- a -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x63.html b/ChartDemo/Doc/html/functions_0x63.html new file mode 100644 index 0000000..24f0aea --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x63.html @@ -0,0 +1,147 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- c -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x64.html b/ChartDemo/Doc/html/functions_0x64.html new file mode 100644 index 0000000..95733bb --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x64.html @@ -0,0 +1,96 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- d -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x65.html b/ChartDemo/Doc/html/functions_0x65.html new file mode 100644 index 0000000..579ed42 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x65.html @@ -0,0 +1,84 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- e -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x66.html b/ChartDemo/Doc/html/functions_0x66.html new file mode 100644 index 0000000..84490d6 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x66.html @@ -0,0 +1,73 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- f -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x67.html b/ChartDemo/Doc/html/functions_0x67.html new file mode 100644 index 0000000..7560d2b --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x67.html @@ -0,0 +1,248 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- g -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x68.html b/ChartDemo/Doc/html/functions_0x68.html new file mode 100644 index 0000000..365a09e --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x68.html @@ -0,0 +1,71 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- h -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x69.html b/ChartDemo/Doc/html/functions_0x69.html new file mode 100644 index 0000000..38a883c --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x69.html @@ -0,0 +1,96 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- i -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x6c.html b/ChartDemo/Doc/html/functions_0x6c.html new file mode 100644 index 0000000..3e009b3 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x6c.html @@ -0,0 +1,71 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- l -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x6d.html b/ChartDemo/Doc/html/functions_0x6d.html new file mode 100644 index 0000000..20c250c --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x6d.html @@ -0,0 +1,144 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- m -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x6e.html b/ChartDemo/Doc/html/functions_0x6e.html new file mode 100644 index 0000000..fa99c79 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x6e.html @@ -0,0 +1,75 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- n -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x6f.html b/ChartDemo/Doc/html/functions_0x6f.html new file mode 100644 index 0000000..adb062b --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x6f.html @@ -0,0 +1,108 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- o -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x70.html b/ChartDemo/Doc/html/functions_0x70.html new file mode 100644 index 0000000..fd142be --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x70.html @@ -0,0 +1,77 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- p -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x72.html b/ChartDemo/Doc/html/functions_0x72.html new file mode 100644 index 0000000..82b797c --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x72.html @@ -0,0 +1,102 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- r -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x73.html b/ChartDemo/Doc/html/functions_0x73.html new file mode 100644 index 0000000..b416200 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x73.html @@ -0,0 +1,245 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- s -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x74.html b/ChartDemo/Doc/html/functions_0x74.html new file mode 100644 index 0000000..132e8eb --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x74.html @@ -0,0 +1,71 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- t -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x75.html b/ChartDemo/Doc/html/functions_0x75.html new file mode 100644 index 0000000..91991e3 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x75.html @@ -0,0 +1,79 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- u -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x76.html b/ChartDemo/Doc/html/functions_0x76.html new file mode 100644 index 0000000..ba370dd --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x76.html @@ -0,0 +1,78 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- v -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x78.html b/ChartDemo/Doc/html/functions_0x78.html new file mode 100644 index 0000000..6b09567 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x78.html @@ -0,0 +1,75 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- x -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x79.html b/ChartDemo/Doc/html/functions_0x79.html new file mode 100644 index 0000000..30d20f0 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x79.html @@ -0,0 +1,75 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- y -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_0x7e.html b/ChartDemo/Doc/html/functions_0x7e.html new file mode 100644 index 0000000..8168cb4 --- /dev/null +++ b/ChartDemo/Doc/html/functions_0x7e.html @@ -0,0 +1,111 @@ + + +ChartDemo: Class Members + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +

+

- ~ -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_enum.html b/ChartDemo/Doc/html/functions_enum.html new file mode 100644 index 0000000..fb3e9dd --- /dev/null +++ b/ChartDemo/Doc/html/functions_enum.html @@ -0,0 +1,58 @@ + + +ChartDemo: Class Members - Enumerations + + + + + +
+  +

+

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_eval.html b/ChartDemo/Doc/html/functions_eval.html new file mode 100644 index 0000000..b2439ea --- /dev/null +++ b/ChartDemo/Doc/html/functions_eval.html @@ -0,0 +1,50 @@ + + +ChartDemo: Class Members - Enumerator + + + + + +
+  +

+

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func.html b/ChartDemo/Doc/html/functions_func.html new file mode 100644 index 0000000..789cc52 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func.html @@ -0,0 +1,84 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- a -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x63.html b/ChartDemo/Doc/html/functions_func_0x63.html new file mode 100644 index 0000000..12ff18d --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x63.html @@ -0,0 +1,140 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- c -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x64.html b/ChartDemo/Doc/html/functions_func_0x64.html new file mode 100644 index 0000000..13ae1bd --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x64.html @@ -0,0 +1,89 @@ + + +ChartDemo: Class Members - Functions + + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x65.html b/ChartDemo/Doc/html/functions_func_0x65.html new file mode 100644 index 0000000..7885ede --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x65.html @@ -0,0 +1,73 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- e -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x67.html b/ChartDemo/Doc/html/functions_func_0x67.html new file mode 100644 index 0000000..6637354 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x67.html @@ -0,0 +1,243 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- g -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x69.html b/ChartDemo/Doc/html/functions_func_0x69.html new file mode 100644 index 0000000..863079d --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x69.html @@ -0,0 +1,91 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- i -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x6e.html b/ChartDemo/Doc/html/functions_func_0x6e.html new file mode 100644 index 0000000..6c1cf5b --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x6e.html @@ -0,0 +1,68 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- n -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x6f.html b/ChartDemo/Doc/html/functions_func_0x6f.html new file mode 100644 index 0000000..a04d99c --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x6f.html @@ -0,0 +1,101 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- o -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x70.html b/ChartDemo/Doc/html/functions_func_0x70.html new file mode 100644 index 0000000..c924a5d --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x70.html @@ -0,0 +1,68 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- p -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x72.html b/ChartDemo/Doc/html/functions_func_0x72.html new file mode 100644 index 0000000..f8e22a1 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x72.html @@ -0,0 +1,97 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- r -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x73.html b/ChartDemo/Doc/html/functions_func_0x73.html new file mode 100644 index 0000000..a0ac19c --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x73.html @@ -0,0 +1,236 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- s -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x75.html b/ChartDemo/Doc/html/functions_func_0x75.html new file mode 100644 index 0000000..3e6d8ef --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x75.html @@ -0,0 +1,74 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- u -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x76.html b/ChartDemo/Doc/html/functions_func_0x76.html new file mode 100644 index 0000000..732cd15 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x76.html @@ -0,0 +1,73 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- v -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x78.html b/ChartDemo/Doc/html/functions_func_0x78.html new file mode 100644 index 0000000..5c931e4 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x78.html @@ -0,0 +1,66 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- x -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x79.html b/ChartDemo/Doc/html/functions_func_0x79.html new file mode 100644 index 0000000..88e6e94 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x79.html @@ -0,0 +1,66 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- y -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_func_0x7e.html b/ChartDemo/Doc/html/functions_func_0x7e.html new file mode 100644 index 0000000..db36be7 --- /dev/null +++ b/ChartDemo/Doc/html/functions_func_0x7e.html @@ -0,0 +1,106 @@ + + +ChartDemo: Class Members - Functions + + + + + +
+  +

+

- ~ -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/functions_vars.html b/ChartDemo/Doc/html/functions_vars.html new file mode 100644 index 0000000..1ddad61 --- /dev/null +++ b/ChartDemo/Doc/html/functions_vars.html @@ -0,0 +1,171 @@ + + +ChartDemo: Class Members - Variables + + + + + +
+  +

+

- c -

+

- e -

+

- h -

+

- l -

+

- m -

+

- o -

+

- p -

+

- s -

+

- x -

+

- y -

+
+
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/hierarchy.html b/ChartDemo/Doc/html/hierarchy.html new file mode 100644 index 0000000..f398392 --- /dev/null +++ b/ChartDemo/Doc/html/hierarchy.html @@ -0,0 +1,95 @@ + + +ChartDemo: Hierarchical Index + + + + + + +
Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/index.html b/ChartDemo/Doc/html/index.html new file mode 100644 index 0000000..b930fd8 --- /dev/null +++ b/ChartDemo/Doc/html/index.html @@ -0,0 +1,26 @@ + + +ChartDemo: Main Page + + + + + +
+

ChartDemo Documentation

+

+

3.0.1

+
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/pages.html b/ChartDemo/Doc/html/pages.html new file mode 100644 index 0000000..1fa3899 --- /dev/null +++ b/ChartDemo/Doc/html/pages.html @@ -0,0 +1,28 @@ + + +ChartDemo: Page Index + + + + + +
+

Related Pages

Here is a list of all related documentation pages: +
+
Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/resource_8h-source.html b/ChartDemo/Doc/html/resource_8h-source.html new file mode 100644 index 0000000..20bb331 --- /dev/null +++ b/ChartDemo/Doc/html/resource_8h-source.html @@ -0,0 +1,103 @@ + + +ChartDemo: E:/Sources Misc/ChartDemo/resource.h Source File + + + + + +
Generated on Sat Mar 7 11:33:24 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_c_chart_points_array_1_1_s_chart_point-members.html b/ChartDemo/Doc/html/struct_c_chart_points_array_1_1_s_chart_point-members.html new file mode 100644 index 0000000..2c2654b --- /dev/null +++ b/ChartDemo/Doc/html/struct_c_chart_points_array_1_1_s_chart_point-members.html @@ -0,0 +1,33 @@ + + +ChartDemo: Member List + + + + + +
+

CChartPointsArray::CChartPointsArray::SChartPoint Member List

This is the complete list of members for CChartPointsArray::CChartPointsArray::SChartPoint, including all inherited members.

+ + +
XCChartPointsArray::CChartPointsArray::SChartPoint
YCChartPointsArray::CChartPointsArray::SChartPoint

+
Generated on Sun Mar 8 17:21:19 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_c_chart_points_array_1_1_s_chart_point.html b/ChartDemo/Doc/html/struct_c_chart_points_array_1_1_s_chart_point.html new file mode 100644 index 0000000..cd783b9 --- /dev/null +++ b/ChartDemo/Doc/html/struct_c_chart_points_array_1_1_s_chart_point.html @@ -0,0 +1,54 @@ + + +ChartDemo: CChartPointsArray::CChartPointsArray::SChartPoint Struct Reference + + + + + +
+

CChartPointsArray::CChartPointsArray::SChartPoint Struct Reference

Structure containing a point data. +More... +

+#include <ChartPointsArray.h> +

+ +

+List of all members. + + + + + + + + +

Public Attributes

+double X
 The point X value.
+double Y
 The point Y value.
+


Detailed Description

+Structure containing a point data.
The documentation for this struct was generated from the following file: +
+
Generated on Sun Mar 8 17:21:19 2009 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_s_chart_candlestick_point-members.html b/ChartDemo/Doc/html/struct_s_chart_candlestick_point-members.html new file mode 100644 index 0000000..4da7640 --- /dev/null +++ b/ChartDemo/Doc/html/struct_s_chart_candlestick_point-members.html @@ -0,0 +1,45 @@ + + +ChartDemo: Member List + + + + + +
+

SChartCandlestickPoint Member List

This is the complete list of members for SChartCandlestickPoint, including all inherited members.

+ + + + + + + + + + + + + +
CloseSChartCandlestickPoint
GetX() const SChartCandlestickPoint [inline]
GetXMax() const SChartCandlestickPoint [inline]
GetXMin() const SChartCandlestickPoint [inline]
GetY() const SChartCandlestickPoint [inline]
GetYMax() const SChartCandlestickPoint [inline]
GetYMin() const SChartCandlestickPoint [inline]
HighSChartCandlestickPoint
LowSChartCandlestickPoint
OpenSChartCandlestickPoint
SChartCandlestickPoint() (defined in SChartCandlestickPoint)SChartCandlestickPoint [inline]
SChartCandlestickPoint(double XValue, double LowVal, double HighVal, double OpenVal, double CloseVal) (defined in SChartCandlestickPoint)SChartCandlestickPoint [inline]
XValSChartCandlestickPoint

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_s_chart_candlestick_point.html b/ChartDemo/Doc/html/struct_s_chart_candlestick_point.html new file mode 100644 index 0000000..64f592f --- /dev/null +++ b/ChartDemo/Doc/html/struct_s_chart_candlestick_point.html @@ -0,0 +1,93 @@ + + +ChartDemo: SChartCandlestickPoint Struct Reference + + + + + +
+

SChartCandlestickPoint Struct Reference

Point structure used as template parameter for candlestick series. +More... +

+#include <ChartCandlestickSerie.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

SChartCandlestickPoint (double XValue, double LowVal, double HighVal, double OpenVal, double CloseVal)
+double GetX () const
 Returns the X value of the point.
+double GetY () const
 Returns the Y value of the point, which is the average between low and high.
+double GetXMin () const
 Returns the minimum X value of the point.
+double GetXMax () const
 Returns the maximum X value of the point.
+double GetYMin () const
 Returns the minimum Y value of the point (the low value).
+double GetYMax () const
 Returns the maximum Y value of the point (the high value).

Public Attributes

+double XVal
 The X value of the point (usually, a time).
+double Low
 The low market price.
+double High
 The high market price.
+double Open
 The open market price.
+double Close
 The close market price.
+


Detailed Description

+Point structure used as template parameter for candlestick series.
The documentation for this struct was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_s_chart_gantt_point-members.html b/ChartDemo/Doc/html/struct_s_chart_gantt_point-members.html new file mode 100644 index 0000000..cd37d72 --- /dev/null +++ b/ChartDemo/Doc/html/struct_s_chart_gantt_point-members.html @@ -0,0 +1,43 @@ + + +ChartDemo: Member List + + + + + +
+

SChartGanttPoint Member List

This is the complete list of members for SChartGanttPoint, including all inherited members.

+ + + + + + + + + + + +
EndTimeSChartGanttPoint
GetX() const SChartGanttPoint [inline]
GetXMax() const SChartGanttPoint [inline]
GetXMin() const SChartGanttPoint [inline]
GetY() const SChartGanttPoint [inline]
GetYMax() const SChartGanttPoint [inline]
GetYMin() const SChartGanttPoint [inline]
SChartGanttPoint()SChartGanttPoint [inline]
SChartGanttPoint(double Start, double End, double YVal)SChartGanttPoint [inline]
StartTimeSChartGanttPoint
YValueSChartGanttPoint

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_s_chart_gantt_point.html b/ChartDemo/Doc/html/struct_s_chart_gantt_point.html new file mode 100644 index 0000000..d77032b --- /dev/null +++ b/ChartDemo/Doc/html/struct_s_chart_gantt_point.html @@ -0,0 +1,90 @@ + + +ChartDemo: SChartGanttPoint Struct Reference + + + + + +
+

SChartGanttPoint Struct Reference

Point structure used as template parameter for gantt series. +More... +

+#include <ChartGanttSerie.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

SChartGanttPoint ()
 Default constructor.
SChartGanttPoint (double Start, double End, double YVal)
 Construct a new gantt point with the specifed values.
+double GetX () const
 Returns the X value of the point, which is the average between start time and end time.
+double GetY () const
 Returns the Y value.
+double GetXMin () const
 Returns the start time.
+double GetXMax () const
 Returns the end time.
+double GetYMin () const
 Returns the Y value.
+double GetYMax () const
 Returns the Y value.

Public Attributes

+double StartTime
 The start time of the gantt point.
+double EndTime
 The end time of the gantt point.
+double YValue
 The Y value of the gantt point.
+


Detailed Description

+Point structure used as template parameter for gantt series.
The documentation for this struct was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_s_chart_x_y_point-members.html b/ChartDemo/Doc/html/struct_s_chart_x_y_point-members.html new file mode 100644 index 0000000..e2acbe7 --- /dev/null +++ b/ChartDemo/Doc/html/struct_s_chart_x_y_point-members.html @@ -0,0 +1,43 @@ + + +ChartDemo: Member List + + + + + +
+

SChartXYPoint Member List

This is the complete list of members for SChartXYPoint, including all inherited members.

+ + + + + + + + + + + +
GetX() const (defined in SChartXYPoint)SChartXYPoint [inline]
GetXMax() const (defined in SChartXYPoint)SChartXYPoint [inline]
GetXMin() const (defined in SChartXYPoint)SChartXYPoint [inline]
GetY() const (defined in SChartXYPoint)SChartXYPoint [inline]
GetYMax() const (defined in SChartXYPoint)SChartXYPoint [inline]
GetYMin() const (defined in SChartXYPoint)SChartXYPoint [inline]
pUserDataSChartXYPoint
SChartXYPoint() (defined in SChartXYPoint)SChartXYPoint [inline]
SChartXYPoint(double XVal, double YVal) (defined in SChartXYPoint)SChartXYPoint [inline]
XSChartXYPoint
YSChartXYPoint

+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/struct_s_chart_x_y_point.html b/ChartDemo/Doc/html/struct_s_chart_x_y_point.html new file mode 100644 index 0000000..b1f6977 --- /dev/null +++ b/ChartDemo/Doc/html/struct_s_chart_x_y_point.html @@ -0,0 +1,79 @@ + + +ChartDemo: SChartXYPoint Struct Reference + + + + + +
+

SChartXYPoint Struct Reference

Structure containing a point data with X and Y values. +More... +

+#include <ChartXYSerie.h> +

+ +

+List of all members. + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

SChartXYPoint (double XVal, double YVal)
+double GetX () const
+double GetY () const
+double GetXMin () const
+double GetXMax () const
+double GetYMin () const
+double GetYMax () const

Public Attributes

+double X
 The point X value.
+double Y
 The point Y value.
+void * pUserData
 Optional user data.
+


Detailed Description

+Structure containing a point data with X and Y values.
The documentation for this struct was generated from the following file: +
+
Generated on Sun Jan 17 13:33:11 2010 for ChartDemo by  + +doxygen 1.5.8
+ + diff --git a/ChartDemo/Doc/html/tab_b.gif b/ChartDemo/Doc/html/tab_b.gif new file mode 100644 index 0000000..0d62348 Binary files /dev/null and b/ChartDemo/Doc/html/tab_b.gif differ diff --git a/ChartDemo/Doc/html/tab_l.gif b/ChartDemo/Doc/html/tab_l.gif new file mode 100644 index 0000000..9b1e633 Binary files /dev/null and b/ChartDemo/Doc/html/tab_l.gif differ diff --git a/ChartDemo/Doc/html/tab_r.gif b/ChartDemo/Doc/html/tab_r.gif new file mode 100644 index 0000000..ce9dd9f Binary files /dev/null and b/ChartDemo/Doc/html/tab_r.gif differ diff --git a/ChartDemo/Doc/html/tabs.css b/ChartDemo/Doc/html/tabs.css new file mode 100644 index 0000000..ab02c62 --- /dev/null +++ b/ChartDemo/Doc/html/tabs.css @@ -0,0 +1,105 @@ +/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ + +DIV.tabs +{ + float : left; + width : 100%; + background : url("tab_b.gif") repeat-x bottom; + margin-bottom : 4px; +} + +DIV.tabs UL +{ + margin : 0px; + padding-left : 10px; + list-style : none; +} + +DIV.tabs LI, DIV.tabs FORM +{ + display : inline; + margin : 0px; + padding : 0px; +} + +DIV.tabs FORM +{ + float : right; +} + +DIV.tabs A +{ + float : left; + background : url("tab_r.gif") no-repeat right top; + border-bottom : 1px solid #84B0C7; + font-size : 80%; + font-weight : bold; + text-decoration : none; +} + +DIV.tabs A:hover +{ + background-position: 100% -150px; +} + +DIV.tabs A:link, DIV.tabs A:visited, +DIV.tabs A:active, DIV.tabs A:hover +{ + color: #1A419D; +} + +DIV.tabs SPAN +{ + float : left; + display : block; + background : url("tab_l.gif") no-repeat left top; + padding : 5px 9px; + white-space : nowrap; +} + +DIV.tabs INPUT +{ + float : right; + display : inline; + font-size : 1em; +} + +DIV.tabs TD +{ + font-size : 80%; + font-weight : bold; + text-decoration : none; +} + + + +/* Commented Backslash Hack hides rule from IE5-Mac \*/ +DIV.tabs SPAN {float : none;} +/* End IE5-Mac hack */ + +DIV.tabs A:hover SPAN +{ + background-position: 0% -150px; +} + +DIV.tabs LI.current A +{ + background-position: 100% -150px; + border-width : 0px; +} + +DIV.tabs LI.current SPAN +{ + background-position: 0% -150px; + padding-bottom : 6px; +} + +DIV.navpath +{ + background : none; + border : none; + border-bottom : 1px solid #84B0C7; + text-align : center; + margin : 2px; + padding : 2px; +} diff --git a/ChartDemo/LinePropDialog.cpp b/ChartDemo/LinePropDialog.cpp new file mode 100644 index 0000000..8092332 --- /dev/null +++ b/ChartDemo/LinePropDialog.cpp @@ -0,0 +1,63 @@ +// LinePropDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "chartdemo.h" +#include "LinePropDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CLinePropDialog dialog + + +CLinePropDialog::CLinePropDialog(CWnd* pParent /*=NULL*/) + : CDialog(CLinePropDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CLinePropDialog) + m_iLineWidth = 0; + m_iPenStyle = -1; + //}}AFX_DATA_INIT +} + + +void CLinePropDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CLinePropDialog) + DDX_Text(pDX, IDC_LINEWIDTH_EDIT, m_iLineWidth); + DDX_CBIndex(pDX, IDC_PENSTYLE_COMBO, m_iPenStyle); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CLinePropDialog, CDialog) + //{{AFX_MSG_MAP(CLinePropDialog) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CLinePropDialog message handlers + +BOOL CLinePropDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_iLineWidth = 1; + m_iPenStyle = 0; + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CLinePropDialog::OnOK() +{ + UpdateData(TRUE); + + CDialog::OnOK(); +} diff --git a/ChartDemo/LinePropDialog.h b/ChartDemo/LinePropDialog.h new file mode 100644 index 0000000..38c7385 --- /dev/null +++ b/ChartDemo/LinePropDialog.h @@ -0,0 +1,48 @@ +#if !defined(AFX_LINEPROPDIALOG_H__8B4BF925_24C6_41B2_8BEB_98E6A52322A8__INCLUDED_) +#define AFX_LINEPROPDIALOG_H__8B4BF925_24C6_41B2_8BEB_98E6A52322A8__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// LinePropDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CLinePropDialog dialog + +class CLinePropDialog : public CDialog +{ +// Construction +public: + CLinePropDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CLinePropDialog) + enum { IDD = IDD_LINEPROP_DLG }; + int m_iLineWidth; + int m_iPenStyle; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CLinePropDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CLinePropDialog) + virtual BOOL OnInitDialog(); + virtual void OnOK(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_LINEPROPDIALOG_H__8B4BF925_24C6_41B2_8BEB_98E6A52322A8__INCLUDED_) diff --git a/ChartDemo/PointsPropDialog.cpp b/ChartDemo/PointsPropDialog.cpp new file mode 100644 index 0000000..989348a --- /dev/null +++ b/ChartDemo/PointsPropDialog.cpp @@ -0,0 +1,73 @@ +// PointsPropDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "chartdemo.h" +#include "PointsPropDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPointsPropDialog dialog + + +CPointsPropDialog::CPointsPropDialog(CWnd* pParent /*=NULL*/) + : CDialog(CPointsPropDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CPointsPropDialog) + m_iPointsHeight = 0; + m_iPointsWidth = 0; + m_iPointsType = -1; + //}}AFX_DATA_INIT +} + + +void CPointsPropDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CPointsPropDialog) + DDX_Text(pDX, IDC_POINTHEIGHT_EDIT, m_iPointsHeight); + DDV_MinMaxInt(pDX, m_iPointsHeight, 0, 20); + DDX_Text(pDX, IDC_POINTWIDTH_EDIT, m_iPointsWidth); + DDV_MinMaxInt(pDX, m_iPointsWidth, 0, 20); + DDX_CBIndex(pDX, IDC_POINTTYPE_COMBO, m_iPointsType); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CPointsPropDialog, CDialog) + //{{AFX_MSG_MAP(CPointsPropDialog) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPointsPropDialog message handlers + +void CPointsPropDialog::OnCancel() +{ + +} + +void CPointsPropDialog::OnOK() +{ + UpdateData(TRUE); + + CDialog::OnOK(); +} + +BOOL CPointsPropDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_iPointsWidth = m_iPointsHeight = 5; + m_iPointsType = 0; + UpdateData(FALSE); + + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/ChartDemo/PointsPropDialog.h b/ChartDemo/PointsPropDialog.h new file mode 100644 index 0000000..0d96c9b --- /dev/null +++ b/ChartDemo/PointsPropDialog.h @@ -0,0 +1,50 @@ +#if !defined(AFX_POINTSPROPDIALOG_H__F83DDA1D_53B7_457E_B354_02462E1C8568__INCLUDED_) +#define AFX_POINTSPROPDIALOG_H__F83DDA1D_53B7_457E_B354_02462E1C8568__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PointsPropDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CPointsPropDialog dialog + +class CPointsPropDialog : public CDialog +{ +// Construction +public: + CPointsPropDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CPointsPropDialog) + enum { IDD = IDD_POINTPROP_DLG }; + int m_iPointsHeight; + int m_iPointsWidth; + int m_iPointsType; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPointsPropDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CPointsPropDialog) + virtual void OnCancel(); + virtual void OnOK(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_POINTSPROPDIALOG_H__F83DDA1D_53B7_457E_B354_02462E1C8568__INCLUDED_) diff --git a/ChartDemo/SeriesPropDlg.cpp b/ChartDemo/SeriesPropDlg.cpp new file mode 100644 index 0000000..4a6f586 --- /dev/null +++ b/ChartDemo/SeriesPropDlg.cpp @@ -0,0 +1,204 @@ +// SeriesPropDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "ChartDemo.h" +#include "SeriesPropDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSeriesPropDlg dialog + + +CSeriesPropDlg::CSeriesPropDlg(CWnd* pParent /*=NULL*/) + : CDialog(CSeriesPropDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSeriesPropDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + m_iHorizAxis = m_iVertAxis = 0; + m_iSeriesType = 1; + //m_SeriesColour = 0; + m_iDataType = 0; + m_fMaxXValue = m_fMinXValue = 0.0; + m_iPointsNumber = 0; + + m_iRandMinVal = m_iRandMaxVal = 0; + m_fSineAmplitude = m_fSinePeriod = 0; + m_fLineSlope = m_fLineOffset = 0; + m_SeriesColour = 0x002068ff; + m_ColourSelect.SetColour(m_SeriesColour); +} + + +void CSeriesPropDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSeriesPropDlg) + DDX_Control(pDX, IDC_VERTICALAXIS_COMBO, m_VertAxisCombo); + DDX_Control(pDX, IDC_HORIZONTALAXIS_COMBO, m_HorizAxisCombo); + DDX_Control(pDX, IDC_SERIESCOLOUR_BTN, m_ColourSelect); + DDX_Control(pDX, IDC_SERIESTYPE_COMBO, m_SeriesTypeCombo); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CSeriesPropDlg, CDialog) + //{{AFX_MSG_MAP(CSeriesPropDlg) + ON_BN_CLICKED(IDC_LINEDATA_RADIO, OnSelectLineData) + ON_BN_CLICKED(IDC_RANDOMDATA_RADIO, OnSelectRandomData) + ON_BN_CLICKED(IDC_SINEDATA_RADIO, OnSelectSineData) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSeriesPropDlg message handlers + +void CSeriesPropDlg::OnOK() +{ + TCHAR szName[255]; + GetDlgItem(IDC_SERIESNAME_EDIT)->GetWindowText(szName,254); + m_strSeriesName = szName; + + if (_tcscmp(szName,_T("")) == 0) + { + MessageBox(_T("You must supply a name"),_T("Error")); + return; + } + + m_iSeriesType = m_SeriesTypeCombo.GetCurSel(); + m_SeriesColour = m_ColourSelect.GetColour(); + + TCHAR szBuff[255]; + GetDlgItem(IDC_MAXXVALUE_EDIT)->GetWindowText(szBuff,254); +// m_fMaxXValue = (float)_tstof(szBuff); + m_fMaxXValue = (float)_tcstod(szBuff, NULL); + GetDlgItem(IDC_MINXVALUE_EDIT)->GetWindowText(szBuff,254); +// m_fMinXValue = (float)_tstof(szBuff); + m_fMinXValue = (float)_tcstod(szBuff, NULL); + if (m_fMinXValue > m_fMaxXValue) + { + MessageBox(_T("Max X value should be > Min X value")); + return; + } + + m_iHorizAxis = m_HorizAxisCombo.GetCurSel(); + m_iVertAxis = m_VertAxisCombo.GetCurSel(); + + GetDlgItem(IDC_POINTSNUMBER_EDIT)->GetWindowText(szBuff,254); +#ifdef UNICODE + m_iPointsNumber = _wtoi(szBuff); +#else + m_iPointsNumber = atoi(szBuff); +#endif + if (m_iPointsNumber < 2) + { + MessageBox(_T("Number of points should be > 2")); + return; + } + + if ( ((CButton*)GetDlgItem(IDC_LINEDATA_RADIO))->GetCheck() == 1) + { + m_iDataType = 0; + + GetDlgItem(IDC_DATAPARAM1_EDIT)->GetWindowText(szBuff,254); +// m_fLineSlope = (float)_tstof(szBuff); + m_fLineSlope = (float)_tcstod(szBuff, NULL); + GetDlgItem(IDC_DATAPARAM2_EDIT)->GetWindowText(szBuff,254); +// m_fLineOffset = (float)_tstof(szBuff); + m_fLineOffset = (float)_tcstod(szBuff, NULL); + } + else if ( ((CButton*)GetDlgItem(IDC_SINEDATA_RADIO))->GetCheck() == 1) + { + m_iDataType = 1; + + GetDlgItem(IDC_DATAPARAM1_EDIT)->GetWindowText(szBuff,254); +// m_fSineAmplitude = (float)_tstof(szBuff); + m_fSineAmplitude = (float)_tcstod(szBuff, NULL); + GetDlgItem(IDC_DATAPARAM2_EDIT)->GetWindowText(szBuff,254); +// m_fSinePeriod = (float)_tstof(szBuff); + m_fSinePeriod = (float)_tcstod(szBuff, NULL); + if (m_fSinePeriod == 0) + { + MessageBox(_T("Sine period cannot be 0"),_T("Error")); + return; + } + } + else + { + m_iDataType = 2; + +#ifdef UNICODE + GetDlgItem(IDC_DATAPARAM1_EDIT)->GetWindowText(szBuff,254); + m_iRandMinVal = _wtoi(szBuff); + GetDlgItem(IDC_DATAPARAM2_EDIT)->GetWindowText(szBuff,254); + m_iRandMaxVal = _wtoi(szBuff); +#else + GetDlgItem(IDC_DATAPARAM1_EDIT)->GetWindowText(szBuff,254); + m_iRandMinVal = atoi(szBuff); + GetDlgItem(IDC_DATAPARAM2_EDIT)->GetWindowText(szBuff,254); + m_iRandMaxVal = atoi(szBuff); +#endif + + if (m_iRandMaxVal < m_iRandMinVal) + { + MessageBox(_T("Max random value should be > Min random value")); + return; + } + } + + CDialog::OnOK(); +} + +BOOL CSeriesPropDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_SeriesTypeCombo.SetCurSel(0); + m_HorizAxisCombo.SetCurSel(0); + m_VertAxisCombo.SetCurSel(0); + ((CButton*)GetDlgItem(IDC_LINEDATA_RADIO))->SetCheck(1); + + GetDlgItem(IDC_MINXVALUE_EDIT)->SetWindowText(_T("0.0")); + GetDlgItem(IDC_MAXXVALUE_EDIT)->SetWindowText(_T("100.0")); + + GetDlgItem(IDC_DATAPARAM1_EDIT)->SetWindowText(_T("1.0")); + GetDlgItem(IDC_DATAPARAM2_EDIT)->SetWindowText(_T("0.0")); + GetDlgItem(IDC_POINTSNUMBER_EDIT)->SetWindowText(_T("100")); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSeriesPropDlg::OnSelectLineData() +{ + GetDlgItem(IDC_DATAPARAM1_TEXT)->SetWindowText(_T("Line Slope 斜率:")); + GetDlgItem(IDC_DATAPARAM2_TEXT)->SetWindowText(_T("Line Offset 偏移量:")); + GetDlgItem(IDC_DATAPARAM1_EDIT)->SetWindowText(_T("1.0")); + GetDlgItem(IDC_DATAPARAM2_EDIT)->SetWindowText(_T("0.0")); + GetDlgItem(IDC_POINTSNUMBER_EDIT)->SetWindowText(_T("100")); +} + +void CSeriesPropDlg::OnSelectRandomData() +{ + + GetDlgItem(IDC_DATAPARAM1_TEXT)->SetWindowText(_T("Min Y value:")); + GetDlgItem(IDC_DATAPARAM2_TEXT)->SetWindowText(_T("Max Y value:")); + GetDlgItem(IDC_DATAPARAM1_EDIT)->SetWindowText(_T("0")); + GetDlgItem(IDC_DATAPARAM2_EDIT)->SetWindowText(_T("100")); + GetDlgItem(IDC_POINTSNUMBER_EDIT)->SetWindowText(_T("100")); +} + +void CSeriesPropDlg::OnSelectSineData() +{ + GetDlgItem(IDC_DATAPARAM1_TEXT)->SetWindowText(_T("Sine Amplitude 正弦振幅:")); + GetDlgItem(IDC_DATAPARAM2_TEXT)->SetWindowText(_T("Sine Period 正弦周期:")); + GetDlgItem(IDC_DATAPARAM1_EDIT)->SetWindowText(_T("3.0")); + GetDlgItem(IDC_DATAPARAM2_EDIT)->SetWindowText(_T("5.0")); + GetDlgItem(IDC_POINTSNUMBER_EDIT)->SetWindowText(_T("1000")); +} diff --git a/ChartDemo/SeriesPropDlg.h b/ChartDemo/SeriesPropDlg.h new file mode 100644 index 0000000..b739783 --- /dev/null +++ b/ChartDemo/SeriesPropDlg.h @@ -0,0 +1,85 @@ +#if !defined(AFX_SERIESPROPDLG_H__EFFE6C6F_39A1_42E7_9B35_1EE66D5AC520__INCLUDED_) +#define AFX_SERIESPROPDLG_H__EFFE6C6F_39A1_42E7_9B35_1EE66D5AC520__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// SeriesPropDlg.h : header file +// + +#include "ChartString.h" +#include "ColourPicker.h" + +///////////////////////////////////////////////////////////////////////////// +// CSeriesPropDlg dialog + +class CSeriesPropDlg : public CDialog +{ +// Construction +public: +// std::string GetSeriesName() const { return m_strSeriesName; } +// int GetSeriesType() const { return m_iSeriesType; } +// COLORREF GetSeriesColour() const { return m_SeriesColour; } + + CSeriesPropDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSeriesPropDlg) + enum { IDD = IDD_SERIESPROP_DLG }; + CComboBox m_VertAxisCombo; + CComboBox m_HorizAxisCombo; + CColourPicker m_ColourSelect; + CComboBox m_SeriesTypeCombo; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSeriesPropDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSeriesPropDlg) + virtual void OnOK(); + virtual BOOL OnInitDialog(); + afx_msg void OnSelectLineData(); + afx_msg void OnSelectRandomData(); + afx_msg void OnSelectSineData(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +public: + TChartString m_strSeriesName; + int m_iSeriesType; + COLORREF m_SeriesColour; + + int m_iVertAxis; + int m_iHorizAxis; + + int m_iDataType; + int m_iPointsNumber; + float m_fMaxXValue; + float m_fMinXValue; + + //Line data: + float m_fLineSlope; + float m_fLineOffset; + + // Sine wave data: + float m_fSineAmplitude; + float m_fSinePeriod; + + // Random values data: + int m_iRandMinVal; + int m_iRandMaxVal; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SERIESPROPDLG_H__EFFE6C6F_39A1_42E7_9B35_1EE66D5AC520__INCLUDED_) diff --git a/ChartDemo/StdAfx.cpp b/ChartDemo/StdAfx.cpp new file mode 100644 index 0000000..6d1be81 --- /dev/null +++ b/ChartDemo/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// ChartDemo.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/ChartDemo/StdAfx.h b/ChartDemo/StdAfx.h new file mode 100644 index 0000000..45e4576 --- /dev/null +++ b/ChartDemo/StdAfx.h @@ -0,0 +1,28 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__F1B266DB_B914_41ED_B713_A3CB4AC72DE8__INCLUDED_) +#define AFX_STDAFX_H__F1B266DB_B914_41ED_B713_A3CB4AC72DE8__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#pragma warning (disable:4786) + +#endif // !defined(AFX_STDAFX_H__F1B266DB_B914_41ED_B713_A3CB4AC72DE8__INCLUDED_) diff --git a/ChartDemo/SurfacePropDialog.cpp b/ChartDemo/SurfacePropDialog.cpp new file mode 100644 index 0000000..777b51e --- /dev/null +++ b/ChartDemo/SurfacePropDialog.cpp @@ -0,0 +1,62 @@ +// SurfacePropDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "chartdemo.h" +#include "SurfacePropDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSurfacePropDialog dialog + + +CSurfacePropDialog::CSurfacePropDialog(CWnd* pParent /*=NULL*/) + : CDialog(CSurfacePropDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSurfacePropDialog) + m_iHorizSurf = -1; + m_FillStyle = -1; + //}}AFX_DATA_INIT +} + + +void CSurfacePropDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSurfacePropDialog) + DDX_Radio(pDX, IDC_HORIZONTAL_RADIO, m_iHorizSurf); + DDX_CBIndex(pDX, IDC_FILLSTYLE_COMBO, m_FillStyle); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CSurfacePropDialog, CDialog) + //{{AFX_MSG_MAP(CSurfacePropDialog) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSurfacePropDialog message handlers + +BOOL CSurfacePropDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_FillStyle = 0; + m_iHorizSurf = 0; + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSurfacePropDialog::OnOK() +{ + UpdateData(TRUE); + CDialog::OnOK(); +} diff --git a/ChartDemo/SurfacePropDialog.h b/ChartDemo/SurfacePropDialog.h new file mode 100644 index 0000000..37e2e39 --- /dev/null +++ b/ChartDemo/SurfacePropDialog.h @@ -0,0 +1,48 @@ +#if !defined(AFX_SURFACEPROPDIALOG_H__88893012_E2F3_477F_833A_B3D7B10CC8A8__INCLUDED_) +#define AFX_SURFACEPROPDIALOG_H__88893012_E2F3_477F_833A_B3D7B10CC8A8__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// SurfacePropDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CSurfacePropDialog dialog + +class CSurfacePropDialog : public CDialog +{ +// Construction +public: + CSurfacePropDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSurfacePropDialog) + enum { IDD = IDD_SURFACEPROP_DLG }; + int m_iHorizSurf; + int m_FillStyle; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSurfacePropDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSurfacePropDialog) + virtual BOOL OnInitDialog(); + virtual void OnOK(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SURFACEPROPDIALOG_H__88893012_E2F3_477F_833A_B3D7B10CC8A8__INCLUDED_) diff --git a/ChartDemo/res/ChartDemo.ico b/ChartDemo/res/ChartDemo.ico new file mode 100644 index 0000000..7eef0bc Binary files /dev/null and b/ChartDemo/res/ChartDemo.ico differ diff --git a/ChartDemo/res/ChartDemo.rc2 b/ChartDemo/res/ChartDemo.rc2 new file mode 100644 index 0000000..4c72645 --- /dev/null +++ b/ChartDemo/res/ChartDemo.rc2 @@ -0,0 +1,13 @@ +// +// CHARTDEMO.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/ChartDemo/resource.h b/ChartDemo/resource.h new file mode 100644 index 0000000..82be42d --- /dev/null +++ b/ChartDemo/resource.h @@ -0,0 +1,76 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ChartDemo.rc +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_CHARTDEMO_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDD_SERIESPROP_DLG 131 +#define IDD_LINEPROP_DLG 135 +#define IDD_SURFACEPROP_DLG 137 +#define IDD_POINTPROP_DLG 139 +#define IDC_CHARTCTRL 1001 +#define IDC_SERIES_GROUP 1007 +#define IDC_ADDSERIES 1009 +#define IDC_SERIESNAME_EDIT 1010 +#define IDC_SERIESTYPE_COMBO 1011 +#define IDC_SERIESCOLOUR_BTN 1012 +#define IDC_SERIES_LIST 1013 +#define IDC_GENERAL_GROUP 1014 +#define IDC_LEGENDVIS_CHECK 1015 +#define IDC_BKGND_COLBTN 1016 +#define IDC_AXIS_GROUP 1017 +#define IDC_LEFTAXIS_RADIO 1018 +#define IDC_BOTTOMAXIS_RADIO 1019 +#define IDC_RIGHTAXIS_RADIO 1020 +#define IDC_TOPAXIS_RADIO 1021 +#define IDC_AXISVISIBLE_CHECK 1022 +#define IDC_AXISAUTOMATIC_CHECK 1023 +#define IDC_AXISGRIDVIS_CHECK 1024 +#define IDC_AXISMINVAL_EDIT 1025 +#define IDC_AXISMAXVAL_EDIT 1026 +#define IDC_AXISLOGARITHMIC_CHECK 1027 +#define IDC_AXISMINVAL_STATIC 1028 +#define IDC_AXISMAXVAL_STATIC 1029 +#define IDC_TITLE_EDIT 1033 +#define IDC_VERTICALAXIS_COMBO 1034 +#define IDC_HORIZONTALAXIS_COMBO 1035 +#define IDC_LINEDATA_RADIO 1036 +#define IDC_SINEDATA_RADIO 1037 +#define IDC_RANDOMDATA_RADIO 1038 +#define IDC_MINXVALUE_EDIT 1039 +#define IDC_MAXXVALUE_EDIT 1040 +#define IDC_POINTSNUMBER_EDIT 1043 +#define IDC_DATAPARAM1_EDIT 1044 +#define IDC_DATAPARAM2_EDIT 1045 +#define IDC_DATAPARAM1_TEXT 1046 +#define IDC_DATAPARAM2_TEXT 1047 +#define IDC_AXISINVERTED_CHECK 1048 +#define IDC_AXISLABEL_EDIT 1049 +#define IDC_DELETESERIES 1050 +#define IDC_CHART2 1052 +#define IDC_PAN_CHECK 1055 +#define IDC_ZOOM_CHECK 1056 +#define IDC_PENSTYLE_COMBO 1058 +#define IDC_LINEWIDTH_EDIT 1059 +#define IDC_HORIZONTAL_RADIO 1060 +#define IDC_RADIO2 1061 +#define IDC_FILLSTYLE_COMBO 1062 +#define IDC_POINTTYPE_COMBO 1063 +#define IDC_POINTWIDTH_EDIT 1064 +#define IDC_POINTHEIGHT_EDIT 1065 +#define IDC_CHECK1 1066 +#define IDC_AXISSCROLLBAR_CHECK 1066 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 141 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1067 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..b6394f9 --- /dev/null +++ b/README.MD @@ -0,0 +1,32 @@ + + + +##### High-speed Charting Control + +[Fork From codeproject](https://www.codeproject.com/Articles/14075/High-speed-Charting-Control) + + +##### 璇存槑 + +鍩轰簬MFC鐨勯珮閫熷浘琛ㄦ帶浠 + + +##### 鍥剧墖鏄剧ず + + + +![sdfsdfs](pic1.jpg) + + + +![sdfsdfs](pic2.jpg) + + +##### 鑻辨枃浠嬬粛 + +[https://www.codeproject.com/Articles/14075/High-speed-Charting-Control](https://www.codeproject.com/Articles/14075/High-speed-Charting-Control) + + +##### ChartDemo Documentation + +[ChartDemo\Doc\html\index.html](./ChartDemo/Doc/html/index.html) \ No newline at end of file diff --git a/pic1.jpg b/pic1.jpg new file mode 100644 index 0000000..8ca6e05 Binary files /dev/null and b/pic1.jpg differ diff --git a/pic2.jpg b/pic2.jpg new file mode 100644 index 0000000..f05317f Binary files /dev/null and b/pic2.jpg differ