Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / win / saldata.hxx
blob519b24489de9b6c1951d518ef8c39ab75a4d63a1
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 #ifndef INCLUDED_VCL_INC_WIN_SALDATA_HXX
21 #define INCLUDED_VCL_INC_WIN_SALDATA_HXX
23 #include "osl/module.h"
25 #include <svdata.hxx>
26 #include <salwtype.hxx>
28 #include <win/wincomp.hxx>
30 #include <set>
31 #include <map>
33 class AutoTimer;
34 class WinSalInstance;
35 class WinSalObject;
36 class WinSalFrame;
37 class WinSalVirtualDevice;
38 class WinSalPrinter;
39 namespace vcl { class Font; }
40 struct HDCCache;
41 struct TempFontItem;
43 typedef HRESULT (WINAPI *DwmIsCompositionEnabled_ptr)(BOOL*);
45 #define MAX_STOCKPEN 4
46 #define MAX_STOCKBRUSH 4
47 #define SAL_CLIPRECT_COUNT 16
49 struct SalIcon
51 int nId;
52 HICON hIcon;
53 HICON hSmallIcon;
54 SalIcon *pNext;
57 class SalData
59 public:
60 SalData();
61 ~SalData();
63 // native widget framework
64 void initNWF();
65 void deInitNWF();
67 // fill maVKMap;
68 void initKeyCodeMap();
70 // checks if the menuhandle was created by VCL
71 bool IsKnownMenuHandle( HMENU hMenu );
73 bool mbResourcesAlreadyFreed;
75 public:
76 HINSTANCE mhInst; // default instance handle
77 int mnCmdShow; // default frame show style
78 HPALETTE mhDitherPal; // dither palette
79 HGLOBAL mhDitherDIB; // dither memory handle
80 BYTE* mpDitherDIB; // dither memory
81 BYTE* mpDitherDIBData; // beginning of DIB data
82 long* mpDitherDiff; // Dither mapping table
83 BYTE* mpDitherLow; // Dither mapping table
84 BYTE* mpDitherHigh; // Dither mapping table
85 sal_uLong mnTimerMS; // Current Time (in MS) of the Timer
86 sal_uLong mnTimerOrgMS; // Current Original Time (in MS)
87 DWORD mnNextTimerTime;
88 DWORD mnLastEventTime;
89 HANDLE mnTimerId; ///< Windows timer id
90 bool mbInTimerProc; // timer event is currently being dispatched
91 HHOOK mhSalObjMsgHook; // hook to get interesting msg for SalObject
92 HWND mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message
93 AutoTimer* mpMouseLeaveTimer; // Timer for MouseLeave Test
94 WinSalInstance* mpFirstInstance; // pointer of first instance
95 WinSalFrame* mpFirstFrame; // pointer of first frame
96 WinSalObject* mpFirstObject; // pointer of first object window
97 WinSalVirtualDevice* mpFirstVD; // first VirDev
98 WinSalPrinter* mpFirstPrinter; // first printing printer
99 HDCCache* mpHDCCache; // Cache for three DC's
100 HBITMAP mh50Bmp; // 50% Bitmap
101 HBRUSH mh50Brush; // 50% Brush
102 COLORREF maStockPenColorAry[MAX_STOCKPEN];
103 COLORREF maStockBrushColorAry[MAX_STOCKBRUSH];
104 HPEN mhStockPenAry[MAX_STOCKPEN];
105 HBRUSH mhStockBrushAry[MAX_STOCKBRUSH];
106 sal_uInt16 mnStockPenCount; // count of static pens
107 sal_uInt16 mnStockBrushCount; // count of static brushes
108 WPARAM mnSalObjWantKeyEvt; // KeyEvent that should be processed by SalObj-Hook
109 BYTE mnCacheDCInUse; // count of CacheDC in use
110 bool mbObjClassInit; // is SALOBJECTCLASS initialised
111 bool mbInPalChange; // is in WM_QUERYNEWPALETTE
112 DWORD mnAppThreadId; // Id from Applikation-Thread
113 BOOL mbScrSvrEnabled; // ScreenSaver enabled
114 int mnSageStatus; // status of Sage-DLL (DISABLE_AGENT == does not exist)
115 SysAgt_Enable_PROC mpSageEnableProc; // funktion to deactivate the system agent
116 SalIcon* mpFirstIcon; // icon cache, points to first icon, NULL if none
117 TempFontItem* mpTempFontItem;
118 bool mbThemeChanged; // true if visual theme was changed: throw away theme handles
119 bool mbThemeMenuSupport;
121 // for GdiPlus GdiplusStartup/GdiplusShutdown
122 ULONG_PTR gdiplusToken;
124 std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
125 std::map< UINT,sal_uInt16 > maVKMap; // map some dynamic VK_* entries
126 oslModule maDwmLib;
127 DwmIsCompositionEnabled_ptr mpDwmIsCompositionEnabled;
130 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; }
131 inline SalData* GetSalData() { return ImplGetSVData()->mpSalData; }
133 struct SalShlData
135 HINSTANCE mhInst; // Instance of SAL-DLL
136 UINT mnWheelScrollLines; // WheelScrollLines
137 UINT mnWheelScrollChars; // WheelScrollChars
138 UINT mnWheelMsgId; // Wheel-Message-Id fuer W95
139 BOOL mbWXP; // Windows XP
140 BOOL mbWVista; // Windows Vista
141 BOOL mbW7; // Windows 7
144 extern SalShlData aSalShlData;
146 #define CACHESIZE_HDC 3
147 #define CACHED_HDC_1 0
148 #define CACHED_HDC_2 1
149 #define CACHED_HDC_DRAW 2
150 #define CACHED_HDC_DEFEXT 64
152 struct HDCCache
154 HDC mhDC;
155 HPALETTE mhDefPal;
156 HBITMAP mhDefBmp;
157 HBITMAP mhSelBmp;
158 HBITMAP mhActBmp;
161 void ImplClearHDCCache( SalData* pData );
162 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = 0 );
163 void ImplReleaseCachedDC( sal_uLong nID );
165 bool ImplAddTempFont( SalData&, const OUString& rFontFileURL );
166 void ImplReleaseTempFonts( SalData& );
168 HCURSOR ImplLoadSalCursor( int nId );
169 HBITMAP ImplLoadSalBitmap( int nId );
170 bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon );
172 void ImplInitSalGDI();
173 void ImplFreeSalGDI();
175 void ImplSalYieldMutexAcquireWithWait();
176 bool ImplSalYieldMutexTryToAcquire();
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 void EmitTimerCallback();
185 void SalTestMouseLeave();
186 void ImplWriteLastError(DWORD lastError, const char *szApiCall);
188 long ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
189 long ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam );
190 bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult );
192 WinSalObject* ImplFindSalObject( HWND hWndChild );
193 bool ImplSalPreDispatchMsg( MSG* pMsg );
194 void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT nDispatchResult );
196 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Font& rFont );
198 rtl_TextEncoding ImplSalGetSystemEncoding();
199 OUString ImplSalGetUniString(const sal_Char* pStr, sal_Int32 nLen = -1);
200 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 );
202 #define SAL_FRAME_WNDEXTRA sizeof( DWORD )
203 #define SAL_FRAME_THIS GWLP_USERDATA
204 #define SAL_FRAME_CLASSNAMEW L"SALFRAME"
205 #define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME"
206 #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME"
207 #define SAL_OBJECT_WNDEXTRA sizeof( DWORD )
208 #define SAL_OBJECT_THIS GWLP_USERDATA
209 #define SAL_OBJECT_CLASSNAMEA "SALOBJECT"
210 #define SAL_OBJECT_CHILDCLASSNAMEA "SALOBJECTCHILD"
211 #define SAL_COM_CLASSNAMEW L"SALCOMWND"
213 #define SAL_MOUSELEAVE_TIMEOUT 300
215 // wParam == hDC; lParam == 0
216 #define SAL_MSG_PRINTABORTJOB (WM_USER+110)
217 // wParam == bWait; lParam == 0
218 #define SAL_MSG_THREADYIELD (WM_USER+111)
219 // wParam == 0; lParam == 0
220 #define SAL_MSG_RELEASEWAITYIELD (WM_USER+112)
221 // wParam == 0; lParam == nMS
222 #define SAL_MSG_STARTTIMER (WM_USER+113)
223 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
224 #define SAL_MSG_CREATEFRAME (WM_USER+114)
225 // wParam == 0; lParam == 0
226 #define SAL_MSG_DESTROYFRAME (WM_USER+115)
227 // wParam == 0; lParam == pParent; lResult == pObject
228 #define SAL_MSG_CREATEOBJECT (WM_USER+116)
229 // wParam == 0; lParam == pObject;
230 #define SAL_MSG_DESTROYOBJECT (WM_USER+117)
231 // wParam == hWnd; lParam == 0; lResult == hDC
232 #define SAL_MSG_GETDC (WM_USER+120)
233 // wParam == hWnd; lParam == 0
234 #define SAL_MSG_RELEASEDC (WM_USER+121)
235 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
236 #define SAL_MSG_RECREATEHWND (WM_USER+122)
237 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
238 #define SAL_MSG_RECREATECHILDHWND (WM_USER+123)
239 // wParam == 0; lParam == HWND;
240 #define SAL_MSG_DESTROYHWND (WM_USER+124)
242 // wParam == 0; lParam == pData
243 #define SAL_MSG_USEREVENT (WM_USER+130)
244 // wParam == 0; lParam == MousePosition relativ to upper left of screen
245 #define SAL_MSG_MOUSELEAVE (WM_USER+131)
246 // NULL-Message, should not be processed
247 #define SAL_MSG_DUMMY (WM_USER+132)
248 // wParam == 0; lParam == 0
249 #define SAL_MSG_POSTFOCUS (WM_USER+133)
250 // wParam == wParam; lParam == lParam
251 #define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134)
252 // wParam == wParam; lParam == lParam
253 #define SAL_MSG_POSTPALCHANGED (WM_USER+135)
254 // wParam == wParam; lParam == lParam
255 #define SAL_MSG_POSTMOVE (WM_USER+136)
256 // wParam == wParam; lParam == lParam
257 #define SAL_MSG_POSTCALLSIZE (WM_USER+137)
258 // wParam == pRECT; lParam == 0
259 #define SAL_MSG_POSTPAINT (WM_USER+138)
260 // wParam == 0; lParam == pFrame; lResult 0
261 #define SAL_MSG_FORCEPALETTE (WM_USER+139)
262 // wParam == 0; lParam == 0
263 #define SAL_MSG_CAPTUREMOUSE (WM_USER+140)
264 // wParam == 0; lParam == 0
265 #define SAL_MSG_RELEASEMOUSE (WM_USER+141)
266 // wParam == nFlags; lParam == 0
267 #define SAL_MSG_TOTOP (WM_USER+142)
268 // wParam == bVisible; lParam == 0
269 #define SAL_MSG_SHOW (WM_USER+143)
270 // wParam == 0; lParam == SalInputContext
271 #define SAL_MSG_SETINPUTCONTEXT (WM_USER+144)
272 // wParam == nFlags; lParam == 0
273 #define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145)
274 // POSTTIMER-Message; wparam = 0, lParam == time
275 #define SAL_MSG_POSTTIMER (WM_USER+161)
277 // SysChild-ToTop; wParam = 0; lParam = 0
278 #define SALOBJ_MSG_TOTOP (WM_USER+160)
279 // POSTFOCUS-Message; wParam == bFocus; lParam == 0
280 #define SALOBJ_MSG_POSTFOCUS (WM_USER+161)
282 // Call the Timer's callback from the main thread
283 #define SAL_MSG_TIMER_CALLBACK (WM_USER+162)
285 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
287 SetWindowLongPtr( hWnd, SAL_FRAME_THIS, (LONG_PTR)pThis );
290 inline WinSalFrame* GetWindowPtr( HWND hWnd )
292 return (WinSalFrame*)GetWindowLongPtrW( hWnd, SAL_FRAME_THIS );
295 inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis )
297 SetWindowLongPtr( hWnd, SAL_OBJECT_THIS, (LONG_PTR)pThis );
300 inline WinSalObject* GetSalObjWindowPtr( HWND hWnd )
302 return (WinSalObject*)GetWindowLongPtr( hWnd, SAL_OBJECT_THIS );
305 #endif // INCLUDED_VCL_INC_WIN_SALDATA_HXX
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */