/** * @file XTPFlowGraphPaintManager.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(__XTPFLOWGRAPHPAINTMANAGER_H__) # define __XTPFLOWGRAPHPAINTMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPFlowGraphControl; class CXTPFlowGraphDrawContext; class CXTPFlowGraphNode; class CXTPFlowGraphConnectionPoint; class CXTPFlowGraphConnection; class CXTPFlowGraphNodeGroup; class CXTPFlowGraphElement; namespace Gdiplus { class Font; } /** * @brief * Node connector styles. * @details * The xtpFlowGraphConnectorType specifies the style of the lines * that "connect" the connections of a Node. * @see * CXTPFlowGraphPaintManager::m_nConnectorType */ enum XTPFlowGraphConnectorType { xtpFlowGraphConnectorStraight = 0, /**< 00000000 */ xtpFlowGraphConnectorStraightArrow = 1, /**< 00000001 */ xtpFlowGraphConnectorStraightDoubleArrow = 3, /**< 00000011 */ xtpFlowGraphConnectorCurved = 4, /**< 00000100 */ xtpFlowGraphConnectorCurvedArrow = 5, /**< 00000101 */ xtpFlowGraphConnectorCurvedDoubleArrow = 7, /**< 00000111 */ xtpFlowGraphConnectorElbow = 8, /**< 00001000 */ xtpFlowGraphConnectorElbowArrow = 9, /**< 00001001 */ xtpFlowGraphConnectorElbowDoubleArrow = 11 /**< 00001011 */ }; # define IsStraightConnection(type) ((type >> 2) == 0) # define IsCurvedConnection(type) ((type & 4)) # define IsElbowConnection(type) ((type & 8)) # define HasStartingArrow(type) ((type & 2)) # define HasEndingArrow(type) ((type & 1)) /** * @brief * Handles most of the drawing activities of the flow graph. */ class _XTP_EXT_CLASS CXTPFlowGraphPaintManager : public CXTPCmdTarget { public: /** * @brief * Constructs a CXTPFlowGraphPaintManager object. */ CXTPFlowGraphPaintManager(); /** * @brief * Destroys a CXTPFlowGraphPaintManager object, handles cleanup and * deallocation. */ virtual ~CXTPFlowGraphPaintManager(); protected: BOOL CalculateConnectionPointsPositions(CXTPFlowGraphConnection* pConnection, CPoint& p1, CPoint& p2); public: /** * @brief * Draws the background for the flow graph control. * @param pDC Pointer to a valid device context. * @param pControl Pointer to the flow graph control. * @param bPrintToFile TRUE to print to file. * @param drawRect Size of the area to draw. */ virtual void DrawControlBackground(CXTPFlowGraphDrawContext* pDC, CXTPFlowGraphControl* pControl, BOOL bPrintToFile = FALSE, const CRect& drawRect = CRect(0, 0, 0, 0)); /** * @brief * This method is called to refresh the visual metrics of the flow graph. */ virtual void RefreshMetrics(); /** * @brief * Recalculates the layout of the connection. * @param pDC Drawing device context pointer. * @param pConnection Connection object pointer. * @details * Call this functions to correctly reposition the connection within * the Node. This will also update any colors, etc. that have changed. */ virtual void RecalcConnectionLayout(CXTPFlowGraphDrawContext* pDC, CXTPFlowGraphConnection* pConnection); /** * @brief * This method is called to draw a single connection in the flow * graph control. * @param pDC Pointer to a valid device context. * @param pConnection Pointer to a CXTPFlowGraphConnection object to draw. */ virtual void DrawConnection(CXTPFlowGraphDrawContext* pDC, CXTPFlowGraphConnection* pConnection); /** * @brief * Retrieves the bounding rectangle for the specified Node. * @param pNode Reference to the Node whose bounding rectangle must be * retrieved. * @return * The bounding rectangle for the specified node. */ virtual CRect GetNodeBoundingRectangle(CXTPFlowGraphNode* pNode); /** * @brief * This method is called to draw a transparent rectangle on the * graph control. * @param pDC Pointer to a valid device context. * @param rect Rectangle boundaries. * @param clrColor Base color. */ void DrawTransparentRectangle(CXTPFlowGraphDrawContext* pDC, CRect rect, COLORREF clrColor); /** * @brief * This method is called to draw a single Node group in the flow * graph control. * @param pDC Pointer to a valid device context. * @param pNodeGroup Pointer to a CXTPFlowGraphNodeGroup object to draw. */ virtual void DrawNodeGroup(CXTPFlowGraphDrawContext* pDC, CXTPFlowGraphNodeGroup* pNodeGroup); /** * @brief * Determines if the specified point is within the connection area. * @param pPoint CXTPFlowGraphConnectionPoint to test. * @param point Point in the flow graph to test. * @return * TRUE if the point is located within the connection area, * otherwise FALSE. */ virtual BOOL HitTestConnectionArea(const CXTPFlowGraphConnectionPoint* pPoint, CPoint point); /** * @brief * Retrieves the bounding rectangle for the caption of the specified Node. * @param pNode Reference to the element to retrieve the bounding rectangle * for the caption. * @return * The bounding rectangle for the caption of the specified Node. */ virtual CRect GetCaptionRect(CXTPFlowGraphElement* pNode); /** * @brief * Cleans up allocated resources used by the paint manager that have * been allocated during draw routines. */ virtual void Cleanup(); /** * @brief * Creates and retrieves a darker color of a specified color. * @param clrBackground Color to make darker. * @details * This will take the specified color and make it darker. For * example, it will take blue and make "dark blue". This is also * used internally to make the Node and group frame colors. * @return * A darker color of the specified color. */ static COLORREF AFX_CDECL GetDarkColor(COLORREF clrBackground); public: COLORREF m_clrBackground; /**< Specifies the background "canvas" color for the flow graph. */ COLORREF m_clrSelection; /**< Specifies the color used for selected Node's connection points' rectangles.*/ COLORREF m_clrSelectionInactive; /**< Specifies the color used for selected Node's (inactive). */ COLORREF m_clrTextColor; /**< Specifies the color used for text. */ COLORREF m_clrTextColorSelected; /**< Specifies the color used for text when a Node is selected. */ COLORREF m_clrGridColor; /**< Specifies the color used for grid lines. */ COLORREF m_clrNodeBackground; /**< Gets/sets the background color used for Nodes. */ LOGFONT m_lfText; /**< Gets/sets the font used for connection captions. */ LOGFONT m_lfCaption; /**< Gets/sets the font used for Node captions. */ int m_nNodeFrameSize; /**< Gets/sets the size of the border-frame of a Node. */ int m_nPointTextMargin; /**< Specifies the margin to place between a connection's caption text and the connection's connection point (if a connection point is present). */ COLORREF m_clrConnection; /**< Specifies the color of the connection lines that connect connection points. */ int m_nEllipseSize; /**< Specifies the size of connection points. */ BOOL m_bShowGrid; /**< Specifies whether to show the grid for the flow graph. */ BOOL m_bShowNodeGroupsAlways; /**< Specifies whether to always show Node groups, even if a non-grouped Node is selected (or if no Nodes are selected). */ BOOL m_bAlwaysDrawConnectionPoints; /**< Specifies whether to draw connection points always draw only on active Nodes. */ BOOL m_bRecalcConnectionLayoutWhenNeeded; /**< Recalculates the end points of a connection its selected state changes. */ BOOL m_bChangeNodeColorWhenSelected; /**< TRUE by default. Otherwise selected Node's caption text color is changed (to white by default, m_clrTextColorSelected). */ XTPFlowGraphConnectorType m_nConnectorType; /**< Node connector style. */ double m_dMinZoomLevelBackground; /**< Specifies the minimum zoom level to stop drawing the background of the flow graph. Default is 20%. Can be used to optimize drawing when a lot of objects are on screen. */ double m_dMinZoomLevelConnectionPoints; /**< Specifies the minimum zoom level to stop drawing connection points in the flow graph. Default is 30%. Can be used to optimize drawing when a lot of objects are on screen. */ double m_dMinZoomLevelConnections; /**< Specifies the minimum zoom level to stop drawing connections in the flow graph. Default is 5%. Can be used to optimize drawing when a lot of objects are on screen. */ double m_dMinZoomLevelGDIQuality; /**< Specifies the minimum zoom level to stop using GDI quality when drawing elements in the flow graph. Default is 40%. Can be used to optimize drawing when a lot of objects are on screen. */ protected: # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPFlowGraphPaintManager) afx_msg void OleSetFont(LPFONTDISP pFontDisp); afx_msg LPFONTDISP OleGetFont(); afx_msg void OleSetCaptionFont(LPFONTDISP pFontDisp); afx_msg LPFONTDISP OleGetCaptionFont(); /** @endcond */ # endif }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPFLOWGRAPHPAINTMANAGER_H__) /** @endcond */