LibreOffice Module vcl (master)  1
win/saldata.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_WIN_SALDATA_HXX
21 #define INCLUDED_VCL_INC_WIN_SALDATA_HXX
22 
23 #include <memory>
24 #include <osl/module.h>
25 
26 #include <svdata.hxx>
27 #include <salwtype.hxx>
28 
29 #include <win/wincomp.hxx>
30 
31 #include <set>
32 #include <map>
33 
34 class AutoTimer;
35 class WinSalInstance;
36 class WinSalObject;
37 class WinSalFrame;
39 class WinSalPrinter;
40 namespace vcl { class Font; }
41 struct GlobalWinGlyphCache;
42 struct HDCCache;
43 struct TempFontItem;
44 class TextOutRenderer;
46 class SkiaControlsCache;
47 
48 #define MAX_STOCKPEN 4
49 #define MAX_STOCKBRUSH 4
50 #define SAL_CLIPRECT_COUNT 16
51 
52 struct SalIcon
53 {
54  int nId;
55  HICON hIcon;
56  HICON hSmallIcon;
58 };
59 
60 class SalData
61 {
62 public:
63  SalData();
64  ~SalData();
65 
66  // native widget framework
67  static void initNWF();
68  static void deInitNWF();
69 
70  // fill maVKMap;
71  void initKeyCodeMap();
72 
73  // checks if the menuhandle was created by VCL
74  bool IsKnownMenuHandle( HMENU hMenu );
75 
77 
78 public:
79  HINSTANCE mhInst; // default instance handle
80  int mnCmdShow; // default frame show style
81  HPALETTE mhDitherPal; // dither palette
82  HGLOBAL mhDitherDIB; // dither memory handle
83  BYTE* mpDitherDIB; // dither memory
84  BYTE* mpDitherDIBData; // beginning of DIB data
85  long* mpDitherDiff; // Dither mapping table
86  BYTE* mpDitherLow; // Dither mapping table
87  BYTE* mpDitherHigh; // Dither mapping table
88  HHOOK mhSalObjMsgHook; // hook to get interesting msg for SalObject
89  HWND mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message
90  AutoTimer* mpMouseLeaveTimer; // Timer for MouseLeave Test
92  WinSalFrame* mpFirstFrame; // pointer of first frame
93  WinSalObject* mpFirstObject; // pointer of first object window
94  WinSalVirtualDevice* mpFirstVD; // first VirDev
95  WinSalPrinter* mpFirstPrinter; // first printing printer
96  HDCCache* mpHDCCache; // Cache for three DC's
97  HBITMAP mh50Bmp; // 50% Bitmap
98  HBRUSH mh50Brush; // 50% Brush
103  sal_uInt16 mnStockPenCount; // count of static pens
104  sal_uInt16 mnStockBrushCount; // count of static brushes
105  WPARAM mnSalObjWantKeyEvt; // KeyEvent that should be processed by SalObj-Hook
106  BYTE mnCacheDCInUse; // count of CacheDC in use
107  bool mbObjClassInit; // is SALOBJECTCLASS initialised
108  bool mbInPalChange; // is in WM_QUERYNEWPALETTE
109  DWORD mnAppThreadId; // Id from Application-Thread
110  BOOL mbScrSvrEnabled; // ScreenSaver enabled
111  SalIcon* mpFirstIcon; // icon cache, points to first icon, NULL if none
112  TempFontItem* mpSharedTempFontItem; // LibreOffice shared fonts
113  TempFontItem* mpOtherTempFontItem; // other temporary fonts (embedded?)
114  bool mbThemeChanged; // true if visual theme was changed: throw away theme handles
116 
117  // for GdiPlus GdiplusStartup/GdiplusShutdown
118  ULONG_PTR gdiplusToken;
119 
120  std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
121  std::map< UINT,sal_uInt16 > maVKMap; // map some dynamic VK_* entries
122 
123  std::unique_ptr<TextOutRenderer> m_pD2DWriteTextOutRenderer;
124  // tdf#107205 need 2 instances because D2DWrite can't rotate text
125  std::unique_ptr<TextOutRenderer> m_pExTextOutRenderer;
126  std::unique_ptr<GlobalWinGlyphCache> m_pGlobalWinGlyphCache;
127  std::unique_ptr<OpenGLControlsCache> m_pOpenGLControlsCache;
128  std::unique_ptr<SkiaControlsCache> m_pSkiaControlsCache;
129 };
130 
131 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; }
132 inline SalData* GetSalData() { return ImplGetSVData()->mpSalData; }
133 
135 {
136  HINSTANCE mhInst; // Instance of SAL-DLL
137  UINT mnWheelScrollLines; // WheelScrollLines
138  UINT mnWheelScrollChars; // WheelScrollChars
139 };
140 
141 extern SalShlData aSalShlData;
142 
143 #define CACHESIZE_HDC 3
144 #define CACHED_HDC_1 0
145 #define CACHED_HDC_2 1
146 #define CACHED_HDC_DRAW 2
147 #define CACHED_HDC_DEFEXT 64
148 
149 struct HDCCache
150 {
151  HDC mhDC;
152  HPALETTE mhDefPal;
153  HBITMAP mhDefBmp;
154  HBITMAP mhSelBmp;
155  HBITMAP mhActBmp;
156 };
157 
158 void ImplClearHDCCache( SalData* pData );
159 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
160 void ImplReleaseCachedDC( sal_uLong nID );
161 
162 void ImplReleaseTempFonts(SalData&, bool bAll);
163 
164 HCURSOR ImplLoadSalCursor( int nId );
165 HBITMAP ImplLoadSalBitmap( int nId );
166 bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon );
167 
168 void ImplInitSalGDI();
169 void ImplFreeSalGDI();
170 
171 void ImplSalYieldMutexAcquireWithWait( sal_uInt32 nCount = 1 );
174 
175 LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
176 
177 void SalTestMouseLeave();
178 
179 bool ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
180 bool ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam );
181 bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult );
182 
183 WinSalObject* ImplFindSalObject( HWND hWndChild );
184 bool ImplSalPreDispatchMsg( const MSG* pMsg );
185 void ImplSalPostDispatchMsg( const MSG* pMsg );
186 
187 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Font& rFont );
188 
189 rtl_TextEncoding ImplSalGetSystemEncoding();
190 OUString ImplSalGetUniString(const char* pStr, sal_Int32 nLen = -1);
191 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 );
192 
193 #define SAL_FRAME_WNDEXTRA sizeof( DWORD )
194 #define SAL_FRAME_THIS GWLP_USERDATA
195 #define SAL_FRAME_CLASSNAMEW L"SALFRAME"
196 #define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME"
197 #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME"
198 #define SAL_OBJECT_WNDEXTRA sizeof( DWORD )
199 #define SAL_OBJECT_THIS GWLP_USERDATA
200 #define SAL_OBJECT_CLASSNAMEW L"SALOBJECT"
201 #define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD"
202 #define SAL_COM_CLASSNAMEW L"SALCOMWND"
203 
204 #define SAL_MOUSELEAVE_TIMEOUT 300
205 
206 // wParam == bWait; lParam == 0
207 #define SAL_MSG_THREADYIELD (WM_USER+111)
208 // wParam == 0; lParam == nMS
209 #define SAL_MSG_STARTTIMER (WM_USER+113)
210 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
211 #define SAL_MSG_CREATEFRAME (WM_USER+114)
212 // wParam == 0; lParam == 0
213 #define SAL_MSG_DESTROYFRAME (WM_USER+115)
214 // wParam == 0; lParam == pParent; lResult == pObject
215 #define SAL_MSG_CREATEOBJECT (WM_USER+116)
216 // wParam == 0; lParam == pObject;
217 #define SAL_MSG_DESTROYOBJECT (WM_USER+117)
218 // wParam == hWnd; lParam == 0; lResult == hDC
219 #define SAL_MSG_GETCACHEDDC (WM_USER+120)
220 // wParam == hWnd; lParam == 0
221 #define SAL_MSG_RELEASEDC (WM_USER+121)
222 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
223 #define SAL_MSG_RECREATEHWND (WM_USER+122)
224 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
225 #define SAL_MSG_RECREATECHILDHWND (WM_USER+123)
226 // wParam == 0; lParam == HWND;
227 #define SAL_MSG_DESTROYHWND (WM_USER+124)
228 
229 // wParam == 0; lParam == pData
230 #define SAL_MSG_USEREVENT (WM_USER+130)
231 // wParam == 0; lParam == MousePosition relative to upper left of screen
232 #define SAL_MSG_MOUSELEAVE (WM_USER+131)
233 // NULL-Message, should not be processed
234 #define SAL_MSG_DUMMY (WM_USER+132)
235 // Used for SETFOCUS and KILLFOCUS
236 // wParam == 0; lParam == 0
237 #define SAL_MSG_POSTFOCUS (WM_USER+133)
238 // wParam == wParam; lParam == lParam
239 #define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134)
240 // wParam == wParam; lParam == lParam
241 #define SAL_MSG_POSTPALCHANGED (WM_USER+135)
242 // wParam == wParam; lParam == lParam
243 #define SAL_MSG_POSTMOVE (WM_USER+136)
244 // wParam == wParam; lParam == lParam
245 #define SAL_MSG_POSTCALLSIZE (WM_USER+137)
246 // wParam == pRECT; lParam == 0
247 #define SAL_MSG_POSTPAINT (WM_USER+138)
248 // wParam == 0; lParam == pFrame; lResult 0
249 #define SAL_MSG_FORCEPALETTE (WM_USER+139)
250 // wParam == 0; lParam == 0
251 #define SAL_MSG_CAPTUREMOUSE (WM_USER+140)
252 // wParam == 0; lParam == 0
253 #define SAL_MSG_RELEASEMOUSE (WM_USER+141)
254 // wParam == nFlags; lParam == 0
255 #define SAL_MSG_TOTOP (WM_USER+142)
256 // wParam == bVisible; lParam == 0
257 #define SAL_MSG_SHOW (WM_USER+143)
258 // wParam == 0; lParam == SalInputContext
259 #define SAL_MSG_SETINPUTCONTEXT (WM_USER+144)
260 // wParam == nFlags; lParam == 0
261 #define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145)
262 
263 // SysChild-ToTop; wParam = 0; lParam = 0
264 #define SALOBJ_MSG_TOTOP (WM_USER+160)
265 // Used for SETFOCUS and KILLFOCUS
266 // POSTFOCUS-Message; wParam == bFocus; lParam == 0
267 #define SALOBJ_MSG_POSTFOCUS (WM_USER+161)
268 
269 // Call the Timer's callback from the main thread
270 // wParam = 1 == run when yield is idle instead of direct
271 #define SAL_MSG_TIMER_CALLBACK (WM_USER+162)
272 // Stop the timer from the main thread; wParam = 0, lParam = 0
273 #define SAL_MSG_STOPTIMER (WM_USER+163)
274 // Start a real timer while GUI is blocked by native dialog
275 #define SAL_MSG_FORCE_REAL_TIMER (WM_USER+164)
276 
277 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
278 {
279  SetWindowLongPtrW( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) );
280 }
281 
282 inline WinSalFrame* GetWindowPtr( HWND hWnd )
283 {
284  return reinterpret_cast<WinSalFrame*>(GetWindowLongPtrW( hWnd, SAL_FRAME_THIS ));
285 }
286 
287 inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis )
288 {
289  SetWindowLongPtrW( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) );
290 }
291 
292 inline WinSalObject* GetSalObjWindowPtr( HWND hWnd )
293 {
294  return reinterpret_cast<WinSalObject*>(GetWindowLongPtrW( hWnd, SAL_OBJECT_THIS ));
295 }
296 
297 #endif // INCLUDED_VCL_INC_WIN_SALDATA_HXX
298 
299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbThemeMenuSupport
std::map< UINT, sal_uInt16 > maVKMap
std::unique_ptr< OpenGLControlsCache > m_pOpenGLControlsCache
SalData * mpSalData
Definition: svdata.hxx:343
HBITMAP mh50Bmp
Definition: win/saldata.hxx:97
bool ImplHandleGlobalMsg(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT &rlResult)
HBITMAP mhActBmp
unsigned char BYTE
std::unique_ptr< TextOutRenderer > m_pExTextOutRenderer
void SalTestMouseLeave()
TempFontItem * mpSharedTempFontItem
sal_uIntPtr sal_uLong
HBRUSH mh50Brush
Definition: win/saldata.hxx:98
bool IsKnownMenuHandle(HMENU hMenu)
BYTE * mpDitherDIB
Definition: win/saldata.hxx:83
WinSalPrinter * mpFirstPrinter
Definition: win/saldata.hxx:95
void ImplSalLogFontToFontW(HDC hDC, const LOGFONTW &rLogFont, vcl::Font &rFont)
DWORD mnAppThreadId
void ImplSalYieldMutexAcquireWithWait(sal_uInt32 nCount=1)
bool ImplHandleSalObjSysCharMsg(HWND hWnd, WPARAM wParam, LPARAM lParam)
HICON hIcon
Definition: win/saldata.hxx:55
COLORREF maStockBrushColorAry[MAX_STOCKBRUSH]
bool ImplLoadSalIcon(int nId, HICON &rIcon, HICON &rSmallIcon)
const wchar_t *typedef BOOL
void ImplSalPostDispatchMsg(const MSG *pMsg)
#define MAX_STOCKPEN
Definition: win/saldata.hxx:48
void ImplSalYieldMutexRelease()
HHOOK mhSalObjMsgHook
Definition: win/saldata.hxx:88
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
An auto-timer is a multi-shot timer re-emitting itself at interval until destroyed or stopped...
Definition: timer.hxx:72
static void initNWF()
UINT mnWheelScrollChars
HWND mhWantLeaveMsg
Definition: win/saldata.hxx:89
BYTE * mpDitherHigh
Definition: win/saldata.hxx:87
void SetWindowPtr(HWND hWnd, WinSalFrame *pThis)
bool ImplSalPreDispatchMsg(const MSG *pMsg)
WinSalFrame * mpFirstFrame
Definition: win/saldata.hxx:92
bool mbThemeChanged
HBITMAP mhDefBmp
#define MAX_STOCKBRUSH
Definition: win/saldata.hxx:49
void ImplFreeSalGDI()
std::set< HMENU > mhMenuSet
void ImplReleaseCachedDC(sal_uLong nID)
HBITMAP ImplLoadSalBitmap(int nId)
#define SAL_OBJECT_THIS
bool mbObjClassInit
bool mbInPalChange
ULONG_PTR gdiplusToken
HPALETTE mhDefPal
HBITMAP mhSelBmp
BYTE * mpDitherDIBData
Definition: win/saldata.hxx:84
HBRUSH mhStockBrushAry[MAX_STOCKBRUSH]
sal_uInt16 mnStockPenCount
static void deInitNWF()
WinSalVirtualDevice * mpFirstVD
Definition: win/saldata.hxx:94
void ImplReleaseTempFonts(SalData &, bool bAll)
HCURSOR ImplLoadSalCursor(int nId)
BOOL mbScrSvrEnabled
WinSalFrame * GetWindowPtr(HWND hWnd)
HINSTANCE mhInst
Definition: win/saldata.hxx:79
std::unique_ptr< SkiaControlsCache > m_pSkiaControlsCache
HINSTANCE mhInst
HPEN mhStockPenAry[MAX_STOCKPEN]
TempFontItem * mpOtherTempFontItem
#define SAL_FRAME_THIS
int ImplSalWICompareAscii(const wchar_t *pStr1, const char *pStr2)
BYTE mnCacheDCInUse
LRESULT CALLBACK SalFrameWndProcW(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
void SetSalData(SalData *pData)
~SalData()
Definition: salplug.cxx:338
void ImplClearHDCCache(SalData *pData)
SalIcon * pNext
Definition: win/saldata.hxx:57
HGLOBAL mhDitherDIB
Definition: win/saldata.hxx:82
sal_uInt16 mnStockBrushCount
bool ImplSalYieldMutexTryToAcquire()
SalData()
Definition: salplug.cxx:332
void ImplInitSalGDI()
WinSalObject * ImplFindSalObject(HWND hWndChild)
WinSalInstance * mpInstance
Definition: win/saldata.hxx:91
SalData * GetSalData()
SalShlData aSalShlData
rtl_TextEncoding ImplSalGetSystemEncoding()
COLORREF maStockPenColorAry[MAX_STOCKPEN]
Definition: win/saldata.hxx:99
HDCCache * mpHDCCache
Definition: win/saldata.hxx:96
WinSalObject * GetSalObjWindowPtr(HWND hWnd)
#define CALLBACK
HDC ImplGetCachedDC(sal_uLong nID, HBITMAP hBmp=nullptr)
AutoTimer * mpMouseLeaveTimer
Definition: win/saldata.hxx:90
bool mbResourcesAlreadyFreed
Definition: win/saldata.hxx:76
SalIcon * mpFirstIcon
std::unique_ptr< TextOutRenderer > m_pD2DWriteTextOutRenderer
bool ImplHandleSalObjKeyMsg(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
int mnCmdShow
Definition: win/saldata.hxx:80
std::unique_ptr< GlobalWinGlyphCache > m_pGlobalWinGlyphCache
BYTE * mpDitherLow
Definition: win/saldata.hxx:86
OUString ImplSalGetUniString(const char *pStr, sal_Int32 nLen=-1)
HPALETTE mhDitherPal
Definition: win/saldata.hxx:81
UINT mnWheelScrollLines
WPARAM mnSalObjWantKeyEvt
void SetSalObjWindowPtr(HWND hWnd, WinSalObject *pThis)
WinSalObject * mpFirstObject
Definition: win/saldata.hxx:93
HICON hSmallIcon
Definition: win/saldata.hxx:56
long * mpDitherDiff
Definition: win/saldata.hxx:85
void initKeyCodeMap()