/** * @file XTPMarkupComboBox.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" #if defined(_XTP_INCLUDE_MARKUP) && !defined(_XTP_EXCLUDE_MARKUP) # 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/XTPDrawHelpers.h" # include "Common/XTPMarkupRender.h" # include "Common/XTPColorManager.h" # include "Common/Base/Types/XTPSize.h" # include "Markup/XTPMarkupContext.h" # include "Markup/XTPMarkupObject.h" # include "Markup/XTPMarkupInputElement.h" # include "Markup/XTPMarkupUIElement.h" # include "Markup/XTPMarkupDrawingContext.h" # include "Controls/Util/XTPControlTheme.h" # include "Controls/Combo/XTPComboBox.h" # include "Controls/Combo/XTPMarkupComboBox.h" # include # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" # ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; # endif XTP_MARKUP_COMBOBOXITEM::XTP_MARKUP_COMBOBOXITEM(CXTPMarkupContext* pContext) { this->pItem = NULL; this->pContext = pContext; } XTP_MARKUP_COMBOBOXITEM::~XTP_MARKUP_COMBOBOXITEM() { MARKUP_RELEASE(pItem); } void XTP_MARKUP_COMBOBOXITEM::Resolve(LPCTSTR lpszMarkup) { strMarkup = lpszMarkup; MARKUP_RELEASE(pItem); pItem = pContext->Parse(strMarkup); } ///////////////////////////////////////////////////////////////////////////// // CXTPMarkupComboBox CXTPMarkupComboBox::CXTPMarkupComboBox() { } CXTPMarkupComboBox::~CXTPMarkupComboBox() { } void CXTPMarkupComboBox::Init() { int Height = ComboBox_GetItemHeight(m_hWnd); ComboBox_SetItemHeight(m_hWnd, -1, XTP_DPI_X(Height)); } IMPLEMENT_DYNAMIC(CXTPMarkupComboBox, CXTPComboBox) # include "Common/Base/Diagnostic/XTPBeginAfxMap.h" BEGIN_MESSAGE_MAP(CXTPMarkupComboBox, CXTPComboBox) //{{AFX_MSG_MAP(CXTPMarkupComboBox) //}}AFX_MSG_MAP END_MESSAGE_MAP() # include "Common/Base/Diagnostic/XTPEndAfxMap.h" ///////////////////////////////////////////////////////////////////////////// // CXTPMarkupComboBox message handlers void CXTPMarkupComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rcItem(lpDrawItemStruct->rcItem); if (lpDrawItemStruct->itemState & ODS_SELECTED) pDC->FillSolidRect(rcItem, GetSysColor(COLOR_HIGHLIGHT)); else pDC->FillSolidRect(rcItem, GetBackColor()); XTP_MARKUP_COMBOBOXITEM* pComboItem = (XTP_MARKUP_COMBOBOXITEM*)lpDrawItemStruct->itemData; if (!pComboItem) return; if (!pComboItem->pItem) return; CXTPMarkupDrawingContext dc(lpDrawItemStruct->hDC); pComboItem->pItem->Arrange(lpDrawItemStruct->rcItem); pComboItem->pItem->Render(&dc); } } void CXTPMarkupComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) { XTP_MARKUP_COMBOBOXITEM* pComboItem = (XTP_MARKUP_COMBOBOXITEM*)lpMeasureItemStruct->itemData; if (!pComboItem) return; if (!pComboItem->pItem) return; CXTPClientRect rc(this); CXTPMarkupDrawingContext dc; pComboItem->pItem->Measure(&dc, CSize(rc.Width(), rc.Height())); CSize desiredSize = pComboItem->pItem->GetDesiredSize(); lpMeasureItemStruct->itemHeight = XTPToUIntChecked(pComboItem->pItem->GetDesiredSize().cy); } void CXTPMarkupComboBox::DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct) { delete (XTP_MARKUP_COMBOBOXITEM*)lpDeleteItemStruct->itemData; CXTPComboBox::DeleteItem(lpDeleteItemStruct); } void CXTPMarkupComboBox::AddMarkupString(LPCTSTR lpszMarkup) { XTP_MARKUP_COMBOBOXITEM* pComboItem = new XTP_MARKUP_COMBOBOXITEM(this); if (pComboItem) { pComboItem->Resolve(lpszMarkup); AddString((LPCTSTR)pComboItem); } } //#define CB_MSGMIN CB_ADDSTRING // First combobox message BOOL CXTPMarkupComboBox::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if ((NULL != m_hWnd)) { if (!IsDpiAware()) { SetDpiAware(TRUE, *this); } // if (((CB_MSGMIN > message) || (CB_MSGMAX < message)) && -1 != m_nHotItem) // { // XTP_MARKUP_COMBOBOXITEM* pItem = reinterpret_cast( // GetItemDataPtr(m_nHotItem)); // // // To Handle Hyperlinks: // if (pItem->pItem) // { // m_hContextWnd = m_hWnd; // // if (CXTPMarkupContext::OnWndMsg(pItem->pItem, message, wParam, lParam, // pResult)) return TRUE; // } // } } return CXTPComboBox::OnWndMsg(message, wParam, lParam, pResult); } #endif