/** * @file XTPMarkupInputElement.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(__XTPMARKUPINPUTELEMENT_H__) # define __XTPMARKUPINPUTELEMENT_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPMarkupString; class CXTPMarkupContext; class CXTPMarkupTriggerCollection; class CXTPMarkupEventHandlerMap; class CXTPMarkupDelegate; class CXTPMarkupDispatchDelegate; class CXTPMarkupRoutedEventArgs; class CXTPMarkupMouseEventArgs; class CXTPMarkupMouseWheelEventArgs; class CXTPMarkupQueryCursorEventArgs; class CXTPMarkupMouseButtonEventArgs; class CXTPMarkupTransformationMatrix; class _XTP_EXT_CLASS CXTPMarkupInputElement : public CXTPMarkupObject { /** @cond */ DECLARE_MARKUPCLASS(CXTPMarkupInputElement); /** @endcond */ protected: CXTPMarkupInputElement(); virtual ~CXTPMarkupInputElement(); public: virtual void OnMouseLeave(CXTPMarkupMouseEventArgs* e); virtual void OnMouseEnter(CXTPMarkupMouseEventArgs* e); virtual void OnMouseMove(CXTPMarkupMouseEventArgs* e); virtual void OnQueryCursor(CXTPMarkupQueryCursorEventArgs* e); virtual void OnMouseLeftButtonUp(CXTPMarkupMouseButtonEventArgs* e); virtual void OnMouseRightButtonUp(CXTPMarkupMouseButtonEventArgs* e); virtual void OnMouseLeftButtonDown(CXTPMarkupMouseButtonEventArgs* e); virtual void OnMouseRightButtonDown(CXTPMarkupMouseButtonEventArgs* e); virtual void OnLostMouseCapture(CXTPMarkupMouseEventArgs* e); CXTPMarkupContext* GetMarkupContext() const; virtual void OnMouseWheel(CXTPMarkupMouseWheelEventArgs* e); void Apply(); public: virtual CXTPMarkupInputElement* InputHitTest(CPoint point) const; BOOL IsMouseOver() const; CXTPMarkupObject* GetToolTip() const; void SetToolTip(LPCTSTR lpszTooltip); void AddHandler(CXTPMarkupRoutedEvent* pEvent, CXTPMarkupDelegate* pDelegate); CXTPMarkupObject* FindResource(const CXTPMarkupObject* pKey) const; void Focus(); BOOL IsKeyboardFocused() const; CXTPMarkupString* GetName() const; void SetName(LPCTSTR lpszName); protected: void RaiseEvent(CXTPMarkupRoutedEventArgs* pEventArgs); protected: void CaptureMouse(); void ReleaseMouseCapture(); protected: void FireTriggers(CXTPMarkupDependencyProperty* pProperty, CXTPMarkupObject* pNewValue); BOOL AddStyleTriggers(CXTPMarkupStyle* pStyle, CXTPMarkupDependencyProperty* pProperty, CXTPMarkupObject* pNewValue); protected: void SetPropertyObject(CXTPMarkupBuilder* pBuilder, CXTPMarkupDependencyProperty* pProperty, CXTPMarkupObject* pValue); virtual void OnFinalRelease(); virtual void OnApply(); void ApplyTree(CXTPMarkupObject* pChild); static void AFX_CDECL OnStylePropertyChanged(CXTPMarkupObject* d, CXTPMarkupPropertyChangedEventArgs* /*e*/); static void AFX_CDECL OnCursorPropertyChanged(CXTPMarkupObject* d, CXTPMarkupPropertyChangedEventArgs* e); virtual CXTPMarkupObject* GetValueCore(CXTPMarkupDependencyProperty* pProperty) const; protected: /** @cond */ public: DECLARE_DISPATCH_MAP() # ifdef _XTP_ACTIVEX DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPMarkupInputElement); # endif afx_msg long OleGetCursor(); afx_msg void OleSetCursor(long nValue); afx_msg VARIANT OleGetToolTip(); afx_msg void OleSetToolTip(const VARIANT& va); afx_msg BOOL OleGetIsMouseOver(); afx_msg void OleAddHandler(LPDISPATCH lpEventDisp, LPCOLESTR Method); afx_msg LPDISPATCH OleFindName(LPCOLESTR lpszName); void OleSetName(LPCTSTR lpszName); BSTR OleGetName(); afx_msg LPDISPATCH OleGetMouseLeaveEvent(); afx_msg LPDISPATCH OleGetMouseEnterEvent(); afx_msg LPDISPATCH OleGetMouseLeftButtonUpEvent(); afx_msg LPDISPATCH OleGetMouseLeftButtonDownEvent(); afx_msg LPDISPATCH OleGetMouseRightButtonUpEvent(); afx_msg LPDISPATCH OleGetMouseRightButtonDownEvent(); afx_msg LPDISPATCH OleGetMouseMoveEvent(); afx_msg LPDISPATCH OleGetLostMouseCaptureEvent(); afx_msg VARIANT OleGetMouseLeave(); afx_msg void OleSetMouseLeave(VARIANT& v); afx_msg VARIANT OleGetMouseEnter(); afx_msg void OleSetMouseEnter(VARIANT& v); afx_msg VARIANT OleGetMouseLeftButtonUp(); afx_msg void OleSetMouseLeftButtonUp(VARIANT& v); afx_msg VARIANT OleGetMouseLeftButtonDown(); afx_msg void OleSetMouseLeftButtonDown(VARIANT& v); afx_msg VARIANT OleGetMouseRightButtonUp(); afx_msg void OleSetMouseRightButtonUp(VARIANT& v); afx_msg VARIANT OleGetMouseRightButtonDown(); afx_msg void OleSetMouseRightButtonDown(VARIANT& v); afx_msg VARIANT OleGetMouseMove(); afx_msg void OleSetMouseMove(VARIANT& v); afx_msg VARIANT OleGetLostMouseCapture(); afx_msg void OleSetLostMouseCapture(VARIANT& v); /** @endcond */ protected: CXTPMarkupEventHandlerMap* AccessHandlers(); IDispatch* GetDispDelegate(CXTPMarkupDispatchDelegate* pDelegate); void SetDispDelegate(CXTPMarkupDispatchDelegate*& pDelegate, CXTPMarkupRoutedEvent* pEvent, IDispatch* pDisp); VARIANT GetDispDelegateVariant(CXTPMarkupDispatchDelegate* pDelegate); void SetDispDelegateVariant(CXTPMarkupDispatchDelegate*& pDelegate, CXTPMarkupRoutedEvent* pEvent, VARIANT v); protected: CXTPMarkupEventHandlerMap* m_pHandlers; CXTPMarkupContext* m_pMarkupContext; CXTPMarkupTriggerCollection* m_pActiveTriggers; CXTPMarkupProperties* m_pTriggerProperties; CXTPMarkupStyle* m_pStyleCache; CXTPMarkupDispatchDelegate* m_pMouseLeave; CXTPMarkupDispatchDelegate* m_pMouseEnter; CXTPMarkupDispatchDelegate* m_pMouseLeftButtonUp; CXTPMarkupDispatchDelegate* m_pMouseLeftButtonDown; CXTPMarkupDispatchDelegate* m_pMouseRightButtonUp; CXTPMarkupDispatchDelegate* m_pMouseRightButtonDown; CXTPMarkupDispatchDelegate* m_pMouseMove; CXTPMarkupDispatchDelegate* m_pLostMouseCapture; public: static CXTPMarkupDependencyProperty* m_pCursorProperty; static CXTPMarkupDependencyProperty* m_pIsMouseOverProperty; static CXTPMarkupDependencyProperty* m_pStyleProperty; static CXTPMarkupDependencyProperty* m_pResourcesProperty; static CXTPMarkupDependencyProperty* m_pToolTipProperty; static CXTPMarkupDependencyProperty* m_pIsKeyboardFocusedProperty; static CXTPMarkupDependencyProperty* m_pIsFocusableProperty; static CXTPMarkupRoutedEvent* m_pMouseLeaveEvent; static CXTPMarkupRoutedEvent* m_pMouseEnterEvent; static CXTPMarkupRoutedEvent* m_pMouseLeftButtonUpEvent; static CXTPMarkupRoutedEvent* m_pMouseLeftButtonDownEvent; static CXTPMarkupRoutedEvent* m_pMouseRightButtonUpEvent; static CXTPMarkupRoutedEvent* m_pMouseRightButtonDownEvent; static CXTPMarkupRoutedEvent* m_pMouseMoveEvent; static CXTPMarkupRoutedEvent* m_pLostMouseCaptureEvent; private: friend class CXTPMarkupContext; }; AFX_INLINE CXTPMarkupContext* CXTPMarkupInputElement::GetMarkupContext() const { return m_pMarkupContext; } /** * @brief * Provides rendering support for XML Markup, which includes hit testing, * coordinate transformation, and bounding box calculations. */ class _XTP_EXT_CLASS CXTPMarkupVisual : public CXTPMarkupInputElement { /** @cond */ DECLARE_MARKUPCLASS(CXTPMarkupVisual); /** @endcond */ public: /** * @brief * Provides the base initialization for objects derived from the * CXTPMarkupVisual class. */ CXTPMarkupVisual(); /** * @brief * Destroys a CXTPMarkupVisual object, handles cleanup and deallocation. */ virtual ~CXTPMarkupVisual(); public: /** * @brief * Call this method to draw a Visual object inside a drawing context. * @param drawingContext Drawing context to draw in. */ void Render(CXTPMarkupDrawingContext* drawingContext); /** * @brief * Determines if a point belongs to this object. * @param point Point to test. * @return * The CXTPMarkupInputElement at the specified point, if any, * otherwise NULL. */ CXTPMarkupInputElement* InputHitTest(CPoint point) const; public: /** * @brief * Gets the number of child elements for the Visual. * @details * By default, a Visual has no children. Therefore, the default * implementation always returns 0. * @return * The number of child elements for the Visual. */ virtual int GetVisualChildrenCount() const; /** * @brief * Retrieves the child Visual object located at a specified index within * the parent VisualCollection. * @param nIndex Specified index within the parent VisualCollection. * @return * The child Visual object located at the specified index within * the parent VisualCollection. */ virtual CXTPMarkupVisual* GetVisualChild(int nIndex) const; /** * @brief * Retrieves the number of logical child elements of this object. * @return * The number of logical child elements of this object. */ virtual int GetLogicalChildrenCount() const; /** * @brief * Retrieves the logical child element located at a specified index * within the parent collection. * @param nIndex Specified index within the parent collection. * @return * The logical child element located at the specified index within * the parent collection. * @details * Logical children allow you to iterate over child elements. This * is useful for elements that may not have a defined, dedicated * collection, but still contain more than one child element. */ virtual CXTPMarkupObject* GetLogicalChild(int nIndex) const; /** * @brief * Retrieves the bounding rectangle of the element. * @return * A CRect object containing the bounding rectangle of the element. */ CRect GetBoundRect() const; /** * @brief * Computes the update rectangle. * @return * The update rectangle. */ CRect GetUpdateRect() const; /** * @brief * Gets the final render size of this element. * @return * The final render size of this element. */ CSize GetRenderSize() const; /** * @brief * Gets or sets the offset value of the visual object. * @return * The offset value of the visual object. */ CPoint GetVisualOffset() const; /** * @brief * Retrieves an alternative clipping geometry that represents the region that * would be clipped if child elements were clipped inside element bounds. * @param rc The available size provided by the element. * @return * The potential clipping geometry. */ virtual BOOL GetLayoutClip(CRect& rc) const; /** * @brief * Gets the Visual tree parent of the Visual object. * @return * The Visual tree parent of the Visual object. */ CXTPMarkupVisual* GetVisualParent() const; /** * @brief * A structure that optionally describes the previous and the * new transformation matrices. */ struct TransformationMatrices { /** * @brief * Constructs an empty object. */ TransformationMatrices(); /** * @brief * Constructs an object with specified old and new tranformation matrices. * @param pOldMatrix A pointer to an old tranformation matrix. * @param pNewMatrix A pointer to a new tranformation matrix. */ TransformationMatrices(CXTPMarkupTransformationMatrix* pOldMatrix, CXTPMarkupTransformationMatrix* pNewMatrix); CXTPMarkupTransformationMatrix* pOldMatrix; /**< A pointer to an old tranformation matrix. */ CXTPMarkupTransformationMatrix* pNewMatrix; /**< A pointer to a new tranformation matrix. */ }; protected: /** * @brief * Applies render transformation if necessary. * @param pContext Drawing context to apply the render transformation for. * @return * A structure that optionally describes the previous and the new * transformation matrices. */ virtual TransformationMatrices ApplyRenderTransform(CXTPMarkupDrawingContext* pContext); /** * @brief * Restores a previously applied render transformation. * @param pContext Drawing context to restore the render transformation for. * @param matrices Transformation matrices previously returned by a call * to ApplyRenderTransform. */ virtual void RestoreRenderTransform(CXTPMarkupDrawingContext* pContext, TransformationMatrices& matrices); /** * @brief * Checks if a point is inside a rectangle with transformation applied. * @param rect Rectangle relative to object position. * @param point Point to check. * @return * TRUE if the point is inside the specified rectangle. */ BOOL PtInRectTransform(const RECT& rect, const POINT& point) const; /** * @brief * Gets the absolute element visual offset. * * @return The absolute element visual offset. */ POINT GetAbsoluteVisualOffset() const; /** * @brief * When overridden in a derived class, participates in rendering * operations that are directed by the layout system. * @param drawingContext Drawing context to draw in. */ virtual void OnRender(CXTPMarkupDrawingContext* drawingContext); /** * @brief * This method is called to render the focus rectangle of a * focused object. * @param drawingContext Drawing context to draw in. */ virtual void OnRenderFocusVisual(CXTPMarkupDrawingContext* drawingContext); /** * @brief * Override this method in the derived class to provide visual hit * testing of a child object. * @param point Position of the cursor to test. * @return * The CXTPMarkupInputElement at the specified position, if any, * otherwise NULL. */ virtual CXTPMarkupInputElement* InputHitTestOverride(CPoint point) const; /** * @brief * Called by the framework when an element is clipped and no rendering will occur. * @param drawingContext Pointer to the markup drawing context. */ virtual void RenderClipped(CXTPMarkupDrawingContext* drawingContext); /** * @brief * Gets either the default or explicitly set opacity factor value. * @return * An opacity factor value in the range 0..1. */ virtual double GetOpacity() const; /** * @brief * Checks if the element is currently visible. * @return * TRUE if visible, FALSE otherwise. */ virtual BOOL IsVisible() const; /** @cond */ // Internal methods protected: void UpdateBoundRect(); CXTPMarkupTransformationMatrix* GetAbsoluteTransformationMatrix() const; void SetCurrentTransformationMatrix(CXTPMarkupTransformationMatrix* pMatrix); /** @endcond */ /** @cond */ public: DECLARE_DISPATCH_MAP() # ifdef _XTP_ACTIVEX DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPMarkupVisual); # endif afx_msg LPDISPATCH OleGetVisualParent(); afx_msg void OleGetBoundingRect(int* left, int* top, int* right, int* bottom); afx_msg int OleGetActualWidth(); afx_msg int OleGetActualHeight(); /** @endcond */ protected: CPoint m_ptVisualOffset; /**< The offset value of the visual object. */ CSize m_szRenderSize; /**< The rendered size for this element. */ CRect m_rcBoundRect; /**< Bounding rectangle of the element */ CRect m_rcUpdateRect; /**< Update rectangle. */ CRect m_rcPrevUpdateRect; /**< Previous update rectangle. */ CXTPMarkupTransformationMatrix* m_pCurrentTransformationMatrix; }; AFX_INLINE CXTPMarkupVisual::TransformationMatrices::TransformationMatrices() : pOldMatrix(NULL) , pNewMatrix(NULL) { } AFX_INLINE CXTPMarkupVisual::TransformationMatrices::TransformationMatrices( CXTPMarkupTransformationMatrix* pOldMatrix, CXTPMarkupTransformationMatrix* pNewMatrix) : pOldMatrix(pOldMatrix) , pNewMatrix(pNewMatrix) { } AFX_INLINE void CXTPMarkupVisual::OnRender(CXTPMarkupDrawingContext* /*drawingContext*/) { } AFX_INLINE void CXTPMarkupVisual::OnRenderFocusVisual(CXTPMarkupDrawingContext* /*drawingContext*/) { } AFX_INLINE CXTPMarkupVisual::TransformationMatrices CXTPMarkupVisual::ApplyRenderTransform(CXTPMarkupDrawingContext* pContext) { UNREFERENCED_PARAMETER(pContext); return TransformationMatrices(); } AFX_INLINE void CXTPMarkupVisual::RestoreRenderTransform(CXTPMarkupDrawingContext* pContext, TransformationMatrices& matrices) { UNREFERENCED_PARAMETER(pContext); UNREFERENCED_PARAMETER(matrices); } AFX_INLINE CSize CXTPMarkupVisual::GetRenderSize() const { return m_szRenderSize; } AFX_INLINE CRect CXTPMarkupVisual::GetBoundRect() const { return m_rcBoundRect; } AFX_INLINE CPoint CXTPMarkupVisual::GetVisualOffset() const { return m_ptVisualOffset; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPMARKUPINPUTELEMENT_H__) /** @endcond */