/** * @file XTPSyntaxEditPaintManager.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(__XTPSYNTAXEDITPAINTMANAGER_H__) # define __XTPSYNTAXEDITPAINTMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPSyntaxEditCtrl; class CXTPImageManager; /** @cond */ # define XTP_DECLARE_COLOR_PROP(propName) \ OLE_COLOR OleGet##propName(); \ void OleSet##propName(OLE_COLOR oleColor); /** @endcond */ /** * @brief * This class is used by CXTPSyntaxEditCtrl as the paint manager. */ class _XTP_EXT_CLASS CXTPSyntaxEditPaintManager : public CXTPCmdTarget { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditPaintManager) /** @endcond */ public: /** * @brief * Default object constructor. */ CXTPSyntaxEditPaintManager(); /** * @brief * Destroys a CXTPSyntaxEditPaintManager object, handles cleanup * and deallocation. */ virtual ~CXTPSyntaxEditPaintManager(); /** * @brief * Initializes default paint manager bitmaps, should be called after * creating the control window. */ virtual void InitBitmaps(); /** * @brief * Refreshes the visual metrics of the manager. */ virtual void RefreshMetrics(); /** * @brief * Updates the edit control text font. * @param pEditCtrl [in] Pointer to the edit control. * @param lf [in] Reference to an XTP_EDIT_FONTOPTIONS structure. * @return * TRUE if the edit control text font was updated, otherwise FALSE. * @see * LOGFONT */ virtual BOOL UpdateTextFont(CXTPSyntaxEditCtrl* pEditCtrl, const XTP_EDIT_FONTOPTIONS& lf); /** * @brief * Draws a line number. * @param pDC [in] Pointer to the device context to draw to. * @param rcRect [in] Reference to the rectangle to draw. * @param nTextRow [in] Text row number for which to draw. * @param pEditCtrl [in] Pointer to the edit control. */ virtual void DrawLineNumber(CDC* pDC, const CRect& rcRect, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Draws the line collapsible node icon. * @param pDC [in] Pointer to the device context to draw to. * @param rcNode [in] Reference to the node rectangle to draw. * @param rcNodeFull [in] Reference to the full node area rectangle. * @param dwType [in] Line node type flags. * @param nTextRow [in] Text row number for which to draw. * @param pEditCtrl [in] Pointer to the edit control. */ virtual void DrawLineNode(CDC* pDC, const CRect& rcNode, const CRect& rcNodeFull, DWORD dwType, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Draws the line node background. * @param pDC [in] Pointer to the device context to draw to. * @param rcNodeFull [in] Reference to the full node area rectangle. * @param dwType [in] Line node type flags. * @param nTextRow [in] Text row number for which to draw. * @param pEditCtrl [in] Pointer to the edit control. */ virtual void DrawLineNodeBackground(CDC* pDC, const CRect& rcNodeFull, DWORD dwType, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Draws frames around collapsed text blocks. * @param pEditCtrl [in] Pointer to the edit control. * @param pDC [in] Pointer to the device context. */ virtual void DrawCollapsedTextMarks(CXTPSyntaxEditCtrl* pEditCtrl, CDC* pDC); /** * @brief * Draws line marks. * @param pDC [in] Pointer to the device context to draw to. * @param rcRect [in] Reference to the rectangle to draw. * @param nTextRow [in] Text row number for which to draw. * @param pEditCtrl [in] Pointer to the edit control. */ virtual void DrawLineMarks(CDC* pDC, const CRect& rcRect, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Draws row text. * @param pDC [in] Pointer to the device context to draw to. * @param rcTextLine [in] Reference to the rectangle to draw. * @param nTextRow [in] Text row number for which to draw. * @param nLine [in] Screen (page) line number. * @param pEditCtrl [in] Pointer to the edit control. * @return * The height to draw row text. */ virtual int DrawLineTextEx(CDC* pDC, const CRect& rcTextLine, int nTextRow, int nLine, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Prints row text. * @param pDC [in] Pointer to the device context to draw to. * @param rcTextLine [in] Reference to the rectangle to draw. * @param nTextRow [in] Text row number for which to draw. * @param nLine [in] Screen (page) line number. * @param pEditCtrl [in] Pointer to the edit control. * @param nFlags [in] Additional printing options. * The following options are supported: * DT_CALCRECT, DT_SINGLELINE, DT_WORDBREAK * @return * The height to print row text. */ virtual int PrintLineTextEx(CDC* pDC, const CRect& rcTextLine, int nTextRow, int nLine, CXTPSyntaxEditCtrl* pEditCtrl, int nFlags = 0); /** * @brief * Draws the editor text line and calculates the selection position. * @param txtBlk [in] Reference to an XTP_EDIT_TEXTBLOCK structure. * @param nSelStartX [in] Start coordinate. * @param nSelEndX [in] End coordinate. * @param arTxtBlk [in] Array of references to XTP_EDIT_TEXTBLOCK structures. * @param bUseBlk [in] Array of references to BOOL values. * @see * XTP_EDIT_TEXTBLOCK */ virtual void DrawLineCalcSel(const XTP_EDIT_TEXTBLOCK& txtBlk, int nSelStartX, int nSelEndX, XTP_EDIT_TEXTBLOCK (&arTxtBlk)[4], BOOL (&bUseBlk)[4]); protected: /** * @brief * Draws a line mark. * @param pEditCtrl [in] Pointer to the edit control. * @param pBookmark [in] Pointer to the structure containing mark parameters. * @see * LPXTP_EDIT_SENMBOOKMARK */ virtual void DrawLineMark(CXTPSyntaxEditCtrl* pEditCtrl, XTP_EDIT_SENMBOOKMARK* pBookmark); /** * @brief * Draws the line numbers border. * @param pDC [in] Pointer to the device context to draw to. * @param rcLineNum [in] Reference to the line number rectangle. * @param clrBorder [in] Border color. */ virtual void DrawLineNumbersBorder(CDC* pDC, const CRect& rcLineNum, const COLORREF clrBorder); public: /** * @brief * Sets the line selection cursor. * @param hCurLine [in] Handle to the cursor. The cursor must have been * created by the CreateCursor function or loaded * by the LoadCursor or LoadImage function. Cursor * appears in lines selection area. * @return * The handle of the previous cursor. */ HCURSOR SetLineSelCursor(HCURSOR hCurLine); /** * @brief * Sets the cursor shape for "copy" cursor. * @param hCurCopy [in] Handle to the cursor. The cursor must have been * created by the CreateCursor function or loaded * by the LoadCursor or LoadImage function. * @return * The handle of the previous cursor. */ HCURSOR SetCopyCursor(HCURSOR hCurCopy); /** * @brief * Sets the cursor shape for "move" cursor. * @param hCurMove [in] Handle to the cursor. The cursor must have been * created by the CreateCursor function or loaded * by the LoadCursor or LoadImage function. * @return * The handle of the previous cursor. */ HCURSOR SetMoveCursor(HCURSOR hCurMove); /** * @brief * Gets the text color. * @return * The text color. * @see * SetTextColor */ COLORREF GetTextColor() const; /** * @brief * Gets the background color. * @return * The background color. * @see * SetBackColor */ COLORREF GetBackColor() const; /** * @brief * Gets the corresponding background color for either * the edit or read-only mode of a specified CXTPSyntaxEditCtrl object. * @param pEditCtrl Pointer to a CXTPSyntaxEditCtrl object. * @return * The corresponding background color. * @see * SetBackColor, GetBackColor */ COLORREF GetBackColorEx(CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Gets the selected text color. * @return * The selected text color. * @see * SetHiliteTextColor */ COLORREF GetHiliteTextColor() const; /** * @brief * Gets the selected background color. * @return * The selected background color. * @see * SetHiliteBackColor */ COLORREF GetHiliteBackColor() const; /** * @brief * Gets the selected text color for when the control does not have focus. * @return * The selected text color for when the control does not have focus. * @see * SetInactiveHiliteTextColor */ COLORREF GetInactiveHiliteTextColor() const; /** * @brief * Gets the selected background color for when the control does not have focus. * @return * The selected background color for when the control does not have focus. * @see * SetInactiveHiliteBackColor */ COLORREF GetInactiveHiliteBackColor() const; /** * @brief * Gets the line numbers text color. * @return * The line numbers text color. * @see * SetLineNumberTextColor */ COLORREF GetLineNumberTextColor() const; /** * @brief * Gets the line numbers background color. * @return * The line numbers background color. * @see * SetLineNumberBackColor */ COLORREF GetLineNumberBackColor() const; /** * @brief * Gets the breakpoint text color. * @return * The breakpoint text color. * @see * SetBreakpointTextColor */ COLORREF GetBreakpointTextColor() const; /** * @brief * Gets the breakpoint background color. * @return * The breakpoint background color. * @see * SetBreakpointBackColor */ COLORREF GetBreakpointBackColor() const; /** * @brief * Sets the text color * @param crText Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetTextColor */ BOOL SetTextColor(COLORREF crText, BOOL bUpdateReg = FALSE); /** * @brief * Sets the background color. * @param crBack Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetBackColor */ BOOL SetBackColor(COLORREF crBack, BOOL bUpdateReg = FALSE); /** * @brief * Sets the background color for read-only mode. * @param crBack Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetBackColor */ BOOL SetReadOnlyBackColor(COLORREF crBack, BOOL bUpdateReg = FALSE); /** * @brief * Sets the selected text color. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetHiliteTextColor */ BOOL SetHiliteTextColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the selected background color. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetHiliteBackColor */ BOOL SetHiliteBackColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the selected text color for when the control does not have focus. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetInactiveHiliteTextColor */ BOOL SetInactiveHiliteTextColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the selected background color for when the control does not have focus. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetInactiveHiliteBackColor */ BOOL SetInactiveHiliteBackColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the line numbers text color. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetLineNumberTextColor */ BOOL SetLineNumberTextColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the line numbers background color. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetLineNumberBackColor */ BOOL SetLineNumberBackColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the breakpoint text color * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetBreakpointTextColor */ BOOL SetBreakpointTextColor(COLORREF color, BOOL bUpdateReg = FALSE); /** * @brief * Sets the breakpoint background color. * @param color Color to be set. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * GetBreakpointBackColor */ BOOL SetBreakpointBackColor(COLORREF color, BOOL bUpdateReg = FALSE); public: /** * @brief * Gets the common font. * @return * A pointer to a CFont object. * @see * SetFont */ CFont* GetFont(); /** * @brief * Gets the editor text font. * @return * A pointer to a CFont object. * @see * SetFontText */ CFont* GetFontText(); /** * @brief * Gets the line numbers font. * @return * A pointer to a CFont object. * @see * SetFontLineNumber */ CFont* GetFontLineNumber(); /** * @brief * Gets the tooltip font. * @return * A pointer to a CFont object. * @see * SetFontToolTip */ CFont* GetFontToolTip(); // ToolTip font. /** * @brief * Set the common font. * @param pLogfont Pointer to a LPLOGFONT structure. * @return * TRUE if successful, otherwise FALSE. * @see * GetFont */ BOOL SetFont(LPLOGFONT pLogfont); /** * @brief * Sets the editor text font. * @param pLogfont Pointer to a LPLOGFONT structure. * @return * TRUE if successful, otherwise FALSE. * @see * GetFontText */ BOOL SetFontText(LPLOGFONT pLogfont); /** * @brief * Sets the line numbers font. * @param pLogfont Pointer to a LPLOGFONT structure. * @return * TRUE if successful, otherwise FALSE. * @see * GetFontLineNumber */ BOOL SetFontLineNumber(LPLOGFONT pLogfont); /** * @brief * Sets the tooltip font. * @param pLogfont Pointer to a LPLOGFONT structure. * @return * TRUE if successful, otherwise FALSE. * @see * GetFontToolTip */ BOOL SetFontToolTip(LPLOGFONT pLogfont); /** * @brief * Sets all editor fonts. * @param pLogfont Pointer to a LPLOGFONT structure. * @param bUpdateReg TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if successful, otherwise FALSE. * @see * SetFont, SetFontText, SetFontLineNumber, SetFontToolTip */ BOOL CreateFontIndirect(LPLOGFONT pLogfont, BOOL bUpdateReg = FALSE); /** * @brief * Gets the cursor to show on the line selection area. * @return * The HCURSOR handle to the cursor. * @see * SetLineSelCursor */ HCURSOR GetCurLine(); /** * @brief * Gets the cursor for moving text. * @return * The HCURSOR handle to the cursor. * @see * SetMoveCursor */ HCURSOR GetCurMove(); /** * @brief * Gets the cursor for copying text. * @return * The HCURSOR handle to the cursor. * @see * SetCopyCursor */ HCURSOR GetCurCopy(); /** * @brief * Gets the standard NO cursor. * @return * The HCURSOR handle to the cursor. */ HCURSOR GetCurNO(); /** * @brief * Gets the standard IBEAM cursor. * @return * The HCURSOR handle to the cursor. */ HCURSOR GetCurIBeam(); /** * @brief * Gets the standard ARROW cursor. * @return * The HCURSOR handle to the cursor. */ HCURSOR GetCurArrow(); CString m_sLineNumberFormat; /**< String to customize Line Number format (e.g. keep it fixed legnth like %04d) If empty - Control used default - variable legnth Line Numbers) */ protected: // fonts CXTPFont m_xtpFont; /**< Default font for normal text. */ CXTPFont m_xtpFontText; /**< Current text font. */ CXTPFont m_xtpFontLineNumber; /**< Font for line numbering. */ CXTPFont m_xtpFontToolTip; /**< Font for tooltip text. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_font, m_xtpFont, GetFontHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fontText, m_xtpFontText, GetTextFontHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fontLineNumber, m_xtpFontLineNumber, GetLineNumberFontHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fontToolTip, m_xtpFontToolTip, GetToolTipFontHandle); // cursors HCURSOR m_hCurLine; /**< Cursor to show on the line selection area. */ HCURSOR m_hCurMove; /**< Cursor for moving text. */ HCURSOR m_hCurCopy; /**< Cursor for copying text. */ HCURSOR m_hCurNO; /**< Standard NO cursor. */ HCURSOR m_hCurIBeam; /**< Standard IBEAM cursor. */ HCURSOR m_hCurArrow; /**< Standard ARROW cursor. */ enum IconType { IconBookmark, IconBookmarkSelected, IconBreakpoint }; CXTPImageManager* m_pImageManager; CPen m_penGray; /**< Standard common gray pen. */ XTP_EDIT_COLORVALUES m_clrValues; /**< Default color. */ /** * @brief * Gets the bookmarks image manager. * @return * A pointer to the bookmarks image manager. */ virtual CXTPImageManager* GetBookmarks(); protected: # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPSyntaxEditPaintManager) XTP_DECLARE_COLOR_PROP(TextColor) XTP_DECLARE_COLOR_PROP(BackColor) XTP_DECLARE_COLOR_PROP(ReadOnlyBackColor) XTP_DECLARE_COLOR_PROP(LineNumberTextColor) XTP_DECLARE_COLOR_PROP(LineNumberBackColor) XTP_DECLARE_COLOR_PROP(SelectedTextColor) XTP_DECLARE_COLOR_PROP(SelectedBackColor) XTP_DECLARE_COLOR_PROP(BreakpontTextColor) XTP_DECLARE_COLOR_PROP(BreakpontBackColor) /** @endcond */ # endif }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetTextColor() const { return m_clrValues.crText; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetBackColor() const { return m_clrValues.crBack; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetBackColorEx(CXTPSyntaxEditCtrl* pEditCtrl) { return m_clrValues.GetBackColorEx(pEditCtrl); } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetHiliteTextColor() const { return m_clrValues.crHiliteText; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetHiliteBackColor() const { return m_clrValues.crHiliteBack; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetInactiveHiliteTextColor() const { return m_clrValues.crInactiveHiliteText; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetInactiveHiliteBackColor() const { return m_clrValues.crInactiveHiliteBack; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetLineNumberTextColor() const { return m_clrValues.crLineNumberText; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetLineNumberBackColor() const { return m_clrValues.crLineNumberBack; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetBreakpointTextColor() const { return m_clrValues.crBreakpointText; } AFX_INLINE COLORREF CXTPSyntaxEditPaintManager::GetBreakpointBackColor() const { return m_clrValues.crBreakpointBack; } ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSYNTAXEDITPAINTMANAGER_H__) /** @endcond */