diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /vcl/inc/win | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/win')
-rw-r--r-- | vcl/inc/win/DWriteTextRenderer.hxx | 101 | ||||
-rw-r--r-- | vcl/inc/win/salbmp.h | 115 | ||||
-rw-r--r-- | vcl/inc/win/saldata.hxx | 305 | ||||
-rw-r--r-- | vcl/inc/win/salframe.h | 154 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 429 | ||||
-rw-r--r-- | vcl/inc/win/salids.hrc | 93 | ||||
-rw-r--r-- | vcl/inc/win/salinst.h | 87 | ||||
-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 | 113 | ||||
-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 | 234 | ||||
-rw-r--r-- | vcl/inc/win/wingdiimpl.hxx | 61 | ||||
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 187 |
18 files changed, 2336 insertions, 0 deletions
diff --git a/vcl/inc/win/DWriteTextRenderer.hxx b/vcl/inc/win/DWriteTextRenderer.hxx new file mode 100644 index 000000000..9011a951d --- /dev/null +++ b/vcl/inc/win/DWriteTextRenderer.hxx @@ -0,0 +1,101 @@ +/* -*- 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(); + virtual ~D2DWriteTextOutRenderer() override; + + bool operator ()(GenericSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC) 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 Ready() const; + + void applyTextAntiAliasMode(); + void changeTextAntiAliasMode(D2DTextAntiAliasMode eMode); + +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); + + ID2D1Factory * mpD2DFactory; + IDWriteFactory * mpDWriteFactory; + IDWriteGdiInterop * mpGdiInterop; + ID2D1DCRenderTarget * mpRT; + const D2D1_RENDER_TARGET_PROPERTIES mRTProps; + + IDWriteFontFace * mpFontFace; + float mlfEmHeight; + HDC mhDC; + 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); + ~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/salbmp.h b/vcl/inc/win/salbmp.h new file mode 100644 index 000000000..d6acd14e8 --- /dev/null +++ b/vcl/inc/win/salbmp.h @@ -0,0 +1,115 @@ +/* -*- 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; + + Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource); + 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, sal_uInt16 nBitCount, const BitmapPalette& rPal ); + static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB ); + static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB ); + static void ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf, + const Size& rSizePixel, bool bRLE4 ); + +public: + + WinSalBitmap(); + virtual ~WinSalBitmap() override; + +public: + + bool Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle ); + virtual bool Create( const Size& rSize, sal_uInt16 nBitCount, 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, sal_uInt16 nNewBitCount ) 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..eadc7ade8 --- /dev/null +++ b/vcl/inc/win/saldata.hxx @@ -0,0 +1,305 @@ +/* -*- 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 <win/wincomp.hxx> + +#include <set> +#include <map> + +class AutoTimer; +class WinSalInstance; +class WinSalObject; +class WinSalFrame; +class WinSalVirtualDevice; +class WinSalPrinter; +namespace vcl { class Font; } +struct GlobalWinGlyphCache; +struct HDCCache; +struct TempFontItem; +class TextOutRenderer; +class OpenGLControlsCache; +#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: + 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 + 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; + std::unique_ptr<GlobalWinGlyphCache> m_pGlobalWinGlyphCache; + std::unique_ptr<OpenGLControlsCache> m_pOpenGLControlsCache; +#if HAVE_FEATURE_SKIA + std::unique_ptr<SkiaControlsCache> m_pSkiaControlsCache; +#endif +}; + +inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; } +inline SalData* GetSalData() { return ImplGetSVData()->mpSalData; } + +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..f0c758806 --- /dev/null +++ b/vcl/inc/win/salframe.h @@ -0,0 +1,154 @@ +/* -*- 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 <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( long nWidth, long nHeight ) override; + virtual void SetMaxClientSize( long nWidth, long nHeight ) override; + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) override; + virtual void GetClientSize( long& rWidth, 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( long nX, 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 bool 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( long nX, long nY, long nWidth, long nHeight ) override; + virtual void EndSetClipRegion() override; +}; + +void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ); + +// get foreign key names +namespace vcl_sal { + OUString getKeysReplacementName( + OUString const & 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..83c6b6f2d --- /dev/null +++ b/vcl/inc/win/salgdi.h @@ -0,0 +1,429 @@ +/* -*- 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_SALGDI_H +#define INCLUDED_VCL_INC_WIN_SALGDI_H + +#include <sallayout.hxx> +#include <salgeom.hxx> +#include <salgdi.hxx> +#include <fontinstance.hxx> +#include <fontattributes.hxx> +#include <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> + +class FontSelectPattern; +class WinFontInstance; +class ImplFontAttrCache; +class PhysicalFontCollection; +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 PhysicalFontFace +{ +public: + explicit WinFontFace( const FontAttributes&, + BYTE eWinCharSet, + BYTE nPitchAndFamily ); + virtual ~WinFontFace() override; + + virtual rtl::Reference<LogicalFontInstance> CreateFontInstance( const 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; + bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; + +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; } + + long getBitmapWidth() const { return maRects.mnSrcWidth; } + long getBitmapHeight() const { return maRects.mnSrcHeight; } + + /// Reset the DC with the defined color. + void fill(sal_uInt32 color); + + /// Base texture class (OpenGL and Skia will provide their implementations). + struct Texture; + + /// Obtain the texture in format for WinSalGraphicsImplBase::DrawTextMask(). + virtual std::unique_ptr<Texture> getAsMaskTexture() const { abort(); }; +}; + +struct CompatibleDC::Texture +{ + virtual ~Texture() {}; + virtual bool isValid() const = 0; + virtual int GetWidth() const = 0; + virtual int GetHeight() const = 0; +}; + +class WinSalGraphics : public SalGraphics +{ + friend class WinSalGraphicsImpl; + friend class WinOpenGLSalGraphicsImpl; + 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 + + bool CacheGlyphs(const GenericSalLayout& rLayout); + bool DrawCachedGlyphs(const GenericSalLayout& rLayout); + +public: + HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); + + HDC getHDC() const { return mhLocalDC; } + void setHDC(HDC aNew) { mhLocalDC = aNew; } + + HPALETTE getDefPal() const; + void setDefPal(HPALETTE hDefPal); + + HRGN getRegion() const; + + void InitGraphics(); + void DeInitGraphics(); + + 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); + +protected: + virtual bool setClipRegion( const vcl::Region& ) override; + // draw --> LineColor and FillColor and RasterOp and ClipRegion + virtual void drawPixel( long nX, long nY ) override; + virtual void drawPixel( long nX, long nY, Color nColor ) override; + virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) override; + virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) override; + virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override; + virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override; + virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* 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 SalPoint* pPtAry, const PolyFlags* pFlgAry ) override; + virtual bool drawPolygonBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry ) override; + virtual bool drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints, const SalPoint* const* pPtAry, const PolyFlags* const* pFlgAry ) override; + virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) override { return false; }; + + // CopyArea --> No RasterOp, but ClipRegion + virtual void copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, + 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( long nX, long nY, long nWidth, long nHeight ) override; + virtual Color getPixel( long nX, long nY ) override; + + // invert --> ClipRegion (only Windows or VirDevs) + virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags) override; + virtual void invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) override; + + virtual bool drawEPS( long nX, long nY, long nWidth, 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) override; + virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) override; + +private: + // local helpers + + void DrawTextLayout(const GenericSalLayout&, HDC, bool bUseDWrite); + +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 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( PhysicalFontCollection* ) override; + // graphics must drop any cached font info + virtual void ClearDevFontCache() override; + virtual bool AddTempDevFont( 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 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 PhysicalFontFace*, long* pDataLen) override; + // frees the font data again + virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override; + virtual void GetGlyphWidths( const 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( HDC, const FontSelectPattern&, + const 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 ); +} + +#endif // INCLUDED_VCL_INC_WIN_SALGDI_H + +/* 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..092a24b52 --- /dev/null +++ b/vcl/inc/win/salids.hrc @@ -0,0 +1,93 @@ +/* -*- 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_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..c06e51c84 --- /dev/null +++ b/vcl/inc/win/salinst.h @@ -0,0 +1,87 @@ +/* -*- 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* pGraphics, + long &nDX, 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 std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override; + + static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo); +}; + +SalFrame* ImplSalCreateFrame( WinSalInstance* pInst, HWND hWndParent, SalFrameStyleFlags nSalFrameStyle ); +SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ); +HWND ImplSalReCreateHWND( HWND hWndParent, HWND oldhWnd, bool bAsChild ); + +#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..465c9ec77 --- /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( long nX, long nY, long nWidth, long nHeight) override; + virtual void EndSetClipRegion() override; + virtual void SetPosSize( long nX, long nY, long nWidth, 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..c0c6e7fb7 --- /dev/null +++ b/vcl/inc/win/salprn.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_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 : public SalInfoPrinter +{ +public: + WinSalGraphics* mpGraphics; // current Printer graphics + OUString maDriverName; // printer driver name + OUString maDeviceName; // printer device name + OUString maPortName; // printer port name + HDC mhDC; // printer hdc + bool mbGraphics; // is Graphics used +public: + WinSalInfoPrinter(); + virtual ~WinSalInfoPrinter() override; + + 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, + long& rOutWidth, 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: + WinSalGraphics* mpGraphics; // current Printer graphics + WinSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter + WinSalPrinter* mpNextPrinter; // next printing printer + HDC mhDC; // printer hdc + SalPrinterError mnError; // error code + sal_uIntPtr 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; } +}; + +#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..4121d2c89 --- /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 + long mnWidth; + 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, long nWidth = 0, long nHeight = 0); + virtual ~WinSalVirtualDevice() override; + + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; + virtual bool SetSize( long nNewDX, long nNewDY ) override; + + static HBITMAP ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, sal_uInt16 nBitCount, void **ppDummy); + + // SalGeometryProvider + virtual long GetWidth() const override { return mnWidth; } + virtual 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..05b4800e1 --- /dev/null +++ b/vcl/inc/win/wincomp.hxx @@ -0,0 +1,234 @@ +/* -*- 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_WINCOMP_HXX +#define INCLUDED_VCL_INC_WIN_WINCOMP_HXX + +#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 + +#endif // INCLUDED_VCL_INC_WIN_WINCOMP_HXX + +/* 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..679be2c36 --- /dev/null +++ b/vcl/inc/win/wingdiimpl.hxx @@ -0,0 +1,61 @@ +/* -*- 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(){}; + + // Implementation for WinSalGraphics::DrawTextLayout(). + // Returns true if handled, if false, then WinSalGraphics will handle it itself. + virtual bool DrawTextLayout(const GenericSalLayout&) { return false; } + // If true is returned, the following functions are used for text rendering. + virtual bool UseTextDraw() const { return false; } + virtual void PreDrawText() {} + virtual void PostDrawText() {} + virtual void DrawTextMask(CompatibleDC::Texture* /*rTexture*/, Color /*nMaskColor*/, + const SalTwoRect& /*rPosAry*/) + { + abort(); + }; + virtual void DeferredTextDraw(const CompatibleDC::Texture* /*pTexture*/, Color /*nMaskColor*/, + const SalTwoRect& /*rPosAry*/) + { + abort(); + }; +}; + +#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..35a855a37 --- /dev/null +++ b/vcl/inc/win/winlayout.hxx @@ -0,0 +1,187 @@ +/* -*- 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_WINLAYOUT_HXX +#define INCLUDED_VCL_INC_WIN_WINLAYOUT_HXX + +#include <rtl/ustring.hxx> + +#include <sallayout.hxx> +#include <svsys.h> +#include <win/salgdi.h> +#include <o3tl/sorted_vector.hxx> + +class WinFontInstance; + +namespace +{ +// Extra space at the top and bottom of the glyph in total = tmHeight / GLYPH_SPACE_RATIO; +const int GLYPH_SPACE_RATIO = 8; +// Border size at the top of the glyph = tmHeight / GLYPH_OFFSET_RATIO; +const int GLYPH_OFFSET_RATIO = GLYPH_SPACE_RATIO * 2; +} + +struct WinGlyphDrawElement +{ + tools::Rectangle maLocation; + int maLeftOverhangs; + std::unique_ptr<CompatibleDC::Texture> maTexture; + int mnBaselineOffset; + int mnHeight; + bool mbVertical; + + int getExtraSpace() const + { + return std::max(mnHeight / GLYPH_SPACE_RATIO, 4); + } + + int getExtraOffset() const + { + return std::max(mnHeight / GLYPH_OFFSET_RATIO, 2); + } +}; + +class WinGlyphCache; + +struct GlobalWinGlyphCache +{ + o3tl::sorted_vector<WinGlyphCache*> maWinGlyphCaches; + + static GlobalWinGlyphCache * get(); + + virtual ~GlobalWinGlyphCache() {} + virtual bool AllocateTexture(WinGlyphDrawElement& rElement, CompatibleDC* dc) = 0; + virtual void NotifyElementUsed(WinGlyphDrawElement& /*rElement*/) {} + virtual void Prune() {} +}; + +class WinGlyphCache +{ +protected: + std::unordered_map<int, WinGlyphDrawElement> maWinTextureCache; + +public: + WinGlyphCache() + { + if(GlobalWinGlyphCache* c = GlobalWinGlyphCache::get()) + c->maWinGlyphCaches.insert(this); + } + + virtual ~WinGlyphCache() + { + if(GlobalWinGlyphCache* c = GlobalWinGlyphCache::get()) + c->maWinGlyphCaches.erase(this); + } + + void PutDrawElementInCache(WinGlyphDrawElement&& rElement, int nGlyphIndex) + { + assert(GlobalWinGlyphCache::get()); + assert(!IsGlyphCached(nGlyphIndex)); + maWinTextureCache[nGlyphIndex] = std::move( rElement ); + } + + WinGlyphDrawElement& GetDrawElement(int nGlyphIndex) + { + assert(GlobalWinGlyphCache::get()); + assert(IsGlyphCached(nGlyphIndex)); + WinGlyphDrawElement& element = maWinTextureCache[nGlyphIndex]; + GlobalWinGlyphCache::get()->NotifyElementUsed(element); + return element; + } + + bool IsGlyphCached(int nGlyphIndex) const + { + return maWinTextureCache.find(nGlyphIndex) != maWinTextureCache.end(); + } +}; + +// win32 specific logical font instance +class WinFontInstance : public LogicalFontInstance +{ + friend rtl::Reference<LogicalFontInstance> WinFontFace::CreateFontInstance(const 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; } + + // Prevent deletion of the HFONT in the WinFontInstance destructor + // Used for the ScopedFont handling + void SetHFONT(HFONT hFont) { m_hFont = hFont; } + + const WinFontFace * GetFontFace() const { return static_cast<const WinFontFace *>(LogicalFontInstance::GetFontFace()); } + WinFontFace * GetFontFace() { return static_cast<WinFontFace *>(LogicalFontInstance::GetFontFace()); } + + bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics, const GenericSalLayout& rLayout); + WinGlyphCache& GetWinGlyphCache() { return maWinGlyphCache; } + + bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override; + +private: + explicit WinFontInstance(const WinFontFace&, const FontSelectPattern&); + + hb_font_t* ImplInitHbFont() override; + bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override; + + WinSalGraphics *m_pGraphics; + HFONT m_hFont; + float m_fScale; + WinGlyphCache maWinGlyphCache; +}; + +class TextOutRenderer +{ +protected: + explicit TextOutRenderer() = default; + TextOutRenderer(const TextOutRenderer &) = delete; + TextOutRenderer & operator = (const TextOutRenderer &) = delete; + +public: + static TextOutRenderer & get(bool bUseDWrite); + + virtual ~TextOutRenderer() = default; + + virtual bool operator ()(GenericSalLayout const &rLayout, + SalGraphics &rGraphics, + HDC hDC) = 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) override; +}; + +#endif // INCLUDED_VCL_INC_WIN_WINLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |