Update ooo320-m1
[ooovba.git] / vcl / win / inc / saldata.hxx
blob134504da0058f02483b57e66f94c27bf869c3aa5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: saldata.hxx,v $
10 * $Revision: 1.30 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_SALDATA_HXX
32 #define _SV_SALDATA_HXX
34 #include <vcl/sv.h>
35 #include <vcl/svdata.hxx>
36 #include <vcl/salwtype.hxx>
37 #include <wincomp.hxx>
39 #include <set> // for hMenu validation
40 #include <map>
42 class AutoTimer;
43 class WinSalInstance;
44 class WinSalObject;
45 class WinSalFrame;
46 class WinSalVirtualDevice;
47 class WinSalPrinter;
48 class Font;
49 struct HDCCache;
50 struct TempFontItem;
52 // --------------------
53 // - Standard-Defines -
54 // --------------------
56 #define MAX_STOCKPEN 4
57 #define MAX_STOCKBRUSH 4
58 #define SAL_CLIPRECT_COUNT 16
60 // --------------------
61 // - Icon cache -
62 // --------------------
64 struct SalIcon
66 int nId;
67 HICON hIcon;
68 HICON hSmallIcon;
69 SalIcon *pNext;
72 // -----------
73 // - SalData -
74 // -----------
76 class SalData
78 public:
79 SalData();
80 ~SalData();
82 // native widget framework
83 void initNWF();
84 void deInitNWF();
86 // fill maVKMap;
87 void initKeyCodeMap();
89 // checks if the menuhandle was created by VCL
90 BOOL IsKnownMenuHandle( HMENU hMenu );
92 public:
93 HINSTANCE mhInst; // default instance handle
94 HINSTANCE mhPrevInst; // previous instance handle
95 int mnCmdShow; // default frame show style
96 HPALETTE mhDitherPal; // dither palette
97 HGLOBAL mhDitherDIB; // dither memory handle
98 BYTE* mpDitherDIB; // dither memory
99 BYTE* mpDitherDIBData; // beginning of DIB data
100 long* mpDitherDiff; // Dither mapping table
101 BYTE* mpDitherLow; // Dither mapping table
102 BYTE* mpDitherHigh; // Dither mapping table
103 ULONG mnTimerMS; // Current Time (in MS) of the Timer
104 ULONG mnTimerOrgMS; // Current Original Time (in MS)
105 DWORD mnNextTimerTime;
106 DWORD mnLastEventTime;
107 UINT mnTimerId; // windows timer id
108 BOOL mbInTimerProc; // timer event is currently being dispatched
109 HHOOK mhSalObjMsgHook; // hook to get interesting msg for SalObject
110 HWND mhWantLeaveMsg; // window handle, that want a MOUSELEAVE message
111 AutoTimer* mpMouseLeaveTimer; // Timer for MouseLeave Test
112 WinSalInstance* mpFirstInstance; // pointer of first instance
113 WinSalFrame* mpFirstFrame; // pointer of first frame
114 WinSalObject* mpFirstObject; // pointer of first object window
115 WinSalVirtualDevice* mpFirstVD; // first VirDev
116 WinSalPrinter* mpFirstPrinter; // first printing printer
117 HDCCache* mpHDCCache; // Cache for three DC's
118 HBITMAP mh50Bmp; // 50% Bitmap
119 HBRUSH mh50Brush; // 50% Brush
120 COLORREF maStockPenColorAry[MAX_STOCKPEN];
121 COLORREF maStockBrushColorAry[MAX_STOCKBRUSH];
122 HPEN mhStockPenAry[MAX_STOCKPEN];
123 HBRUSH mhStockBrushAry[MAX_STOCKBRUSH];
124 USHORT mnStockPenCount; // count of static pens
125 USHORT mnStockBrushCount; // count of static brushes
126 WPARAM mnSalObjWantKeyEvt; // KeyEvent, welcher vom SalObj-Hook verarbeitet werden soll
127 BYTE mnCacheDCInUse; // count of CacheDC in use
128 BOOL mbObjClassInit; // is SALOBJECTCLASS initialised
129 BOOL mbInPalChange; // is in WM_QUERYNEWPALETTE
130 DWORD mnAppThreadId; // Id from Applikation-Thread
131 WIN_BOOL mbScrSvrEnabled; // ScreenSaver enabled
132 int mnSageStatus; // status of Sage-DLL (DISABLE_AGENT == nicht vorhanden)
133 SysAgt_Enable_PROC mpSageEnableProc; // funktion to deactivate the system agent
134 SalIcon* mpFirstIcon; // icon cache, points to first icon, NULL if none
135 TempFontItem* mpTempFontItem;
136 BOOL mbThemeChanged; // true if visual theme was changed: throw away theme handles
138 // for GdiPlus GdiplusStartup/GdiplusShutdown
139 ULONG_PTR gdiplusToken;
141 std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
142 std::map< UINT,USHORT > maVKMap; // map some dynamic VK_* entries
145 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; }
146 inline SalData* GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; }
147 inline SalData* GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; }
149 // --------------
150 // - SalShlData -
151 // --------------
153 struct SalShlData
155 HINSTANCE mhInst; // Instance of SAL-DLL
156 UINT mnWheelScrollLines; // WheelScrollLines
157 UINT mnWheelScrollChars; // WheelScrollChars
158 UINT mnWheelMsgId; // Wheel-Message-Id fuer W95
159 WORD mnVersion; // System-Version (311 == 3.11)
160 WIN_BOOL mbWNT; // kein W16/W95/W98 sondern ein NT
161 WIN_BOOL mbW40; // Is System-Version >= 4.0
162 WIN_BOOL mbWXP; // Windows XP
163 WIN_BOOL mbWPrinter; // true: use unicode printer functions
164 // false: use anis compat printer functions
165 OSVERSIONINFO maVersionInfo;
168 extern SalShlData aSalShlData;
170 // ------------
171 // - GDICache -
172 // ------------
174 #define CACHESIZE_HDC 3
175 #define CACHED_HDC_1 0
176 #define CACHED_HDC_2 1
177 #define CACHED_HDC_DRAW 2
178 #define CACHED_HDC_DEFEXT 64
180 struct HDCCache
182 HDC mhDC;
183 HPALETTE mhDefPal;
184 HBITMAP mhDefBmp;
185 HBITMAP mhSelBmp;
186 HBITMAP mhActBmp;
189 void ImplClearHDCCache( SalData* pData );
190 HDC ImplGetCachedDC( ULONG nID, HBITMAP hBmp = 0 );
191 void ImplReleaseCachedDC( ULONG nID );
193 bool ImplAddTempFont( SalData&, const String& rFontFileURL );
194 void ImplReleaseTempFonts( SalData& );
196 // --------------------------------------------
197 // - SALSHL.CXX - for accessing DLL resources -
198 // --------------------------------------------
200 HCURSOR ImplLoadSalCursor( int nId );
201 HBITMAP ImplLoadSalBitmap( int nId );
202 BOOL ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon );
204 // SALGDI.CXX
205 void ImplInitSalGDI();
206 void ImplFreeSalGDI();
208 // --------------
209 // - Prototypes -
210 // --------------
212 // \\WIN\SOURCE\APP\SALINST.CXX
213 void ImplSalYieldMutexAcquireWithWait();
214 BOOL ImplSalYieldMutexTryToAcquire();
215 void ImplSalYieldMutexAcquire();
216 void ImplSalYieldMutexRelease();
217 ULONG ImplSalReleaseYieldMutex();
218 void ImplSalAcquireYieldMutex( ULONG nCount );
220 // \\WIN\SOURCE\WINDOW\SALFRAME.CXX
221 LRESULT CALLBACK SalFrameWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
222 LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
223 // \SV\WIN\SOURCE\APP\SALTIMER.CXX
224 #define SALTIMERPROC_RECURSIVE 0xffffffff
225 void CALLBACK SalTimerProc( HWND hWnd, UINT nMsg, UINT_PTR nId, DWORD nTime );
227 // \WIN\SOURCE\WINDOW\SALFRAME.CXX
228 void SalTestMouseLeave();
229 BOOL ImplWriteLastError( DWORD lastError, const char *szApiCall );
231 // \WIN\SOURCE\WINDOW\SALFRAME.CXX
232 long ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
233 long ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam );
234 BOOL ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT& rlResult );
236 // \WIN\SOURCE\WINDOW\SALOBJ.CXX
237 WinSalObject* ImplFindSalObject( HWND hWndChild );
238 BOOL ImplSalPreDispatchMsg( MSG* pMsg );
239 void ImplSalPostDispatchMsg( MSG* pMsg, LRESULT nDispatchResult );
241 // \WIN\SOURCE\GDI\SALGDI3.CXX
242 void ImplSalLogFontToFontA( HDC hDC, const LOGFONTA& rLogFont, Font& rFont );
243 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont );
244 bool ImplIsFontAvailable( HDC hDC, const UniString& rName );
246 // \WIN\SOURCE\APP\SALDATA.CXX
247 rtl_TextEncoding ImplSalGetSystemEncoding();
248 ByteString ImplSalGetWinAnsiString( const UniString& rStr, BOOL bFileName = FALSE );
249 UniString ImplSalGetUniString( const sal_Char* pStr, xub_StrLen nLen = STRING_LEN );
250 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 );
252 // -----------
253 // - Defines -
254 // -----------
256 #define SAL_FRAME_WNDEXTRA sizeof( DWORD )
257 #define SAL_FRAME_THIS 0
258 #define SAL_FRAME_CLASSNAMEA "SALFRAME"
259 #define SAL_FRAME_CLASSNAMEW L"SALFRAME"
260 #define SAL_SUBFRAME_CLASSNAMEA "SALSUBFRAME"
261 #define SAL_SUBFRAME_CLASSNAMEW L"SALSUBFRAME"
262 #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME"
263 #define SAL_OBJECT_WNDEXTRA sizeof( DWORD )
264 #define SAL_OBJECT_THIS 0
265 #define SAL_OBJECT_CLASSNAMEA "SALOBJECT"
266 #define SAL_OBJECT_CLASSNAMEW L"SALOBJECT"
267 #define SAL_OBJECT_CHILDCLASSNAMEA "SALOBJECTCHILD"
268 #define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD"
269 #define SAL_COM_CLASSNAMEA "SALCOMWND"
270 #define SAL_COM_CLASSNAMEW L"SALCOMWND"
272 #define SAL_MOUSELEAVE_TIMEOUT 300
274 // wParam == hDC; lParam == 0
275 #define SAL_MSG_PRINTABORTJOB (WM_USER+110)
276 // wParam == bWait; lParam == 0
277 #define SAL_MSG_THREADYIELD (WM_USER+111)
278 // wParam == 0; lParam == 0
279 #define SAL_MSG_RELEASEWAITYIELD (WM_USER+112)
280 // wParam == 0; lParam == nMS
281 #define SAL_MSG_STARTTIMER (WM_USER+113)
282 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
283 #define SAL_MSG_CREATEFRAME (WM_USER+114)
284 // wParam == 0; lParam == 0
285 #define SAL_MSG_DESTROYFRAME (WM_USER+115)
286 // wParam == 0; lParam == pParent; lResult == pObject
287 #define SAL_MSG_CREATEOBJECT (WM_USER+116)
288 // wParam == 0; lParam == pObject;
289 #define SAL_MSG_DESTROYOBJECT (WM_USER+117)
290 // wParam == hWnd; lParam == 0; lResult == hDC
291 #define SAL_MSG_GETDC (WM_USER+120)
292 // wParam == hWnd; lParam == 0
293 #define SAL_MSG_RELEASEDC (WM_USER+121)
294 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
295 #define SAL_MSG_RECREATEHWND (WM_USER+122)
296 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
297 #define SAL_MSG_RECREATECHILDHWND (WM_USER+123)
298 // wParam == 0; lParam == HWND;
299 #define SAL_MSG_DESTROYHWND (WM_USER+124)
301 // wParam == 0; lParam == pData
302 #define SAL_MSG_USEREVENT (WM_USER+130)
303 // wParam == 0; lParam == MousePosition relativ to upper left of screen
304 #define SAL_MSG_MOUSELEAVE (WM_USER+131)
305 // NULL-Message, soll nicht verarbeitet werden
306 #define SAL_MSG_DUMMY (WM_USER+132)
307 // wParam == 0; lParam == 0
308 #define SAL_MSG_POSTFOCUS (WM_USER+133)
309 // wParam == wParam; lParam == lParam
310 #define SAL_MSG_POSTQUERYNEWPAL (WM_USER+134)
311 // wParam == wParam; lParam == lParam
312 #define SAL_MSG_POSTPALCHANGED (WM_USER+135)
313 // wParam == wParam; lParam == lParam
314 #define SAL_MSG_POSTMOVE (WM_USER+136)
315 // wParam == wParam; lParam == lParam
316 #define SAL_MSG_POSTCALLSIZE (WM_USER+137)
317 // wParam == pRECT; lParam == 0
318 #define SAL_MSG_POSTPAINT (WM_USER+138)
319 // wParam == 0; lParam == pFrame; lResult 0
320 #define SAL_MSG_FORCEPALETTE (WM_USER+139)
321 // wParam == 0; lParam == 0
322 #define SAL_MSG_CAPTUREMOUSE (WM_USER+140)
323 // wParam == 0; lParam == 0
324 #define SAL_MSG_RELEASEMOUSE (WM_USER+141)
325 // wParam == nFlags; lParam == 0
326 #define SAL_MSG_TOTOP (WM_USER+142)
327 // wParam == bVisible; lParam == 0
328 #define SAL_MSG_SHOW (WM_USER+143)
329 // wParam == 0; lParam == SalInputContext
330 #define SAL_MSG_SETINPUTCONTEXT (WM_USER+144)
331 // wParam == nFlags; lParam == 0
332 #define SAL_MSG_ENDEXTTEXTINPUT (WM_USER+145)
333 // POSTTIMER-Message; wparam = 0, lParam == time
334 #define SAL_MSG_POSTTIMER (WM_USER+161)
336 // SysChild-ToTop; wParam = 0; lParam = 0
337 #define SALOBJ_MSG_TOTOP (WM_USER+160)
338 // POSTFOCUS-Message; wParam == bFocus; lParam == 0
339 #define SALOBJ_MSG_POSTFOCUS (WM_USER+161)
342 // -----------------
343 // - Helpfunctions -
344 // -----------------
346 // A/W-Wrapper
347 LONG ImplSetWindowLong( HWND hWnd, int nIndex, DWORD dwNewLong );
348 LONG ImplGetWindowLong( HWND hWnd, int nIndex );
349 WIN_BOOL ImplPostMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
350 WIN_BOOL ImplSendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
351 WIN_BOOL ImplGetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax );
352 WIN_BOOL ImplPeekMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg );
353 LONG ImplDispatchMessage( CONST MSG *lpMsg );
355 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
357 ImplSetWindowLong( hWnd, SAL_FRAME_THIS, (LONG)pThis );
360 inline WinSalFrame* GetWindowPtr( HWND hWnd )
362 return (WinSalFrame*)ImplGetWindowLong( hWnd, SAL_FRAME_THIS );
365 inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis )
367 ImplSetWindowLong( hWnd, SAL_OBJECT_THIS, (LONG)pThis );
370 inline WinSalObject* GetSalObjWindowPtr( HWND hWnd )
372 return (WinSalObject*)ImplGetWindowLong( hWnd, SAL_OBJECT_THIS );
375 #endif // _SV_SALDATA_HXX