diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /vcl/inc/win | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/win')
-rw-r--r-- | vcl/inc/win/DWriteTextRenderer.hxx | 104 | ||||
-rw-r--r-- | vcl/inc/win/dnd_source.hxx | 124 | ||||
-rw-r--r-- | vcl/inc/win/dnd_target.hxx | 177 | ||||
-rw-r--r-- | vcl/inc/win/salbmp.h | 113 | ||||
-rw-r--r-- | vcl/inc/win/saldata.hxx | 301 | ||||
-rw-r--r-- | vcl/inc/win/salframe.h | 160 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 432 | ||||
-rw-r--r-- | vcl/inc/win/salids.hrc | 94 | ||||
-rw-r--r-- | vcl/inc/win/salinst.h | 91 | ||||
-rw-r--r-- | vcl/inc/win/salmenu.h | 68 | ||||
-rw-r--r-- | vcl/inc/win/salobj.h | 55 | ||||
-rw-r--r-- | vcl/inc/win/salprn.h | 118 | ||||
-rw-r--r-- | vcl/inc/win/salsys.h | 70 | ||||
-rw-r--r-- | vcl/inc/win/saltimer.h | 86 | ||||
-rw-r--r-- | vcl/inc/win/salvd.h | 70 | ||||
-rw-r--r-- | vcl/inc/win/scoped_gdi.hxx | 75 | ||||
-rw-r--r-- | vcl/inc/win/svsys.h | 33 | ||||
-rw-r--r-- | vcl/inc/win/wincomp.hxx | 231 | ||||
-rw-r--r-- | vcl/inc/win/wingdiimpl.hxx | 51 | ||||
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 102 |
20 files changed, 2555 insertions, 0 deletions
diff --git a/vcl/inc/win/DWriteTextRenderer.hxx b/vcl/inc/win/DWriteTextRenderer.hxx new file mode 100644 index 000000000..b64cc48a1 --- /dev/null +++ b/vcl/inc/win/DWriteTextRenderer.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX +#define INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX + +#include <usp10.h> +#include <d2d1.h> +#include <dwrite.h> + +#include <win/winlayout.hxx> + +enum class D2DTextAntiAliasMode +{ + Default, + Aliased, + AntiAliased, + ClearType, +}; + +class D2DWriteTextOutRenderer : public TextOutRenderer +{ +public: + explicit D2DWriteTextOutRenderer(bool bRenderingModeNatural); + virtual ~D2DWriteTextOutRenderer() override; + + bool operator()(GenericSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, + bool bRenderingModeNatural) override; + + HRESULT BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 0, 1, 1)); + + bool BindFont(HDC hDC) /*override*/; + bool ReleaseFont() /*override*/; + + std::vector<tools::Rectangle> GetGlyphInkBoxes(uint16_t const * pGid, uint16_t const * pGidEnd) const /*override*/; + ID2D1RenderTarget * GetRenderTarget() const { return mpRT; } + IDWriteFontFace * GetFontFace() const { return mpFontFace; } + float GetEmHeight() const { return mlfEmHeight; } + + HRESULT CreateRenderTarget(bool bRenderingModeNatural); + + bool Ready() const; + + void applyTextAntiAliasMode(bool bRenderingModeNatural); + + bool GetRenderingModeNatural() const { return mbRenderingModeNatural; } + +private: + // This is a singleton object disable copy ctor and assignment operator + D2DWriteTextOutRenderer(const D2DWriteTextOutRenderer &) = delete; + D2DWriteTextOutRenderer & operator = (const D2DWriteTextOutRenderer &) = delete; + + bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * lfSize) const; + bool performRender(GenericSalLayout const &rLayout, SalGraphics &rGraphics, HDC hDC, bool& bRetry, bool bRenderingModeNatural); + + ID2D1Factory * mpD2DFactory; + IDWriteFactory * mpDWriteFactory; + IDWriteGdiInterop * mpGdiInterop; + ID2D1DCRenderTarget * mpRT; + const D2D1_RENDER_TARGET_PROPERTIES mRTProps; + + IDWriteFontFace * mpFontFace; + float mlfEmHeight; + HDC mhDC; + bool mbRenderingModeNatural; + D2DTextAntiAliasMode meTextAntiAliasMode; +}; + +/** + * Sets and unsets the needed DirectWrite transform to support the font's horizontal scaling and + * rotation. + */ +class WinFontTransformGuard +{ +public: + WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool bIsVertical); + ~WinFontTransformGuard(); + +private: + ID2D1RenderTarget* mpRenderTarget; + D2D1::Matrix3x2F maTransform; +}; + +#endif // INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/dnd_source.hxx b/vcl/inc/win/dnd_source.hxx new file mode 100644 index 000000000..ea794f069 --- /dev/null +++ b/vcl/inc/win/dnd_source.hxx @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/datatransfer/dnd/XDragSource.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <osl/mutex.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <oleidl.h> + +#include <systools/win32/comtools.hxx> + +namespace com::sun::star::uno { class XComponentContext; } + +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace cppu; +using namespace osl; +using namespace ::com::sun::star::datatransfer; +using namespace ::com::sun::star::datatransfer::dnd; + +class SourceContext; +// RIGHT MOUSE BUTTON drag and drop not supported currently. +// ALT modifier is considered to effect a user selection of effects +class DragSource: + public cppu::BaseMutex, + public WeakComponentImplHelper<XDragSource, XInitialization, XServiceInfo>, + public IDropSource + +{ + Reference<XComponentContext> m_xContext; + HWND m_hAppWindow; + + // The mouse button that set off the drag and drop operation + short m_MouseButton; + + // First starting a new drag and drop thread if + // the last one has finished + void StartDragImpl( + const DragGestureEvent& trigger, + sal_Int8 sourceActions, + sal_Int32 cursor, + sal_Int32 image, + const Reference<XTransferable >& trans, + const Reference<XDragSourceListener >& listener); + +public: + LONG m_RunningDndOperationCount; + +public: + // only valid for one dnd operation + // the thread ID of the thread which created the window + DWORD m_threadIdWindow; + // The context notifies the XDragSourceListener s + Reference<XDragSourceContext> m_currentContext; + + // the wrapper for the Transferable ( startDrag) + IDataObjectPtr m_spDataObject; + + sal_Int8 m_sourceActions; + +public: + explicit DragSource(const Reference<XComponentContext>& rxContext); + virtual ~DragSource() override; + DragSource(const DragSource&) = delete; + DragSource &operator= ( const DragSource&) = delete; + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override; + + // XDragSource + virtual sal_Bool SAL_CALL isDragImageSupported( ) override; + virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) override; + virtual void SAL_CALL startDrag( const DragGestureEvent& trigger, + sal_Int8 sourceActions, + sal_Int32 cursor, + sal_Int32 image, + const Reference<XTransferable >& trans, + const Reference<XDragSourceListener >& listener ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + /* [in] */ REFIID riid, + /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) override; + + virtual ULONG STDMETHODCALLTYPE AddRef( ) override; + + virtual ULONG STDMETHODCALLTYPE Release( ) override; + + // IDropSource + virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( + /* [in] */ BOOL fEscapePressed, + /* [in] */ DWORD grfKeyState) override; + + virtual HRESULT STDMETHODCALLTYPE GiveFeedback( + /* [in] */ DWORD dwEffect) override; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/dnd_target.hxx b/vcl/inc/win/dnd_target.hxx new file mode 100644 index 000000000..4c4e8eebc --- /dev/null +++ b/vcl/inc/win/dnd_target.hxx @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <osl/mutex.hxx> + +#include <oleidl.h> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace cppu; +using namespace osl; +using namespace ::com::sun::star::datatransfer; +using namespace ::com::sun::star::datatransfer::dnd; + +// The client +// has to call XComponent::dispose. The thread that calls initialize +// must also execute the destruction of the instance. This is because +// initialize calls OleInitialize and the destructor calls OleUninitialize. +// If the service calls OleInitialize then it also calls OleUnitialize when +// it is destroyed. Therefore no second instance may exist which was +// created in the same thread and still needs OLE. +class DropTarget : public cppu::BaseMutex, + public WeakComponentImplHelper<XInitialization, XDropTarget, XServiceInfo> + +{ +private: + friend DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams); + // The native window which acts as drop target. + // It is set in initialize. In case RegisterDragDrop fails it is set + // to NULL + HWND m_hWnd; // set by initialize + // Holds the thread id of the thread which created the window that is the + // drop target. Only used when DropTarget::initialize is called from an MTA + // thread + DWORD m_threadIdWindow; + // This is the thread id of the OLE thread that is created in DropTarget::initialize + // when the calling thread is an MTA + DWORD m_threadIdTarget; + // The handle of the thread that is created in DropTarget::initialize + // when the calling thread is an MTA + HANDLE m_hOleThread; + // The thread id of the thread which called initialize. When the service dies + // than m_oleThreadId is used to determine if the service successfully called + // OleInitialize. If so then OleUninitialize has to be called. + DWORD m_oleThreadId; + // An Instance of IDropTargetImpl which receives calls from the system's drag + // and drop implementation. It delegate the calls to name alike functions in + // this class. + IDropTarget* m_pDropTarget; + + Reference<XComponentContext> m_xContext; + // If m_bActive == sal_True then events are fired to XDropTargetListener s, + // none otherwise. The default value is sal_True. + bool m_bActive; + sal_Int8 m_nDefaultActions; + + // This value is set when a XDropTargetListener calls accept or reject on + // the XDropTargetDropContext or XDropTargetDragContext. + // The values are from the DNDConstants group. + sal_Int8 m_nCurrentDropAction; + // This value is manipulated by the XDropTargetListener + sal_Int8 m_nLastDropAction; + + Reference<XTransferable> m_currentData; + // The current action is used to determine if the USER + // action has changed (dropActionChanged) + // sal_Int8 m_userAction; + // Set by listeners when they call XDropTargetDropContext::dropComplete + bool m_bDropComplete; + Reference<XDropTargetDragContext> m_currentDragContext; + Reference<XDropTargetDropContext> m_currentDropContext; + +public: + explicit DropTarget(const Reference<XComponentContext>& rxContext); + virtual ~DropTarget() override; + DropTarget(DropTarget const&) = delete; + DropTarget& operator=(DropTarget const&) = delete; + + // Overrides WeakComponentImplHelper::disposing which is called by + // WeakComponentImplHelper::dispose + // Must be called. + virtual void SAL_CALL disposing() override; + // XInitialization + virtual void SAL_CALL initialize(const Sequence<Any>& aArguments) override; + + // XDropTarget + virtual void SAL_CALL addDropTargetListener(const Reference<XDropTargetListener>& dtl) override; + virtual void SAL_CALL + removeDropTargetListener(const Reference<XDropTargetListener>& dtl) override; + // Default is not active + virtual sal_Bool SAL_CALL isActive() override; + virtual void SAL_CALL setActive(sal_Bool isActive) override; + virtual sal_Int8 SAL_CALL getDefaultActions() override; + virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // Functions called from the IDropTarget implementation ( m_pDropTarget) + virtual HRESULT DragEnter( + /* [unique][in] */ IDataObject* pDataObj, + /* [in] */ DWORD grfKeyState, + /* [in] */ POINTL pt, + /* [out][in] */ DWORD* pdwEffect); + + virtual HRESULT STDMETHODCALLTYPE DragOver( + /* [in] */ DWORD grfKeyState, + /* [in] */ POINTL pt, + /* [out][in] */ DWORD* pdwEffect); + + virtual HRESULT STDMETHODCALLTYPE DragLeave(); + + virtual HRESULT STDMETHODCALLTYPE Drop( + /* [unique][in] */ IDataObject* pDataObj, + /* [in] */ DWORD grfKeyState, + /* [in] */ POINTL pt, + /* [out][in] */ DWORD* pdwEffect); + + // Non - interface functions -------------------------------------------------- + // XDropTargetDropContext delegated from DropContext + + void _acceptDrop(sal_Int8 dropOperation, const Reference<XDropTargetDropContext>& context); + void _rejectDrop(const Reference<XDropTargetDropContext>& context); + void _dropComplete(bool success, const Reference<XDropTargetDropContext>& context); + + // XDropTargetDragContext delegated from DragContext + void _acceptDrag(sal_Int8 dragOperation, const Reference<XDropTargetDragContext>& context); + void _rejectDrag(const Reference<XDropTargetDragContext>& context); + +protected: + // Gets the current action dependent on the pressed modifiers, the effects + // supported by the drop source (IDropSource) and the default actions of the + // drop target (XDropTarget, this class)) + inline sal_Int8 getFilteredActions(DWORD grfKeyState, DWORD sourceActions); + // Only filters with the default actions + inline sal_Int8 getFilteredActions(DWORD grfKeyState); + + void fire_drop(const DropTargetDropEvent& dte); + void fire_dragEnter(const DropTargetDragEnterEvent& dtde); + void fire_dragExit(const DropTargetEvent& dte); + void fire_dragOver(const DropTargetDragEvent& dtde); + void fire_dropActionChanged(const DropTargetDragEvent& dtde); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h new file mode 100644 index 000000000..c8fe3d851 --- /dev/null +++ b/vcl/inc/win/salbmp.h @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALBMP_H +#define INCLUDED_VCL_INC_WIN_SALBMP_H + +#include <tools/gen.hxx> +#include <win/wincomp.hxx> +#include <salbmp.hxx> +#include <basegfx/utils/systemdependentdata.hxx> +#include <memory> + + +struct BitmapBuffer; +class BitmapColor; +class BitmapPalette; +class SalGraphics; +namespace Gdiplus { class Bitmap; } + +class WinSalBitmap final: public SalBitmap, public basegfx::SystemDependentDataHolder +{ +private: + Size maSize; + HGLOBAL mhDIB; + HBITMAP mhDDB; + + sal_uInt16 mnBitCount; + + std::shared_ptr<Gdiplus::Bitmap> ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource); + std::shared_ptr<Gdiplus::Bitmap> ImplCreateGdiPlusBitmap(); + +public: + + HGLOBAL ImplGethDIB() const { return mhDIB; } + HBITMAP ImplGethDDB() const { return mhDDB; } + + std::shared_ptr< Gdiplus::Bitmap > ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = nullptr) const; + + static HGLOBAL ImplCreateDIB( const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal ); + static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB ); + static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB ); + +public: + + WinSalBitmap(); + virtual ~WinSalBitmap() override; + +public: + + bool Create( HANDLE hBitmap ); + virtual bool Create( const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal ) override; + virtual bool Create( const SalBitmap& rSalBmpImpl ) override; + virtual bool Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics ) override; + virtual bool Create( const SalBitmap& rSalBmpImpl, vcl::PixelFormat eNewPixelFormat ) override; + virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas, + Size& rSize, + bool bMask = false ) override; + + virtual void Destroy() override; + + virtual Size GetSize() const override { return maSize; } + virtual sal_uInt16 GetBitCount() const override { return mnBitCount; } + + virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override; + virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override; + virtual bool GetSystemData( BitmapSystemData& rData ) override; + + virtual bool ScalingSupported() const override; + virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; + + // exclusive management op's for SystemDependentData at WinSalBitmap + template<class T> + std::shared_ptr<T> getSystemDependentData() const + { + return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code())); + } + + template<class T, class... Args> + std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const + { + std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...); + + // tdf#129845 only add to buffer if a relevant buffer time is estimated + if(r->calculateCombinedHoldCyclesInSeconds() > 0) + { + basegfx::SystemDependentData_SharedPtr r2(r); + const_cast< WinSalBitmap* >(this)->basegfx::SystemDependentDataHolder::addOrReplaceSystemDependentData(r2); + } + + return r; + } +}; + +#endif // INCLUDED_VCL_INC_WIN_SALBMP_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx new file mode 100644 index 000000000..dce54d03f --- /dev/null +++ b/vcl/inc/win/saldata.hxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALDATA_HXX +#define INCLUDED_VCL_INC_WIN_SALDATA_HXX + +#include <config_features.h> + +#include <memory> +#include <osl/module.h> + +#include <svdata.hxx> +#include <salwtype.hxx> + +#include <systools/win32/comtools.hxx> +#include <tools/long.hxx> + +#include <win/wincomp.hxx> + +#include <set> +#include <map> + +class AutoTimer; +class WinSalInstance; +class WinSalObject; +class WinSalFrame; +class WinSalVirtualDevice; +class WinSalPrinter; +namespace vcl { class Font; } +struct HDCCache; +struct TempFontItem; +class TextOutRenderer; +#if HAVE_FEATURE_SKIA +class SkiaControlsCache; +#endif + +#define MAX_STOCKPEN 4 +#define MAX_STOCKBRUSH 4 +#define SAL_CLIPRECT_COUNT 16 + +struct SalIcon +{ + int nId; + HICON hIcon; + HICON hSmallIcon; + SalIcon *pNext; +}; + +class SalData : public sal::systools::CoInitializeGuard +{ +public: + SalData(); + ~SalData(); + + // native widget framework + static void initNWF(); + static void deInitNWF(); + + // fill maVKMap; + void initKeyCodeMap(); + + // checks if the menuhandle was created by VCL + bool IsKnownMenuHandle( HMENU hMenu ); + + bool mbResourcesAlreadyFreed; + +public: + HINSTANCE mhInst; // default instance handle + int mnCmdShow; // default frame show style + HPALETTE mhDitherPal; // dither palette + HGLOBAL mhDitherDIB; // dither memory handle + BYTE* mpDitherDIB; // dither memory + BYTE* mpDitherDIBData; // beginning of DIB data + tools::Long* mpDitherDiff; // Dither mapping table + BYTE* mpDitherLow; // Dither mapping table + BYTE* mpDitherHigh; // Dither mapping table + HHOOK mhSalObjMsgHook; // hook to get interesting msg for SalObject + HWND mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message + AutoTimer* mpMouseLeaveTimer; // Timer for MouseLeave Test + WinSalInstance* mpInstance; + WinSalFrame* mpFirstFrame; // pointer of first frame + WinSalObject* mpFirstObject; // pointer of first object window + WinSalVirtualDevice* mpFirstVD; // first VirDev + WinSalPrinter* mpFirstPrinter; // first printing printer + HDCCache* mpHDCCache; // Cache for three DC's + HBITMAP mh50Bmp; // 50% Bitmap + HBRUSH mh50Brush; // 50% Brush + COLORREF maStockPenColorAry[MAX_STOCKPEN]; + COLORREF maStockBrushColorAry[MAX_STOCKBRUSH]; + HPEN mhStockPenAry[MAX_STOCKPEN]; + HBRUSH mhStockBrushAry[MAX_STOCKBRUSH]; + sal_uInt16 mnStockPenCount; // count of static pens + sal_uInt16 mnStockBrushCount; // count of static brushes + WPARAM mnSalObjWantKeyEvt; // KeyEvent that should be processed by SalObj-Hook + BYTE mnCacheDCInUse; // count of CacheDC in use + bool mbObjClassInit; // is SALOBJECTCLASS initialised + bool mbInPalChange; // is in WM_QUERYNEWPALETTE + DWORD mnAppThreadId; // Id from Application-Thread + BOOL mbScrSvrEnabled; // ScreenSaver enabled + SalIcon* mpFirstIcon; // icon cache, points to first icon, NULL if none + TempFontItem* mpSharedTempFontItem; // LibreOffice shared fonts + TempFontItem* mpOtherTempFontItem; // other temporary fonts (embedded?) + bool mbThemeChanged; // true if visual theme was changed: throw away theme handles + bool mbThemeMenuSupport; + + // for GdiPlus GdiplusStartup/GdiplusShutdown + ULONG_PTR gdiplusToken; + + std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle() + std::map< UINT,sal_uInt16 > maVKMap; // map some dynamic VK_* entries + + std::unique_ptr<TextOutRenderer> m_pD2DWriteTextOutRenderer; + // tdf#107205 need 2 instances because D2DWrite can't rotate text + std::unique_ptr<TextOutRenderer> m_pExTextOutRenderer; +#if HAVE_FEATURE_SKIA + std::unique_ptr<SkiaControlsCache> m_pSkiaControlsCache; +#endif +}; + +struct SalShlData +{ + HINSTANCE mhInst; // Instance of SAL-DLL + UINT mnWheelScrollLines; // WheelScrollLines + UINT mnWheelScrollChars; // WheelScrollChars +}; + +extern SalShlData aSalShlData; + +#define CACHESIZE_HDC 3 +#define CACHED_HDC_1 0 +#define CACHED_HDC_2 1 +#define CACHED_HDC_DRAW 2 +#define CACHED_HDC_DEFEXT 64 + +struct HDCCache +{ + HDC mhDC; + HPALETTE mhDefPal; + HBITMAP mhDefBmp; + HBITMAP mhSelBmp; + HBITMAP mhActBmp; +}; + +void ImplClearHDCCache( SalData* pData ); +HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr ); +void ImplReleaseCachedDC( sal_uLong nID ); + +void ImplReleaseTempFonts(SalData&, bool bAll); + +HCURSOR ImplLoadSalCursor( int nId ); +HBITMAP ImplLoadSalBitmap( int nId ); +bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon ); + +void ImplInitSalGDI(); +void ImplFreeSalGDI(); + +void ImplSalYieldMutexAcquireWithWait( sal_uInt32 nCount = 1 ); +bool ImplSalYieldMutexTryToAcquire(); +void ImplSalYieldMutexRelease(); + +LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); + +void SalTestMouseLeave(); + +bool ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ); +bool ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam ); +bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult ); + +WinSalObject* ImplFindSalObject( HWND hWndChild ); +bool ImplSalPreDispatchMsg( const MSG* pMsg ); +void ImplSalPostDispatchMsg( const MSG* pMsg ); + +void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Font& rFont ); + +rtl_TextEncoding ImplSalGetSystemEncoding(); +OUString ImplSalGetUniString(const char* pStr, sal_Int32 nLen = -1); +int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ); + +#define SAL_FRAME_WNDEXTRA sizeof( DWORD ) +#define SAL_FRAME_THIS GWLP_USERDATA +#define SAL_FRAME_CLASSNAMEW L"SALFRAME" +#define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME" +#define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME" +#define SAL_OBJECT_WNDEXTRA sizeof( DWORD ) +#define SAL_OBJECT_THIS GWLP_USERDATA +#define SAL_OBJECT_CLASSNAMEW L"SALOBJECT" +#define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD" +#define SAL_COM_CLASSNAMEW L"SALCOMWND" + +#define SAL_MOUSELEAVE_TIMEOUT 300 + +// wParam == bWait; lParam == 0 +#define SAL_MSG_THREADYIELD (WM_USER+111) +// wParam == 0; lParam == nMS +#define SAL_MSG_STARTTIMER (WM_USER+113) +// wParam == nFrameStyle; lParam == pParent; lResult == pFrame +#define SAL_MSG_CREATEFRAME (WM_USER+114) +// wParam == 0; lParam == 0 +#define SAL_MSG_DESTROYFRAME (WM_USER+115) +// wParam == 0; lParam == pParent; lResult == pObject +#define SAL_MSG_CREATEOBJECT (WM_USER+116) +// wParam == 0; lParam == pObject; +#define SAL_MSG_DESTROYOBJECT (WM_USER+117) +// wParam == hWnd; lParam == 0; lResult == hDC +#define SAL_MSG_GETCACHEDDC (WM_USER+120) +// wParam == hWnd; lParam == 0 +#define SAL_MSG_RELEASEDC (WM_USER+121) +// wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd +#define SAL_MSG_RECREATEHWND (WM_USER+122) +// wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd +#define SAL_MSG_RECREATECHILDHWND (WM_USER+123) +// wParam == 0; lParam == HWND; +#define SAL_MSG_DESTROYHWND (WM_USER+124) + +// wParam == 0; lParam == pData +#define SAL_MSG_USEREVENT (WM_USER+130) +// wParam == 0; lParam == MousePosition relative to upper left of screen +#define SAL_MSG_MOUSELEAVE (WM_USER+131) +// NULL-Message, should not be processed +#define SAL_MSG_DUMMY (WM_USER+132) +// Used for SETFOCUS and KILLFOCUS +// wParam == 0; lParam == 0 +#define SAL_MSG_POSTFOCUS (WM_USER+133) +// wParam == wParam; lParam == lParam +#define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134) +// wParam == wParam; lParam == lParam +#define SAL_MSG_POSTPALCHANGED (WM_USER+135) +// wParam == wParam; lParam == lParam +#define SAL_MSG_POSTMOVE (WM_USER+136) +// wParam == wParam; lParam == lParam +#define SAL_MSG_POSTCALLSIZE (WM_USER+137) +// wParam == pRECT; lParam == 0 +#define SAL_MSG_POSTPAINT (WM_USER+138) +// wParam == 0; lParam == pFrame; lResult 0 +#define SAL_MSG_FORCEPALETTE (WM_USER+139) +// wParam == 0; lParam == 0 +#define SAL_MSG_CAPTUREMOUSE (WM_USER+140) +// wParam == 0; lParam == 0 +#define SAL_MSG_RELEASEMOUSE (WM_USER+141) +// wParam == nFlags; lParam == 0 +#define SAL_MSG_TOTOP (WM_USER+142) +// wParam == bVisible; lParam == 0 +#define SAL_MSG_SHOW (WM_USER+143) +// wParam == 0; lParam == SalInputContext +#define SAL_MSG_SETINPUTCONTEXT (WM_USER+144) +// wParam == nFlags; lParam == 0 +#define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145) + +// SysChild-ToTop; wParam = 0; lParam = 0 +#define SALOBJ_MSG_TOTOP (WM_USER+160) +// Used for SETFOCUS and KILLFOCUS +// POSTFOCUS-Message; wParam == bFocus; lParam == 0 +#define SALOBJ_MSG_POSTFOCUS (WM_USER+161) + +// Call the Timer's callback from the main thread +// wParam = 1 == run when yield is idle instead of direct +#define SAL_MSG_TIMER_CALLBACK (WM_USER+162) +// Stop the timer from the main thread; wParam = 0, lParam = 0 +#define SAL_MSG_STOPTIMER (WM_USER+163) +// Start a real timer while GUI is blocked by native dialog +#define SAL_MSG_FORCE_REAL_TIMER (WM_USER+164) + +inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis ) +{ + SetWindowLongPtrW( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) ); +} + +inline WinSalFrame* GetWindowPtr( HWND hWnd ) +{ + return reinterpret_cast<WinSalFrame*>(GetWindowLongPtrW( hWnd, SAL_FRAME_THIS )); +} + +inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis ) +{ + SetWindowLongPtrW( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) ); +} + +inline WinSalObject* GetSalObjWindowPtr( HWND hWnd ) +{ + return reinterpret_cast<WinSalObject*>(GetWindowLongPtrW( hWnd, SAL_OBJECT_THIS )); +} + +#endif // INCLUDED_VCL_INC_WIN_SALDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h new file mode 100644 index 000000000..e3d8b685a --- /dev/null +++ b/vcl/inc/win/salframe.h @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALFRAME_H +#define INCLUDED_VCL_INC_WIN_SALFRAME_H + +#include <sal/config.h> + +#include <string_view> + +#include <vcl/sysdata.hxx> +#include <salframe.hxx> +#include <svsys.h> + +class WinSalGraphics; + + +class WinSalFrame final: public SalFrame +{ +public: + HWND mhWnd; // Window handle + HCURSOR mhCursor; // cursor handle + HIMC mhDefIMEContext; // default IME-Context + WinSalGraphics* mpLocalGraphics; // current main thread frame graphics + WinSalGraphics* mpThreadGraphics; // current frame graphics for other threads (DCX_CACHE) + WinSalFrame* mpNextFrame; // pointer to next frame + HMENU mSelectedhMenu; // the menu where highlighting is currently going on + HMENU mLastActivatedhMenu; // the menu that was most recently opened + SystemEnvData maSysData; // system data + SalFrameState maState = {}; // frame state + int mnShowState; // show state + LONG mnWidth; // client width in pixeln + LONG mnHeight; // client height in pixeln + int mnMinWidth; // min. client width in pixeln + int mnMinHeight; // min. client height in pixeln + int mnMaxWidth; // max. client width in pixeln + int mnMaxHeight; // max. client height in pixeln + RECT maFullScreenRect; // fullscreen rect + int mnFullScreenShowState; // fullscreen restore show state + bool mbFullScreenCaption; // WS_CAPTION reset in full screen mode. + UINT mnInputLang; // current Input Language + UINT mnInputCodePage; // current Input CodePage + SalFrameStyleFlags mnStyle; // style + bool mbGraphics; // is Graphics used + bool mbCaption; // has window a caption + bool mbBorder; // has window a border + bool mbFixBorder; // has window a fixed border + bool mbSizeBorder; // has window a sizeable border + bool mbNoIcon; // is a window without an icon + bool mbFloatWin; // is a FloatingWindow + bool mbFullScreen; // TRUE: in full screen mode + bool mbPresentation; // TRUE: Presentation Mode running + bool mbInShow; // inside a show call + bool mbRestoreMaximize; // Restore-Maximize + bool mbInMoveMsg; // Move-Message is being processed + bool mbInSizeMsg; // Size-Message is being processed + bool mbFullScreenToolWin; // WS_EX_TOOLWINDOW reset in FullScreenMode + bool mbDefPos; // default-position + bool mbOverwriteState; // TRUE: possible to change WindowState + bool mbIME; // TRUE: We are in IME Mode + bool mbHandleIME; // TRUE: We are handling the IME-Messages + bool mbSpezIME; // TRUE: special IME + bool mbAtCursorIME; // TRUE: We are only handling some IME-Messages + bool mbCandidateMode; // TRUE: We are in Candidate-Mode + static bool mbInReparent; // TRUE: ignore focus lost and gain due to reparenting + + RGNDATA* mpClipRgnData; + RECT* mpNextClipRect; + bool mbFirstClipRect; + sal_Int32 mnDisplay; // Display used for Fullscreen, 0 is primary monitor + bool mbPropertiesStored; // has values stored in the window property store + + void updateScreenNumber(); + +private: + void ImplSetParentFrame( HWND hNewParentWnd, bool bAsChild ); + bool InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, HWND hWnd ); + bool ReleaseFrameGraphicsDC( WinSalGraphics* pGraphics ); + +public: + WinSalFrame(); + virtual ~WinSalFrame() override; + + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; + virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override; + virtual void SetTitle( const OUString& rTitle ) override; + virtual void SetIcon( sal_uInt16 nIcon ) override; + virtual void SetMenu( SalMenu* pSalMenu ) override; + virtual void DrawMenuBar() override; + virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override; + virtual void Show( bool bVisible, bool bNoActivate = false ) override; + virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override; + virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override; + virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override; + virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override; + virtual void GetWorkArea( tools::Rectangle& rRect ) override; + virtual SalFrame* GetParent() const override; + virtual void SetWindowState( const SalFrameState* pState ) override; + virtual bool GetWindowState( SalFrameState* pState ) override; + virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override; + virtual void StartPresentation( bool bStart ) override; + virtual void SetAlwaysOnTop( bool bOnTop ) override; + virtual void ToTop( SalFrameToTop nFlags ) override; + virtual void SetPointer( PointerStyle ePointerStyle ) override; + virtual void CaptureMouse( bool bMouse ) override; + virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override; + using SalFrame::Flush; + virtual void Flush() override; + virtual void SetInputContext( SalInputContext* pContext ) override; + virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override; + virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override; + virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override; + virtual LanguageType GetInputLanguage() override; + virtual void UpdateSettings( AllSettings& rSettings ) override; + virtual void Beep() override; + virtual const SystemEnvData* GetSystemData() const override; + virtual SalPointerState GetPointerState() override; + virtual KeyIndicatorState GetIndicatorState() override; + virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override; + virtual void SetParent( SalFrame* pNewParent ) override; + virtual void SetPluginParent( SystemParentData* pNewParent ) override; + virtual void SetScreenNumber( unsigned int ) override; + virtual void SetApplicationID( const OUString &rApplicationID ) override; + virtual void ResetClipRegion() override; + virtual void BeginSetClipRegion( sal_uInt32 nRects ) override; + virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + virtual void EndSetClipRegion() override; +}; + +void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ); + +bool UseDarkMode(); + +// get foreign key names +namespace vcl_sal { + OUString getKeysReplacementName( + std::u16string_view pLang, + LONG nSymbol ); +} + +#endif // INCLUDED_VCL_INC_WIN_SALFRAME_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h new file mode 100644 index 000000000..7833f988b --- /dev/null +++ b/vcl/inc/win/salgdi.h @@ -0,0 +1,432 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <sallayout.hxx> +#include <salgeom.hxx> +#include <salgdi.hxx> +#include <fontinstance.hxx> +#include <fontattributes.hxx> +#include <font/PhysicalFontFace.hxx> +#include <impfont.hxx> +#include <vcl/fontcapabilities.hxx> +#include <vcl/fontcharmap.hxx> + +#include <memory> +#include <unordered_set> + +#ifndef INCLUDED_PRE_POST_WIN_H +#define INCLUDED_PRE_POST_WIN_H +# include <prewin.h> +# include <postwin.h> +#endif + +#include <hb-ot.h> +#include <dwrite.h> + +namespace vcl::font +{ +class PhysicalFontCollection; +class FontSelectPattern; +} +class WinFontInstance; +class ImplFontAttrCache; +class SalGraphicsImpl; +class WinSalGraphicsImplBase; +class ImplFontMetricData; + +#define RGB_TO_PALRGB(nRGB) ((nRGB)|0x02000000) +#define PALRGB_TO_RGB(nPalRGB) ((nPalRGB)&0x00ffffff) + +// win32 specific physically available font face +class WinFontFace : public vcl::font::PhysicalFontFace +{ +public: + explicit WinFontFace( const FontAttributes&, + BYTE eWinCharSet, + BYTE nPitchAndFamily ); + virtual ~WinFontFace() override; + + virtual rtl::Reference<LogicalFontInstance> CreateFontInstance( const vcl::font::FontSelectPattern& ) const override; + virtual sal_IntPtr GetFontId() const override; + void SetFontId( sal_IntPtr nId ) { mnId = nId; } + void UpdateFromHDC( HDC ) const; + + bool HasChar( sal_uInt32 cChar ) const; + + BYTE GetCharSet() const { return meWinCharSet; } + BYTE GetPitchAndFamily() const { return mnPitchAndFamily; } + + FontCharMapRef GetFontCharMap() const override; + bool GetFontCapabilities(vcl::FontCapabilities&) const override; + +private: + sal_IntPtr mnId; + + // some members that are initialized lazily when the font gets selected into a HDC + mutable bool mbFontCapabilitiesRead; + mutable FontCharMapRef mxUnicodeMap; + mutable vcl::FontCapabilities maFontCapabilities; + + BYTE meWinCharSet; + BYTE mnPitchAndFamily; + bool mbAliasSymbolsHigh; + bool mbAliasSymbolsLow; + + void ReadCmapTable( HDC ) const; + void GetFontCapabilities( HDC hDC ) const; +}; + +/** Class that creates (and destroys) a compatible Device Context. + +This is to be used for GDI drawing into a DIB that we later use for a different +drawing method, such as a texture for OpenGL drawing or surface for Skia drawing. +*/ +class CompatibleDC +{ +protected: + /// The compatible DC that we create for our purposes. + HDC mhCompatibleDC; + + /// DIBSection that we use for the GDI drawing, and later obtain. + HBITMAP mhBitmap; + + /// Return the previous bitmap to undo the SelectObject. + HBITMAP mhOrigBitmap; + + /// DIBSection data. + sal_uInt32 *mpData; + + /// Mapping between the GDI position and OpenGL, to use for OpenGL drawing. + SalTwoRect maRects; + + /// The SalGraphicsImpl where we will draw. If null, we ignore the drawing, it means it happened directly to the DC... + WinSalGraphicsImplBase *mpImpl; + + // If 'disable' is true, this class is a simple wrapper for drawing directly. Subclasses should use true. + CompatibleDC(SalGraphics &rGraphics, int x, int y, int width, int height, bool disable=true); + +public: + static std::unique_ptr< CompatibleDC > create(SalGraphics &rGraphics, int x, int y, int width, int height); + + virtual ~CompatibleDC(); + + HDC getCompatibleHDC() { return mhCompatibleDC; } + + SalTwoRect getTwoRect() const { return maRects; } + + tools::Long getBitmapWidth() const { return maRects.mnSrcWidth; } + tools::Long getBitmapHeight() const { return maRects.mnSrcHeight; } + + /// Reset the DC with the defined color. + void fill(sal_uInt32 color); +}; + +/** + * WinSalGraphics never owns the HDC it uses to draw, because the HDC can have + * various origins with different ways to correctly free it. And WinSalGraphics + * stores all default values (mhDef*) of the HDC, which must be restored when + * the HDC changes (setHDC) or the SalGraphics is destructed. So think of the + * HDC in terms of Rust's Borrowing semantics. + */ +class WinSalGraphics : public SalGraphics +{ + friend class WinSalGraphicsImpl; + friend class ScopedFont; + +protected: + std::unique_ptr<SalGraphicsImpl> mpImpl; + +private: + HDC mhLocalDC; // HDC + bool mbPrinter : 1; // is Printer + bool mbVirDev : 1; // is VirDev + bool mbWindow : 1; // is Window + bool mbScreen : 1; // is Screen compatible + HWND mhWnd; // Window-Handle, when Window-Graphics + + rtl::Reference<WinFontInstance> + mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the most recent font instance + HRGN mhRegion; // vcl::Region Handle + HPEN mhDefPen; // DefaultPen + HBRUSH mhDefBrush; // DefaultBrush + HFONT mhDefFont; // DefaultFont + HPALETTE mhDefPal; // DefaultPalette + COLORREF mnTextColor; // TextColor + RGNDATA* mpClipRgnData; // ClipRegion-Data + RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data + int mnPenWidth; // line width + + // just call both from setHDC! + void InitGraphics(); + void DeInitGraphics(); + +public: + // Return HFONT, and whether the font is for vertical writing ( prefixed with '@' ) + // and tmDescent value for adjusting offset in vertical writing mode. + std::tuple<HFONT,bool,sal_Int32> ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); + + HDC getHDC() const { return mhLocalDC; } + // NOTE: this doesn't transfer ownership! See class comment. + void setHDC(HDC aNew); + + HPALETTE getDefPal() const; + // returns the result from RealizePalette, otherwise 0 on success or GDI_ERROR + UINT setPalette(HPALETTE, BOOL bForceBkgd = TRUE); + + HRGN getRegion() const; + + + enum Type + { + PRINTER, + VIRTUAL_DEVICE, + WINDOW, + SCREEN + }; + +public: + + HWND gethWnd(); + + +public: + explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd, + SalGeometryProvider *pProvider); + virtual ~WinSalGraphics() override; + + SalGraphicsImpl* GetImpl() const override; + bool isPrinter() const; + bool isVirtualDevice() const; + bool isWindow() const; + bool isScreen() const; + + void setHWND(HWND hWnd); + void Flush(); + +protected: + virtual bool setClipRegion( const vcl::Region& ) override; + // draw --> LineColor and FillColor and RasterOp and ClipRegion + virtual void drawPixel( tools::Long nX, tools::Long nY ) override; + virtual void drawPixel( tools::Long nX, tools::Long nY, Color nColor ) override; + virtual void drawLine( tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2 ) override; + virtual void drawRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + virtual void drawPolyLine( sal_uInt32 nPoints, const Point* pPtAry ) override; + virtual void drawPolygon( sal_uInt32 nPoints, const Point* pPtAry ) override; + virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, const Point** pPtAry ) override; + virtual bool drawPolyPolygon( + const basegfx::B2DHomMatrix& rObjectToDevice, + const basegfx::B2DPolyPolygon&, + double fTransparency) override; + virtual bool drawPolyLine( + const basegfx::B2DHomMatrix& rObjectToDevice, + const basegfx::B2DPolygon&, + double fTransparency, + double fLineWidth, + const std::vector< double >* pStroke, // MM01 + basegfx::B2DLineJoin, + css::drawing::LineCap, + double fMiterMinimumAngle, + bool bPixelSnapHairline) override; + virtual bool drawPolyLineBezier( sal_uInt32 nPoints, const Point* pPtAry, const PolyFlags* pFlgAry ) override; + virtual bool drawPolygonBezier( sal_uInt32 nPoints, const Point* pPtAry, const PolyFlags* pFlgAry ) override; + virtual bool drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints, const Point* const* pPtAry, const PolyFlags* const* pFlgAry ) override; + virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) override; + virtual bool implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolygon, SalGradient const & rGradient) override; + + // CopyArea --> No RasterOp, but ClipRegion + virtual void copyArea( tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, tools::Long nSrcWidth, + tools::Long nSrcHeight, bool bWindowInvalidate ) override; + + // CopyBits and DrawBitmap --> RasterOp and ClipRegion + // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics + virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) override; + virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) override; + virtual void drawBitmap( const SalTwoRect& rPosAry, + const SalBitmap& rSalBitmap, + const SalBitmap& rTransparentBitmap ) override; + virtual void drawMask( const SalTwoRect& rPosAry, + const SalBitmap& rSalBitmap, + Color nMaskColor ) override; + + virtual std::shared_ptr<SalBitmap> getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + virtual Color getPixel( tools::Long nX, tools::Long nY ) override; + + // invert --> ClipRegion (only Windows or VirDevs) + virtual void invert( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, SalInvert nFlags) override; + virtual void invert( sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags ) override; + + virtual bool drawEPS( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, void* pPtr, sal_uInt32 nSize ) override; + + // native widget rendering methods that require mirroring +protected: + virtual bool isNativeControlSupported( ControlType nType, ControlPart nPart ) override; + virtual bool hitTestNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, + const Point& aPos, bool& rIsInside ) override; + virtual bool drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + const OUString& aCaption, const Color& rBackgroundColor ) override; + virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState, + const ImplControlValue& aValue, const OUString& aCaption, + tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override; + +public: + virtual bool blendBitmap( const SalTwoRect&, + const SalBitmap& rBitmap ) override; + + virtual bool blendAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) override; + + virtual bool drawAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSourceBitmap, + const SalBitmap& rAlphaBitmap ) override; + virtual bool drawTransformedBitmap( + const basegfx::B2DPoint& rNull, + const basegfx::B2DPoint& rX, + const basegfx::B2DPoint& rY, + const SalBitmap& rSourceBitmap, + const SalBitmap* pAlphaBitmap, + double fAlpha) override; + + virtual bool hasFastDrawTransformedBitmap() const override; + + virtual bool drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) override; + +private: + // local helpers + + void DrawTextLayout(const GenericSalLayout&, HDC, bool bUseDWrite, bool bRenderingModeNatural); + +public: + // public SalGraphics methods, the interface to the independent vcl part + + // get device resolution + virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override; + // get the depth of the device + virtual sal_uInt16 GetBitCount() const override; + // get the width of the device + virtual tools::Long GetGraphicsWidth() const override; + + // set the clip region to empty + virtual void ResetClipRegion() override; + + // set the line color to transparent (= don't draw lines) + virtual void SetLineColor() override; + // set the line color to a specific color + virtual void SetLineColor( Color nColor ) override; + // set the fill color to transparent (= don't fill) + virtual void SetFillColor() override; + // set the fill color to a specific color, shapes will be + // filled accordingly + virtual void SetFillColor( Color nColor ) override; + // enable/disable XOR drawing + virtual void SetXORMode( bool bSet, bool ) override; + // set line color for raster operations + virtual void SetROPLineColor( SalROPColor nROPColor ) override; + // set fill color for raster operations + virtual void SetROPFillColor( SalROPColor nROPColor ) override; + // set the text color to a specific color + virtual void SetTextColor( Color nColor ) override; + // set the font + virtual void SetFont( LogicalFontInstance*, int nFallbackLevel ) override; + // get the current font's metrics + virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override; + // get the repertoire of the current font + virtual FontCharMapRef GetFontCharMap() const override; + // get the layout capabilities of the current font + virtual bool GetFontCapabilities(vcl::FontCapabilities &rGetFontCapabilities) const override; + // graphics must fill supplied font list + virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) override; + // graphics must drop any cached font info + virtual void ClearDevFontCache() override; + virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override; + // CreateFontSubset: a method to get a subset of glyhps of a font + // inside a new valid font file + // returns TRUE if creation of subset was successful + // parameters: rToFile: contains an osl file URL to write the subset to + // pFont: describes from which font to create a subset + // pGlyphIDs: the glyph ids to be extracted + // pEncoding: the character code corresponding to each glyph + // pWidths: the advance widths of the corresponding glyphs (in PS font units) + // nGlyphs: the number of glyphs + // rInfo: additional outgoing information + // implementation note: encoding 0 with glyph id 0 should be added implicitly + // as "undefined character" + virtual bool CreateFontSubset( const OUString& rToFile, + const vcl::font::PhysicalFontFace*, + const sal_GlyphId* pGlyphIDs, + const sal_uInt8* pEncoding, + sal_Int32* pWidths, + int nGlyphs, + FontSubsetInfo& rInfo // out parameter + ) override; + + // GetEmbedFontData: gets the font data for a font marked + // embeddable by GetDevFontList or NULL in case of error + // parameters: pFont: describes the font in question + // pDataLen: out parameter, contains the byte length of the returned buffer + virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override; + // frees the font data again + virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override; + virtual void GetGlyphWidths( const vcl::font::PhysicalFontFace*, + bool bVertical, + std::vector< sal_Int32 >& rWidths, + Ucs2UIntMap& rUnicodeEnc ) override; + + virtual std::unique_ptr<GenericSalLayout> + GetTextLayout(int nFallbackLevel) override; + virtual void DrawTextLayout( const GenericSalLayout& ) override; + + virtual bool supportsOperation( OutDevSupportType ) const override; + + virtual SystemGraphicsData GetGraphicsData() const override; + + /// Update settings based on the platform values + static void updateSettingsNative( AllSettings& rSettings ); +}; + +// Init/Deinit Graphics +void ImplUpdateSysColorEntries(); +int ImplIsSysColorEntry( Color nColor ); +void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern&, + const vcl::font::PhysicalFontFace*, LOGFONTW& ); + +#define MAX_64KSALPOINTS ((((sal_uInt16)0xFFFF)-8)/sizeof(POINTS)) + +// called extremely often from just one spot => inline +inline bool WinFontFace::HasChar( sal_uInt32 cChar ) const +{ + if( mxUnicodeMap->HasChar( cChar ) ) + return true; + // second chance to allow symbol aliasing + if( mbAliasSymbolsLow && ((cChar-0xF000) <= 0xFF) ) + cChar -= 0xF000; + else if( mbAliasSymbolsHigh && (cChar <= 0xFF) ) + cChar += 0xF000; + else + return false; + return mxUnicodeMap->HasChar( cChar ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salids.hrc b/vcl/inc/win/salids.hrc new file mode 100644 index 000000000..7212ee902 --- /dev/null +++ b/vcl/inc/win/salids.hrc @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALIDS_HRC +#define INCLUDED_VCL_INC_WIN_SALIDS_HRC + +// Cursor +#define SAL_RESID_POINTER_NULL 10000 +#define SAL_RESID_POINTER_MAGNIFY 10015 +#define SAL_RESID_POINTER_FILL 10016 +#define SAL_RESID_POINTER_ROTATE 10017 +#define SAL_RESID_POINTER_HSHEAR 10018 +#define SAL_RESID_POINTER_VSHEAR 10019 +#define SAL_RESID_POINTER_MIRROR 10020 +#define SAL_RESID_POINTER_CROOK 10021 +#define SAL_RESID_POINTER_CROP 10022 +#define SAL_RESID_POINTER_MOVEPOINT 10023 +#define SAL_RESID_POINTER_MOVEBEZIERWEIGHT 10024 +#define SAL_RESID_POINTER_MOVEDATA 10025 +#define SAL_RESID_POINTER_COPYDATA 10026 +#define SAL_RESID_POINTER_LINKDATA 10027 +#define SAL_RESID_POINTER_MOVEDATALINK 10028 +#define SAL_RESID_POINTER_COPYDATALINK 10029 +#define SAL_RESID_POINTER_MOVEFILE 10030 +#define SAL_RESID_POINTER_COPYFILE 10031 +#define SAL_RESID_POINTER_LINKFILE 10032 +#define SAL_RESID_POINTER_MOVEFILELINK 10033 +#define SAL_RESID_POINTER_COPYFILELINK 10034 +#define SAL_RESID_POINTER_MOVEFILES 10035 +#define SAL_RESID_POINTER_COPYFILES 10036 +#define SAL_RESID_POINTER_DRAW_LINE 10038 +#define SAL_RESID_POINTER_DRAW_RECT 10039 +#define SAL_RESID_POINTER_DRAW_POLYGON 10040 +#define SAL_RESID_POINTER_DRAW_BEZIER 10041 +#define SAL_RESID_POINTER_DRAW_ARC 10042 +#define SAL_RESID_POINTER_DRAW_PIE 10043 +#define SAL_RESID_POINTER_DRAW_CIRCLECUT 10044 +#define SAL_RESID_POINTER_DRAW_ELLIPSE 10045 +#define SAL_RESID_POINTER_DRAW_FREEHAND 10046 +#define SAL_RESID_POINTER_DRAW_CONNECT 10047 +#define SAL_RESID_POINTER_DRAW_TEXT 10048 +#define SAL_RESID_POINTER_DRAW_CAPTION 10049 +#define SAL_RESID_POINTER_CHART 10050 +#define SAL_RESID_POINTER_DETECTIVE 10051 +#define SAL_RESID_POINTER_PIVOT_COL 10052 +#define SAL_RESID_POINTER_PIVOT_ROW 10053 +#define SAL_RESID_POINTER_PIVOT_FIELD 10054 +#define SAL_RESID_POINTER_CHAIN 10055 +#define SAL_RESID_POINTER_CHAIN_NOTALLOWED 10056 +#define SAL_RESID_POINTER_AUTOSCROLL_N 10059 +#define SAL_RESID_POINTER_AUTOSCROLL_S 10060 +#define SAL_RESID_POINTER_AUTOSCROLL_W 10061 +#define SAL_RESID_POINTER_AUTOSCROLL_E 10062 +#define SAL_RESID_POINTER_AUTOSCROLL_NW 10063 +#define SAL_RESID_POINTER_AUTOSCROLL_NE 10064 +#define SAL_RESID_POINTER_AUTOSCROLL_SW 10065 +#define SAL_RESID_POINTER_AUTOSCROLL_SE 10066 +#define SAL_RESID_POINTER_AUTOSCROLL_NS 10067 +#define SAL_RESID_POINTER_AUTOSCROLL_WE 10068 +#define SAL_RESID_POINTER_AUTOSCROLL_NSWE 10069 +#define SAL_RESID_POINTER_TEXT_VERTICAL 10071 +#define SAL_RESID_POINTER_PIVOT_DELETE 10072 +#define SAL_RESID_POINTER_TAB_SELECT_S 10073 +#define SAL_RESID_POINTER_TAB_SELECT_E 10074 +#define SAL_RESID_POINTER_TAB_SELECT_SE 10075 +#define SAL_RESID_POINTER_TAB_SELECT_W 10076 +#define SAL_RESID_POINTER_TAB_SELECT_SW 10077 +#define SAL_RESID_POINTER_HIDEWHITESPACE 10079 +#define SAL_RESID_POINTER_SHOWWHITESPACE 10080 +#define SAL_RESID_POINTER_FATCROSS 10081 + +#define SAL_RESID_BITMAP_50 11000 + +#define SAL_RESID_ICON_DEFAULT 1 + +#endif // INCLUDED_VCL_INC_WIN_SALIDS_HRC + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h new file mode 100644 index 000000000..c62a68ae0 --- /dev/null +++ b/vcl/inc/win/salinst.h @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALINST_H +#define INCLUDED_VCL_INC_WIN_SALINST_H + +#include <sal/config.h> + +#include <osl/conditn.hxx> + +#include <salinst.hxx> + +class SalYieldMutex; + +class WinSalInstance : public SalInstance +{ +public: + /// Instance Handle + HINSTANCE mhInst; + /// invisible Window so non-main threads can SendMessage() the main thread + HWND mhComWnd; + + osl::Condition maWaitingYieldCond; + unsigned m_nNoYieldLock; + +public: + WinSalInstance(); + virtual ~WinSalInstance() override; + + virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override; + virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override; + virtual void DestroyFrame( SalFrame* pFrame ) override; + virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override; + virtual void DestroyObject( SalObject* pObject ) override; + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics& rGraphics, + tools::Long &nDX, tools::Long &nDY, + DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override; + virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ) override; + virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override; + virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override; + virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override; + virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override; + virtual OUString GetDefaultPrinter() override; + virtual SalTimer* CreateSalTimer() override; + virtual SalSystem* CreateSalSystem() override; + virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override; + virtual bool IsMainThread() const override; + + virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override; + virtual bool AnyInput( VclInputFlags nType ) override; + virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* ) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override; + virtual OpenGLContext* CreateOpenGLContext() override; + virtual OUString GetConnectionIdentifier() override; + virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; + + virtual OUString getOSVersion() override; + virtual void BeforeAbort(const OUString&, bool) override; + + static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo); + + virtual css::uno::Reference<css::uno::XInterface> ImplCreateDragSource(const SystemEnvData*) override; + virtual css::uno::Reference<css::uno::XInterface> ImplCreateDropTarget(const SystemEnvData*) override; +}; + +SalFrame* ImplSalCreateFrame( WinSalInstance* pInst, HWND hWndParent, SalFrameStyleFlags nSalFrameStyle ); +SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ); +HWND ImplSalReCreateHWND( HWND hWndParent, HWND oldhWnd, bool bAsChild ); +bool OSSupportsDarkMode(); + +#endif // INCLUDED_VCL_INC_WIN_SALINST_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salmenu.h b/vcl/inc/win/salmenu.h new file mode 100644 index 000000000..7058d9c82 --- /dev/null +++ b/vcl/inc/win/salmenu.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALMENU_H +#define INCLUDED_VCL_INC_WIN_SALMENU_H + +#include <vcl/bitmap.hxx> +#include <salmenu.hxx> + +class WinSalMenu : public SalMenu +{ +public: + WinSalMenu(); + virtual ~WinSalMenu() override; + virtual bool VisibleMenuBar() override; // must return TRUE to actually DISPLAY native menu bars + // otherwise only menu messages are processed (eg, OLE on Windows) + + virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) override; + virtual void RemoveItem( unsigned nPos ) override; + virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) override; + virtual void SetFrame( const SalFrame* pFrame ) override; + virtual void CheckItem( unsigned nPos, bool bCheck ) override; + virtual void EnableItem( unsigned nPos, bool bEnable ) override; + virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const OUString& rText ) override; + virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage ) override; + virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const vcl::KeyCode& rKeyCode, const OUString& rKeyName ) override; + virtual void GetSystemMenuData( SystemMenuData* pData ) override; + + HMENU mhMenu; // the menu handle + bool mbMenuBar; // true for menu bars + HWND mhWnd; // the window handle where the menubar is attached, may be NULL + WinSalMenu *mpParentMenu; // the parent menu +}; + +class WinSalMenuItem : public SalMenuItem +{ +public: + WinSalMenuItem(); + virtual ~WinSalMenuItem() override; + + MENUITEMINFOW mInfo; + void* mpMenu; // pointer to corresponding VCL menu + OUString mText; // the item text + OUString mAccelText; // the accelerator string + Bitmap maBitmap; // item image + int mnId; // item id + WinSalMenu* mpSalMenu; // the menu where this item is inserted +}; + +#endif // INCLUDED_VCL_INC_WIN_SALMENU_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salobj.h b/vcl/inc/win/salobj.h new file mode 100644 index 000000000..e76c4787e --- /dev/null +++ b/vcl/inc/win/salobj.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALOBJ_H +#define INCLUDED_VCL_INC_WIN_SALOBJ_H + +#include <salobj.hxx> + + +class WinSalObject : public SalObject +{ +public: + HWND mhWnd; // Window handle + HWND mhWndChild; // Child Window handle + HWND mhLastFocusWnd; // Child-Window, which had the last focus + SystemEnvData maSysData; // SystemEnvData + RGNDATA* mpClipRgnData; // ClipRegion-Data + RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data + RECT* mpNextClipRect; // next ClipRegion-Rect + bool mbFirstClipRect; // Flag for first cliprect to insert + WinSalObject* mpNextObject; // pointer to next object + + WinSalObject(); + virtual ~WinSalObject() override; + + virtual void ResetClipRegion() override; + virtual void BeginSetClipRegion( sal_uInt32 nRects ) override; + virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override; + virtual void EndSetClipRegion() override; + virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + virtual void Show( bool bVisible ) override; + virtual void Enable( bool bEnable ) override; + virtual void GrabFocus() override; + virtual const SystemEnvData* GetSystemData() const override; +}; + +#endif // INCLUDED_VCL_INC_WIN_SALOBJ_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h new file mode 100644 index 000000000..2d02aa5b0 --- /dev/null +++ b/vcl/inc/win/salprn.h @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALPRN_H +#define INCLUDED_VCL_INC_WIN_SALPRN_H + +#include <salprn.hxx> + + +// WNT3 +#define SAL_DRIVERDATA_SYSSIGN ((sal_uIntPtr)0x574E5433) + +#pragma pack( 1 ) + +struct SalDriverData +{ + sal_uIntPtr mnSysSignature; + sal_uInt16 mnDriverOffset; + BYTE maDriverData[1]; +}; + +#pragma pack() + + +class WinSalGraphics; + +class WinSalInfoPrinter final : public SalInfoPrinter +{ +public: + OUString maDriverName; // printer driver name + OUString maDeviceName; // printer device name + OUString maPortName; // printer port name + +private: + HDC m_hDC; ///< printer hdc + WinSalGraphics* m_pGraphics; ///< current Printer graphics + bool m_bGraphics; ///< is Graphics used + +public: + WinSalInfoPrinter(); + virtual ~WinSalInfoPrinter() override; + + void setHDC(HDC); + + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; + virtual bool Setup( weld::Window* pFrame, ImplJobSetup* pSetupData ) override; + virtual bool SetPrinterData( ImplJobSetup* pSetupData ) override; + virtual bool SetData( JobSetFlags nFlags, ImplJobSetup* pSetupData ) override; + virtual void GetPageInfo( const ImplJobSetup* pSetupData, + tools::Long& rOutWidth, tools::Long& rOutHeight, + Point& rPageOffset, + Size& rPaperSize ) override; + virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) override; + virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* pSetupData ) override; + virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) override; + virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) override; + virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ) override; +}; + + +class WinSalPrinter : public SalPrinter +{ +public: + std::unique_ptr<WinSalGraphics> mxGraphics; // current Printer graphics + WinSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter + WinSalPrinter* mpNextPrinter; // next printing printer + HDC mhDC; // printer hdc + SalPrinterError mnError; // error code + sal_uInt32 mnCopies; // copies + bool mbCollate; // collated copies + bool mbAbort; // Job Aborted + + bool mbValid; + +protected: + void DoEndDoc(HDC hDC); + +public: + WinSalPrinter(); + virtual ~WinSalPrinter() override; + + using SalPrinter::StartJob; + virtual bool StartJob( const OUString* pFileName, + const OUString& rJobName, + const OUString& rAppName, + sal_uInt32 nCopies, + bool bCollate, + bool bDirect, + ImplJobSetup* pSetupData ) override; + virtual bool EndJob() override; + virtual SalGraphics* StartPage( ImplJobSetup* pSetupData, bool bNewJobData ) override; + virtual void EndPage() override; + virtual SalPrinterError GetErrorCode() override; + + void markInvalid(); + bool isValid() const { return mbValid && mhDC; } +}; + +#endif // INCLUDED_VCL_INC_WIN_SALPRN_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salsys.h b/vcl/inc/win/salsys.h new file mode 100644 index 000000000..03f627b5a --- /dev/null +++ b/vcl/inc/win/salsys.h @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALSYS_H +#define INCLUDED_VCL_INC_WIN_SALSYS_H + +#include <salsys.hxx> + +#include <vector> +#include <map> + +class WinSalSystem : public SalSystem +{ +public: + struct DisplayMonitor + { + OUString m_aName; + tools::Rectangle m_aArea; + + DisplayMonitor() {} + DisplayMonitor( const OUString& rName, + const tools::Rectangle& rArea ) + : m_aName( rName ), + m_aArea( rArea ) + { + } + }; +private: + std::vector<DisplayMonitor> m_aMonitors; + std::map<OUString, unsigned int> m_aDeviceNameToMonitor; + unsigned int m_nPrimary; +public: + WinSalSystem() : m_nPrimary( 0 ) {} + virtual ~WinSalSystem() override; + + virtual unsigned int GetDisplayScreenCount() override; + virtual unsigned int GetDisplayBuiltInScreen() override; + virtual tools::Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; + virtual int ShowNativeMessageBox( const OUString& rTitle, + const OUString& rMessage) override; + bool initMonitors(); + // discards monitorinfo; used by WM_DISPLAYCHANGED handler + void clearMonitors(); + const std::vector<DisplayMonitor>& getMonitors() + { initMonitors(); return m_aMonitors;} + + bool handleMonitorCallback( sal_IntPtr /*HMONITOR*/, + sal_IntPtr /*HDC*/, + sal_IntPtr /*LPRECT*/ ); +}; + +#endif // INCLUDED_VCL_INC_WIN_SALSYS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h new file mode 100644 index 000000000..a467de815 --- /dev/null +++ b/vcl/inc/win/saltimer.h @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALTIMER_H +#define INCLUDED_VCL_INC_WIN_SALTIMER_H + +#include <saltimer.hxx> + +class WinSalTimer final : public SalTimer, protected VersionedEvent +{ + // for access to Impl* functions + friend LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, bool& rDef ); + // for access to GetNextVersionedEvent + friend void CALLBACK SalTimerProc( PVOID data, BOOLEAN ); + // for access to ImplHandleElapsedTimer + friend bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ); + + /** + * Identifier for our SetTimer based timer + */ + static constexpr UINT_PTR m_aWmTimerId = 0xdeadbeef; + + HANDLE m_nTimerId; ///< Windows timer id + bool m_bDirectTimeout; ///< timeout can be processed directly + bool m_bForceRealTimer; ///< enforce using a real timer for 0ms + bool m_bSetTimerRunning; ///< true, if a SetTimer is running + + void ImplStart( sal_uInt64 nMS ); + void ImplStop(); + void ImplHandleTimerEvent( WPARAM aWPARAM ); + void ImplHandleElapsedTimer(); + void ImplHandle_WM_TIMER( WPARAM aWPARAM ); + +public: + WinSalTimer(); + virtual ~WinSalTimer() override; + + virtual void Start(sal_uInt64 nMS) override; + virtual void Stop() override; + + inline bool IsDirectTimeout() const; + inline bool HasTimerElapsed() const; + + /** + * Enforces the usage of a real timer instead of the message queue + * + * Needed for Window resize processing, as this starts a modal event loop. + */ + void SetForceRealTimer( bool bVal ); + inline bool GetForceRealTimer() const; +}; + +inline bool WinSalTimer::IsDirectTimeout() const +{ + return m_bDirectTimeout; +} + +inline bool WinSalTimer::HasTimerElapsed() const +{ + return m_bDirectTimeout || ExistsValidEvent(); +} + +inline bool WinSalTimer::GetForceRealTimer() const +{ + return m_bForceRealTimer; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h new file mode 100644 index 000000000..7a776056c --- /dev/null +++ b/vcl/inc/win/salvd.h @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SALVD_H +#define INCLUDED_VCL_INC_WIN_SALVD_H + +#include <sal/config.h> +#include <win/scoped_gdi.hxx> + +#include <memory> + +#include <salvd.hxx> + +class WinSalGraphics; + + +class WinSalVirtualDevice : public SalVirtualDevice +{ +private: + HDC mhLocalDC; // HDC or 0 for Cache Device + ScopedHBITMAP mhBmp; // Memory Bitmap + HBITMAP mhDefBmp; // Default Bitmap + std::unique_ptr<WinSalGraphics> mpGraphics; // current VirDev graphics + WinSalVirtualDevice* mpNext; // next VirDev + sal_uInt16 mnBitCount; // BitCount (0 or 1) + bool mbGraphics; // is Graphics used + bool mbForeignDC; // uses a foreign DC instead of a bitmap + tools::Long mnWidth; + tools::Long mnHeight; + +public: + HDC getHDC() const { return mhLocalDC; } + WinSalGraphics* getGraphics() const { return mpGraphics.get(); } + void setGraphics(WinSalGraphics* pVirGraphics) { mpGraphics.reset(pVirGraphics); } + WinSalVirtualDevice* getNext() const { return mpNext; } + + WinSalVirtualDevice(HDC hDC = nullptr, HBITMAP hBMP = nullptr, sal_uInt16 nBitCount = 0, bool bForeignDC = false, tools::Long nWidth = 0, tools::Long nHeight = 0); + virtual ~WinSalVirtualDevice() override; + + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; + virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) override; + + static HBITMAP ImplCreateVirDevBitmap(HDC hDC, tools::Long nDX, tools::Long nDY, sal_uInt16 nBitCount, void **ppDummy); + + // SalGeometryProvider + virtual tools::Long GetWidth() const override { return mnWidth; } + virtual tools::Long GetHeight() const override { return mnHeight; } +}; + + +#endif // INCLUDED_VCL_INC_WIN_SALVD_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx new file mode 100644 index 000000000..d02ad9545 --- /dev/null +++ b/vcl/inc/win/scoped_gdi.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX +#define INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX + +#include <win/svsys.h> +#include <win/wincomp.hxx> +#include <win/saldata.hxx> + +#include <memory> + +template <typename H, auto DeleterFunc> struct GDIDeleter +{ + using pointer = H; + void operator()(H h) { DeleterFunc(h); } +}; + +template <typename H, auto DeleterFunc> +using ScopedGDI = std::unique_ptr<H, GDIDeleter<H, DeleterFunc>>; + +using ScopedHBRUSH = ScopedGDI<HBRUSH, DeleteBrush>; +using ScopedHRGN = ScopedGDI<HRGN, DeleteRegion>; +using ScopedHDC = ScopedGDI<HDC, DeleteDC>; +using ScopedHPEN = ScopedGDI<HPEN, DeletePen>; +using ScopedHFONT = ScopedGDI<HFONT, DeleteFont>; +using ScopedHBITMAP = ScopedGDI<HBITMAP, DeleteBitmap>; + +template <typename ScopedH, auto SelectorFunc> class ScopedSelectedGDI +{ +public: + ScopedSelectedGDI(HDC hDC, typename ScopedH::pointer h) + : m_hDC(hDC) + , m_hSelectedH(h) + , m_hOrigH(SelectorFunc(hDC, h)) + { + } + + ~ScopedSelectedGDI() { SelectorFunc(m_hDC, m_hOrigH); } + +private: + HDC m_hDC; + ScopedH m_hSelectedH; + typename ScopedH::pointer m_hOrigH; +}; + +using ScopedSelectedHPEN = ScopedSelectedGDI<ScopedHPEN, SelectPen>; +using ScopedSelectedHFONT = ScopedSelectedGDI<ScopedHFONT, SelectFont>; +using ScopedSelectedHBRUSH = ScopedSelectedGDI<ScopedHBRUSH, SelectBrush>; + +template <sal_uLong ID> class ScopedCachedHDC +{ +public: + explicit ScopedCachedHDC(HBITMAP hBitmap) + : m_hDC(ImplGetCachedDC(ID, hBitmap)) + { + } + + ~ScopedCachedHDC() { ImplReleaseCachedDC(ID); } + + HDC get() const { return m_hDC; } + +private: + HDC m_hDC; +}; + +#endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/win/svsys.h b/vcl/inc/win/svsys.h new file mode 100644 index 000000000..44cae93cf --- /dev/null +++ b/vcl/inc/win/svsys.h @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_WIN_SVSYS_H +#define INCLUDED_VCL_INC_WIN_SVSYS_H + +#ifdef _WIN32 +#ifndef INCLUDED_PRE_POST_WIN_H +#define INCLUDED_PRE_POST_WIN_H +#include <prewin.h> +#include <postwin.h> +#endif +#endif + +#endif // INCLUDED_VCL_INC_WIN_SVSYS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx new file mode 100644 index 000000000..6f5b0ebc4 --- /dev/null +++ b/vcl/inc/win/wincomp.hxx @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <string.h> + + +// Adjustments for TypeChecking + +inline HPEN SelectPen( HDC hDC, HPEN hPen ) +{ + return static_cast<HPEN>(SelectObject( hDC, static_cast<HGDIOBJ>(hPen) )); +} + +inline void DeletePen( HPEN hPen ) +{ + DeleteObject( static_cast<HGDIOBJ>(hPen) ); +} + +inline HPEN GetStockPen( int nObject ) +{ + return static_cast<HPEN>(GetStockObject( nObject )); +} + +inline HBRUSH SelectBrush( HDC hDC, HBRUSH hBrush ) +{ + return static_cast<HBRUSH>(SelectObject( hDC, static_cast<HGDIOBJ>(hBrush) )); +} + +inline void DeleteBrush( HBRUSH hBrush ) +{ + DeleteObject( static_cast<HGDIOBJ>(hBrush) ); +} + +inline HBRUSH GetStockBrush( int nObject ) +{ + return static_cast<HBRUSH>(GetStockObject( nObject )); +} + +inline HFONT SelectFont( HDC hDC, HFONT hFont ) +{ + return static_cast<HFONT>(SelectObject( hDC, static_cast<HGDIOBJ>(hFont) )); +} + +inline void DeleteFont( HFONT hFont ) +{ + DeleteObject( static_cast<HGDIOBJ>(hFont) ); +} + +inline HFONT GetStockFont( int nObject ) +{ + return static_cast<HFONT>(GetStockObject( nObject )); +} + +inline HBITMAP SelectBitmap( HDC hDC, HBITMAP hBitmap ) +{ + return static_cast<HBITMAP>(SelectObject( hDC, static_cast<HGDIOBJ>(hBitmap) )); +} + +inline void DeleteBitmap( HBITMAP hBitmap ) +{ + DeleteObject( static_cast<HGDIOBJ>(hBitmap) ); +} + +inline void DeleteRegion( HRGN hRegion ) +{ + DeleteObject( static_cast<HGDIOBJ>(hRegion) ); +} + +inline HPALETTE GetStockPalette( int nObject ) +{ + return static_cast<HPALETTE>(GetStockObject( nObject )); +} + +inline void DeletePalette( HPALETTE hPalette ) +{ + DeleteObject( static_cast<HGDIOBJ>(hPalette) ); +} + +inline void SetWindowStyle( HWND hWnd, DWORD nStyle ) +{ + SetWindowLongPtrW( hWnd, GWL_STYLE, nStyle ); +} + +inline DWORD GetWindowStyle( HWND hWnd ) +{ + return GetWindowLongPtrW( hWnd, GWL_STYLE ); +} + +inline void SetWindowExStyle( HWND hWnd, DWORD nStyle ) +{ + SetWindowLongPtrW( hWnd, GWL_EXSTYLE, nStyle ); +} + +inline DWORD GetWindowExStyle( HWND hWnd ) +{ + return GetWindowLongPtrW( hWnd, GWL_EXSTYLE ); +} + +inline BOOL IsMinimized( HWND hWnd ) +{ + return IsIconic( hWnd ); +} + +inline BOOL IsMaximized( HWND hWnd ) +{ + return IsZoomed( hWnd ); +} + +inline void SetWindowFont( HWND hWnd, HFONT hFont, BOOL bRedraw ) +{ + SendMessageW( hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), MAKELPARAM(static_cast<UINT>(bRedraw),0) ); +} + +inline HFONT GetWindowFont( HWND hWnd ) +{ + return reinterpret_cast<HFONT>(SendMessageW( hWnd, WM_GETFONT, 0, 0 )); +} + +inline void SetClassCursor( HWND hWnd, HCURSOR hCursor ) +{ + SetClassLongPtr( hWnd, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(hCursor) ); +} + +inline HCURSOR GetClassCursor( HWND hWnd ) +{ + return reinterpret_cast<HCURSOR>(GetClassLongPtr( hWnd, GCLP_HCURSOR )); +} + +inline void SetClassIcon( HWND hWnd, HICON hIcon ) +{ + SetClassLongPtr( hWnd, GCLP_HICON, reinterpret_cast<LONG_PTR>(hIcon) ); +} + +inline HICON GetClassIcon( HWND hWnd ) +{ + return reinterpret_cast<HICON>(GetClassLongPtr( hWnd, GCLP_HICON )); +} + +inline HBRUSH SetClassBrush( HWND hWnd, HBRUSH hBrush ) +{ + return reinterpret_cast<HBRUSH>(SetClassLongPtr( hWnd, GCLP_HBRBACKGROUND, reinterpret_cast<LONG_PTR>(hBrush) )); +} + +inline HBRUSH GetClassBrush( HWND hWnd ) +{ + return reinterpret_cast<HBRUSH>(GetClassLongPtr( hWnd, GCLP_HBRBACKGROUND )); +} + +inline HINSTANCE GetWindowInstance( HWND hWnd ) +{ + return reinterpret_cast<HINSTANCE>(GetWindowLongPtrW( hWnd, GWLP_HINSTANCE )); +} + + +#define MOUSEZ_CLASSNAME L"MouseZ" // wheel window class +#define MOUSEZ_TITLE L"Magellan MSWHEEL" // wheel window title + +#define MSH_WHEELMODULE_CLASS (MOUSEZ_CLASSNAME) +#define MSH_WHEELMODULE_TITLE (MOUSEZ_TITLE) + +#define MSH_SCROLL_LINES L"MSH_SCROLL_LINES_MSG" + +#ifndef WHEEL_DELTA +#define WHEEL_DELTA 120 +#endif +#ifndef WM_MOUSEWHEEL +#define WM_MOUSEWHEEL 0x020A +#endif +#ifndef SPI_GETWHEELSCROLLLINES +#define SPI_GETWHEELSCROLLLINES 104 +#endif +#ifndef SPI_SETWHEELSCROLLLINES +#define SPI_SETWHEELSCROLLLINES 105 +#endif +#ifndef WHEEL_PAGESCROLL +#define WHEEL_PAGESCROLL (UINT_MAX) +#endif + + +// - 5.0 extensions - + +#ifndef COLOR_GRADIENTACTIVECAPTION +#define COLOR_GRADIENTACTIVECAPTION 27 +#endif +#ifndef COLOR_GRADIENTINACTIVECAPTION +#define COLOR_GRADIENTINACTIVECAPTION 28 +#endif + +#ifndef SPI_GETFLATMENU +#define SPI_GETFLATMENU 0x1022 +#endif +#ifndef COLOR_MENUBAR +#define COLOR_MENUBAR 30 +#endif +#ifndef COLOR_MENUHILIGHT +#define COLOR_MENUHILIGHT 29 +#endif + +#ifndef CS_DROPSHADOW +#define CS_DROPSHADOW 0x00020000 +#endif + +// MT 12/03: From winuser.h, only needed in salframe.cxx +// Better change salframe.cxx to include winuser.h + +#define WS_EX_LAYERED 0x00080000 + +#ifndef WM_UNICHAR +#define WM_UNICHAR 0x0109 +#define UNICODE_NOCHAR 0xFFFF +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/wingdiimpl.hxx b/vcl/inc/win/wingdiimpl.hxx new file mode 100644 index 000000000..d9616292b --- /dev/null +++ b/vcl/inc/win/wingdiimpl.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_WIN_WINGDIIMPL_HXX +#define INCLUDED_VCL_INC_WIN_WINGDIIMPL_HXX + +#include <win/salgdi.h> +#include <ControlCacheKey.hxx> + +class ControlCacheKey; + +// Base class for some functionality that OpenGL/Skia/GDI backends must each implement. +class WinSalGraphicsImplBase +{ +public: + virtual ~WinSalGraphicsImplBase() {} + + // If true is returned, the following functions are used for drawing controls. + virtual bool UseRenderNativeControl() const { return false; } + virtual bool TryRenderCachedNativeControl(const ControlCacheKey& /*rControlCacheKey*/, + int /*nX*/, int /*nY*/) + { + abort(); + } + virtual bool RenderAndCacheNativeControl(CompatibleDC& /*rWhite*/, CompatibleDC& /*rBlack*/, + int /*nX*/, int /*nY*/, + ControlCacheKey& /*aControlCacheKey*/) + { + abort(); + } + + virtual void ClearDevFontCache() {} + + virtual void Flush() {} + + // Implementation for WinSalGraphics::DrawTextLayout(). + // Returns true if handled, if false, then WinSalGraphics will handle it itself. + virtual bool DrawTextLayout(const GenericSalLayout&) { return false; } + + virtual void ClearNativeControlCache() {} +}; + +#endif // INCLUDED_VCL_INC_WIN_WINGDIIMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx new file mode 100644 index 000000000..5f56fe6b0 --- /dev/null +++ b/vcl/inc/win/winlayout.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <rtl/ustring.hxx> + +#include <sallayout.hxx> +#include <svsys.h> +#include <win/salgdi.h> +#include <o3tl/sorted_vector.hxx> + +// win32 specific logical font instance +class WinFontInstance : public LogicalFontInstance +{ + friend rtl::Reference<LogicalFontInstance> WinFontFace::CreateFontInstance(const vcl::font::FontSelectPattern&) const; + +public: + ~WinFontInstance() override; + + bool hasHScale() const; + float getHScale() const; + + void SetGraphics(WinSalGraphics*); + WinSalGraphics* GetGraphics() const { return m_pGraphics; } + + HFONT GetHFONT() const { return m_hFont; } + float GetScale() const { return m_fScale; } + // Return true if the font is for vertical writing. + // I.e. the font name of the LOGFONT is prefixed with '@'. + bool IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; } + sal_Int32 GetTmDescent() const { return m_nTmDescent; } + + const WinFontFace * GetFontFace() const { return static_cast<const WinFontFace *>(LogicalFontInstance::GetFontFace()); } + WinFontFace * GetFontFace() { return static_cast<WinFontFace *>(LogicalFontInstance::GetFontFace()); } + + bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override; + +private: + explicit WinFontInstance(const WinFontFace&, const vcl::font::FontSelectPattern&); + + hb_font_t* ImplInitHbFont() override; + bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override; + + WinSalGraphics *m_pGraphics; + HFONT m_hFont; + float m_fScale; + bool m_bIsCJKVerticalFont; + sal_Int32 m_nTmDescent; +}; + +class TextOutRenderer +{ +protected: + explicit TextOutRenderer() = default; + TextOutRenderer(const TextOutRenderer &) = delete; + TextOutRenderer & operator = (const TextOutRenderer &) = delete; + +public: + static TextOutRenderer & get(bool bUseDWrite, bool bRenderingModeNatural); + + virtual ~TextOutRenderer() = default; + + virtual bool operator ()(GenericSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, + bool bRenderingModeNatural) = 0; +}; + +class ExTextOutRenderer : public TextOutRenderer +{ + ExTextOutRenderer(const ExTextOutRenderer &) = delete; + ExTextOutRenderer & operator = (const ExTextOutRenderer &) = delete; + +public: + explicit ExTextOutRenderer() = default; + + bool operator ()(GenericSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC, + bool bRenderingModeNatural) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |