/** * @file XTPChartLegendView.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPCHARTLEGENDVIEW_H__) # define __XTPCHARTLEGENDVIEW_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChartFont; class CXTPChartElementView; class CXTPChartDeviceContext; class CXTPChartLegend; class CXTPChartDeviceContext; class CXTPChartDeviceCommand; class CXTPChartBorder; class CXTPChartFillStyle; class CXTPPropExchange; /** * @brief * This class abstracts the view of a legend and its child items in * a bounding rectangle context. */ class _XTP_EXT_CLASS CXTPChartLegendView : public CXTPChartElementView { public: /** * @brief * Constructs a CXTPChartLegendView object. * * @param pLegend Pointer to a CXTPChartLegend object. * @param pParentView Pointer to a CXTPChartElementView object. */ CXTPChartLegendView(CXTPChartLegend* pLegend, CXTPChartElementView* pParentView); /** * @brief * Destroys a CXTPChartLegendView object, handles cleanup. */ virtual ~CXTPChartLegendView(); public: /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of a legend in the chart. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return * Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. Here it handles * the drawing of the legend. */ virtual CXTPChartDeviceCommand* CreateDeviceCommand(CXTPChartDeviceContext* pDC); /** * @brief * This function calculates the legend location in the chart based on the state * of the CXTPChartLegend object and adjusts the chart layout accordingly. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param rcChart The chart bounding rectangle. */ void CalculateView(CXTPChartDeviceContext* pDC, CRect& rcChart); /** * @brief * This member function calculates the legend's width and height based * on the number of legend items present. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return * The return value is a CSize object representing the height and width * of the legend. */ CSize CalcSize(CXTPChartDeviceContext* pDC); /** * @brief * Call this function to add a new legend item. * * @param pItem Pointer to a CXTPChartLegendItemView object. * @param minimum minimum of the point collection. * @param maximum maximum of the point collection. */ void AddItem(CXTPChartLegendItemView* pItem, double minimum = 0, double maximum = 0); protected: CXTPChartLegend* m_pLegend; /**< Pointer to the legend object.*/ CRect m_rcBounds; /**< The bounding rectangle of the legend.*/ struct CHARTLEGEND_ITEM { CXTPChartLegendItemView* pView; double min; double max; CXTPChartString str; }; CArray m_arrItems; /**< The list of legend items.*/ static int CompareFuncAsc(const CHARTLEGEND_ITEM* pItem1, const CHARTLEGEND_ITEM* pItem2); static int CompareFuncDesc(const CHARTLEGEND_ITEM* pItem1, const CHARTLEGEND_ITEM* pItem2); static int CompareFuncMinToMax(const CHARTLEGEND_ITEM* pItem1, const CHARTLEGEND_ITEM* pItem2); static int CompareFuncMaxToMin(const CHARTLEGEND_ITEM* pItem1, const CHARTLEGEND_ITEM* pItem2); }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTLEGENDVIEW_H__) /** @endcond */