/** * @file XTPFlowGraphConnection.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(__XTPFLOWGRAPHCONNECTION_H__) # define __XTPFLOWGRAPHCONNECTION_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPFlowGraphPage; class CXTPFlowGraphConnectionPoint; class CXTPFlowGraphDrawContext; class CXTPFlowGraphNode; namespace Gdiplus { class GraphicsPath; } /** * @brief * Represents a connection. Connections are the lines that connect * two connection points. */ class _XTP_EXT_CLASS CXTPFlowGraphConnection : public CXTPFlowGraphElement { DECLARE_SERIAL(CXTPFlowGraphConnection); public: /** * @brief * Constructs a CXTPFlowGraphConnection object. */ CXTPFlowGraphConnection(); /** * @brief * Destroys a CXTPFlowGraphConnection object, handles cleanup and * deallocation. */ virtual ~CXTPFlowGraphConnection(); public: /** * @brief * Sets the input connection point that this connection line is * connected to. * @param pPoint Reference to the connection point to connect to. */ virtual void SetInputPoint(CXTPFlowGraphConnectionPoint* pPoint); /** * @brief * Gets the input connection point that this connection line is * connected to. * @return * Reference to the input connection point that this connection line * is connected to. */ CXTPFlowGraphConnectionPoint* GetInputPoint() const; /** * @brief * Sets the output connection point that this connection line is * connected to. * @param pPoint Reference to the connection point to connect to. */ virtual void SetOutputPoint(CXTPFlowGraphConnectionPoint* pPoint); /** * @brief * Gets the output connection point that this connection line is * connected to. * @return * Reference to the output connection point that this connection line * is connected to. */ CXTPFlowGraphConnectionPoint* GetOutputPoint() const; /** * @brief * Sets the middle point of the connection (this is also what * happens when a connection is dragged by the mouse). * @param pt Point to use as the middle point in the connection. * @details * This sets the point where the little circle glyph is drawn along the * spline/line (connection). When a connection is clicked and * dragged with the mouse, a small circle "point" is drawn to indicate * where the line was clicked and how much it has been dragged. */ void SetControlPoint(CPoint pt); /** * @brief * Gets the middle point of the connection (this is also what * happens when a connection is dragged by the mouse). * @details * This is the point where the little circle glyph is drawn along the * spline/line (connection). When a connection is clicked and * dragged with the mouse, a small circle "point" is drawn to indicate * where the line was clicked and how much it has been dragged. * @return * The middle point for the connection. */ CPoint GetControlPoint() const; /** * @brief * Sets the caption for the connection. * @param lpszCaption Caption for the connection. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the caption of the connection. * @details * The connection's caption is not visible in the graph. It can be * used like a tag property. * @return * The caption of the connection. */ CString GetCaption() const; /** * @brief * Sets the tooltip for this connection. * @param lpszTooltip Tooltip for this connection. * @details * This is the text that is displayed when the mouse is hovered over * the connection. */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Gets the tooltip of this connection. * @details * This is the text that is displayed when the mouse is hovered over * the connection. * @return * The tooltip of this connection. */ CString GetTooltip() const; void SetTag(LPCTSTR lpszTag); CString GetTag() const; /** * @brief * Sets the color for the connection line. * @param clr Color for the connection line. */ void SetColor(COLORREF clr); /** * @brief * Gets the color of the connection line. * @return * The color of the connection line. */ COLORREF GetColor() const; /** * @brief * Sets the style for the connector. * @param nStyle Style for the connector. This will be a value from the * XTPFlowGraphConnectorType enumeration. * @details * Use a value from the XTPFlowGraphConnectorType enumeration to set * the style for the connector. */ void SetStyle(int nStyle); /** * @brief * Gets the style of the connector. * @details * This will return a value from the XTPFlowGraphConnectorType * enumeration. * @return * The style of the connector. */ int GetStyle() const; /** * @brief * Sets the width for the connector line. * @param nWidth Width for the connector line. */ void SetWidth(int nWidth); /** * @brief * Gets the width of the connector line. * @return * The width of the connector line. */ int GetWidth() const; /** * @brief * Enables/disables dashed style for the connector line. * @param bDashed TRUE to enable dashed style, FALSE to disable. */ void SetDashed(BOOL bDashed); /** * @brief * Determines if dashed style is enabled/disabled for the connector line. * @return * TRUE if dashed style is enabled for the connector line, * FALSE if it is disabled. */ BOOL GetDashed() const; public: /** * @brief * Gets the bounding rectangle for this element. * @return * The bounding rectangle for this element. */ CRect GetBoundingRect(); /** * @brief * Determines if the specified point is within the connection. * @param pt Point to test. * @return * TRUE if the point is located within the connection, otherwise FALSE. */ virtual BOOL PtInRect(POINT pt); public: /** * @brief * Gets the input Node that this connection line is connected to. * @return * Reference to the input Node that this connection line is connected to. */ CXTPFlowGraphNode* GetInputNode() const; /** * @brief * Gets the output Node that this connection line is connected to. * @return * Reference to the output Node that this connection line is connected to. */ CXTPFlowGraphNode* GetOutputNode() const; /** * @brief * Gets a reference to the parent FlowGraph control. * @return * A reference to the parent FlowGraph control. */ CXTPFlowGraphControl* GetControl() const; /** * @brief * Gets a reference to the page that this connection belongs to. * @return * A reference to the page that this connection belongs to. */ CXTPFlowGraphPage* GetPage() const; public: /** * @brief * Call this method to recalculate the size and layout of the * connection. * @param pDC Reference to a valid device context. */ virtual void RecalcLayout(CXTPFlowGraphDrawContext* pDC); public: /** * @brief * Remove/delete this connection from its parent node. */ void Remove(); /** * @brief * This method is called when the connection is removed. */ virtual void OnRemoved(); void SetPathReversed(BOOL bReversed); BOOL IsPathReversed() const; public: /** * @brief * Call this member function to store/load a connection using the * specified data object. * @param pPX Source/destination CXTPPropExchange data object reference. * @details * This member function is used to store/load connection data to/from * storage. */ virtual void DoPropExchange(CXTPPropExchange* pPX); protected: /** * @brief * Used internally to restore the connection when loaded from a * resource. This is used in DoPropExchange. */ virtual void RestoreConnection(); int GetConnectionPointIndex(CXTPFlowGraphConnectionPoint* pPoint) const; protected: CXTPFlowGraphPage* m_pPage; /**< The page that this connection belongs to. */ CXTPFlowGraphConnectionPoint* m_pInputPoint; /**< The input ConnectionPoint that this connection line is connected to.*/ CXTPFlowGraphConnectionPoint* m_pOutputPoint; /**< The output ConnectionPoint that this connection line is connected to.*/ CXTPFlowGraphConnection* m_pNextVisibleConnection; /**< Reference to the next visible connection.*/ CPoint m_ptInputPoint; /**< Stores the coordinates of the Input connection point (if any), also is used internally for drag/drop.*/ CPoint m_ptOutputPoint; /**< Stores the coordinates of the Output connection point (if any), also is used internally for drag/drop.*/ CPoint m_ptControlPoint; /**< Middle point for the connection. This is the point that is set a connection is clicked and dragged by a mouse.*/ CString m_strCaption; /**< The caption of the connection. */ CString m_strTooltip; /**< Tooltip text for the item. */ CString m_strTag; /**< A tag property to define a connection */ COLORREF m_clrConnection; /**< Color of the connection. */ int m_nStyle; /**< Style of the connection. It uses a value from the XTPFlowGraphConnectorType enumeration. */ int m_nInputId; /**< Used internally to store the ID of the Input connection point. */ int m_nOutputId; /**< Used internally to store the ID of the Output connection point. */ int m_nInputPointIndex; int m_nOutputPointIndex; int m_nInputPointConnectionIndex; int m_nOutputPointConnectionIndex; int m_nConnectionIndex; CRect m_rcBoundingRect; /**< The bounding rectangle for this element. */ Gdiplus::GraphicsPath* m_pPath; /**< Path to the GDI Plus graphics used to draw the conneciton. */ BOOL m_bPathReversed; int m_nWidth; BOOL m_bDashed; friend class CXTPFlowGraphPaintManager; friend class CXTPFlowGraphConnections; friend class CXTPFlowGraphControl; friend class CXTPFlowGraphPage; # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPFlowGraphConnection) afx_msg void OleSetCaption(LPCTSTR lpszCaption); afx_msg BSTR OleGetCaption(); afx_msg void OleSetTooltip(LPCTSTR lpszTooltip); afx_msg BSTR OleGetTooltip(); afx_msg void OleSetTag(LPCTSTR lpszTag); afx_msg BSTR OleGetTag(); afx_msg void OleSetColor(OLE_COLOR clr); afx_msg OLE_COLOR OleGetColor(); afx_msg void OleSetStyle(int nStyle); afx_msg int OleGetStyle(); afx_msg LPDISPATCH OleGetOutputPoint(); afx_msg void OleSetOutputPoint(LPDISPATCH lpDisp); afx_msg LPDISPATCH OleGetInputPoint(); afx_msg void OleSetInputPoint(LPDISPATCH lpDisp); afx_msg void OleSetWidth(int nWidth); afx_msg int OleGetWidth(); afx_msg void OleSetDashed(BOOL bDashed); afx_msg BOOL OleGetDashed(); /** @endcond */ # endif }; AFX_INLINE CXTPFlowGraphConnectionPoint* CXTPFlowGraphConnection::GetInputPoint() const { return m_pInputPoint; } AFX_INLINE CXTPFlowGraphConnectionPoint* CXTPFlowGraphConnection::GetOutputPoint() const { return m_pOutputPoint; } AFX_INLINE CString CXTPFlowGraphConnection::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPFlowGraphConnection::SetTooltip(LPCTSTR lpszTooltip) { m_strTooltip = lpszTooltip; } AFX_INLINE CString CXTPFlowGraphConnection::GetTooltip() const { return m_strTooltip; } AFX_INLINE void CXTPFlowGraphConnection::SetTag(LPCTSTR lpszTag) { m_strTag = lpszTag; } AFX_INLINE CString CXTPFlowGraphConnection::GetTag() const { return m_strTag; } AFX_INLINE void CXTPFlowGraphConnection::SetColor(COLORREF clr) { m_clrConnection = clr; } AFX_INLINE COLORREF CXTPFlowGraphConnection::GetColor() const { return m_clrConnection; } AFX_INLINE void CXTPFlowGraphConnection::SetStyle(int nStyle) { m_nStyle = nStyle; OnGraphChanged(); } AFX_INLINE int CXTPFlowGraphConnection::GetStyle() const { return m_nStyle; } AFX_INLINE void CXTPFlowGraphConnection::SetPathReversed(BOOL bReversed) { m_bPathReversed = bReversed; } AFX_INLINE BOOL CXTPFlowGraphConnection::IsPathReversed() const { return m_bPathReversed; } AFX_INLINE CPoint CXTPFlowGraphConnection::GetControlPoint() const { return m_ptControlPoint; } AFX_INLINE CXTPFlowGraphPage* CXTPFlowGraphConnection::GetPage() const { return m_pPage; } AFX_INLINE void CXTPFlowGraphConnection::SetWidth(int nWidth) { m_nWidth = nWidth; } AFX_INLINE int CXTPFlowGraphConnection::GetWidth() const { return m_nWidth; } AFX_INLINE void CXTPFlowGraphConnection::SetDashed(BOOL bDashed) { m_bDashed = bDashed; } AFX_INLINE BOOL CXTPFlowGraphConnection::GetDashed() const { return m_bDashed; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPFLOWGRAPHCONNECTION_H__) /** @endcond */