/** * @file XTPChartControl.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(__XTPCHARTCONTROL_H__) # define __XTPCHARTCONTROL_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" const UINT WM_XTP_CHART_BASE = (WM_USER + 9700); static const DWORD XTP_NC_CHARTMOUSEMOVE = (WM_XTP_CHART_BASE + 1); class CXTPChartContent; class CXTPChartDeviceCommand; class CXTPChartDrawThread; class CXTPChartDrawThreadDeviceCommand; class CXTPChartContentView; class CXTPToolTipContext; /** * @brief * CXTPChartControl is a CWnd derived class. It represents the main window * that contains the chart content and draws the chart. */ class _XTP_EXT_CLASS CXTPChartControl : public CWnd , public CXTPChartContainer { public: /** * @brief * Constructs a CXTPChartControl object. */ CXTPChartControl(); /** * @brief * Destroys a CXTPChartControl object, handles cleanup. */ virtual ~CXTPChartControl(); public: /** * @brief * Call this function to get the pointer to the chart content object. * * @return * A pointer to a CXTPChartContent object. */ CXTPChartContent* GetContent() const; /** * @copydoc CXTPChartContainer::GetControl */ virtual CWnd* GetControl(); /** * @brief * This method creates the chart control. * * @param dwStyle Style for the window. * @param rect Specifies the size and position of the control. * @param pParentWnd Specifies the parent window of the control. * @param nID Specifies the window control ID. * * @return * TRUE if successful, FALSE otherwise. */ using CWnd::Create; BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); void Draw(CDC* pDC, CRect rc); public: /** * @brief * Call this function whenever a change occurs in the chart content. * This call causes a redraw. * * @param updateOptions Options which indicate the kind of change performed. */ void OnChartChanged(XTPChartUpdateOptions updateOptions = xtpChartUpdateView); /** * @brief * Registers the window class if it has not already been registered. * * @param hInstance Instance of the resource where the control is located. * * @return * TRUE if the window class was successfully registered, FALSE otherwise. */ BOOL RegisterWindowClass(HINSTANCE hInstance = NULL); public: /** * @brief * Call this method to hit test the element under the cursor. * * @param point Position to hit test. * * @return * Pointer to a CXTPChartElement element under position. */ CXTPChartElement* HitTest(CPoint point) const; /** * @brief * Call this method to draw chart to a device context. * * @param hDC Device context to draw to. * @param rcBounds Bounding position for chart. * @return TRUE if successful, FALSE otherwise. */ BOOL PrintToDC(HDC hDC, CRect rcBounds); /** * @brief * Call this method to copy chart image to clipboard. * * @param szSize Chart image size to put to clipboard. * @return TRUE if successful, FALSE otherwise. */ BOOL CopyToClipboard(CSize szSize); /** * @brief * Call this method to save chart to a file as an image. * * @param lpszFilePath File path to save. * @param szBounds Bounding size for chart. * @return TRUE if successful, FALSE otherwise. */ BOOL SaveAsImage(LPCTSTR lpszFilePath, CSize szBounds); /** * @brief * Call this method to set the content of the chart control. * * @param pContent Pointer to new content. */ void SetContent(CXTPChartContent* pContent); /** * @brief * Call this method to enable/disable automatic chart updates when a change * is detected. * * @param bUpdateWindow TRUE to call UpdateWindow after each change. * * @details * Automatic chart updates are disabled by default requiring manual updates * after chart changes are made. * Frequent changes made with automatic chart updates enabled can result in * decreased performance. */ void SetUpdateWindow(BOOL bUpdateWindow); /** * @brief * Call this method to get a pointer to the tooltip context. * * @return * A pointer to the tooltip context. */ CXTPToolTipContext* GetToolTipContext() const; /** * @brief * Call this method to enable chart tooltips. * * @param bEnable TRUE to enable chart tooltips. */ void EnableToolTips(BOOL bEnable /* = TRUE */); public: /** * @brief * Call this method to set capture to view. * * @param pView View that will receive all mouse messages. */ void SetCapture(CXTPChartElementView* pView); protected: //{{AFX_VIRTUAL virtual void PreSubclassWindow(); virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; //}}AFX_VIRTUAL /** @cond */ DECLARE_MESSAGE_MAP(); afx_msg void OnPaint(); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg void OnCaptureChanged(CWnd* pWnd); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); /** @endcond */ protected: CXTPChartContent* m_pContent; /**< Chart Content*/ CBitmap m_bmpCache; /**< Bitmap Cache*/ CXTPChartDrawThreadDeviceCommand* m_pCommand; /**< Root of Chart Command tree*/ CXTPChartContentView* m_pContentView; /**< Current Content View*/ DWORD m_dwUpdateOptions; /**< Update options*/ CXTPToolTipContext* m_pToolTipContext; /**< Tooltip Context.*/ CXTPChartDrawThread* m_pDrawThread; /**< Helper draw thread that render 3D Charts*/ CXTPChartElementView* m_pCaptureView; /**< Captured View.*/ BOOL m_bUpdateWindow; /**< UpdateWindow flag.*/ }; AFX_INLINE CXTPChartContent* CXTPChartControl::GetContent() const { return m_pContent; } AFX_INLINE void CXTPChartControl::SetUpdateWindow(BOOL bUpdateWindow) { m_bUpdateWindow = bUpdateWindow; } AFX_INLINE CXTPToolTipContext* CXTPChartControl::GetToolTipContext() const { return m_pToolTipContext; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTCONTROL_H__) /** @endcond */