xref: /AOO41X/main/vcl/inc/os2/saldata.hxx (revision fc9fd3f14a55d77b35643a64034752a178b2a5b0)
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)
208 #define SAL_FRAME_THIS              0
209 #define SAL_FRAME_CLASSNAME         "SALFRAME"
210 #define SAL_SUBFRAME_CLASSNAME      "SALSUBFRAME"
211 #define SAL_OBJECT_WNDEXTRA         sizeof(ULONG)
212 #define SAL_OBJECT_THIS             0
213 #define SAL_OBJECT_CLASSNAME        "SALOBJECT"
214 #define SAL_OBJECT_CHILDCLASSNAME   "SALOBJECTCHILD"
215 #define SAL_OBJECT_CLIPCLASSNAME    "SALOBJECTCLIP"
216 #define SAL_COM_CLASSNAME           "SALCOMWND"
217 
218 #define SAL_MOUSELEAVE_TIMEOUT      300
219 
220 // MP1 == 0; MP2 == pData
221 #define SAL_MSG_USEREVENT           (WM_USER+111)
222 // MP1 == 0; MP2 == MousePosition relativ to upper left of screen
223 #define SAL_MSG_MOUSELEAVE          (WM_USER+112)
224 // MP1 == hDC; MP2 == 0
225 #define SAL_MSG_PRINTABORTJOB       (WM_USER+113)
226 // MP1 == 0; MP2 == 0
227 #define SAL_MSG_STARTTIMER          (WM_USER+114)
228 // MP1 == nFrameStyle; MP2 == pParent; lResult pFrame
229 #define SAL_MSG_CREATEFRAME         (WM_USER+115)
230 // MP1 == 0; MP2 == pParent; lResult pObject
231 #define SAL_MSG_CREATEOBJECT        (WM_USER+116)
232 // MP1 == bWait; MP2 == pMutex
233 #define SAL_MSG_THREADYIELD         (WM_USER+117)
234 // MP1 == 0; MP2 == 0
235 #define SAL_MSG_RELEASEWAITYIELD    (WM_USER+118)
236 // MP1 == 0; MP2 == pData
237 #define SAL_MSG_SYSPROCESSMENU      (WM_USER+119)
238 // POSTFOCUS-Message; MP1 == nMP1; MP2 == nMP2 (SHORT1( bFocus ), 0)
239 #define SAL_MSG_POSTFOCUS           (WM_USER+120)
240 // POSTSIZE-Message; MP1 == nMP1; MP2 == nMP2
241 #define SAL_MSG_POSTSIZE            (WM_USER+121)
242 
243 // wParam == wParam; lParam == lParam
244 #define SAL_MSG_POSTMOVE            (WM_USER+136)
245 // wParam == pRECT; lParam == 0
246 #define SAL_MSG_POSTPAINT           (WM_USER+137)
247 // wParam == nFlags; lParam == 0
248 #define SAL_MSG_TOTOP               (WM_USER+142)
249 // wParam == bVisible; lParam == 0
250 #define SAL_MSG_SHOW                (WM_USER+143)
251 
252 // SysChild-ToTop; nMP1 = 0; nMP2 = 0
253 #define SALOBJ_MSG_TOTOP            (WM_USER+150)
254 // POSTFOCUS-Message; MP1 == nMP1; MP2 == nMP2 (SHORT1( bFocus ), 0)
255 #define SALOBJ_MSG_POSTFOCUS        (WM_USER+151)
256 
257 // wParam == 0; lParam == 0
258 #define SAL_MSG_DESTROYFRAME        (WM_USER+160)
259 // wParam == 0; lParam == pObject;
260 #define SAL_MSG_DESTROYOBJECT       (WM_USER+161)
261 // wParam == 0; lParam == this; lResult == bRet
262 #define SAL_MSG_CREATESOUND         (WM_USER+162)
263 // wParam == 0; lParam == this
264 #define SAL_MSG_DESTROYSOUND        (WM_USER+163)
265 // wParam == hWnd; lParam == 0; lResult == hDC
266 #define SAL_MSG_GETDC               (WM_USER+164)
267 // wParam == hWnd; lParam == 0
268 #define SAL_MSG_RELEASEDC           (WM_USER+165)
269 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
270 #define SAL_MSG_RECREATEHWND         (WM_USER+166)
271 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
272 #define SAL_MSG_RECREATECHILDHWND    (WM_USER+167)
273 // wParam == 0; lParam == HWND;
274 #define SAL_MSG_DESTROYHWND         (WM_USER+168)
275 // POSTTIMER-Message; wparam = 0, lParam == time
276 #define SAL_MSG_POSTTIMER           (WM_USER+169)
277 
278 // -----------------
279 // - Helpfunctions -
280 // -----------------
281 
SetWindowPtr(HWND hWnd,SalFrame * pThis)282 inline void SetWindowPtr( HWND hWnd, SalFrame* pThis )
283 {
284     WinSetWindowULong( hWnd, SAL_FRAME_THIS, (ULONG)pThis );
285 }
286 
GetWindowPtr(HWND hWnd)287 inline Os2SalFrame* GetWindowPtr( HWND hWnd )
288 {
289     return (Os2SalFrame*)WinQueryWindowULong( hWnd, SAL_FRAME_THIS );
290 }
291 
SetSalObjWindowPtr(HWND hWnd,SalObject * pThis)292 inline void SetSalObjWindowPtr( HWND hWnd, SalObject* pThis )
293 {
294     WinSetWindowULong( hWnd, SAL_OBJECT_THIS, (ULONG)pThis );
295 }
296 
GetSalObjWindowPtr(HWND hWnd)297 inline Os2SalObject* GetSalObjWindowPtr( HWND hWnd )
298 {
299     return (Os2SalObject*)WinQueryWindowULong( hWnd, SAL_OBJECT_THIS );
300 }
301 
302 #endif  // _SV_SALDATA_HXX
303