/** * @file XTPSvgPreview.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 "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" #include #include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.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/XTPColorManager.h" #include "Common/XTPGdiObjects.h" #include "Common/XTPDrawHelpers.h" #include "GraphicLibrary/XTPSvgImage.h" #include "Controls/Preview/XTPPreviewAbstract.h" #include "Controls/Preview/Providers/Svg/XTPSvgPreview.h" #include "Controls/Resource.h" #include "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" #include #include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" CXTPSvgPreview::CXTPSvgPreview(IXTPPreviewHost& host, LPCTSTR pFilePath) : m_bLoadFinished(TRUE) , m_bLoadSuccess(FALSE) , m_pImage(new CXTPSvgImage()) , m_hwnd(NULL) , m_host(host) { m_bLoadSuccess = m_pImage->Load(pFilePath); } CXTPSvgPreview::CXTPSvgPreview(IXTPPreviewHost& host, IStream& stream, LPCTSTR pImpliedFileName) : m_bLoadFinished(TRUE) , m_bLoadSuccess(FALSE) , m_pImage(NULL) , m_hwnd(NULL) , m_host(host) { UNREFERENCED_PARAMETER(pImpliedFileName); m_bLoadSuccess = m_pImage->Load(&stream); } CXTPSvgPreview::~CXTPSvgPreview() { if (NULL != m_pImage) delete m_pImage; } BOOL CXTPSvgPreview::IsReady() const { return m_bLoadFinished; } BOOL CXTPSvgPreview::IsAvailable() const { return m_bLoadSuccess; } BOOL CXTPSvgPreview::HasOwnNavigator() const { return FALSE; } UINT CXTPSvgPreview::GetNumberOfPages() const { return 0; } SIZE CXTPSvgPreview::GetPreferredPageSize() const { CSize maxSize(INT_MAX, INT_MAX); if (::IsWindow(m_hwnd)) { CXTPClientRect rc(m_hwnd); maxSize = rc.Size(); } _ASSERTE(NULL != m_pImage); CSize imgSize = m_pImage->GetSize(); return CSize(__min(imgSize.cx, maxSize.cx), __min(imgSize.cy, maxSize.cy)); } void CXTPSvgPreview::GoToPage(UINT page) { UNREFERENCED_PARAMETER(page); } void CXTPSvgPreview::Draw(HDC dc, SIZE clientSize, RECT updateRect) { _ASSERTE(NULL != m_pImage); UNREFERENCED_PARAMETER(updateRect); if (!m_bLoadSuccess) return; if (0 == clientSize.cx || 0 == clientSize.cy) return; m_pImage->Draw(dc, updateRect); } BOOL CXTPSvgPreview::OnHostWndMsg(LPMSG msg, LRESULT* result) { XTP_UNUSED_PARAMETER(msg); XTP_UNUSED_PARAMETER(result); return FALSE; } BOOL CXTPSvgPreview::SupportsCompositedParent() const { return TRUE; } void CXTPSvgPreview::Activate() { // Does not support activation } #include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"