/** * @file XTPFlowGraphPage.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(__XTPFLOWGRAPHPAGE_H__) # define __XTPFLOWGRAPHPAGE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPFlowGraphControl; class CXTPFlowGraphNodes; class CXTPFlowGraphNodeGroups; class CXTPFlowGraphConnections; class CXTPFlowGraphDrawContext; class CXTPPropExchange; class CXTPFlowGraphNode; class CXTPFlowGraphSelectedElements; class CXTPFlowGraphConnection; /** * @brief * Represents a page in the flow graph. * @details * A page is what contains all the elements in the flow graph. The * flow graph can contain many pages, each of which can contain * Nodes, Node groups, and connections. A page is the first thing that * you must add to the flow graph and then you can add elements * to the pages. */ class _XTP_EXT_CLASS CXTPFlowGraphPage : public CXTPCmdTarget { DECLARE_SERIAL(CXTPFlowGraphPage); public: /** * @brief * Constructs a CXTPFlowGraphPage object. */ CXTPFlowGraphPage(); protected: /** * @brief * Destroys a CXTPFlowGraphPage object, handles cleanup and * deallocation. */ virtual ~CXTPFlowGraphPage(); public: /** * @brief * Gets a collection of all Nodes that have been added to this page. * @details * Nodes are the main objects that are displayed in the flow graph. * In terms of a database, they can be thought of as tables. Nodes contain * many connection points, which are like the fields in a table. Finally, * there are connections that are used to draw a relationship between the * fields of two tables. * @return * A collection of all Nodes that have been added to this page. */ CXTPFlowGraphNodes* GetNodes() const; /** * @brief * Gets a collection of all groups that have been added to this page. * @details * A group is just a "box" that is used to visually group Nodes * together. By default, the group will only be shown when a Node in * the group is selected, but you can choose to always show the * groups with ShowNodeGroupsAlways. * @return * A collection of all groups that have been added to this page. */ CXTPFlowGraphNodeGroups* GetGroups() const; /** * @brief * Gets a reference to the parent FlowGraph control. * @return * A reference to the parent FlowGraph control. */ CXTPFlowGraphControl* GetControl() const; /** * @brief * Gets a collection of all connections that have been added to this * page. * @return * A collection of all connections that have been added to this page. */ CXTPFlowGraphConnections* GetConnections() const; public: /** * @brief * Sets the ID for this page. * @param nId New ID for this page. */ void SetID(int nId); /** * @brief * Gets the ID of this page. * @return * The ID of this page. */ int GetID() const; /** * @brief * Sets the caption for this page. * @param lpszCaption New caption for this page. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the caption of this page. * @return * The caption of this page. */ CString GetCaption() const; public: /** * @brief * This method is called when the flow graph layout is changed. * @details * This method is called when the page zoom level, page scroll offset, * window/Node size, window handle, Node style, Node color, or * connection style is changed. */ virtual void OnGraphChanged(); /** * @brief * This method is called to move the contents of the page to their * correct positions. * @param pDC Pointer to a valid device context. * @param rcPage Bounding rectangle of the page. */ virtual void Reposition(CXTPFlowGraphDrawContext* pDC, CRect rcPage); /** * @brief * This method is called when the page is drawn. * @param pDC Pointer to a valid device context. */ virtual void OnDraw(CXTPFlowGraphDrawContext* pDC); /** * @brief * Converts the page coordinates of a given point or rectangle on the * display to screen coordinates. * @param lpRect Pointer to a RECT structure or CRect object that contains * the page coordinates to be converted. * @return * A rectangle with page coordinates converted into screen coordinates. */ CRect PageToScreen(LPCRECT lpRect) const; /** * @brief * Converts the given x- and y- screen coordinates to page coordinates. * @param x Reference to the x- screen coordinate to be converted. This * parameter will receive the converted x- page coordinate. * @param y Reference to the y- screen coordinate to be converted. This * parameter will receive the converted y- page coordinate. * @details * The ScreenToPage member function replaces the given x- and y- screen * coordinates with converted page coordinates. The new coordinates are * relative to the upper-left corner of the page area. */ void ScreenToPage(double& x, double& y) const; /** * @brief * Converts the screen coordinates of a given point or rectangle on * the display to page coordinates. * @param point Pointer to a CPoint object or POINT structure that contains * the screen coordinates to be converted. * @details * The ScreenToPage member function replaces the screen coordinates * given in lpPoint or lpRect with page coordinates. The new * coordinates are relative to the upper-left corner of the page * area. * @return * A point with screen coordinates converted into page coordinates. */ CPoint ScreenToPage(CPoint point) const; /** * @brief * Converts the screen coordinates of a given point or rectangle on * the display to page coordinates. * @param lpRect Pointer to a CRect object or RECT structure that contains * the screen coordinates to be converted. * @details * The ScreenToPage member function replaces the screen coordinates * given in lpPoint or lpRect with page coordinates. The new * coordinates are relative to the upper-left corner of the page * area. * @return * A rectangle with screen coordinates converted into page coordinates. */ CRect ScreenToPage(LPCRECT lpRect) const; /** * @brief * Call this method to copy all the currently selected elements to * the flow graph's clipboard. */ virtual void Copy(); /** * @brief * Call this method to paste the contents of the flow graph's * clipboard to the currently active page. */ virtual void Paste(); /** * @brief * Specifies whether the flow control can perform a paste operation. * @details * There must be something in the control's clipboard from a previous * copy/cut before a paste operation can be performed. * @return * TRUE if the flow control can perform a paste operation. */ virtual BOOL CanPaste(); /** * @brief * Call this method to copy all the currently selected elements to * the flow graph's clipboard and then remove the selected contents * from the active page. */ virtual void Cut(); /** * @brief * Removes this page from the flow graph. */ void Remove(); /** * @brief * Auto-arranges the Nodes in this page. * @details * This will left-align all Nodes in this page. Nodes with * connections will be placed to the right of the connected Node. */ virtual void Arrange(); public: /** * @brief * Gets a reference to the collection of selected elements in the * flow graph in this page. * @details * Selected elements will include Nodes, connections, and connection * points. This collection can be used to add/remove elements * to/from the selection. Elements can be selected with the mouse or * by using methods in code. * @return * A reference to the collection of selected elements in the * flow graph in this page. */ CXTPFlowGraphSelectedElements* GetSelection() const; public: /** * @brief * Gets the bounding rectangle for this page. * @return * The bounding rectangle for this page. */ CRect GetPageRect() const; /** * @brief * Retrieves the scroll offset (how much the page has been scrolled). * This retrieves the X/Y coordinates excluding the left/right offset. * @return * The scroll offset (how much the page has been scrolled); a point * that contains the X/Y coordinates excluding the left/right offset. */ CPoint GetScrollOffset() const; /** * @brief * Sets the scroll offset (how much the page has been scrolled). This * sets the X/Y coordinates excluding the left/right offset. * @param ptScrollOffset New scroll offset (how much the page has been * scrolled); a point that contains the X/Y * coordinates excluding the left/right offset. */ void SetScrollOffset(CPoint ptScrollOffset); /** * @brief * Gets the current zoom level of the page. * @details * 0.0 is 0 zoom and 1.0 is 100% zoom. * @return * The current zoom level of the page. */ double GetZoomLevel() const; /** * @brief * Sets the current zoom level of the page. * @param dZoomLevel New zoom level to use. * @details * 0.0 is 0 zoom and 1.0 is 100% zoom. */ void SetZoomLevel(double dZoomLevel); protected: /** * @brief * This method is called when the page is removed. */ virtual void OnRemoved(); /** * @brief * Define visible regions of windows inside Nodes * (if windows exist inside Nodes). */ void SetVisibleNodesWindowsRegions(); public: /** * @brief * Call this member function to store/load a page using the specified * data object. * @param pPX Source/destination CXTPPropExchange data object reference. * @details * This member function is used to store/load page data to/from storage. */ virtual void DoPropExchange(CXTPPropExchange* pPX); private: /** @cond */ void SetArrangeLevel(int v, CArray& graph); int SetArrangeLocation(int v, int x, int y, int nLevelWidth, CArray& graph); /** @endcond */ public: static CLIPFORMAT m_cfNode; /**< Clipboard format. */ protected: CXTPFlowGraphControl* m_pControl; /**< Pointer to the parent flow graph control. */ CXTPFlowGraphNodes* m_pNodes; /**< Collection of Nodes that are displayed on this page. */ CXTPFlowGraphNodeGroups* m_pGroups; /**< Collection of groups that are displayed on this page. */ CXTPFlowGraphConnections* m_pConnections; /**< Collection of connections that are used in this page. */ CXTPFlowGraphSelectedElements* m_pSelectedElements; /**< Collection of elements that are used this page. */ CXTPFlowGraphNode* m_pFirstVisibleNode; /**< Pointer to the first visible Node in the page. */ CXTPFlowGraphConnection* m_pFirstVisibleConnection; /**< Pointer to the first visible connection in the page. */ CRect m_rcPage; /**< Bounding rectangle for this page. */ CRect m_rcWorkRect; /**< Rectangle for the currently visible portion of the page (it might be zoomed or scrolled). */ CPoint m_ptScrollOffset; /**< The scroll offset (how much the page has been scrolled). This returns the X and Y coordinates - up/down offset. */ double m_dZoomLevel; /**< Current zoom level of the page. */ int m_nId; /**< ID of the page. */ CString m_strCaption; /**< Caption of the page. */ friend class CXTPFlowGraphPages; friend class CXTPFlowGraphControl; # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPFlowGraphPage) afx_msg LPDISPATCH OleGetNodes(); afx_msg LPDISPATCH OleGetGroups(); afx_msg LPDISPATCH OleGetConnections(); afx_msg void OleSetCaption(LPCTSTR lpszCaption); afx_msg BSTR OleGetCaption(); afx_msg void OleScreenToPage(int* x, int* y); afx_msg void OlePageToScreen(int* x, int* y); afx_msg int OleGetScrollOffsetX(); afx_msg int OleGetScrollOffsetY(); afx_msg void OleSetScrollOffsetX(int x); afx_msg void OleSetScrollOffsetY(int y); afx_msg void OleSetZoomLevel(double dZoomLevel); afx_msg double OleGetZoomLevel(); afx_msg LPDISPATCH OleGetSelection(); /** @endcond */ # endif }; AFX_INLINE CXTPFlowGraphSelectedElements* CXTPFlowGraphPage::GetSelection() const { return m_pSelectedElements; } AFX_INLINE CXTPFlowGraphNodes* CXTPFlowGraphPage::GetNodes() const { return m_pNodes; } AFX_INLINE CXTPFlowGraphNodeGroups* CXTPFlowGraphPage::GetGroups() const { return m_pGroups; } AFX_INLINE CXTPFlowGraphConnections* CXTPFlowGraphPage::GetConnections() const { return m_pConnections; } AFX_INLINE CXTPFlowGraphControl* CXTPFlowGraphPage::GetControl() const { return m_pControl; } AFX_INLINE CRect CXTPFlowGraphPage::GetPageRect() const { return m_rcPage; } AFX_INLINE CPoint CXTPFlowGraphPage::GetScrollOffset() const { return m_ptScrollOffset; } AFX_INLINE void CXTPFlowGraphPage::SetScrollOffset(CPoint ptScrollOffset) { m_ptScrollOffset = ptScrollOffset; OnGraphChanged(); } AFX_INLINE void CXTPFlowGraphPage::SetID(int nId) { m_nId = nId; } AFX_INLINE int CXTPFlowGraphPage::GetID() const { return m_nId; } AFX_INLINE CString CXTPFlowGraphPage::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPFlowGraphPage::SetCaption(LPCTSTR lpszCaption) { m_strCaption = lpszCaption; } AFX_INLINE double CXTPFlowGraphPage::GetZoomLevel() const { return m_dZoomLevel; } AFX_INLINE void CXTPFlowGraphPage::SetZoomLevel(double dZoomLevel) { m_dZoomLevel = dZoomLevel; OnGraphChanged(); } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPFLOWGRAPHPAGE_H__) /** @endcond */