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 _SV_SALDATA_HXX
21 #define _SV_SALDATA_HXX
23 #include "osl/module.h"
26 #include <salwtype.hxx>
28 #include <win/wincomp.hxx>
37 class WinSalVirtualDevice
;
43 typedef HRESULT (WINAPI
*DwmIsCompositionEnabled_ptr
)(BOOL
*);
45 #define MAX_STOCKPEN 4
46 #define MAX_STOCKBRUSH 4
47 #define SAL_CLIPRECT_COUNT 16
63 // native widget framework
68 void initKeyCodeMap();
70 // checks if the menuhandle was created by VCL
71 sal_Bool
IsKnownMenuHandle( HMENU hMenu
);
74 HINSTANCE mhInst
; // default instance handle
75 HINSTANCE mhPrevInst
; // previous instance handle
76 int mnCmdShow
; // default frame show style
77 HPALETTE mhDitherPal
; // dither palette
78 HGLOBAL mhDitherDIB
; // dither memory handle
79 BYTE
* mpDitherDIB
; // dither memory
80 BYTE
* mpDitherDIBData
; // beginning of DIB data
81 long* mpDitherDiff
; // Dither mapping table
82 BYTE
* mpDitherLow
; // Dither mapping table
83 BYTE
* mpDitherHigh
; // Dither mapping table
84 sal_uLong mnTimerMS
; // Current Time (in MS) of the Timer
85 sal_uLong mnTimerOrgMS
; // Current Original Time (in MS)
86 DWORD mnNextTimerTime
;
87 DWORD mnLastEventTime
;
88 UINT mnTimerId
; // windows timer id
89 sal_Bool mbInTimerProc
; // timer event is currently being dispatched
90 HHOOK mhSalObjMsgHook
; // hook to get interesting msg for SalObject
91 HWND mhWantLeaveMsg
; // window handle, that want a MOUSELEAVE message
92 AutoTimer
* mpMouseLeaveTimer
; // Timer for MouseLeave Test
93 WinSalInstance
* mpFirstInstance
; // pointer of first instance
94 WinSalFrame
* mpFirstFrame
; // pointer of first frame
95 WinSalObject
* mpFirstObject
; // pointer of first object window
96 WinSalVirtualDevice
* mpFirstVD
; // first VirDev
97 WinSalPrinter
* mpFirstPrinter
; // first printing printer
98 HDCCache
* mpHDCCache
; // Cache for three DC's
99 HBITMAP mh50Bmp
; // 50% Bitmap
100 HBRUSH mh50Brush
; // 50% Brush
101 COLORREF maStockPenColorAry
[MAX_STOCKPEN
];
102 COLORREF maStockBrushColorAry
[MAX_STOCKBRUSH
];
103 HPEN mhStockPenAry
[MAX_STOCKPEN
];
104 HBRUSH mhStockBrushAry
[MAX_STOCKBRUSH
];
105 sal_uInt16 mnStockPenCount
; // count of static pens
106 sal_uInt16 mnStockBrushCount
; // count of static brushes
107 WPARAM mnSalObjWantKeyEvt
; // KeyEvent that should be processed by SalObj-Hook
108 BYTE mnCacheDCInUse
; // count of CacheDC in use
109 sal_Bool mbObjClassInit
; // is SALOBJECTCLASS initialised
110 sal_Bool mbInPalChange
; // is in WM_QUERYNEWPALETTE
111 DWORD mnAppThreadId
; // Id from Applikation-Thread
112 BOOL mbScrSvrEnabled
; // ScreenSaver enabled
113 int mnSageStatus
; // status of Sage-DLL (DISABLE_AGENT == does not exist)
114 SysAgt_Enable_PROC mpSageEnableProc
; // funktion to deactivate the system agent
115 SalIcon
* mpFirstIcon
; // icon cache, points to first icon, NULL if none
116 TempFontItem
* mpTempFontItem
;
117 sal_Bool mbThemeChanged
; // true if visual theme was changed: throw away theme handles
118 sal_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 DwmIsCompositionEnabled_ptr mpDwmIsCompositionEnabled
;
129 inline void SetSalData( SalData
* pData
) { ImplGetSVData()->mpSalData
= pData
; }
130 inline SalData
* GetSalData() { return ImplGetSVData()->mpSalData
; }
134 HINSTANCE mhInst
; // Instance of SAL-DLL
135 UINT mnWheelScrollLines
; // WheelScrollLines
136 UINT mnWheelScrollChars
; // WheelScrollChars
137 UINT mnWheelMsgId
; // Wheel-Message-Id fuer W95
138 BOOL mbWXP
; // Windows XP
139 BOOL mbW7
; // Windows 7
140 OSVERSIONINFO maVersionInfo
;
143 extern SalShlData aSalShlData
;
145 #define CACHESIZE_HDC 3
146 #define CACHED_HDC_1 0
147 #define CACHED_HDC_2 1
148 #define CACHED_HDC_DRAW 2
149 #define CACHED_HDC_DEFEXT 64
160 void ImplClearHDCCache( SalData
* pData
);
161 HDC
ImplGetCachedDC( sal_uLong nID
, HBITMAP hBmp
= 0 );
162 void ImplReleaseCachedDC( sal_uLong nID
);
164 bool ImplAddTempFont( SalData
&, const OUString
& rFontFileURL
);
165 void ImplReleaseTempFonts( SalData
& );
167 HCURSOR
ImplLoadSalCursor( int nId
);
168 HBITMAP
ImplLoadSalBitmap( int nId
);
169 sal_Bool
ImplLoadSalIcon( int nId
, HICON
& rIcon
, HICON
& rSmallIcon
);
171 void ImplInitSalGDI();
172 void ImplFreeSalGDI();
174 void ImplSalYieldMutexAcquireWithWait();
175 sal_Bool
ImplSalYieldMutexTryToAcquire();
176 void ImplSalYieldMutexAcquire();
177 void ImplSalYieldMutexRelease();
178 sal_uLong
ImplSalReleaseYieldMutex();
179 void ImplSalAcquireYieldMutex( sal_uLong nCount
);
181 LRESULT CALLBACK
SalFrameWndProcW( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
);
183 #define SALTIMERPROC_RECURSIVE 0xffffffff
184 void CALLBACK
SalTimerProc( HWND hWnd
, UINT nMsg
, UINT_PTR nId
, DWORD nTime
);
186 void SalTestMouseLeave();
187 sal_Bool
ImplWriteLastError( DWORD lastError
, const char *szApiCall
);
189 long ImplHandleSalObjKeyMsg( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
);
190 long ImplHandleSalObjSysCharMsg( HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
191 sal_Bool
ImplHandleGlobalMsg( HWND hWnd
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
& rlResult
);
193 WinSalObject
* ImplFindSalObject( HWND hWndChild
);
194 sal_Bool
ImplSalPreDispatchMsg( MSG
* pMsg
);
195 void ImplSalPostDispatchMsg( MSG
* pMsg
, LRESULT nDispatchResult
);
197 void ImplSalLogFontToFontW( HDC hDC
, const LOGFONTW
& rLogFont
, Font
& rFont
);
199 rtl_TextEncoding
ImplSalGetSystemEncoding();
200 OUString
ImplSalGetUniString(const sal_Char
* pStr
, sal_Int32 nLen
= -1);
201 int ImplSalWICompareAscii( const wchar_t* pStr1
, const char* pStr2
);
203 #define SAL_FRAME_WNDEXTRA sizeof( DWORD )
204 #define SAL_FRAME_THIS 0
205 #define SAL_FRAME_CLASSNAMEA "SALFRAME"
206 #define SAL_FRAME_CLASSNAMEW L"SALFRAME"
207 #define SAL_SUBFRAME_CLASSNAMEA "SALSUBFRAME"
208 #define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME"
209 #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME"
210 #define SAL_OBJECT_WNDEXTRA sizeof( DWORD )
211 #define SAL_OBJECT_THIS 0
212 #define SAL_OBJECT_CLASSNAMEA "SALOBJECT"
213 #define SAL_OBJECT_CLASSNAMEW L"SALOBJECT"
214 #define SAL_OBJECT_CHILDCLASSNAMEA "SALOBJECTCHILD"
215 #define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD"
216 #define SAL_COM_CLASSNAMEA "SALCOMWND"
217 #define SAL_COM_CLASSNAMEW L"SALCOMWND"
219 #define SAL_MOUSELEAVE_TIMEOUT 300
221 // wParam == hDC; lParam == 0
222 #define SAL_MSG_PRINTABORTJOB (WM_USER+110)
223 // wParam == bWait; lParam == 0
224 #define SAL_MSG_THREADYIELD (WM_USER+111)
225 // wParam == 0; lParam == 0
226 #define SAL_MSG_RELEASEWAITYIELD (WM_USER+112)
227 // wParam == 0; lParam == nMS
228 #define SAL_MSG_STARTTIMER (WM_USER+113)
229 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
230 #define SAL_MSG_CREATEFRAME (WM_USER+114)
231 // wParam == 0; lParam == 0
232 #define SAL_MSG_DESTROYFRAME (WM_USER+115)
233 // wParam == 0; lParam == pParent; lResult == pObject
234 #define SAL_MSG_CREATEOBJECT (WM_USER+116)
235 // wParam == 0; lParam == pObject;
236 #define SAL_MSG_DESTROYOBJECT (WM_USER+117)
237 // wParam == hWnd; lParam == 0; lResult == hDC
238 #define SAL_MSG_GETDC (WM_USER+120)
239 // wParam == hWnd; lParam == 0
240 #define SAL_MSG_RELEASEDC (WM_USER+121)
241 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
242 #define SAL_MSG_RECREATEHWND (WM_USER+122)
243 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
244 #define SAL_MSG_RECREATECHILDHWND (WM_USER+123)
245 // wParam == 0; lParam == HWND;
246 #define SAL_MSG_DESTROYHWND (WM_USER+124)
248 // wParam == 0; lParam == pData
249 #define SAL_MSG_USEREVENT (WM_USER+130)
250 // wParam == 0; lParam == MousePosition relativ to upper left of screen
251 #define SAL_MSG_MOUSELEAVE (WM_USER+131)
252 // NULL-Message, should not be processed
253 #define SAL_MSG_DUMMY (WM_USER+132)
254 // wParam == 0; lParam == 0
255 #define SAL_MSG_POSTFOCUS (WM_USER+133)
256 // wParam == wParam; lParam == lParam
257 #define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134)
258 // wParam == wParam; lParam == lParam
259 #define SAL_MSG_POSTPALCHANGED (WM_USER+135)
260 // wParam == wParam; lParam == lParam
261 #define SAL_MSG_POSTMOVE (WM_USER+136)
262 // wParam == wParam; lParam == lParam
263 #define SAL_MSG_POSTCALLSIZE (WM_USER+137)
264 // wParam == pRECT; lParam == 0
265 #define SAL_MSG_POSTPAINT (WM_USER+138)
266 // wParam == 0; lParam == pFrame; lResult 0
267 #define SAL_MSG_FORCEPALETTE (WM_USER+139)
268 // wParam == 0; lParam == 0
269 #define SAL_MSG_CAPTUREMOUSE (WM_USER+140)
270 // wParam == 0; lParam == 0
271 #define SAL_MSG_RELEASEMOUSE (WM_USER+141)
272 // wParam == nFlags; lParam == 0
273 #define SAL_MSG_TOTOP (WM_USER+142)
274 // wParam == bVisible; lParam == 0
275 #define SAL_MSG_SHOW (WM_USER+143)
276 // wParam == 0; lParam == SalInputContext
277 #define SAL_MSG_SETINPUTCONTEXT (WM_USER+144)
278 // wParam == nFlags; lParam == 0
279 #define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145)
280 // POSTTIMER-Message; wparam = 0, lParam == time
281 #define SAL_MSG_POSTTIMER (WM_USER+161)
283 // SysChild-ToTop; wParam = 0; lParam = 0
284 #define SALOBJ_MSG_TOTOP (WM_USER+160)
285 // POSTFOCUS-Message; wParam == bFocus; lParam == 0
286 #define SALOBJ_MSG_POSTFOCUS (WM_USER+161)
290 BOOL
ImplPostMessage( HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
);
291 BOOL
ImplSendMessage( HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
);
292 BOOL
ImplGetMessage( LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
);
293 BOOL
ImplPeekMessage( LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
, UINT wRemoveMsg
);
294 LONG
ImplDispatchMessage( CONST MSG
*lpMsg
);
296 inline void SetWindowPtr( HWND hWnd
, WinSalFrame
* pThis
)
298 SetWindowLongPtr( hWnd
, SAL_FRAME_THIS
, (LONG_PTR
)pThis
);
301 inline WinSalFrame
* GetWindowPtr( HWND hWnd
)
303 return (WinSalFrame
*)GetWindowLongPtrW( hWnd
, SAL_FRAME_THIS
);
306 inline void SetSalObjWindowPtr( HWND hWnd
, WinSalObject
* pThis
)
308 SetWindowLongPtr( hWnd
, SAL_OBJECT_THIS
, (LONG_PTR
)pThis
);
311 inline WinSalObject
* GetSalObjWindowPtr( HWND hWnd
)
313 return (WinSalObject
*)GetWindowLongPtr( hWnd
, SAL_OBJECT_THIS
);
316 #endif // _SV_SALDATA_HXX
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */