/** * @file XTPChartTextPainter.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(__XTPCHARTROTATEDTEXTPAINTE_H__) # define __XTPCHARTROTATEDTEXTPAINTE_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChartDeviceContext; class CXTPChartDeviceCommand; class CXTPChartFont; class CXTPMarkupUIElement; /** * @brief * This enumeration defines the various text rotations used in the XTP chart. */ enum XTPChartTextRotation { xtpChartTextLeftTop, /**< Left top. */ xtpChartTextCenterTop, /**< Center top. */ xtpChartTextRightTop, /**< Right top. */ xtpChartTextLeftCenter, /**< Left center. */ xtpChartTextCenterCenter, /**< Center center.*/ xtpChartTextRightCenter, /**< Right center. */ xtpChartTextLeftBottom, /**< Left bottom. */ xtpChartTextCenterBottom, /**< Center bottom.*/ xtpChartTextRightBottom /**< Right bottom. */ }; class CXTPChartTextElement; /** * @brief * This abstract class represents a text painter which is used for drawing * various text elements in the chart. */ class _XTP_EXT_CLASS CXTPChartTextPainterBase { protected: /** * @brief * Constructs a CXTPChartTextPainterBase object. * * @param text The text to be rendered. * @param pDC Pointer to a valid device context. * @param pTextProvider The element which owns the text. */ CXTPChartTextPainterBase(CXTPChartDeviceContext* pDC, const CXTPChartString& text, CXTPChartTextElement* pTextProvider); public: /** * @brief * Destroys a CXTPChartTextPainterBase object, handles cleanup. */ virtual ~CXTPChartTextPainterBase(); public: /** * @brief * Call this function to get the rounded bounds of the text. * * @return A CRect object specifying the rounded bounds. */ CRect GetRoundedBounds(); CXTPChartSizeF GetSize() const; protected: /** * @brief * Call this function to calculate the bounds of the text. * * @return A CXTPChartRectF object specifying the rounded bounds. * * @details * This is a pure virtual function, so give meaningful implementation * to this function within derived classes. */ virtual CXTPChartRectF CalculateBounds() = 0; protected: CXTPChartString m_strText; /**< The text to be painted*/ CXTPChartSizeF m_szTextSize; /**< The measurements of the text.*/ CXTPChartTextElement* m_pTextProvider; /**< The chart element which owns the text.*/ int m_nHeight; /**< The height of the text.*/ int m_nWidth; /**< The width of the text.*/ CRect m_rcRoundedBounds; /**< The rounded bounds of the text.*/ CXTPChartRectF m_rcBounds; /**< The bounds of the text.*/ CXTPMarkupUIElement* m_pMarkupUIElement; }; /** * @brief * This class represents a text painter which is used for drawing various * text elements in the chart. This is a kind of CXTPChartTextPainterBase. */ class _XTP_EXT_CLASS CXTPChartTextPainter : public CXTPChartTextPainterBase { public: /** * @brief * Constructs a CXTPChartTextPainterBase object. * * @param text The text to be rendered. * @param pTextProvider The element which owns the text. * @param pDC Pointer to a valid device context. */ CXTPChartTextPainter(CXTPChartDeviceContext* pDC, const CXTPChartString& text, CXTPChartTextElement* pTextProvider); void SetLocation(const CXTPChartPointF& location); public: /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of a text. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param color The color of the text. * * @return Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. Here it handles * the drawing of a text. */ virtual CXTPChartDeviceCommand* CreateDeviceCommand(CXTPChartDeviceContext* pDC, const CXTPChartColor& color); /** * @brief * Call this function to calculate the bounds of the text. * * @return A CXTPChartRectF object specifying the bounds. */ CXTPChartRectF CalculateBounds(); protected: CXTPChartPointF m_ptLocation; // The location of the text. }; /** * @brief * This abstract base class represents a rotated text painter which is used * for drawing various rotated text elements in the chart. This is a kind * of CXTPChartTextPainterBase. */ class _XTP_EXT_CLASS CXTPChartRotatedTextPainterBase : public CXTPChartTextPainterBase { protected: /** * @brief * Constructs a CXTPChartRotatedTextPainterBase object. * * @param pDC Pointer to the chart device context. * @param text The text to be rendered. * @param pTextProvider The element which owns the text. * @param ptBase The base point of the text. */ CXTPChartRotatedTextPainterBase(CXTPChartDeviceContext* pDC, const CXTPChartString& text, CXTPChartTextElement* pTextProvider, CPoint ptBase = CPoint(0, 0)); public: /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of a rotated text. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param color The color of the text. * * @return * Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. Here it handles * the drawing of a rotated text. */ virtual CXTPChartDeviceCommand* CreateDeviceCommand(CXTPChartDeviceContext* pDC, const CXTPChartColor& color); public: /** * @brief * Set base point of the text. * * @param pt The base point of the text. */ void SetBasePoint(CPoint pt); /** * @brief * Call this function to calculate the bounds of the text. * * @return A CXTPChartRectF object specifying the bounds. */ CXTPChartRectF CalculateBounds(); /** * @brief * Call this function to calculate the bounds of the text. * * @return A CXTPChartRectF object specifying the bounds. */ CRect GetInitialTextRect(); /** * @brief * Call this function to calculate the left top point of the text. * * @return A CXTPChartRectF object specifying the bounds. * * @details * This is a pure virtual function, so give meaningful implementation * to this function within derived classes. */ virtual CPoint CalculateLeftTopPoint() = 0; /** * @brief * Use this function to calculate the rotation of the text. * * @return An enumerated value, XTPChartTextRotation specifies the text rotation type. * * @details * This is a pure virtual function, so give meaningful implementation * to this function within derived classes. */ virtual XTPChartTextRotation CalculateRotation() = 0; /** * @brief * Computes text rectangle points taking into account text rotation. * * @param rotation Text rotation type. * @param rect Text rectangle. * @param angle The angle of rotation. * @param points On return contains coordinates of the rotated text rectangle corners. */ void CalculatePoints(XTPChartTextRotation rotation, CRect rect, float angle, float points[4][2]); protected: CPoint m_ptBasePoint; /**< The base point of the text.*/ float m_fAngle; /**< The angle of text rotation.*/ }; /** * @brief * This abstract base class renders a rotated text near a line which is used * for drawing various rotated text elements near lines in the chart. This * is a kind of CXTPChartTextPainterBase. */ class _XTP_EXT_CLASS CXTPChartRotatedTextPainterNearLine : public CXTPChartRotatedTextPainterBase { public: /** * @brief * Constructs a CXTPChartRotatedTextPainterNearLine object. * * @param pDC Pointer to the chart device context. * @param text The text to be rendered. * @param pTextProvider The element which owns the text. * @param ptBase The base point of the text. * @param position An enumerated value specifying the near text position. * @param fAngle The angle of rotation. */ CXTPChartRotatedTextPainterNearLine(CXTPChartDeviceContext* pDC, const CXTPChartString& text, CXTPChartTextElement* pTextProvider, CPoint ptBase, XTPChartNearTextPosition position, float fAngle); public: /** * @brief * Use this function to calculate the left top point of the text. * * @return A CPoint object specifying the left top. */ CPoint CalculateLeftTopPoint(); /** * @brief * Use this function to calculate the rotation of the text. * * @return An enumerated value, XTPChartTextRotation specifies the text rotation type. */ XTPChartTextRotation CalculateRotation(); protected: XTPChartNearTextPosition m_nNearPosition; /**< The near text position.*/ }; AFX_INLINE CXTPChartSizeF CXTPChartTextPainterBase::GetSize() const { return m_szTextSize; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTROTATEDTEXTPAINTE_H__) /** @endcond */