tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / vcl / inc / win / saldata.hxx
blob607788fbd34f740034ab592de3c15f8f910d33e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <config_features.h>
24 #include <array>
25 #include <memory>
26 #include <osl/module.h>
28 #include <svdata.hxx>
29 #include <salwtype.hxx>
31 #include <systools/win32/comtools.hxx>
32 #include <tools/long.hxx>
34 #include <win/wincomp.hxx>
36 #include <set>
37 #include <map>
39 class AutoTimer;
40 class WinSalInstance;
41 class WinSalObject;
42 class WinSalFrame;
43 class WinSalVirtualDevice;
44 class WinSalPrinter;
45 namespace vcl { class Font; }
46 struct HDCCache;
47 struct TempFontItem;
48 class TextOutRenderer;
49 #if HAVE_FEATURE_SKIA
50 class SkiaControlsCache;
51 #endif
53 #define MAX_STOCKPEN 4
54 #define MAX_STOCKBRUSH 4
55 #define SAL_CLIPRECT_COUNT 16
57 #define CACHESIZE_HDC 3
58 #define CACHED_HDC_1 0
59 #define CACHED_HDC_2 1
60 #define CACHED_HDC_DRAW 2
61 #define CACHED_HDC_DEFEXT 64
63 struct HDCCache
65 HDC mhDC = nullptr;
66 HPALETTE mhDefPal = nullptr;
67 HBITMAP mhDefBmp = nullptr;
68 HBITMAP mhSelBmp = nullptr;
69 HBITMAP mhActBmp = nullptr;
72 struct SalIcon
74 int nId;
75 HICON hIcon;
76 HICON hSmallIcon;
77 SalIcon *pNext;
80 class SalData : public sal::systools::CoInitializeGuard
82 public:
83 SalData();
84 ~SalData();
86 // native widget framework
87 static void initNWF();
88 static void deInitNWF();
90 // fill maVKMap;
91 void initKeyCodeMap();
93 // checks if the menuhandle was created by VCL
94 bool IsKnownMenuHandle( HMENU hMenu );
96 bool mbResourcesAlreadyFreed;
98 public:
99 HINSTANCE mhInst; // default instance handle
100 int mnCmdShow; // default frame show style
101 HPALETTE mhDitherPal; // dither palette
102 HGLOBAL mhDitherDIB; // dither memory handle
103 BYTE* mpDitherDIB; // dither memory
104 BYTE* mpDitherDIBData; // beginning of DIB data
105 std::unique_ptr<tools::Long[]> mpDitherDiff; // Dither mapping table
106 std::unique_ptr<BYTE[]> mpDitherLow; // Dither mapping table
107 std::unique_ptr<BYTE[]> mpDitherHigh; // Dither mapping table
108 HHOOK mhSalObjMsgHook; // hook to get interesting msg for SalObject
109 HWND mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message
110 WinSalInstance* mpInstance;
111 WinSalFrame* mpFirstFrame; // pointer of first frame
112 WinSalObject* mpFirstObject; // pointer of first object window
113 WinSalVirtualDevice* mpFirstVD; // first VirDev
114 WinSalPrinter* mpFirstPrinter; // first printing printer
115 std::array<HDCCache, CACHESIZE_HDC> maHDCCache; // Cache for three DC's
116 HBITMAP mh50Bmp; // 50% Bitmap
117 HBRUSH mh50Brush; // 50% Brush
118 COLORREF maStockPenColorAry[MAX_STOCKPEN];
119 COLORREF maStockBrushColorAry[MAX_STOCKBRUSH];
120 HPEN mhStockPenAry[MAX_STOCKPEN];
121 HBRUSH mhStockBrushAry[MAX_STOCKBRUSH];
122 sal_uInt16 mnStockPenCount; // count of static pens
123 sal_uInt16 mnStockBrushCount; // count of static brushes
124 WPARAM mnSalObjWantKeyEvt; // KeyEvent that should be processed by SalObj-Hook
125 BYTE mnCacheDCInUse; // count of CacheDC in use
126 bool mbObjClassInit; // is SALOBJECTCLASS initialised
127 bool mbInPalChange; // is in WM_QUERYNEWPALETTE
128 DWORD mnAppThreadId; // Id from Application-Thread
129 SalIcon* mpFirstIcon; // icon cache, points to first icon, NULL if none
130 TempFontItem* mpSharedTempFontItem; // LibreOffice shared fonts
131 TempFontItem* mpOtherTempFontItem; // other temporary fonts (embedded?)
132 bool mbThemeChanged; // true if visual theme was changed: throw away theme handles
133 bool mbThemeMenuSupport;
135 // for GdiPlus GdiplusStartup/GdiplusShutdown
136 ULONG_PTR gdiplusToken;
138 std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
139 std::map< UINT,sal_uInt16 > maVKMap; // map some dynamic VK_* entries
141 std::unique_ptr<TextOutRenderer> m_pD2DWriteTextOutRenderer;
142 // tdf#107205 need 2 instances because D2DWrite can't rotate text
143 std::unique_ptr<TextOutRenderer> m_pExTextOutRenderer;
144 #if HAVE_FEATURE_SKIA
145 std::unique_ptr<SkiaControlsCache> m_pSkiaControlsCache;
146 #endif
149 struct SalShlData
151 HINSTANCE mhInst; // Instance of SAL-DLL
152 UINT mnWheelScrollLines; // WheelScrollLines
153 UINT mnWheelScrollChars; // WheelScrollChars
156 extern SalShlData aSalShlData;
158 void ImplClearHDCCache( SalData* pData );
159 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
160 void ImplReleaseCachedDC( sal_uLong nID );
162 void ImplReleaseTempFonts(SalData&, bool bAll);
164 HCURSOR ImplLoadSalCursor( int nId );
165 HBITMAP ImplLoadSalBitmap( int nId );
166 bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon );
168 void ImplInitSalGDI();
169 void ImplFreeSalGDI();
171 void ImplSalYieldMutexAcquireWithWait( sal_uInt32 nCount = 1 );
172 bool ImplSalYieldMutexTryToAcquire();
173 void ImplSalYieldMutexRelease();
175 LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
177 void SalTestMouseLeave();
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 );
183 WinSalObject* ImplFindSalObject( HWND hWndChild );
184 bool ImplSalPreDispatchMsg( const MSG* pMsg );
185 void ImplSalPostDispatchMsg( const MSG* pMsg );
187 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Font& rFont );
189 rtl_TextEncoding ImplSalGetSystemEncoding();
190 OUString ImplSalGetUniString(const char* pStr, sal_Int32 nLen = -1);
192 #define SAL_FRAME_WNDEXTRA sizeof( DWORD )
193 #define SAL_FRAME_THIS GWLP_USERDATA
194 #define SAL_FRAME_CLASSNAMEW L"SALFRAME"
195 #define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME"
196 #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME"
197 #define SAL_OBJECT_WNDEXTRA sizeof( DWORD )
198 #define SAL_OBJECT_THIS GWLP_USERDATA
199 #define SAL_OBJECT_CLASSNAMEW L"SALOBJECT"
200 #define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD"
201 #define SAL_COM_CLASSNAMEW L"SALCOMWND"
203 // wParam == bWait; lParam == 0
204 #define SAL_MSG_THREADYIELD (WM_USER+111)
205 // wParam == 0; lParam == nMS
206 #define SAL_MSG_STARTTIMER (WM_USER+113)
207 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
208 #define SAL_MSG_CREATEFRAME (WM_USER+114)
209 // wParam == 0; lParam == 0
210 #define SAL_MSG_DESTROYFRAME (WM_USER+115)
211 // wParam == 0; lParam == pParent; lResult == pObject
212 #define SAL_MSG_CREATEOBJECT (WM_USER+116)
213 // wParam == 0; lParam == pObject;
214 #define SAL_MSG_DESTROYOBJECT (WM_USER+117)
215 // wParam == hWnd; lParam == 0; lResult == hDC
216 #define SAL_MSG_GETCACHEDDC (WM_USER+120)
217 // wParam == hWnd; lParam == 0
218 #define SAL_MSG_RELEASEDC (WM_USER+121)
219 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
220 #define SAL_MSG_RECREATEHWND (WM_USER+122)
221 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
222 #define SAL_MSG_RECREATECHILDHWND (WM_USER+123)
223 // wParam == 0; lParam == HWND;
224 #define SAL_MSG_DESTROYHWND (WM_USER+124)
226 // wParam == 0; lParam == pData
227 #define SAL_MSG_USEREVENT (WM_USER+130)
228 // wParam == 0; lParam == MousePosition relative to upper left of screen
229 #define SAL_MSG_MOUSELEAVE (WM_USER+131)
230 // NULL-Message, should not be processed
231 #define SAL_MSG_DUMMY (WM_USER+132)
232 // Used for SETFOCUS and KILLFOCUS
233 // wParam == 0; lParam == 0
234 #define SAL_MSG_POSTFOCUS (WM_USER+133)
235 // wParam == wParam; lParam == lParam
236 #define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134)
237 // wParam == wParam; lParam == lParam
238 #define SAL_MSG_POSTPALCHANGED (WM_USER+135)
239 // wParam == wParam; lParam == lParam
240 #define SAL_MSG_POSTMOVE (WM_USER+136)
241 // wParam == wParam; lParam == lParam
242 #define SAL_MSG_POSTCALLSIZE (WM_USER+137)
243 // wParam == pRECT; lParam == 0
244 #define SAL_MSG_POSTPAINT (WM_USER+138)
245 // wParam == 0; lParam == pFrame; lResult 0
246 #define SAL_MSG_FORCEPALETTE (WM_USER+139)
247 // wParam == 0; lParam == 0
248 #define SAL_MSG_CAPTUREMOUSE (WM_USER+140)
249 // wParam == 0; lParam == 0
250 #define SAL_MSG_RELEASEMOUSE (WM_USER+141)
251 // wParam == nFlags; lParam == 0
252 #define SAL_MSG_TOTOP (WM_USER+142)
253 // wParam == bVisible; lParam == 0
254 #define SAL_MSG_SHOW (WM_USER+143)
255 // wParam == 0; lParam == SalInputContext
256 #define SAL_MSG_SETINPUTCONTEXT (WM_USER+144)
257 // wParam == nFlags; lParam == 0
258 #define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145)
260 // SysChild-ToTop; wParam = 0; lParam = 0
261 #define SALOBJ_MSG_TOTOP (WM_USER+160)
262 // Used for SETFOCUS and KILLFOCUS
263 // POSTFOCUS-Message; wParam == bFocus; lParam == 0
264 #define SALOBJ_MSG_POSTFOCUS (WM_USER+161)
266 // Call the Timer's callback from the main thread
267 // wParam = 1 == run when yield is idle instead of direct
268 #define SAL_MSG_TIMER_CALLBACK (WM_USER+162)
269 // Stop the timer from the main thread; wParam = 0, lParam = 0
270 #define SAL_MSG_STOPTIMER (WM_USER+163)
271 // Start a real timer while GUI is blocked by native dialog
272 #define SAL_MSG_FORCE_REAL_TIMER (WM_USER+164)
274 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
276 SetWindowLongPtrW( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) );
279 inline WinSalFrame* GetWindowPtr( HWND hWnd )
281 return reinterpret_cast<WinSalFrame*>(GetWindowLongPtrW( hWnd, SAL_FRAME_THIS ));
284 inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis )
286 SetWindowLongPtrW( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) );
289 inline WinSalObject* GetSalObjWindowPtr( HWND hWnd )
291 return reinterpret_cast<WinSalObject*>(GetWindowLongPtrW( hWnd, SAL_OBJECT_THIS ));
294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */