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