Click here to Skip to main content
15,860,972 members
Articles / Desktop Programming / MFC

High-speed Charting Control

Rate me:
Please Sign up or sign in to vote.
4.95/5 (327 votes)
13 Jul 2010CPOL35 min read 4.1M   99.5K   787  
A flexible charting control to display 2D data
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartLegend.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>E:/Sources Misc/ChartDemo/ChartCtrl/ChartLegend.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *</span>
<a name="l00003"></a>00003 <span class="comment"> *      ChartLegend.h</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> *      Written by C�dric Moonen (cedric_moonen@hotmail.com)</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> *      This code may be used for any non-commercial and commercial purposes in a compiled form.</span>
<a name="l00010"></a>00010 <span class="comment"> *      The code may be redistributed as long as it remains unmodified and providing that the </span>
<a name="l00011"></a>00011 <span class="comment"> *      author name and this disclaimer remain intact. The sources can be modified WITH the author </span>
<a name="l00012"></a>00012 <span class="comment"> *      consent only.</span>
<a name="l00013"></a>00013 <span class="comment"> *      </span>
<a name="l00014"></a>00014 <span class="comment"> *      This code is provided without any garanties. I cannot be held responsible for the damage or</span>
<a name="l00015"></a>00015 <span class="comment"> *      the loss of time it causes. Use it at your own risks</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> *      An e-mail to notify me that you are using this code is appreciated also.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> */</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#if !defined(AFX_CHARTLEGEND_H__CD72E5A0_8F52_472A_A611_C588F642080B__INCLUDED_)</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define AFX_CHARTLEGEND_H__CD72E5A0_8F52_472A_A611_C588F642080B__INCLUDED_</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 <span class="preprocessor">#if _MSC_VER &gt; 1000</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#endif // _MSC_VER &gt; 1000</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "ChartCtrl.h"</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include "ChartString.h"</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">class </span><a class="code" href="class_c_chart_serie.html" title="Abstract class that provides a common &amp;quot;interface&amp;quot; for all series in the...">CChartSerie</a>;
<a name="l00034"></a>00034 
<a name="l00036"></a>00036 
<a name="l00041"></a><a class="code" href="class_c_chart_legend.html">00041</a> <span class="keyword">class </span><a class="code" href="class_c_chart_legend.html" title="This class is responsible for the legend displayed on the control.">CChartLegend</a>  
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043         <span class="keyword">friend</span> <a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="keyword">public</span>:
<a name="l00047"></a>00047         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#a23df25eefd5506133162db7b291fdfe" title="Sets the font used to display the series names.">SetFont</a>(<span class="keywordtype">int</span> iPointSize, <span class="keyword">const</span> TChartString&amp; strFaceName);
<a name="l00048"></a>00048 
<a name="l00050"></a><a class="code" href="class_c_chart_legend.html#b638f2259d00f46816a5c0bba7529a54">00050</a>         <span class="keyword">enum</span> <a class="code" href="class_c_chart_legend.html#b638f2259d00f46816a5c0bba7529a54" title="Enumeration specifying on which side of the control the legend is docked.">DockSide</a>
<a name="l00051"></a>00051         {
<a name="l00052"></a>00052                 dsDockRight,
<a name="l00053"></a>00053                 dsDockLeft,
<a name="l00054"></a>00054                 dsDockTop,
<a name="l00055"></a>00055                 dsDockBottom
<a name="l00056"></a>00056         };
<a name="l00057"></a>00057 
<a name="l00059"></a>00059         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#37edaeb7516a4c0e0473f30afd211aec" title="Dock the legend on a specific side of the control. Default is right.">DockLegend</a>(<a class="code" href="class_c_chart_legend.html#b638f2259d00f46816a5c0bba7529a54" title="Enumeration specifying on which side of the control the legend is docked.">DockSide</a> dsSide);
<a name="l00061"></a>00061 
<a name="l00070"></a>00070         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#398a83f500e7d3ec88b53baac0caa8f9" title="Undock the legend.">UndockLegend</a>(<span class="keywordtype">int</span> iLeftPos, <span class="keywordtype">int</span> iTopPos);
<a name="l00071"></a>00071 
<a name="l00073"></a>00073         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#316543887a3a6af4a4133049a6574130" title="Sets the background of the legend transparent.">SetTransparent</a>(<span class="keywordtype">bool</span> bTransparent);  
<a name="l00075"></a>00075 
<a name="l00079"></a>00079         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#0bb7fb625a300c260390c96422db725b" title="Sets the legend in horizontal/vertical mode.">SetHorizontalMode</a>(<span class="keywordtype">bool</span> bHorizontal);
<a name="l00080"></a>00080 
<a name="l00082"></a>00082         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#ea145cd45c337496e726a9a958205f1b" title="Sets the legend visible/invisible.">SetVisible</a>(<span class="keywordtype">bool</span> bVisible);
<a name="l00084"></a><a class="code" href="class_c_chart_legend.html#b2c65ac7823a1551eff83709f4310ddf">00084</a>         <span class="keywordtype">bool</span> <a class="code" href="class_c_chart_legend.html#b2c65ac7823a1551eff83709f4310ddf" title="Returns true if the legend is visible.">IsVisible</a>()<span class="keyword">  const         </span>{ <span class="keywordflow">return</span> m_bIsVisible; }
<a name="l00085"></a>00085 
<a name="l00087"></a><a class="code" href="class_c_chart_legend.html#03431c7ae2764527fead0db1f129c187">00087</a>         COLORREF <a class="code" href="class_c_chart_legend.html#03431c7ae2764527fead0db1f129c187" title="Returns the back color of the legend.">GetBackColor</a>()<span class="keyword"> const                      </span>{ <span class="keywordflow">return</span> m_BackColor; }
<a name="l00089"></a>00089         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#949ef9f6d4d372efec72017fa5d101d6" title="Sets the back color of the legend.">SetBackColor</a>(COLORREF NewColor);
<a name="l00091"></a><a class="code" href="class_c_chart_legend.html#89ee10fed100ff1b19c16908bc79491d">00091</a>         COLORREF <a class="code" href="class_c_chart_legend.html#89ee10fed100ff1b19c16908bc79491d" title="Returns the shadow color.">GetShadowColor</a>()<span class="keyword"> const            </span>{ <span class="keywordflow">return</span> m_ShadowColor; }
<a name="l00093"></a>00093         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#db9a437ec8a341503bcf03ad8f04b780" title="Sets the shadow color.">SetShadowColor</a>(COLORREF NewColor);
<a name="l00095"></a>00095         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#3e492ab1e36f3e861b82dd688f35ab2b" title="Enables/disables the shadow.">EnableShadow</a>(<span class="keywordtype">bool</span> bEnable);
<a name="l00097"></a>00097         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_legend.html#4fe2a3537a6f8474cd2fe5010ecb0dcc" title="Sets the shadow depth (in pixels).">SetShadowDepth</a>(<span class="keywordtype">int</span> Depth);
<a name="l00098"></a>00098 
<a name="l00100"></a>00100         BOOL <a class="code" href="class_c_chart_legend.html#de42499c29132ecdda476afb6a9b366c" title="Returns true if the screen point is on the legend region.">IsPointInside</a>(<span class="keyword">const</span> CPoint&amp; screenPoint) <span class="keyword">const</span>;
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 <span class="keyword">private</span>:
<a name="l00104"></a>00104         <a class="code" href="class_c_chart_legend.html" title="This class is responsible for the legend displayed on the control.">CChartLegend</a>(<a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>* pParent);
<a name="l00106"></a>00106         <span class="keyword">virtual</span> ~<a class="code" href="class_c_chart_legend.html" title="This class is responsible for the legend displayed on the control.">CChartLegend</a>();
<a name="l00107"></a>00107 
<a name="l00109"></a>00109         <span class="keywordtype">void</span> Draw(CDC* pDC);
<a name="l00111"></a>00111         <span class="keywordtype">void</span> ClipArea(CRect&amp; rcControl, CDC* pDC);
<a name="l00113"></a>00113         <span class="keywordtype">void</span> UpdatePosition(CDC* pDC, <span class="keyword">const</span> CRect&amp; rcControl);
<a name="l00114"></a>00114 
<a name="l00116"></a>00116         <a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>* m_pParentCtrl;
<a name="l00118"></a>00118         CRect m_LegendRect;
<a name="l00119"></a>00119 
<a name="l00121"></a>00121         TChartString m_strFontName;
<a name="l00123"></a>00123         <span class="keywordtype">int</span>          m_iFontSize;
<a name="l00124"></a>00124 
<a name="l00126"></a>00126         <span class="keywordtype">bool</span> m_bDocked; 
<a name="l00128"></a>00128         <a class="code" href="class_c_chart_legend.html#b638f2259d00f46816a5c0bba7529a54" title="Enumeration specifying on which side of the control the legend is docked.">DockSide</a> m_DockSide;
<a name="l00129"></a>00129 
<a name="l00131"></a>00131         <span class="keywordtype">int</span> m_iLeftPos;
<a name="l00133"></a>00133         <span class="keywordtype">int</span> m_iTopPos;
<a name="l00134"></a>00134 
<a name="l00136"></a>00136         <span class="keywordtype">bool</span> m_bIsVisible;
<a name="l00138"></a>00138         <span class="keywordtype">bool</span> m_bIsTransparent;
<a name="l00140"></a>00140         <span class="keywordtype">bool</span> m_bIsHorizontal;
<a name="l00142"></a>00142         <span class="keywordtype">bool</span> m_bShadow;
<a name="l00144"></a>00144         <span class="keywordtype">int</span> m_iShadowDepth;
<a name="l00145"></a>00145 
<a name="l00147"></a>00147         COLORREF m_BackColor;
<a name="l00149"></a>00149         COLORREF m_ShadowColor;
<a name="l00150"></a>00150 
<a name="l00152"></a>00152         CSize m_BitmapSize;
<a name="l00153"></a>00153 };
<a name="l00154"></a>00154 
<a name="l00155"></a>00155 <span class="preprocessor">#endif // !defined(AFX_CHARTLEGEND_H__CD72E5A0_8F52_472A_A611_C588F642080B__INCLUDED_)</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 17 13:33:09 2010 for ChartDemo by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Belgium Belgium
I am a 29 years old guy and I live with my girlfriend in Hoegaarden, little city from Belgium well known for its white beer Smile | :) .
I studied as an industrial engineer in electronics but I oriented myself more towards software development when I started to work.
Currently I am working in a research centre in mechatronica. I mainly develop in C++ but I also do a bit of Java.
When I have so spare time, I like to read (mainly fantasy) and play electric guitar.

Comments and Discussions