/** * @file XTPMarkupControl.cpp * * @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 * */ #include "stdafx.h" #include "GraphicLibrary/GdiPlus/XTPGdiPlus.h" #include "Common/XTPTypeId.h" #include "Common/XTPCasting.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "Common/XTPSynchro.h" #include "Common/XTPApplication.h" #include "Common/XTPSingleton.h" #include "Common/XTPGdiObjects.h" #include "Common/Base/Types/XTPSize.h" #include #include "Markup/XTPMarkupContext.h" #include "Markup/XTPMarkupTools.h" #include "Markup/XTPMarkupObject.h" #include "Markup/XTPMarkupInputElement.h" #include "Markup/XTPMarkupUIElement.h" #include "Markup/XTPMarkupFrameworkElement.h" #include "Markup/Controls/XTPMarkupDecorator.h" #include "Markup/Controls/XTPMarkupBorder.h" #include "Markup/Controls/XTPMarkupControl.h" #include "Markup/Controls/XTPMarkupPanel.h" #include "Markup/XTPMarkupFrameworkContentElement.h" #include "Markup/Text/XTPMarkupTextElement.h" #include "Markup/XTPMarkupDrawingContext.h" #include "Markup/XTPMarkupThickness.h" #include "Markup/XTPMarkupIIDs.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # undef THIS_FILE static char THIS_FILE[] = __FILE__; # define new DEBUG_NEW #endif CXTPMarkupDependencyProperty* CXTPMarkupControl::m_pBackgroundProperty = NULL; CXTPMarkupDependencyProperty* CXTPMarkupControl::m_pForegroundProperty = NULL; CXTPMarkupDependencyProperty* CXTPMarkupControl::m_pPaddingProperty = NULL; IMPLEMENT_MARKUPCLASS(L"Control", CXTPMarkupControl, CXTPMarkupFrameworkElement) void CXTPMarkupControl::RegisterMarkupClass() { CXTPMarkupBorder::RegisterType(); CXTPMarkupPanel::RegisterType(); CXTPMarkupTextElement::RegisterType(); m_pPaddingProperty = CXTPMarkupBorder::m_pPaddingProperty->AddOwner( MARKUP_TYPE(CXTPMarkupControl)); m_pBackgroundProperty = CXTPMarkupPanel::m_pBackgroundProperty->AddOwner( MARKUP_TYPE(CXTPMarkupControl)); m_pForegroundProperty = CXTPMarkupTextElement::m_pForegroundProperty->AddOwner( MARKUP_TYPE(CXTPMarkupControl)); } CSize CXTPMarkupControl::ArrangeOverride(CSize szFinalSize) { if (GetVisualChildrenCount() > 0) { CXTPMarkupUIElement* pVisualChild = (CXTPMarkupUIElement*)GetVisualChild(0); pVisualChild->Arrange(CRect(0, 0, szFinalSize.cx, szFinalSize.cy)); } return szFinalSize; } CSize CXTPMarkupControl::MeasureOverride(CXTPMarkupDrawingContext* pDC, CSize szAvailableSize) { if (GetVisualChildrenCount() > 0) { CXTPMarkupUIElement* pVisualChild = (CXTPMarkupUIElement*)GetVisualChild(0); pVisualChild->Measure(pDC, szAvailableSize); return pVisualChild->GetDesiredSize(); } return CSize(0, 0); } CXTPMarkupBrush* CXTPMarkupControl::GetBackground() const { return MARKUP_STATICCAST(CXTPMarkupBrush, GetValue(m_pBackgroundProperty)); } void CXTPMarkupControl::SetBackground(CXTPMarkupBrush* pBrush) { SetValue(m_pBackgroundProperty, pBrush); } CXTPMarkupBrush* CXTPMarkupControl::GetForeground() const { return MARKUP_STATICCAST(CXTPMarkupBrush, GetValue(m_pForegroundProperty)); } void CXTPMarkupControl::SetForeground(CXTPMarkupBrush* pBrush) { SetValue(m_pForegroundProperty, pBrush); } void CXTPMarkupControl::SetPadding(int nLeft, int nTop, int nRight, int nBottom) { SetValue(m_pPaddingProperty, new CXTPMarkupThickness(nLeft, nTop, nRight, nBottom)); } void CXTPMarkupControl::SetPadding(int padding) { SetValue(m_pPaddingProperty, new CXTPMarkupThickness(padding)); } CXTPMarkupThickness* CXTPMarkupControl::GetPadding() const { return MARKUP_STATICCAST(CXTPMarkupThickness, GetValue(m_pPaddingProperty)); } #include "Common/Base/Diagnostic/XTPBeginAfxMap.h" BEGIN_DISPATCH_MAP(CXTPMarkupControl, CXTPMarkupFrameworkElement) DISP_PROPERTY_EX_ID(CXTPMarkupControl, "Background", 500, OleGetBackground, OleSetBackground, VT_DISPATCH) DISP_PROPERTY_EX_ID(CXTPMarkupControl, "Foreground", 501, OleGetForeground, OleSetForeground, VT_DISPATCH) DISP_PROPERTY_EX_ID(CXTPMarkupControl, "Padding", 502, OleGetPadding, OleSetPadding, VT_DISPATCH) END_DISPATCH_MAP() #include "Common/Base/Diagnostic/XTPEndAfxMap.h" #ifdef _XTP_ACTIVEX BEGIN_INTERFACE_MAP(CXTPMarkupControl, CXTPMarkupFrameworkElement) INTERFACE_PART(CXTPMarkupControl, XTPDIID_MarkupControl, Dispatch) END_INTERFACE_MAP() IMPLEMENT_OLETYPELIB_EX(CXTPMarkupControl, XTPDIID_MarkupControl) #endif LPDISPATCH CXTPMarkupControl::OleGetBackground() { return XTPGetDispatch(GetBackground()); } void CXTPMarkupControl::OleSetBackground(LPDISPATCH pDisp) { CXTPMarkupObject* pObject = FromDispatchAs(MARKUP_TYPE(CXTPMarkupBrush), pDisp); SetBackground(NULL != pObject ? static_cast(pObject) : NULL); } LPDISPATCH CXTPMarkupControl::OleGetForeground() { return XTPGetDispatch(GetForeground()); } void CXTPMarkupControl::OleSetForeground(LPDISPATCH pDisp) { CXTPMarkupObject* pObject = FromDispatchAs(MARKUP_TYPE(CXTPMarkupBrush), pDisp); SetForeground(NULL != pObject ? static_cast(pObject) : NULL); } LPDISPATCH CXTPMarkupControl::OleGetPadding() { return XTPGetDispatch(GetPadding()); } void CXTPMarkupControl::OleSetPadding(LPDISPATCH pDisp) { CXTPMarkupObject* pObject = FromDispatchAs(MARKUP_TYPE(CXTPMarkupThickness), pDisp); SetValue(m_pPaddingProperty, NULL != pObject ? static_cast(pObject) : NULL); }