/** * @file XTPChartElementView.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(__XTPCHARTELEMENTVIEW_H__) # define __XTPCHARTELEMENTVIEW_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChartDeviceCommand; class CXTPChartDeviceContext; class CXTPChartContainer; /** * @brief * This class represents the view of a chart element. All views have a * parent view and one or more child views. * * @details * This a base class for the views of various chart elements like axis, * legend, diagram, tick marks etc. */ class _XTP_EXT_CLASS CXTPChartElementView : public CXTPChartObject { DECLARE_DYNAMIC(CXTPChartElementView); public: /** * @brief * Constructs a CXTPChartElementView object. * * @param pParentView A pointer to the parent view. */ CXTPChartElementView(CXTPChartElementView* pParentView); /** * @brief * Constructs a CXTPChartElementView object. * * @param pParentView A pointer to the parent view. * @param bAddToParent If TRUE, then the view will be added to parent's child elements. */ CXTPChartElementView(CXTPChartElementView* pParentView, BOOL bAddToParent); /** * @brief * Constructs a CXTPChartElementView object. * * @param pContainer Parent container pointer. */ CXTPChartElementView(CXTPChartContainer* pContainer); protected: /** * @brief * Destroys a CXTPChartElementView object, handles cleanup. */ virtual ~CXTPChartElementView(); public: /** * @brief * Call this function to get the number of child views associated * with this view. * * @return * An integer specifying the number of children. */ int GetCount() const; /** * @brief * Call this function to get a child view at a particular index. * @param nIndex Point index. * @return * A pointer to a chart element view object. */ CXTPChartElementView* GetAt(int nIndex) const; /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the chart element. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return * Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. * Derived class objects will return more specific device command objects * according to their type. * * @details * This is a virtual function, so sub-classes can override this function * and can give specific implementations according to their type. */ virtual CXTPChartDeviceCommand* CreateDeviceCommand(CXTPChartDeviceContext* pDC); /** * @brief * Call this function to get the parent view. * * @return * A pointer to a chart element view object. */ CXTPChartElementView* GetParentView() const; /** * @brief * Call this function to add a child view to the current view. * * @param pChildView A pointer to a chart element view object. * @return Adds a child view to current view */ CXTPChartElementView* AddChildView(CXTPChartElementView* pChildView); /** * @brief * Provides access to the collection of children elements * owned by the view. * * @return * A pointer to the first element in the collection. The total number * of elements can be determined by use GetCount method. * * @see * GetCount */ CXTPChartElementView** GetChildren(); /** * @brief * Obtains viewed object's bound rectangle. * * @return * Viewed object's bound rectangle. */ CRect GetBounds() const; /** * @brief * Obtains viewed object's bound rectangle. * * @param bIncludingChildren If TRUE, the bounding rectangle will include all * children objects' rectangles. * * @return * Viewed object's bound rectangle. */ CRect GetBounds(BOOL bIncludingChildren) const; public: /** @cond */ virtual void OnMouseMove(UINT nFlags, CPoint point); virtual void OnLButtonDown(UINT nFlags, CPoint point); virtual void OnLButtonUp(UINT nFlags, CPoint point); virtual BOOL OnSetCursor(CPoint point); /** @endcond */ public: void Release(); private: void Initialize(CXTPChartElementView* pParentView, BOOL bAddToParent); protected: CArray m_arrChildren; /**< The child view collection.*/ CXTPChartElementView* m_pParentView; /**< The parent view.*/ CXTPChartContainer* m_pContainer; /**< The parent container.*/ CRect m_rcBounds; /**< Bounding rectangle.*/ }; AFX_INLINE int CXTPChartElementView::GetCount() const { return (int)m_arrChildren.GetSize(); } AFX_INLINE CXTPChartElementView* CXTPChartElementView::GetAt(int nIndex) const { return nIndex >= 0 && nIndex < m_arrChildren.GetSize() ? m_arrChildren.GetAt(nIndex) : NULL; } AFX_INLINE CXTPChartElementView* CXTPChartElementView::GetParentView() const { return m_pParentView; } AFX_INLINE CXTPChartElementView** CXTPChartElementView::GetChildren() { return m_arrChildren.GetData(); } AFX_INLINE CRect CXTPChartElementView::GetBounds() const { return m_rcBounds; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTELEMENTVIEW_H__) /** @endcond */