1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_VCL_INC_WIN_SALDATA_HXX
21 #define INCLUDED_VCL_INC_WIN_SALDATA_HXX
24 #include "osl/module.h"
27 #include <salwtype.hxx>
29 #include <win/wincomp.hxx>
38 class WinSalVirtualDevice
;
40 namespace vcl
{ class Font
; }
41 struct GlobalGlyphCache
;
44 class TextOutRenderer
;
45 class TheTextureCache
;
47 #define MAX_STOCKPEN 4
48 #define MAX_STOCKBRUSH 4
49 #define SAL_CLIPRECT_COUNT 16
65 // native widget framework
66 static void initNWF();
67 static void deInitNWF();
70 void initKeyCodeMap();
72 // checks if the menuhandle was created by VCL
73 bool IsKnownMenuHandle( HMENU hMenu
);
75 bool mbResourcesAlreadyFreed
;
78 HINSTANCE mhInst
; // default instance handle
79 int mnCmdShow
; // default frame show style
80 HPALETTE mhDitherPal
; // dither palette
81 HGLOBAL mhDitherDIB
; // dither memory handle
82 BYTE
* mpDitherDIB
; // dither memory
83 BYTE
* mpDitherDIBData
; // beginning of DIB data
84 long* mpDitherDiff
; // Dither mapping table
85 BYTE
* mpDitherLow
; // Dither mapping table
86 BYTE
* mpDitherHigh
; // Dither mapping table
87 sal_uLong mnTimerMS
; // Current Time (in MS) of the Timer
88 sal_uLong mnTimerOrgMS
; // Current Original Time (in MS)
89 DWORD mnNextTimerTime
;
90 DWORD mnLastEventTime
;
91 HANDLE mnTimerId
; ///< Windows timer id
92 HHOOK mhSalObjMsgHook
; // hook to get interesting msg for SalObject
93 HWND mhWantLeaveMsg
; // window handle, that want a MOUSELEAVE message
94 AutoTimer
* mpMouseLeaveTimer
; // Timer for MouseLeave Test
95 WinSalInstance
* mpFirstInstance
; // pointer of first instance
96 WinSalFrame
* mpFirstFrame
; // pointer of first frame
97 WinSalObject
* mpFirstObject
; // pointer of first object window
98 WinSalVirtualDevice
* mpFirstVD
; // first VirDev
99 WinSalPrinter
* mpFirstPrinter
; // first printing printer
100 HDCCache
* mpHDCCache
; // Cache for three DC's
101 HBITMAP mh50Bmp
; // 50% Bitmap
102 HBRUSH mh50Brush
; // 50% Brush
103 COLORREF maStockPenColorAry
[MAX_STOCKPEN
];
104 COLORREF maStockBrushColorAry
[MAX_STOCKBRUSH
];
105 HPEN mhStockPenAry
[MAX_STOCKPEN
];
106 HBRUSH mhStockBrushAry
[MAX_STOCKBRUSH
];
107 sal_uInt16 mnStockPenCount
; // count of static pens
108 sal_uInt16 mnStockBrushCount
; // count of static brushes
109 WPARAM mnSalObjWantKeyEvt
; // KeyEvent that should be processed by SalObj-Hook
110 BYTE mnCacheDCInUse
; // count of CacheDC in use
111 bool mbObjClassInit
; // is SALOBJECTCLASS initialised
112 bool mbInPalChange
; // is in WM_QUERYNEWPALETTE
113 DWORD mnAppThreadId
; // Id from Application-Thread
114 BOOL mbScrSvrEnabled
; // ScreenSaver enabled
115 SalIcon
* mpFirstIcon
; // icon cache, points to first icon, NULL if none
116 TempFontItem
* mpTempFontItem
;
117 bool mbThemeChanged
; // true if visual theme was changed: throw away theme handles
118 bool mbThemeMenuSupport
;
120 // for GdiPlus GdiplusStartup/GdiplusShutdown
121 ULONG_PTR gdiplusToken
;
123 std::set
< HMENU
> mhMenuSet
; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
124 std::map
< UINT
,sal_uInt16
> maVKMap
; // map some dynamic VK_* entries
126 // must be deleted before exit(), so delete it in DeInitSalData()
127 std::unique_ptr
<TextOutRenderer
> m_pD2DWriteTextOutRenderer
;
128 // tdf#107205 need 2 instances because D2DWrite can't rotate text
129 std::unique_ptr
<TextOutRenderer
> m_pExTextOutRenderer
;
130 std::unique_ptr
<GlobalGlyphCache
> m_pGlobalGlyphCache
;
131 std::unique_ptr
<TheTextureCache
> m_pTextureCache
;
134 inline void SetSalData( SalData
* pData
) { ImplGetSVData()->mpSalData
= pData
; }
135 inline SalData
* GetSalData() { return ImplGetSVData()->mpSalData
; }
139 HINSTANCE mhInst
; // Instance of SAL-DLL
140 UINT mnWheelScrollLines
; // WheelScrollLines
141 UINT mnWheelScrollChars
; // WheelScrollChars
142 BOOL mbWXP
; // Windows XP
143 BOOL mbWVista
; // Windows Vista
144 BOOL mbW7
; // Windows 7
147 extern SalShlData aSalShlData
;
149 #define CACHESIZE_HDC 3
150 #define CACHED_HDC_1 0
151 #define CACHED_HDC_2 1
152 #define CACHED_HDC_DRAW 2
153 #define CACHED_HDC_DEFEXT 64
164 void ImplClearHDCCache( SalData
* pData
);
165 HDC
ImplGetCachedDC( sal_uLong nID
, HBITMAP hBmp
= nullptr );
166 void ImplReleaseCachedDC( sal_uLong nID
);
168 bool ImplAddTempFont( SalData
&, const OUString
& rFontFileURL
);
169 void ImplReleaseTempFonts( SalData
& );
171 HCURSOR
ImplLoadSalCursor( int nId
);
172 HBITMAP
ImplLoadSalBitmap( int nId
);
173 bool ImplLoadSalIcon( int nId
, HICON
& rIcon
, HICON
& rSmallIcon
);
175 void ImplInitSalGDI();
176 void ImplFreeSalGDI();
178 void ImplSalYieldMutexAcquireWithWait();
179 bool ImplSalYieldMutexTryToAcquire();
180 void ImplSalYieldMutexRelease();
181 sal_uLong
ImplSalReleaseYieldMutex();
182 void ImplSalAcquireYieldMutex( sal_uLong nCount
);
184 LRESULT CALLBACK
SalFrameWndProcW( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
);
186 void EmitTimerCallback();
188 void SalTestMouseLeave();
190 long ImplHandleSalObjKeyMsg( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
);
191 long ImplHandleSalObjSysCharMsg( HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
192 bool ImplHandleGlobalMsg( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
& rlResult
);
194 WinSalObject
* ImplFindSalObject( HWND hWndChild
);
195 bool ImplSalPreDispatchMsg( MSG
* pMsg
);
196 void ImplSalPostDispatchMsg( MSG
* pMsg
, LRESULT nDispatchResult
);
198 void ImplSalLogFontToFontW( HDC hDC
, const LOGFONTW
& rLogFont
, vcl::Font
& rFont
);
200 rtl_TextEncoding
ImplSalGetSystemEncoding();
201 OUString
ImplSalGetUniString(const sal_Char
* pStr
, sal_Int32 nLen
= -1);
202 int ImplSalWICompareAscii( const wchar_t* pStr1
, const char* pStr2
);
204 #define SAL_FRAME_WNDEXTRA sizeof( DWORD )
205 #define SAL_FRAME_THIS GWLP_USERDATA
206 #define SAL_FRAME_CLASSNAMEW L"SALFRAME"
207 #define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME"
208 #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME"
209 #define SAL_OBJECT_WNDEXTRA sizeof( DWORD )
210 #define SAL_OBJECT_THIS GWLP_USERDATA
211 #define SAL_OBJECT_CLASSNAMEA "SALOBJECT"
212 #define SAL_OBJECT_CHILDCLASSNAMEA "SALOBJECTCHILD"
213 #define SAL_COM_CLASSNAMEW L"SALCOMWND"
215 #define SAL_MOUSELEAVE_TIMEOUT 300
217 // wParam == bWait; lParam == 0
218 #define SAL_MSG_THREADYIELD (WM_USER+111)
219 // wParam == 0; lParam == nMS
220 #define SAL_MSG_STARTTIMER (WM_USER+113)
221 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
222 #define SAL_MSG_CREATEFRAME (WM_USER+114)
223 // wParam == 0; lParam == 0
224 #define SAL_MSG_DESTROYFRAME (WM_USER+115)
225 // wParam == 0; lParam == pParent; lResult == pObject
226 #define SAL_MSG_CREATEOBJECT (WM_USER+116)
227 // wParam == 0; lParam == pObject;
228 #define SAL_MSG_DESTROYOBJECT (WM_USER+117)
229 // wParam == hWnd; lParam == 0; lResult == hDC
230 #define SAL_MSG_GETDC (WM_USER+120)
231 // wParam == hWnd; lParam == 0
232 #define SAL_MSG_RELEASEDC (WM_USER+121)
233 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
234 #define SAL_MSG_RECREATEHWND (WM_USER+122)
235 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
236 #define SAL_MSG_RECREATECHILDHWND (WM_USER+123)
237 // wParam == 0; lParam == HWND;
238 #define SAL_MSG_DESTROYHWND (WM_USER+124)
240 // wParam == 0; lParam == pData
241 #define SAL_MSG_USEREVENT (WM_USER+130)
242 // wParam == 0; lParam == MousePosition relative to upper left of screen
243 #define SAL_MSG_MOUSELEAVE (WM_USER+131)
244 // NULL-Message, should not be processed
245 #define SAL_MSG_DUMMY (WM_USER+132)
246 // wParam == 0; lParam == 0
247 #define SAL_MSG_POSTFOCUS (WM_USER+133)
248 // wParam == wParam; lParam == lParam
249 #define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134)
250 // wParam == wParam; lParam == lParam
251 #define SAL_MSG_POSTPALCHANGED (WM_USER+135)
252 // wParam == wParam; lParam == lParam
253 #define SAL_MSG_POSTMOVE (WM_USER+136)
254 // wParam == wParam; lParam == lParam
255 #define SAL_MSG_POSTCALLSIZE (WM_USER+137)
256 // wParam == pRECT; lParam == 0
257 #define SAL_MSG_POSTPAINT (WM_USER+138)
258 // wParam == 0; lParam == pFrame; lResult 0
259 #define SAL_MSG_FORCEPALETTE (WM_USER+139)
260 // wParam == 0; lParam == 0
261 #define SAL_MSG_CAPTUREMOUSE (WM_USER+140)
262 // wParam == 0; lParam == 0
263 #define SAL_MSG_RELEASEMOUSE (WM_USER+141)
264 // wParam == nFlags; lParam == 0
265 #define SAL_MSG_TOTOP (WM_USER+142)
266 // wParam == bVisible; lParam == 0
267 #define SAL_MSG_SHOW (WM_USER+143)
268 // wParam == 0; lParam == SalInputContext
269 #define SAL_MSG_SETINPUTCONTEXT (WM_USER+144)
270 // wParam == nFlags; lParam == 0
271 #define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145)
272 // POSTTIMER-Message; wparam = 0, lParam == time
273 #define SAL_MSG_POSTTIMER (WM_USER+161)
275 // SysChild-ToTop; wParam = 0; lParam = 0
276 #define SALOBJ_MSG_TOTOP (WM_USER+160)
277 // POSTFOCUS-Message; wParam == bFocus; lParam == 0
278 #define SALOBJ_MSG_POSTFOCUS (WM_USER+161)
280 // Call the Timer's callback from the main thread
281 #define SAL_MSG_TIMER_CALLBACK (WM_USER+162)
282 // Stop the timer from the main thread; wParam = 0, lParam = 0
283 #define SAL_MSG_STOPTIMER (WM_USER+163)
285 inline void SetWindowPtr( HWND hWnd
, WinSalFrame
* pThis
)
287 SetWindowLongPtr( hWnd
, SAL_FRAME_THIS
, reinterpret_cast<LONG_PTR
>(pThis
) );
290 inline WinSalFrame
* GetWindowPtr( HWND hWnd
)
292 return reinterpret_cast<WinSalFrame
*>(GetWindowLongPtrW( hWnd
, SAL_FRAME_THIS
));
295 inline void SetSalObjWindowPtr( HWND hWnd
, WinSalObject
* pThis
)
297 SetWindowLongPtr( hWnd
, SAL_OBJECT_THIS
, reinterpret_cast<LONG_PTR
>(pThis
) );
300 inline WinSalObject
* GetSalObjWindowPtr( HWND hWnd
)
302 return reinterpret_cast<WinSalObject
*>(GetWindowLongPtr( hWnd
, SAL_OBJECT_THIS
));
305 #endif // INCLUDED_VCL_INC_WIN_SALDATA_HXX
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */