00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024
00025 #if _MSC_VER >= 1000
00026 #pragma once
00027 #endif // _MSC_VER >= 1000
00028
00029 #include "ChartSerie.h"
00030 #include "ChartAxis.h"
00031 #include "ChartGrid.h"
00032 #include "ChartLegend.h"
00033 #include "ChartTitle.h"
00034 #include "ChartGradient.h"
00035 #include "ChartCursor.h"
00036 #include "ChartMouseListener.h"
00037 #include "ChartStandardAxis.h"
00038 #include "ChartLogarithmicAxis.h"
00039 #include "ChartDateTimeAxis.h"
00040 #include "ChartCrossHairCursor.h"
00041 #include "ChartDragLineCursor.h"
00042
00043 #include <map>
00044
00045
00046 class CChartStandardAxis;
00047 class CChartLogarithmicAxis;
00048 class CChartDateTimeAxis;
00049 class CChartCrossHairCursor;
00050 class CChartDragLineCursor;
00051
00052 class CChartPointsSerie;
00053 class CChartLineSerie;
00054 class CChartSurfaceSerie;
00055 class CChartBarSerie;
00056 class CChartCandlestickSerie;
00057 class CChartGanttSerie;
00058
00060
00061
00063
00066 class CChartCtrl : public CWnd
00067 {
00068
00069 public:
00071
00074 CDC* GetDC();
00076 CRect GetPlottingRect() const { return m_PlottingRect; }
00077
00079 CChartLegend* GetLegend() const { return m_pLegend; }
00081 CChartTitle* GetTitle() const { return m_pTitles; }
00082
00084 enum EAxisPos
00085 {
00086 LeftAxis = 0,
00087 BottomAxis,
00088 RightAxis,
00089 TopAxis
00090 };
00091
00093
00098 CChartStandardAxis* CreateStandardAxis(EAxisPos axisPos);
00100
00105 CChartLogarithmicAxis* CreateLogarithmicAxis(EAxisPos axisPos);
00107
00112 CChartDateTimeAxis* CreateDateTimeAxis(EAxisPos axisPos);
00114
00131 void AttachCustomAxis(CChartAxis* pAxis, EAxisPos axisPos);
00132
00134
00144 CChartPointsSerie* CreatePointsSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00146
00158 CChartLineSerie* CreateLineSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00160
00172 CChartSurfaceSerie* CreateSurfaceSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00174
00184 CChartBarSerie* CreateBarSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00186
00196 CChartCandlestickSerie* CreateCandlestickSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00198
00208 CChartGanttSerie* CreateGanttSerie(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00210
00227 void AttachCustomSerie(CChartSerie* pNewSeries, bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00229
00234 CChartSerie* GetSerie(unsigned uSerieId) const;
00236
00240 void RemoveSerie(unsigned uSerieId);
00242 void RemoveAllSeries();
00244 size_t GetSeriesCount() const;
00245
00247
00258 CChartCrossHairCursor* CreateCrossHairCursor(bool bSecondaryHorizAxis=false, bool bSecondaryVertAxis=false);
00260
00269 CChartDragLineCursor* CreateDragLineCursor(EAxisPos relatedAxis);
00271
00277 void AttachCustomCursor(CChartCursor* pCursor);
00279
00284 void RemoveCursor(unsigned cursorId);
00285
00287 void ShowMouseCursor(bool bShow);
00288
00289 CChartAxis* GetBottomAxis() const;
00290 CChartAxis* GetLeftAxis() const;
00291 CChartAxis* GetTopAxis() const;
00292 CChartAxis* GetRightAxis() const;
00294
00299 CChartAxis* GetAxis(EAxisPos axisPos) const
00300 {
00301 return m_pAxes[axisPos];
00302 }
00303
00305 UINT GetEdgeType() const { return EdgeType; }
00307
00312 void SetEdgeType(UINT NewEdge)
00313 {
00314 EdgeType = NewEdge;
00315 RefreshCtrl();
00316 }
00317
00319 COLORREF GetBackColor() const { return m_BackColor; }
00321 void SetBackColor(COLORREF NewCol)
00322 {
00323 m_BackColor = NewCol;
00324 m_bBackGradient = false;
00325 RefreshCtrl();
00326 }
00328 COLORREF GetBorderColor() const { return m_BorderColor; }
00330 void SetBorderColor(COLORREF NewCol) { m_BorderColor = NewCol; RefreshCtrl(); }
00332 COLORREF GetZoomRectColor() const { return m_ZoomRectColor; }
00334 void SetZoomRectColor(COLORREF NewCol) { m_ZoomRectColor = NewCol; RefreshCtrl(); }
00336
00348 void SetBackGradient(COLORREF Col1, COLORREF Col2, EGradientType GradientType);
00349
00351 void SetPanEnabled(bool bEnabled) { m_bPanEnabled = bEnabled; }
00353 bool GetPanEnabled() const { return m_bPanEnabled; }
00355 void SetZoomEnabled(bool bEnabled) { m_bZoomEnabled = bEnabled; }
00357 bool GetZoomEnabled() const { return m_bZoomEnabled; }
00359 void UndoPanZoom();
00360
00362
00365 void RefreshCtrl();
00367
00374 void EnableRefresh(bool bEnable);
00376
00386 int Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle=WS_VISIBLE);
00387
00389 static double DateToValue(const COleDateTime& Date);
00391 static COleDateTime ValueToDate(double Value);
00392
00394
00401 virtual void Print(const TChartString& strTitle, CPrintDialog* pPrntDialog = NULL);
00402
00403 #if _MFC_VER > 0x0600
00405
00419 void SaveAsImage(const TChartString& strFilename, const CRect& rect,
00420 int nBPP, REFGUID guidFileType= GUID_NULL);
00421 #endif
00422
00424 CChartCtrl();
00426 virtual ~CChartCtrl();
00427
00429
00434 void RegisterMouseListener(CChartMouseListener* pMouseListener) { m_pMouseListener = pMouseListener;}
00435
00437
00441 void GoToFirstSerie();
00443
00452 CChartSerie* GetNextSerie();
00453
00455 void RefreshScreenAutoAxes();
00456
00457
00458 protected:
00459
00460 afx_msg void OnPaint();
00461 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00462 afx_msg void OnSize(UINT nType, int cx, int cy);
00463 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00464 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00465 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00466 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00467 afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00468 afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
00469 afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
00470 afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00471 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00472
00473 DECLARE_MESSAGE_MAP()
00474
00475 protected:
00476 virtual void OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo);
00477 virtual void OnPrint(CDC *pDC, CPrintInfo *pInfo);
00478 virtual void OnEndPrinting(CDC *pDC, CPrintInfo *pInfo);
00479
00480
00481
00482 virtual void DrawChart(CDC* pDC, CRect ChartRect);
00483 virtual void DrawBackground(CDC* pDC, CRect ChartRect);
00484
00485 private:
00487 bool RegisterWindowClass();
00488
00490
00497 void SendMouseEvent(CChartMouseListener::MouseEvent mouseEvent, const CPoint& screenPoint) const;
00498
00500 int m_iEnableRefresh ;
00502
00506 bool m_bPendingRefresh;
00508 CDC m_BackgroundDC;
00510 bool m_bMemDCCreated;
00511
00513 bool m_bBackGradient;
00515 COLORREF m_BackGradientCol1;
00517 COLORREF m_BackGradientCol2;
00519 EGradientType m_BackGradientType;
00521 COLORREF m_BackColor;
00523 COLORREF m_BorderColor;
00525 UINT EdgeType;
00526
00528 CRect m_PlottingRect;
00529
00530 typedef std::map<unsigned, CChartSerie*> TSeriesMap;
00532 TSeriesMap m_mapSeries;
00534 CChartAxis* m_pAxes[4];
00535
00537 CChartLegend* m_pLegend;
00539 CChartTitle* m_pTitles;
00540
00542 bool m_bPanEnabled;
00544 bool m_bRMouseDown;
00546 CPoint m_PanAnchor;
00547
00549 bool m_bZoomEnabled;
00551 bool m_bLMouseDown;
00553 CRect m_rectZoomArea;
00555 COLORREF m_ZoomRectColor;
00556
00558 bool m_bToolBarCreated;
00559
00561 CFont m_PrinterFont;
00563 CSize m_LogicalPageSize;
00565 CSize m_PaperSize;
00566
00567 typedef std::map<unsigned, CChartCursor*> TCursorMap;
00569 TCursorMap m_mapCursors;
00570
00572 CChartMouseListener* m_pMouseListener;
00573
00575 bool m_bMouseVisible;
00576
00577 typedef TSeriesMap::const_iterator TSeriesMapIter;
00579 TSeriesMapIter m_currentSeries;
00580 };
00581
00583
00584
00585
00586