/** * @file XTPTextOnPath.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(__XTPTEXTONPATH_H__) # define __XTPTEXTONPATH_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" // an array that can be copied with a copy constructor (e.g. returned from a function/method) template class CCArray : public CArray { public: CCArray(const CCArray& rhs) { CCArray::Copy(rhs); } CCArray() { } bool operator=(const CCArray& rhs) { CCArray::Copy(rhs); return true; } }; /** * @brief * GDI+ drawing of text on path. */ class _XTP_EXT_CLASS CXTPTextOnPath { enum TextPathAlign { Left = 0, Center = 1, Right = 2 }; enum TextPathPosition { OverPath = 0, CenterPath = 1, UnderPath = 2 }; protected: void GetLinePoints(Gdiplus::PointF p1, Gdiplus::PointF p2, int stepWitdth, CCArray& ret); Gdiplus::SizeF MeasureString(const CString& str, Gdiplus::StringFormat* pFormat); static CCArray AFX_CDECL CleanPoints(CCArray points); static double AFX_CDECL GetAngle(Gdiplus::PointF point1, Gdiplus::PointF point2); void DrawSingleRotatedLetter(const CString& letter, Gdiplus::REAL angle, Gdiplus::PointF pointCenter); Gdiplus::REAL StringRegionWidth(int textpos); void DrawText(CCArray points, int maxPoints); int CalculatePathPoints(Gdiplus::PointF* pPathPoints, int maxCount); void DoTests(); public: void Draw(); CXTPTextOnPath(const CString& text, Gdiplus::Graphics* pGraphics, Gdiplus::GraphicsPath* pPath); ~CXTPTextOnPath(); void SetFont(LOGFONT* lf); void ReversePath(); private: Gdiplus::Font* m_pFont; /**< Drawing font. */ Gdiplus::Graphics* m_pGraphics; /**< GDI+ graphics object. */ Gdiplus::GraphicsPath* m_pPath; Gdiplus::PathData m_Pathdata; CString m_sText; /**< The actual text. */ TextPathPosition m_TextPathPathPosition; TextPathAlign m_pathalign; Gdiplus::Brush* m_pFillBrush; int m_LetterSpacingPercentage; /**< 100 by default. */ ////////////////////////////////////////////////////////////////////////// CCArray m_TmpPointsReserved; Gdiplus::CharacterRange m_characterRanges[2]; Gdiplus::Region m_stringRegions[2]; Gdiplus::SizeF m_TextSize; /**< Should be calculated once. */ # ifdef _TEXTONPATH_TESTING ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // testing mode CCArray _regionList; CCArray _angles; CCArray _pointText; CCArray _pointTextUp; # endif }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // __XTPTEXTONPATH_H__ /** @endcond */