xref: /aoo42x/main/vcl/inc/os2/saldata.hxx (revision cc13e73e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SALDATA_HXX
25 #define _SV_SALDATA_HXX
26 
27 #include <svdata.hxx>
28 #include <salwtype.hxx>
29 
30 class Os2SalInstance;
31 class Os2SalFrame;
32 class Os2SalObject;
33 
34 extern "C" int debug_printf(const char *f, ...);
35 
36 // --------------
37 // - SalIMEData -
38 // --------------
39 
40 // YD FIXME #define ENABLE_IME
41 
42 #ifdef ENABLE_IME
43 
44 struct SalIMEData;
45 
46 #ifdef OS2IM_INCLUDED
47 
48 typedef APIRET (APIENTRY ImAssociateInstanceFunc)( HWND hwnd, HIMI himi, PHIMI phimiPrev );
49 typedef APIRET (APIENTRY ImGetInstanceFunc)( HWND hwnd, PHIMI phimi );
50 typedef APIRET (APIENTRY ImReleaseInstanceFunc)( HWND hwnd, HIMI himi );
51 typedef APIRET (APIENTRY ImSetConversionFontFunc)( HIMI himi, PFATTRS pFontAttrs );
52 typedef APIRET (APIENTRY ImSetConversionFontSizeFunc)( HIMI himi, PSIZEF psizfxBox );
53 typedef APIRET (APIENTRY ImGetConversionStringFunc)( HIMI himi, ULONG ulIndex, PVOID pBuf, PULONG pulBufLen );
54 typedef APIRET (APIENTRY ImGetResultStringFunc)( HIMI himi, ULONG ulIndex, PVOID pBuf, PULONG pulBufLen );
55 typedef APIRET (APIENTRY ImSetCandidateWindowPosFunc)( HIMI himi, PCANDIDATEPOS pCandidatePos );
56 typedef APIRET (APIENTRY ImQueryIMEPropertyFunc)( HIMI himi, ULONG ulIndex, PULONG pulProp );
57 typedef APIRET (APIENTRY ImRequestIMEFunc)( HIMI himi, ULONG ulAction, ULONG ulIndex, ULONG ulValue );
58 typedef APIRET (APIENTRY ImSetIMModeFunc)( HIMI himi, ULONG ulInputMode, ULONG ulConversionMode );
59 typedef APIRET (APIENTRY ImQueryIMModeFunc)( HIMI himi, PULONG pulInputMode, PULONG pulConversionMode );
60 
61 struct SalIMEData
62 {
63 	HMODULE 						mhModIME;
64 	ImAssociateInstanceFunc*		mpAssocIME;
65 	ImGetInstanceFunc*				mpGetIME;
66 	ImReleaseInstanceFunc*			mpReleaseIME;
67 	ImSetConversionFontFunc*		mpSetConversionFont;
68 	ImSetConversionFontSizeFunc*	mpSetConversionFontSize;
69 	ImGetConversionStringFunc*		mpGetConversionString;
70 	ImGetResultStringFunc*			mpGetResultString;
71 	ImSetCandidateWindowPosFunc*	mpSetCandidateWin;
72 	ImQueryIMEPropertyFunc* 		mpQueryIMEProperty;
73 	ImRequestIMEFunc*				mpRequestIME;
74 	ImSetIMModeFunc*				mpSetIMEMode;
75 	ImQueryIMModeFunc*				mpQueryIMEMode;
76 };
77 
78 #endif
79 
80 #endif
81 
82 // --------------------
83 // - Icon cache       -
84 // --------------------
85 
86 struct SalIcon
87 {
88     int     nId;
89     HPOINTER hIcon;
90     SalIcon *pNext;
91 };
92 
93 // -----------
94 // - SalData -
95 // -----------
96 
97 struct SalData
98 {
99 	HAB 					mhAB;					// anchor block handle
100 	HMQ 					mhMQ;					// handle of os2 message queue
101 	int 					mnArgc; 				// commandline param count
102 	char**					mpArgv; 				// commandline
103 	ULONG					mnNewTimerMS;			// Neue Zeit, mit dem der Timer gestartet werden soll
104 	ULONG                   		mnTimerMS;              	// Current Time (in MS) of the Timer
105 	ULONG                   		mnTimerOrgMS;          		// Current Original Time (in MS)
106 	ULONG					mnNextTimerTime;
107 	ULONG					mnLastEventTime;
108 	ULONG					mnTimerId;			// os2 timer id
109 	PM_BOOL      				mbInTimerProc;			// timer event is currently being dispatched
110 	//SALTIMERPROC				mpTimerProc;			// timer callback proc
111 	HWND					mhWantLeaveMsg; 		// window handle, that want a MOUSELEAVE message
112 	AutoTimer*				mpMouseLeaveTimer;		// Timer for MouseLeave Test
113 	Os2SalInstance*				mpFirstInstance;		// pointer of first instance
114 	Os2SalFrame*				mpFirstFrame;			// pointer of first frame
115 	Os2SalFrame*				mpCreateFrame;			// Create-Frame for WM_CREATE
116 	Os2SalObject*				mpFirstObject;			// pointer of first object window
117 	ULONG					mnAppThreadId;			// Id from Applikation-Thread
118 	ULONG					mnFontMetricCount;		// number of entries in the font list
119 	PFONTMETRICS				mpFontMetrics;			// cached font list
120 	PM_BOOL					mbObjClassInit; 		// Ist SALOBJECTCLASS initialised
121 #ifdef ENABLE_IME
122 	SalIMEData* 				mpIMEData;				// SalIME-Data
123 	PM_BOOL					mbIMEInit;				// SalIME-Data-Init
124 #endif
125 
126     SalIcon*                mpFirstIcon;            // icon cache, points to first icon, NULL if none
127 
128 };
129 
SetSalData(SalData * pData)130 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; }
GetSalData()131 inline SalData* GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; }
GetAppSalData()132 inline SalData* GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; }
133 
134 // --------------
135 // - SalShlData -
136 // --------------
137 
138 #define OS2_VER_211 	211
139 #define OS2_VER_WARP3	230
140 #define OS2_VER_WARP4	240
141 
142 struct SalShlData
143 {
144     HMODULE	mhMod;		// Module handle of SAL-DLL
145     USHORT	mnVersion;	// 211 = OS2 2.11; 230 = OS2 3.0; 240 = OS2 4.0
146     PFNWP	mpFrameProc; 	// old frame proc
147 };
148 
149 extern SalShlData aSalShlData;
150 
151 PM_BOOL SalImplHandleProcessMenu( HWND hWnd, ULONG nMsg, MPARAM nMP1, MPARAM nMP2 );
152 
153 // --------------------------------------------
154 // - SALSHL.CXX - for accessing DLL resources -
155 // --------------------------------------------
156 
157 HPOINTER ImplLoadSalCursor( int nId );
158 HBITMAP ImplLoadSalBitmap( int nId );
159 sal_Bool ImplLoadSalIcon( int nId, HPOINTER& rIcon);
160 
161 // SALGDI.CXX
162 void ImplInitSalGDI();
163 void ImplFreeSalGDI();
164 
165 // --------------
166 // - Prototypes -
167 // --------------
168 
169 // \\OS2\SOURCE\APP\SALINST.CXX
170 void ImplSalYieldMutexAcquireWithWait();
171 ULONG ImplSalReleaseYieldMutex();
172 void ImplSalAcquireYieldMutex( ULONG nCount );
173 ULONG GetCurrentThreadId();
174 sal_Bool ImplSalYieldMutexTryToAcquire();
175 void ImplSalYieldMutexAcquire();
176 void ImplSalYieldMutexRelease();
177 
178 // \\OS2\SOURCE\WINDOW\SALFRAME.CXX
179 MRESULT EXPENTRY SalFrameWndProc( HWND hWnd, ULONG nMsg, MPARAM nMP1, MPARAM nMP2 );
180 MRESULT EXPENTRY SalFrameFrameProc( HWND hWnd, ULONG nMsg, MPARAM nMP1, MPARAM nMP2 );
181 // \SV\WIN\SOURCE\APP\SALTIMER.CXX
182 #define SALTIMERPROC_RECURSIVE 0xffffffff
183 void SalTimerProc( HWND hWnd, UINT nMsg, UINT nId, ULONG nTime );
184 
185 // \WIN\SOURCE\WINDOW\SALFRAME.CXX
186 void SalTestMouseLeave();
187 
188 // \\OS2\SOURCE\WINDOW\SALFRAME.CXX
189 // return Frame for Message-Handling
190 Os2SalFrame* GetSalDefaultFrame();
191 
192 // \\OS2\SOURCE\WINDOW\SALFRAME.CXX
193 // IME-Daten wieder freigeben
194 #ifdef ENABLE_IME
195 void ImplReleaseSALIMEData();
196 #endif
197 
198 // -----------
199 // - Defines -
200 // -----------
201 
202 #define SAL_PROFILE_APPNAME 		((PSZ)"StarOffice")
203 #define SAL_PROFILE_USEDJP			((PSZ)"UseDJP")
204 #define SAL_PROFILE_PRINTDJP		((PSZ)"PrintDJP")
205 #define SAL_PROFILE_PRINTRAW		((PSZ)"PrintRAW")
206 
207 #define SAL_FRAME_WNDEXTRA		(sizeof(ULONG)*3)
208 #define SAL_FRAME_THIS			0
209 // these offsets are hardcoded in dnd/globals.hxx too to avoid vcl dependancies
210 #define SAL_FRAME_DROPTARGET		sizeof(ULONG)
211 #define SAL_FRAME_DRAGSOURCE		(sizeof(ULONG)*2)
212 
213 #define SAL_FRAME_CLASSNAME 		"SALFRAME"
214 #define SAL_SUBFRAME_CLASSNAME 		"SALSUBFRAME"
215 #define SAL_OBJECT_WNDEXTRA 		sizeof(ULONG)
216 #define SAL_OBJECT_THIS 			0
217 #define SAL_OBJECT_CLASSNAME		"SALOBJECT"
218 #define SAL_OBJECT_CHILDCLASSNAME	"SALOBJECTCHILD"
219 #define SAL_OBJECT_CLIPCLASSNAME	"SALOBJECTCLIP"
220 #define SAL_COM_CLASSNAME			"SALCOMWND"
221 
222 #define SAL_MOUSELEAVE_TIMEOUT		300
223 
224 // MP1 == 0; MP2 == pData
225 #define SAL_MSG_USEREVENT			(WM_USER+111)
226 // MP1 == 0; MP2 == MousePosition relativ to upper left of screen
227 #define SAL_MSG_MOUSELEAVE			(WM_USER+112)
228 // MP1 == hDC; MP2 == 0
229 #define SAL_MSG_PRINTABORTJOB		(WM_USER+113)
230 // MP1 == 0; MP2 == 0
231 #define SAL_MSG_STARTTIMER			(WM_USER+114)
232 // MP1 == nFrameStyle; MP2 == pParent; lResult pFrame
233 #define SAL_MSG_CREATEFRAME 		(WM_USER+115)
234 // MP1 == 0; MP2 == pParent; lResult pObject
235 #define SAL_MSG_CREATEOBJECT		(WM_USER+116)
236 // MP1 == bWait; MP2 == pMutex
237 #define SAL_MSG_THREADYIELD 		(WM_USER+117)
238 // MP1 == 0; MP2 == 0
239 #define SAL_MSG_RELEASEWAITYIELD	(WM_USER+118)
240 // MP1 == 0; MP2 == pData
241 #define SAL_MSG_SYSPROCESSMENU		(WM_USER+119)
242 // POSTFOCUS-Message; MP1 == nMP1; MP2 == nMP2 (SHORT1( bFocus ), 0)
243 #define SAL_MSG_POSTFOCUS			(WM_USER+120)
244 // POSTSIZE-Message; MP1 == nMP1; MP2 == nMP2
245 #define SAL_MSG_POSTSIZE			(WM_USER+121)
246 
247 // wParam == wParam; lParam == lParam
248 #define SAL_MSG_POSTMOVE            (WM_USER+136)
249 // wParam == pRECT; lParam == 0
250 #define SAL_MSG_POSTPAINT           (WM_USER+137)
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 
256 // SysChild-ToTop; nMP1 = 0; nMP2 = 0
257 #define SALOBJ_MSG_TOTOP			(WM_USER+150)
258 // POSTFOCUS-Message; MP1 == nMP1; MP2 == nMP2 (SHORT1( bFocus ), 0)
259 #define SALOBJ_MSG_POSTFOCUS		(WM_USER+151)
260 
261 // wParam == 0; lParam == 0
262 #define SAL_MSG_DESTROYFRAME        (WM_USER+160)
263 // wParam == 0; lParam == pObject;
264 #define SAL_MSG_DESTROYOBJECT       (WM_USER+161)
265 // wParam == 0; lParam == this; lResult == bRet
266 #define SAL_MSG_CREATESOUND         (WM_USER+162)
267 // wParam == 0; lParam == this
268 #define SAL_MSG_DESTROYSOUND        (WM_USER+163)
269 // wParam == hWnd; lParam == 0; lResult == hDC
270 #define SAL_MSG_GETDC               (WM_USER+164)
271 // wParam == hWnd; lParam == 0
272 #define SAL_MSG_RELEASEDC           (WM_USER+165)
273 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
274 #define SAL_MSG_RECREATEHWND         (WM_USER+166)
275 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
276 #define SAL_MSG_RECREATECHILDHWND    (WM_USER+167)
277 // wParam == 0; lParam == HWND;
278 #define SAL_MSG_DESTROYHWND         (WM_USER+168)
279 // POSTTIMER-Message; wparam = 0, lParam == time
280 #define SAL_MSG_POSTTIMER           (WM_USER+169)
281 
282 // drag&drop internal messages (see dnd/globals.hxx)
283 #define DM_AOO_ENDCONVERSATION      (WM_USER+170)
284 
285 // -----------------
286 // - Helpfunctions -
287 // -----------------
288 
SetWindowPtr(HWND hWnd,SalFrame * pThis)289 inline void SetWindowPtr( HWND hWnd, SalFrame* pThis )
290 {
291 	WinSetWindowULong( hWnd, SAL_FRAME_THIS, (ULONG)pThis );
292 }
293 
GetWindowPtr(HWND hWnd)294 inline Os2SalFrame* GetWindowPtr( HWND hWnd )
295 {
296 	return (Os2SalFrame*)WinQueryWindowULong( hWnd, SAL_FRAME_THIS );
297 }
298 
SetSalObjWindowPtr(HWND hWnd,SalObject * pThis)299 inline void SetSalObjWindowPtr( HWND hWnd, SalObject* pThis )
300 {
301 	WinSetWindowULong( hWnd, SAL_OBJECT_THIS, (ULONG)pThis );
302 }
303 
GetSalObjWindowPtr(HWND hWnd)304 inline Os2SalObject* GetSalObjWindowPtr( HWND hWnd )
305 {
306 	return (Os2SalObject*)WinQueryWindowULong( hWnd, SAL_OBJECT_THIS );
307 }
308 
309 #endif	// _SV_SALDATA_HXX
310