xref: /AOO41X/main/vcl/os2/source/window/salframe.cxx (revision 1b00c71b67bac457029f0dc3644d5b8a237d4a92)
19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59f62ea84SAndrew Rist  * distributed with this work for additional information
69f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist  * software distributed under the License is distributed on an
159f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
179f62ea84SAndrew Rist  * specific language governing permissions and limitations
189f62ea84SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209f62ea84SAndrew Rist  *************************************************************/
219f62ea84SAndrew Rist 
229f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #define INCL_DOS
25cdf0e10cSrcweir #define INCL_PM
26cdf0e10cSrcweir #define INCL_WIN
27a37d1728SYuri Dario #define VCL_OS2
28cdf0e10cSrcweir #include <svpm.h>
29cdf0e10cSrcweir 
30fc9fd3f1SPedro Giffuni #include <string.h>
31fc9fd3f1SPedro Giffuni 
32fc9fd3f1SPedro Giffuni #include <tools/svwin.h>
33fc9fd3f1SPedro Giffuni 
34cdf0e10cSrcweir // =======================================================================
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #define _SV_SALFRAME_CXX
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef DEBUG_HXX
39cdf0e10cSrcweir #include <tools/debug.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define private public
43cdf0e10cSrcweir 
44fc9fd3f1SPedro Giffuni #include "os2/sallang.hxx"
45fc9fd3f1SPedro Giffuni #include "os2/salids.hrc"
46fc9fd3f1SPedro Giffuni #include "os2/saldata.hxx"
47fc9fd3f1SPedro Giffuni #include "os2/salinst.h"
48fc9fd3f1SPedro Giffuni #include "os2/salgdi.h"
49fc9fd3f1SPedro Giffuni #include "os2/salframe.h"
50fc9fd3f1SPedro Giffuni #include "os2/saltimer.h"
51fc9fd3f1SPedro Giffuni 
52cdf0e10cSrcweir #include <vcl/timer.hxx>
53cdf0e10cSrcweir #include <vcl/settings.hxx>
54cdf0e10cSrcweir #include <vcl/keycodes.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
57cdf0e10cSrcweir extern "C" int debug_printf(const char *f, ...);
58cdf0e10cSrcweir 
59fc9fd3f1SPedro Giffuni static sal_Bool _bCapture;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #else
62cdf0e10cSrcweir #define debug_printf( ...) { 1; }
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // =======================================================================
66cdf0e10cSrcweir 
67fc9fd3f1SPedro Giffuni #undef WinEnableMenuItem
68fc9fd3f1SPedro Giffuni #define WinEnableMenuItem(hwndMenu,id,fEnable) \
69fc9fd3f1SPedro Giffuni     ((PM_BOOL)WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (id, TRUE), \
70fc9fd3f1SPedro Giffuni 		       MPFROM2SHORT (MIA_DISABLED, \
71fc9fd3f1SPedro Giffuni 				     ((USHORT)(fEnable) ? 0 : MIA_DISABLED))))
72fc9fd3f1SPedro Giffuni 
73fc9fd3f1SPedro Giffuni // =======================================================================
74fc9fd3f1SPedro Giffuni 
75cdf0e10cSrcweir HPOINTER ImplLoadPointer( ULONG nId );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir static void SetMaximizedFrameGeometry( HWND hWnd, Os2SalFrame* pFrame );
78cdf0e10cSrcweir static void UpdateFrameGeometry( HWND hWnd, Os2SalFrame* pFrame );
79cdf0e10cSrcweir static void ImplSalCalcFrameSize( HWND hWnd,
80cdf0e10cSrcweir                                   LONG& nFrameX, LONG& nFrameY, LONG& nCaptionY );
81cdf0e10cSrcweir static void ImplSalCalcFrameSize( const Os2SalFrame* pFrame,
82cdf0e10cSrcweir                                   LONG& nFrameX, LONG& nFrameY, LONG& nCaptionY );
83cdf0e10cSrcweir MRESULT EXPENTRY SalFrameSubClassWndProc( HWND hWnd, ULONG nMsg,
84cdf0e10cSrcweir                                   MPARAM nMP1, MPARAM nMP2 );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // =======================================================================
87cdf0e10cSrcweir 
88cdf0e10cSrcweir static LanguageType eImplKeyboardLanguage = LANGUAGE_DONTKNOW;
89fc9fd3f1SPedro Giffuni sal_Bool Os2SalFrame::mbInReparent = FALSE;
90cdf0e10cSrcweir ULONG Os2SalFrame::mnInputLang = 0;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // =======================================================================
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // define a new flag
95cdf0e10cSrcweir #define SWP_CENTER			(SWP_NOAUTOCLOSE<<4)
96cdf0e10cSrcweir #define SWP_SHOWMAXIMIZED	(SWP_ACTIVATE | SWP_SHOW | SWP_MAXIMIZE)
97cdf0e10cSrcweir #define SWP_SHOWMINIMIZED	(SWP_ACTIVATE | SWP_SHOW | SWP_MINIMIZE)
98cdf0e10cSrcweir #define SWP_SHOWNORMAL		(SWP_ACTIVATE | SWP_SHOW | SWP_RESTORE)
99cdf0e10cSrcweir 
100cdf0e10cSrcweir static LONG nScreenHeight  = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN);
101cdf0e10cSrcweir static LONG nScreenWidth   = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
102cdf0e10cSrcweir 
_WinQueryWindowRect(HWND hwnd,PRECTL prclDest)103fc9fd3f1SPedro Giffuni sal_Bool APIENTRY _WinQueryWindowRect( HWND hwnd, PRECTL prclDest)
104cdf0e10cSrcweir {
105fc9fd3f1SPedro Giffuni 	sal_Bool rc = WinQueryWindowRect( hwnd, prclDest);
106cdf0e10cSrcweir 	ULONG tmp = prclDest->yBottom;
107cdf0e10cSrcweir 	prclDest->yBottom = prclDest->yTop;
108cdf0e10cSrcweir 	prclDest->yTop = tmp;
109cdf0e10cSrcweir 	return rc;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
_WinQueryPointerPos(HWND hwndDesktop,PPOINTL pptl)112fc9fd3f1SPedro Giffuni sal_Bool APIENTRY _WinQueryPointerPos (HWND hwndDesktop, PPOINTL pptl)
113cdf0e10cSrcweir {
114fc9fd3f1SPedro Giffuni 	sal_Bool rc = WinQueryPointerPos( hwndDesktop, pptl);
115cdf0e10cSrcweir 	pptl->y = nScreenHeight - pptl->y;
116cdf0e10cSrcweir 	return rc;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
_WinQueryWindowPos(Os2SalFrame * pFrame,PSWP pswp)119fc9fd3f1SPedro Giffuni sal_Bool APIENTRY _WinQueryWindowPos( Os2SalFrame* pFrame, PSWP pswp)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	SWP swpOwner;
122fc9fd3f1SPedro Giffuni 	sal_Bool rc = WinQueryWindowPos( pFrame->mhWndFrame, pswp);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>1
125cdf0e10cSrcweir 	debug_printf( "> WinQueryWindowPos hwnd %x at %d,%d (%dx%d)\n",
126cdf0e10cSrcweir 					pFrame->mhWndFrame, pswp->x, pswp->y, pswp->cx, pswp->cy);
127cdf0e10cSrcweir #endif
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	Os2SalFrame* pParentFrame = pFrame->mpParentFrame;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	//YD adjust to owner coordinates
132cdf0e10cSrcweir 	if ( pParentFrame )
133cdf0e10cSrcweir 	{
134cdf0e10cSrcweir 		POINTL ptlOwner = {0};
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		// coords are relative to screen, map to parent frame client area
137cdf0e10cSrcweir 		ptlOwner.x = pswp->x;
138cdf0e10cSrcweir 		ptlOwner.y = pswp->y;
139cdf0e10cSrcweir 		WinMapWindowPoints( HWND_DESKTOP, pParentFrame->mhWndClient, &ptlOwner, 1);
140cdf0e10cSrcweir 		pswp->x = ptlOwner.x;
141cdf0e10cSrcweir 		pswp->y = ptlOwner.y;
142cdf0e10cSrcweir 		// get parent client area size
143cdf0e10cSrcweir 		WinQueryWindowPos( pParentFrame->mhWndClient, &swpOwner);
144cdf0e10cSrcweir 	} else
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 		// no owner info, use DESKTOP????
147cdf0e10cSrcweir 		swpOwner.cx = nScreenWidth;
148cdf0e10cSrcweir 		swpOwner.cy = nScreenHeight;
149cdf0e10cSrcweir 	}
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	// invert Y coordinate
152cdf0e10cSrcweir 	pswp->y = swpOwner.cy - (pswp->y + pswp->cy);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>1
155cdf0e10cSrcweir 	debug_printf( "< WinQueryWindowPos hwnd %x at %d,%d (%dx%d)\n",
156cdf0e10cSrcweir 					pFrame->mhWndFrame, pswp->x, pswp->y, pswp->cx, pswp->cy);
157cdf0e10cSrcweir #endif
158cdf0e10cSrcweir 	return rc;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
_WinSetWindowPos(Os2SalFrame * pFrame,HWND hwndInsertBehind,LONG x,LONG y,LONG cx,LONG cy,ULONG fl)161fc9fd3f1SPedro Giffuni sal_Bool APIENTRY _WinSetWindowPos( Os2SalFrame* pFrame, HWND hwndInsertBehind, LONG x, LONG y,
162cdf0e10cSrcweir     LONG cx, LONG cy, ULONG fl)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	SWP 	swpOwner = {0};
165cdf0e10cSrcweir 	POINTL 	ptlOwner = {0};
166cdf0e10cSrcweir 	HWND	hParent = NULL;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>1
169cdf0e10cSrcweir 	debug_printf( ">WinSetWindowPos hwnd %x at %d,%d (%dx%d) fl 0x%08x\n",
170cdf0e10cSrcweir 					pFrame->mhWndFrame, x, y, cx, cy, fl);
171cdf0e10cSrcweir #endif
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	// first resize window if requested
174cdf0e10cSrcweir 	if ( (fl & SWP_SIZE) ) {
175cdf0e10cSrcweir 		ULONG	flag = SWP_SIZE;
176cdf0e10cSrcweir 		LONG	nX = 0, nY = 0;
177cdf0e10cSrcweir 		LONG	frameFrameX, frameFrameY, frameCaptionY;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 		ImplSalCalcFrameSize( pFrame, frameFrameX, frameFrameY, frameCaptionY );
180cdf0e10cSrcweir 		// if we change y size, we need to move the window down
181cdf0e10cSrcweir 		// because os2 window origin is lower left corner
182cdf0e10cSrcweir 		if (pFrame->maGeometry.nHeight != cy) {
183cdf0e10cSrcweir 			SWP		aSWP;
184cdf0e10cSrcweir 			WinQueryWindowPos( pFrame->mhWndFrame, &aSWP);
185cdf0e10cSrcweir 			nX = aSWP.x;
186cdf0e10cSrcweir 			nY = aSWP.y - (cy + 2*frameFrameY + frameCaptionY - aSWP.cy);
187cdf0e10cSrcweir 			flag |= SWP_MOVE;
188cdf0e10cSrcweir 		}
189cdf0e10cSrcweir 		WinSetWindowPos( pFrame->mhWndFrame, NULL, nX, nY,
190cdf0e10cSrcweir 			cx+2*frameFrameX, cy+2*frameFrameY+frameCaptionY, flag);
191cdf0e10cSrcweir 		fl = fl & ~SWP_SIZE;
192cdf0e10cSrcweir 	}
193cdf0e10cSrcweir 	else // otherwise get current size
194cdf0e10cSrcweir 	{
195cdf0e10cSrcweir 		SWP swp = {0};
196cdf0e10cSrcweir 		WinQueryWindowPos( pFrame->mhWndClient, &swp);
197cdf0e10cSrcweir 		cx = swp.cx;
198cdf0e10cSrcweir 		cy = swp.cy;
199cdf0e10cSrcweir 	}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	// get parent window handle
202cdf0e10cSrcweir 	Os2SalFrame* pParentFrame = pFrame->mpParentFrame;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	// use desktop if parent is not defined
205cdf0e10cSrcweir 	hParent = pParentFrame ? pParentFrame->mhWndClient : HWND_DESKTOP;
206cdf0e10cSrcweir 	// if parent is not visible, use desktop as reference
207cdf0e10cSrcweir 	hParent = WinIsWindowVisible( hParent) ? hParent : HWND_DESKTOP;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	WinQueryWindowPos( hParent, &swpOwner);
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	//YD adjust to owner coordinates only when moving and not centering
212cdf0e10cSrcweir 	//if (!(fl & SWP_CENTER) && (fl & SWP_MOVE))
213cdf0e10cSrcweir 	if ((fl & SWP_MOVE))
214cdf0e10cSrcweir 	{
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 		// if SWP_CENTER is specified, change position to parent center
217cdf0e10cSrcweir 		if (fl & SWP_CENTER) {
218cdf0e10cSrcweir 			ptlOwner.x = (swpOwner.cx - cx) / 2;
219cdf0e10cSrcweir 			ptlOwner.y = (swpOwner.cy - cy) / 2;
220cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
221cdf0e10cSrcweir 			debug_printf( "_WinSetWindowPos SWP_CENTER\n");
222cdf0e10cSrcweir #endif
223cdf0e10cSrcweir 			fl = fl & ~SWP_CENTER;
224cdf0e10cSrcweir 		} else {
225cdf0e10cSrcweir 			// coords are relative to parent frame client area, map to screen
226cdf0e10cSrcweir 			// map Y to OS/2 system coordinates
227cdf0e10cSrcweir 			ptlOwner.x = x;
228cdf0e10cSrcweir 			ptlOwner.y = swpOwner.cy - (y + cy);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
231cdf0e10cSrcweir 			debug_printf( "_WinSetWindowPos owner 0x%x at %d,%d (%dx%d) OS2\n",
232cdf0e10cSrcweir 				hParent, ptlOwner.x, ptlOwner.y, swpOwner.cx, swpOwner.cy);
233cdf0e10cSrcweir #endif
234cdf0e10cSrcweir 		}
235cdf0e10cSrcweir 		// map from client area to screen
236cdf0e10cSrcweir 		WinMapWindowPoints( hParent, HWND_DESKTOP, &ptlOwner, 1);
237cdf0e10cSrcweir 		x = ptlOwner.x;
238cdf0e10cSrcweir 		y = ptlOwner.y;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
241cdf0e10cSrcweir 		debug_printf( "_WinSetWindowPos owner 0x%x at %d,%d (%dx%d) MAPPED OS2\n",
242cdf0e10cSrcweir 			hParent, ptlOwner.x, ptlOwner.y, swpOwner.cx, swpOwner.cy);
243cdf0e10cSrcweir #endif
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir 
246cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
247cdf0e10cSrcweir 	debug_printf( "<WinSetWindowPos hwnd %x at %d,%d (%dx%d) fl=%x\n",
248cdf0e10cSrcweir 					pFrame->mhWndFrame, x, y, cx, cy, fl);
249cdf0e10cSrcweir #endif
250cdf0e10cSrcweir 	return WinSetWindowPos( pFrame->mhWndFrame, hwndInsertBehind, x, y, 0, 0, fl);
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir // =======================================================================
254cdf0e10cSrcweir 
255cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
dumpWindowInfo(char * fnc,HWND hwnd)256cdf0e10cSrcweir static void dumpWindowInfo( char* fnc, HWND hwnd)
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	SWP aSWP;
259cdf0e10cSrcweir 	HWND	hwnd2;
260cdf0e10cSrcweir 	char	szTitle[256];
261cdf0e10cSrcweir 
262cdf0e10cSrcweir #if 0
263cdf0e10cSrcweir 	_WinQueryWindowPos( hwnd, &aSWP );
264cdf0e10cSrcweir 	strcpy(szTitle,"");
265cdf0e10cSrcweir 	WinQueryWindowText(hwnd, sizeof(szTitle), szTitle);
266cdf0e10cSrcweir 	debug_printf( "%s: window %08x at %d,%d (size %dx%d) '%s'\n", fnc, hwnd,
267cdf0e10cSrcweir 				aSWP.x, aSWP.y, aSWP.cx, aSWP.cy, szTitle);
268cdf0e10cSrcweir 	hwnd2 = WinQueryWindow(hwnd, QW_PARENT);
269cdf0e10cSrcweir 	_WinQueryWindowPos( hwnd2, &aSWP );
270cdf0e10cSrcweir 	strcpy(szTitle,"");
271cdf0e10cSrcweir 	WinQueryWindowText(hwnd2, sizeof(szTitle), szTitle);
272cdf0e10cSrcweir 	debug_printf( "%s: parent %08x at %d,%d (size %dx%d) '%s'\n", fnc, hwnd2,
273cdf0e10cSrcweir 				aSWP.x, aSWP.y, aSWP.cx, aSWP.cy, szTitle);
274cdf0e10cSrcweir 	hwnd2 = WinQueryWindow(hwnd, QW_OWNER);
275cdf0e10cSrcweir 	_WinQueryWindowPos( hwnd2, &aSWP );
276cdf0e10cSrcweir 	strcpy(szTitle,"");
277cdf0e10cSrcweir 	WinQueryWindowText(hwnd2, sizeof(szTitle), szTitle);
278cdf0e10cSrcweir 	debug_printf( "%s: owner %08x at %d,%d (size %dx%d) '%s'\n", fnc, hwnd2,
279cdf0e10cSrcweir 				aSWP.x, aSWP.y, aSWP.cx, aSWP.cy, szTitle);
280cdf0e10cSrcweir #endif
281cdf0e10cSrcweir }
282cdf0e10cSrcweir #endif
283cdf0e10cSrcweir 
284cdf0e10cSrcweir // =======================================================================
285cdf0e10cSrcweir 
286cdf0e10cSrcweir #ifdef ENABLE_IME
287cdf0e10cSrcweir 
288cdf0e10cSrcweir struct ImplSalIMEProc
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     ULONG       nOrd;
291cdf0e10cSrcweir     PFN*        pProc;
292cdf0e10cSrcweir };
293cdf0e10cSrcweir 
294cdf0e10cSrcweir #define SAL_IME_PROC_COUNT          12
295cdf0e10cSrcweir 
296cdf0e10cSrcweir // -----------------------------------------------------------------------
297cdf0e10cSrcweir 
GetSalIMEData()298cdf0e10cSrcweir static SalIMEData* GetSalIMEData()
299cdf0e10cSrcweir {
300cdf0e10cSrcweir     SalData* pSalData = GetSalData();
301cdf0e10cSrcweir 
302cdf0e10cSrcweir     if ( !pSalData->mbIMEInit )
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         pSalData->mbIMEInit = TRUE;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir         HMODULE hMod = 0;
307cdf0e10cSrcweir         if ( 0 == DosLoadModule( NULL, 0, "OS2IM", &hMod ) )
308cdf0e10cSrcweir         {
309cdf0e10cSrcweir             SalIMEData*     pIMEData = new SalIMEData;
310fc9fd3f1SPedro Giffuni             sal_Bool            bError = FALSE;
311cdf0e10cSrcweir             ImplSalIMEProc  aProcAry[SAL_IME_PROC_COUNT] =
312cdf0e10cSrcweir             {
313cdf0e10cSrcweir             { 101, (PFN*)&(pIMEData->mpAssocIME) },
314cdf0e10cSrcweir             { 104, (PFN*)&(pIMEData->mpGetIME) },
315cdf0e10cSrcweir             { 106, (PFN*)&(pIMEData->mpReleaseIME) },
316cdf0e10cSrcweir             { 117, (PFN*)&(pIMEData->mpSetConversionFont) },
317cdf0e10cSrcweir             { 144, (PFN*)&(pIMEData->mpSetConversionFontSize) },
318cdf0e10cSrcweir             { 118, (PFN*)&(pIMEData->mpGetConversionString) },
319cdf0e10cSrcweir             { 122, (PFN*)&(pIMEData->mpGetResultString) },
320cdf0e10cSrcweir             { 115, (PFN*)&(pIMEData->mpSetCandidateWin) },
321cdf0e10cSrcweir             { 130, (PFN*)&(pIMEData->mpQueryIMEProperty) },
322cdf0e10cSrcweir             { 131, (PFN*)&(pIMEData->mpRequestIME) },
323cdf0e10cSrcweir             { 128, (PFN*)&(pIMEData->mpSetIMEMode) },
324cdf0e10cSrcweir             { 127, (PFN*)&(pIMEData->mpQueryIMEMode) }
325cdf0e10cSrcweir             };
326cdf0e10cSrcweir 
327cdf0e10cSrcweir             pIMEData->mhModIME = hMod;
328cdf0e10cSrcweir             for ( USHORT i = 0; i < SAL_IME_PROC_COUNT; i++ )
329cdf0e10cSrcweir             {
330cdf0e10cSrcweir                 if ( 0 != DosQueryProcAddr( pIMEData->mhModIME, aProcAry[i].nOrd, 0, aProcAry[i].pProc ) )
331cdf0e10cSrcweir                 {
332cdf0e10cSrcweir                     bError = TRUE;
333cdf0e10cSrcweir                     break;
334cdf0e10cSrcweir                 }
335cdf0e10cSrcweir             }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir             if ( bError )
338cdf0e10cSrcweir             {
339cdf0e10cSrcweir                 DosFreeModule( pIMEData->mhModIME );
340cdf0e10cSrcweir                 delete pIMEData;
341cdf0e10cSrcweir             }
342cdf0e10cSrcweir             else
343cdf0e10cSrcweir                 pSalData->mpIMEData = pIMEData;
344cdf0e10cSrcweir         }
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     return pSalData->mpIMEData;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir // -----------------------------------------------------------------------
351cdf0e10cSrcweir 
ImplReleaseSALIMEData()352cdf0e10cSrcweir void ImplReleaseSALIMEData()
353cdf0e10cSrcweir {
354cdf0e10cSrcweir     SalData* pSalData = GetSalData();
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     if ( pSalData->mpIMEData )
357cdf0e10cSrcweir     {
358cdf0e10cSrcweir         DosFreeModule( pSalData->mpIMEData->mhModIME );
359cdf0e10cSrcweir         delete pSalData->mpIMEData;
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir #endif
364cdf0e10cSrcweir 
365cdf0e10cSrcweir // =======================================================================
366cdf0e10cSrcweir 
ImplSaveFrameState(Os2SalFrame * pFrame)367cdf0e10cSrcweir static void ImplSaveFrameState( Os2SalFrame* pFrame )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir     // Position, Groesse und Status fuer GetWindowState() merken
370cdf0e10cSrcweir     if ( !pFrame->mbFullScreen )
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         SWP aSWP;
373fc9fd3f1SPedro Giffuni         sal_Bool bVisible = WinIsWindowVisible( pFrame->mhWndFrame);
374cdf0e10cSrcweir 
375cdf0e10cSrcweir         // Query actual state (maState uses screen coords)
376cdf0e10cSrcweir         WinQueryWindowPos( pFrame->mhWndFrame, &aSWP );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir         if ( aSWP.fl & SWP_MINIMIZE )
379cdf0e10cSrcweir         {
380cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
381cdf0e10cSrcweir 			debug_printf("Os2SalFrame::GetWindowState %08x SAL_FRAMESTATE_MINIMIZED\n",
382cdf0e10cSrcweir 					pFrame->mhWndFrame);
383cdf0e10cSrcweir #endif
384cdf0e10cSrcweir             pFrame->maState.mnState |= SAL_FRAMESTATE_MINIMIZED;
385cdf0e10cSrcweir             if ( bVisible )
386cdf0e10cSrcweir                 pFrame->mnShowState = SWP_SHOWMAXIMIZED;
387cdf0e10cSrcweir         }
388cdf0e10cSrcweir         else if ( aSWP.fl & SWP_MAXIMIZE )
389cdf0e10cSrcweir         {
390cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
391cdf0e10cSrcweir 			debug_printf("Os2SalFrame::GetWindowState %08x SAL_FRAMESTATE_MAXIMIZED\n",
392cdf0e10cSrcweir 					pFrame->mhWndFrame);
393cdf0e10cSrcweir #endif
394cdf0e10cSrcweir             pFrame->maState.mnState &= ~SAL_FRAMESTATE_MINIMIZED;
395cdf0e10cSrcweir             pFrame->maState.mnState |= SAL_FRAMESTATE_MAXIMIZED;
396cdf0e10cSrcweir             if ( bVisible )
397cdf0e10cSrcweir                 pFrame->mnShowState = SWP_SHOWMINIMIZED;
398cdf0e10cSrcweir             pFrame->mbRestoreMaximize = TRUE;
399cdf0e10cSrcweir         }
400cdf0e10cSrcweir         else
401cdf0e10cSrcweir         {
402cdf0e10cSrcweir 			LONG nFrameX, nFrameY, nCaptionY;
403cdf0e10cSrcweir 			ImplSalCalcFrameSize( pFrame, nFrameX, nFrameY, nCaptionY );
404cdf0e10cSrcweir 			// to be consistent with Unix, the frame state is without(!) decoration
405cdf0e10cSrcweir 			long nTopDeco = nFrameY + nCaptionY;
406cdf0e10cSrcweir 			long nLeftDeco = nFrameX;
407cdf0e10cSrcweir 			long nBottomDeco = nFrameY;
408cdf0e10cSrcweir 			long nRightDeco = nFrameX;
409cdf0e10cSrcweir 
410cdf0e10cSrcweir             pFrame->maState.mnState &= ~(SAL_FRAMESTATE_MINIMIZED | SAL_FRAMESTATE_MAXIMIZED);
411cdf0e10cSrcweir             // subtract decoration, store screen coords
412cdf0e10cSrcweir             pFrame->maState.mnX      = aSWP.x+nLeftDeco;
413cdf0e10cSrcweir             pFrame->maState.mnY      = nScreenHeight - (aSWP.y+aSWP.cy)+nTopDeco;
414cdf0e10cSrcweir             pFrame->maState.mnWidth  = aSWP.cx-nLeftDeco-nRightDeco;
415cdf0e10cSrcweir             pFrame->maState.mnHeight = aSWP.cy-nTopDeco-nBottomDeco;
416cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
417cdf0e10cSrcweir 			debug_printf("Os2SalFrame::GetWindowState %08x (%dx%d) at %d,%d VCL\n",
418cdf0e10cSrcweir 					pFrame->mhWndFrame,
419cdf0e10cSrcweir 					pFrame->maState.mnWidth,pFrame->maState.mnHeight,pFrame->maState.mnX,pFrame->maState.mnY);
420cdf0e10cSrcweir #endif
421cdf0e10cSrcweir             if ( bVisible )
422cdf0e10cSrcweir                 pFrame->mnShowState = SWP_SHOWNORMAL;
423cdf0e10cSrcweir             pFrame->mbRestoreMaximize = FALSE;
424cdf0e10cSrcweir 			//debug_printf( "ImplSaveFrameState: window %08x at %d,%d (size %dx%d)\n",
425cdf0e10cSrcweir 			//	pFrame->mhWndFrame,
426cdf0e10cSrcweir 			//	pFrame->maState.mnX, pFrame->maState.mnY, pFrame->maState.mnWidth, pFrame->maState.mnHeight);
427cdf0e10cSrcweir         }
428cdf0e10cSrcweir     }
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
431cdf0e10cSrcweir // -----------------------------------------------------------------------
432cdf0e10cSrcweir 
ImplSalCallbackDummy(void *,SalFrame *,USHORT,const void *)433cdf0e10cSrcweir long ImplSalCallbackDummy( void*, SalFrame*, USHORT, const void* )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir     return 0;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // -----------------------------------------------------------------------
439cdf0e10cSrcweir 
ImplSalCalcFrameSize(HWND hWnd,LONG & nFrameX,LONG & nFrameY,LONG & nCaptionY)440cdf0e10cSrcweir static void ImplSalCalcFrameSize( HWND hWnd,
441cdf0e10cSrcweir                                   LONG& nFrameX, LONG& nFrameY, LONG& nCaptionY )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
444cdf0e10cSrcweir     if ( !pFrame )
445cdf0e10cSrcweir         return;
446cdf0e10cSrcweir 	return ImplSalCalcFrameSize( pFrame, nFrameX, nFrameY, nCaptionY );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
ImplSalCalcFrameSize(const Os2SalFrame * pFrame,LONG & nFrameX,LONG & nFrameY,LONG & nCaptionY)449cdf0e10cSrcweir static void ImplSalCalcFrameSize( const Os2SalFrame* pFrame,
450cdf0e10cSrcweir                                   LONG& nFrameX, LONG& nFrameY, LONG& nCaptionY )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir     if ( pFrame->mbSizeBorder )
453cdf0e10cSrcweir     {
454cdf0e10cSrcweir         nFrameX = WinQuerySysValue( HWND_DESKTOP, SV_CXSIZEBORDER );
455cdf0e10cSrcweir         nFrameY = WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER );
456cdf0e10cSrcweir     }
457cdf0e10cSrcweir     else if ( pFrame->mbFixBorder )
458cdf0e10cSrcweir     {
459cdf0e10cSrcweir         nFrameX = WinQuerySysValue( HWND_DESKTOP, SV_CXDLGFRAME );
460cdf0e10cSrcweir         nFrameY = WinQuerySysValue( HWND_DESKTOP, SV_CYDLGFRAME );
461cdf0e10cSrcweir     }
462cdf0e10cSrcweir     else if ( pFrame->mbBorder )
463cdf0e10cSrcweir     {
464cdf0e10cSrcweir         nFrameX = WinQuerySysValue( HWND_DESKTOP, SV_CXBORDER );
465cdf0e10cSrcweir         nFrameY = WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER );
466cdf0e10cSrcweir     }
467cdf0e10cSrcweir     else
468cdf0e10cSrcweir     {
469cdf0e10cSrcweir         nFrameX = 0;
470cdf0e10cSrcweir         nFrameY = 0;
471cdf0e10cSrcweir     }
472cdf0e10cSrcweir     if ( pFrame->mbCaption )
473cdf0e10cSrcweir         nCaptionY = WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR );
474cdf0e10cSrcweir     else
475cdf0e10cSrcweir         nCaptionY = 0;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
478cdf0e10cSrcweir 	//if (_bCapture)
479cdf0e10cSrcweir 		debug_printf("ImplSalCalcFrameSize 0x%08x x=%d y=%d t=%d\n", pFrame->mhWndFrame, nFrameX, nFrameY, nCaptionY);
480cdf0e10cSrcweir #endif
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir // -----------------------------------------------------------------------
484cdf0e10cSrcweir 
ImplSalCalcFullScreenSize(const Os2SalFrame * pFrame,LONG & rX,LONG & rY,LONG & rDX,LONG & rDY)485cdf0e10cSrcweir static void ImplSalCalcFullScreenSize( const Os2SalFrame* pFrame,
486cdf0e10cSrcweir                                        LONG& rX, LONG& rY, LONG& rDX, LONG& rDY )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     // set window to screen size
489cdf0e10cSrcweir     LONG nFrameX, nFrameY, nCaptionY;
490cdf0e10cSrcweir     LONG rScreenDX = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
491cdf0e10cSrcweir     LONG rScreenDY = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir     // Framegroessen berechnen
494cdf0e10cSrcweir     ImplSalCalcFrameSize( pFrame, nFrameX, nFrameY, nCaptionY );
495cdf0e10cSrcweir 
496cdf0e10cSrcweir     rX  = -nFrameX;
497cdf0e10cSrcweir     rY  = -(nFrameY+nCaptionY);
498cdf0e10cSrcweir     rDX = rScreenDX+(nFrameX*2);
499cdf0e10cSrcweir     rDY = rScreenDY+(nFrameY*2)+nCaptionY;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir // -----------------------------------------------------------------------
503cdf0e10cSrcweir 
ImplSalFrameFullScreenPos(Os2SalFrame * pFrame,sal_Bool bAlways=FALSE)504fc9fd3f1SPedro Giffuni static void ImplSalFrameFullScreenPos( Os2SalFrame* pFrame, sal_Bool bAlways = FALSE )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir     SWP aSWP;
507cdf0e10cSrcweir     _WinQueryWindowPos( pFrame, &aSWP );
508cdf0e10cSrcweir     if ( bAlways || !(aSWP.fl & SWP_MINIMIZE) )
509cdf0e10cSrcweir     {
510cdf0e10cSrcweir         // set window to screen size
511cdf0e10cSrcweir         LONG nX;
512cdf0e10cSrcweir         LONG nY;
513cdf0e10cSrcweir         LONG nWidth;
514cdf0e10cSrcweir         LONG nHeight;
515cdf0e10cSrcweir         ImplSalCalcFullScreenSize( pFrame, nX, nY, nWidth, nHeight );
516cdf0e10cSrcweir         _WinSetWindowPos( pFrame, 0,
517cdf0e10cSrcweir                          nX, nY, nWidth, nHeight,
518cdf0e10cSrcweir                          SWP_MOVE | SWP_SIZE );
519cdf0e10cSrcweir     }
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir // -----------------------------------------------------------------------
523cdf0e10cSrcweir 
524cdf0e10cSrcweir // Uebersetzungstabelle von System-Keycodes in StarView-Keycodes
525cdf0e10cSrcweir #define KEY_TAB_SIZE     (VK_ENDDRAG+1)
526cdf0e10cSrcweir 
527cdf0e10cSrcweir static USHORT aImplTranslateKeyTab[KEY_TAB_SIZE] =
528cdf0e10cSrcweir {
529cdf0e10cSrcweir     // StarView-Code      System-Code                         Index
530cdf0e10cSrcweir     0,                    //                                  0x00
531cdf0e10cSrcweir     0,                    // VK_BUTTON1                       0x01
532cdf0e10cSrcweir     0,                    // VK_BUTTON2                       0x02
533cdf0e10cSrcweir     0,                    // VK_BUTTON3                       0x03
534cdf0e10cSrcweir     0,                    // VK_BREAK                         0x04
535cdf0e10cSrcweir     KEY_BACKSPACE,        // VK_BACKSPACE                     0x05
536cdf0e10cSrcweir     KEY_TAB,              // VK_TAB                           0x06
537cdf0e10cSrcweir     KEY_TAB,              // VK_BACKTAB                       0x07
538cdf0e10cSrcweir     KEY_RETURN,           // VK_NEWLINE                       0x08
539cdf0e10cSrcweir     0,                    // VK_SHIFT                         0x09
540cdf0e10cSrcweir     0,                    // VK_CTRL                          0x0A
541cdf0e10cSrcweir     0,                    // VK_ALT                           0x0B
542cdf0e10cSrcweir     0,                    // VK_ALTGRAF                       0x0C
543cdf0e10cSrcweir     0,                    // VK_PAUSE                         0x0D
544cdf0e10cSrcweir     0,                    // VK_CAPSLOCK                      0x0E
545cdf0e10cSrcweir     KEY_ESCAPE,           // VK_ESC                           0x0F
546cdf0e10cSrcweir     KEY_SPACE,            // VK_SPACE                         0x10
547cdf0e10cSrcweir     KEY_PAGEUP,           // VK_PAGEUP                        0x11
548cdf0e10cSrcweir     KEY_PAGEDOWN,         // VK_PAGEDOWN                      0x12
549cdf0e10cSrcweir     KEY_END,              // VK_END                           0x13
550cdf0e10cSrcweir     KEY_HOME,             // VK_HOME                          0x14
551cdf0e10cSrcweir     KEY_LEFT,             // VK_LEFT                          0x15
552cdf0e10cSrcweir     KEY_UP,               // VK_UP                            0x16
553cdf0e10cSrcweir     KEY_RIGHT,            // VK_RIGHT                         0x17
554cdf0e10cSrcweir     KEY_DOWN,             // VK_DOWN                          0x18
555cdf0e10cSrcweir     0,                    // VK_PRINTSCRN                     0x19
556cdf0e10cSrcweir     KEY_INSERT,           // VK_INSERT                        0x1A
557cdf0e10cSrcweir     KEY_DELETE,           // VK_DELETE                        0x1B
558cdf0e10cSrcweir     0,                    // VK_SCRLLOCK                      0x1C
559cdf0e10cSrcweir     0,                    // VK_NUMLOCK                       0x1D
560cdf0e10cSrcweir     KEY_RETURN,           // VK_ENTER                         0x1E
561cdf0e10cSrcweir     0,                    // VK_SYSRQ                         0x1F
562cdf0e10cSrcweir     KEY_F1,               // VK_F1                            0x20
563cdf0e10cSrcweir     KEY_F2,               // VK_F2                            0x21
564cdf0e10cSrcweir     KEY_F3,               // VK_F3                            0x22
565cdf0e10cSrcweir     KEY_F4,               // VK_F4                            0x23
566cdf0e10cSrcweir     KEY_F5,               // VK_F5                            0x24
567cdf0e10cSrcweir     KEY_F6,               // VK_F6                            0x25
568cdf0e10cSrcweir     KEY_F7,               // VK_F7                            0x26
569cdf0e10cSrcweir     KEY_F8,               // VK_F8                            0x27
570cdf0e10cSrcweir     KEY_F9,               // VK_F9                            0x28
571cdf0e10cSrcweir     KEY_F10,              // VK_F10                           0x29
572cdf0e10cSrcweir     KEY_F11,              // VK_F11                           0x2A
573cdf0e10cSrcweir     KEY_F12,              // VK_F12                           0x2B
574cdf0e10cSrcweir     KEY_F13,              // VK_F13                           0x2C
575cdf0e10cSrcweir     KEY_F14,              // VK_F14                           0x2D
576cdf0e10cSrcweir     KEY_F15,              // VK_F15                           0x2E
577cdf0e10cSrcweir     KEY_F16,              // VK_F16                           0x2F
578cdf0e10cSrcweir     KEY_F17,              // VK_F17                           0x30
579cdf0e10cSrcweir     KEY_F18,              // VK_F18                           0x31
580cdf0e10cSrcweir     KEY_F19,              // VK_F19                           0x32
581cdf0e10cSrcweir     KEY_F20,              // VK_F20                           0x33
582cdf0e10cSrcweir     KEY_F21,              // VK_F21                           0x34
583cdf0e10cSrcweir     KEY_F22,              // VK_F22                           0x35
584cdf0e10cSrcweir     KEY_F23,              // VK_F23                           0x36
585cdf0e10cSrcweir     KEY_F24,              // VK_F24                           0x37
586cdf0e10cSrcweir     0                     // VK_ENDDRAG                       0x38
587cdf0e10cSrcweir };
588cdf0e10cSrcweir 
589cdf0e10cSrcweir // =======================================================================
590cdf0e10cSrcweir 
ImplSalCreateFrame(Os2SalInstance * pInst,HWND hWndParent,ULONG nSalFrameStyle)591cdf0e10cSrcweir SalFrame* ImplSalCreateFrame( Os2SalInstance* pInst, HWND hWndParent, ULONG nSalFrameStyle )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir     SalData*    	pSalData = GetSalData();
594cdf0e10cSrcweir     Os2SalFrame*   	pFrame = new Os2SalFrame;
595cdf0e10cSrcweir     HWND        	hWndFrame;
596cdf0e10cSrcweir     HWND        	hWndClient;
597cdf0e10cSrcweir     ULONG    		nFrameFlags = FCF_NOBYTEALIGN | FCF_SCREENALIGN;
598cdf0e10cSrcweir     ULONG    		nFrameStyle = 0;
599cdf0e10cSrcweir     ULONG    		nClientStyle = WS_CLIPSIBLINGS;
600fc9fd3f1SPedro Giffuni     sal_Bool        	bSubFrame = FALSE;
601cdf0e10cSrcweir 
602cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
603cdf0e10cSrcweir     debug_printf(">ImplSalCreateFrame hWndParent 0x%x, nSalFrameStyle 0x%x\n", hWndParent, nSalFrameStyle);
604cdf0e10cSrcweir #endif
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	if ( hWndParent )
607cdf0e10cSrcweir 	{
608cdf0e10cSrcweir 		bSubFrame = TRUE;
609cdf0e10cSrcweir 		pFrame->mbNoIcon = TRUE;
610cdf0e10cSrcweir 	}
611cdf0e10cSrcweir 
612cdf0e10cSrcweir     // determine creation data (bei Moveable nehmen wir DLG-Border, damit
613cdf0e10cSrcweir     // es besser aussieht)
614cdf0e10cSrcweir     if ( nSalFrameStyle & SAL_FRAME_STYLE_CLOSEABLE )
615cdf0e10cSrcweir         nFrameFlags |= FCF_CLOSEBUTTON;
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	if ( nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE ) {
618cdf0e10cSrcweir 		pFrame->mbCaption = TRUE;
619cdf0e10cSrcweir 		nFrameStyle = WS_ANIMATE;
620cdf0e10cSrcweir 		nFrameFlags |= FCF_SYSMENU | FCF_TITLEBAR | FCF_DLGBORDER;
621cdf0e10cSrcweir 		if ( !hWndParent )
622cdf0e10cSrcweir 			nFrameFlags |= FCF_MINBUTTON;
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 		if ( nSalFrameStyle & SAL_FRAME_STYLE_SIZEABLE )
625cdf0e10cSrcweir 		{
626cdf0e10cSrcweir 			pFrame->mbSizeBorder = TRUE;
627cdf0e10cSrcweir 			nFrameFlags |= FCF_SIZEBORDER;
628cdf0e10cSrcweir 			if ( !hWndParent )
629cdf0e10cSrcweir 				nFrameFlags |= FCF_MAXBUTTON;
630cdf0e10cSrcweir 		}
631cdf0e10cSrcweir 		else
632cdf0e10cSrcweir 			pFrame->mbFixBorder = TRUE;
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 		// add task list style if not a tool window
635cdf0e10cSrcweir 		if ( !(nSalFrameStyle & SAL_FRAME_STYLE_TOOLWINDOW) ) {
636cdf0e10cSrcweir 			nFrameFlags |= FCF_TASKLIST;
637cdf0e10cSrcweir 		}
638cdf0e10cSrcweir 	}
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 	if( nSalFrameStyle & SAL_FRAME_STYLE_TOOLWINDOW )
641cdf0e10cSrcweir 	{
642cdf0e10cSrcweir 		pFrame->mbNoIcon = TRUE;
643cdf0e10cSrcweir 		// YD gives small caption -> nExSysStyle |= WS_EX_TOOLWINDOW;
644cdf0e10cSrcweir 	}
645cdf0e10cSrcweir 
646cdf0e10cSrcweir     if ( nSalFrameStyle & SAL_FRAME_STYLE_FLOAT )
647cdf0e10cSrcweir     {
648cdf0e10cSrcweir         //nExSysStyle |= WS_EX_TOOLWINDOW;
649cdf0e10cSrcweir         pFrame->mbFloatWin = TRUE;
650cdf0e10cSrcweir     }
651cdf0e10cSrcweir     //if( nSalFrameStyle & SAL_FRAME_STYLE_TOOLTIP )
652cdf0e10cSrcweir     //    nExSysStyle |= WS_EX_TOPMOST;
653cdf0e10cSrcweir 
654cdf0e10cSrcweir     // init frame data
655cdf0e10cSrcweir     pFrame->mnStyle = nSalFrameStyle;
656cdf0e10cSrcweir 
657cdf0e10cSrcweir     // determine show style
658cdf0e10cSrcweir     pFrame->mnShowState = SWP_SHOWNORMAL;
659cdf0e10cSrcweir 
660cdf0e10cSrcweir     // create frame
661cdf0e10cSrcweir 	//YD FIXME this is a potential bug with multiple threads and cuncurrent
662cdf0e10cSrcweir 	//window creation, because this field is accessed in
663cdf0e10cSrcweir 	//WM_CREATE to get window data,
664cdf0e10cSrcweir     pSalData->mpCreateFrame = pFrame;
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	//YD FIXME if SAL_FRAME_CHILD is specified, use hWndParent as parent handle...
667cdf0e10cSrcweir     hWndFrame = WinCreateStdWindow( HWND_DESKTOP, nFrameStyle, &nFrameFlags,
668cdf0e10cSrcweir 					(PSZ)(bSubFrame ? SAL_SUBFRAME_CLASSNAME : SAL_FRAME_CLASSNAME),
669cdf0e10cSrcweir 					NULL,
670cdf0e10cSrcweir 					nClientStyle, 0, 0, &hWndClient );
671cdf0e10cSrcweir     debug_printf("ImplSalCreateFrame hWndParent 0x%x, hWndFrame 0x%x, hWndClient 0x%x\n", hWndParent, hWndFrame, hWndClient);
672cdf0e10cSrcweir     if ( !hWndFrame )
673cdf0e10cSrcweir     {
674cdf0e10cSrcweir         delete pFrame;
675cdf0e10cSrcweir         return NULL;
676cdf0e10cSrcweir     }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir     // Parent setzen (Owner)
679cdf0e10cSrcweir     if ( hWndParent != 0 && hWndParent != HWND_DESKTOP )
680cdf0e10cSrcweir         WinSetOwner( hWndFrame, hWndParent );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir     Os2SalFrame* pParentFrame = GetWindowPtr( hWndParent );
683cdf0e10cSrcweir     if ( pParentFrame )
684cdf0e10cSrcweir 		pFrame->mpParentFrame = pParentFrame;
685cdf0e10cSrcweir 
686*1b00c71bSYuri Dario     // since os2 windows always have a close button, always set icon
687cdf0e10cSrcweir     WinSendMsg( hWndFrame, WM_SETICON, (MPARAM)pInst->mhAppIcon, (MPARAM)0 );
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     // If we have an Window with an Caption Bar and without
690cdf0e10cSrcweir     // an MaximizeBox, we change the SystemMenu
691cdf0e10cSrcweir     if ( (nFrameFlags & (FCF_TITLEBAR | FCF_MAXBUTTON)) == (FCF_TITLEBAR) )
692cdf0e10cSrcweir     {
693cdf0e10cSrcweir         HWND hSysMenu = WinWindowFromID( hWndFrame, FID_SYSMENU );
694cdf0e10cSrcweir         if ( hSysMenu )
695cdf0e10cSrcweir         {
696cdf0e10cSrcweir             if ( !(nFrameFlags & (FCF_MINBUTTON | FCF_MAXBUTTON)) )
697cdf0e10cSrcweir 				WinEnableMenuItem(hSysMenu, SC_RESTORE, FALSE);
698cdf0e10cSrcweir             if ( !(nFrameFlags & FCF_MINBUTTON) )
699cdf0e10cSrcweir 				WinEnableMenuItem(hSysMenu, SC_MINIMIZE, FALSE);
700cdf0e10cSrcweir             if ( !(nFrameFlags & FCF_MAXBUTTON) )
701cdf0e10cSrcweir 				WinEnableMenuItem(hSysMenu, SC_MAXIMIZE, FALSE);
702cdf0e10cSrcweir             if ( !(nFrameFlags & FCF_SIZEBORDER) )
703cdf0e10cSrcweir 				WinEnableMenuItem(hSysMenu, SC_SIZE, FALSE);
704cdf0e10cSrcweir         }
705cdf0e10cSrcweir     }
706cdf0e10cSrcweir     if ( (nFrameFlags & FCF_SYSMENU) && !(nSalFrameStyle & SAL_FRAME_STYLE_CLOSEABLE) )
707cdf0e10cSrcweir     {
708cdf0e10cSrcweir         HWND hSysMenu = WinWindowFromID( hWndFrame, FID_SYSMENU );
709cdf0e10cSrcweir         if ( hSysMenu )
710cdf0e10cSrcweir         {
711cdf0e10cSrcweir             WinEnableMenuItem(hSysMenu, SC_CLOSE, FALSE);
712cdf0e10cSrcweir         }
713cdf0e10cSrcweir     }
714cdf0e10cSrcweir 
715cdf0e10cSrcweir     // ticket#124 subclass frame window: we need to intercept TRACK message
716cdf0e10cSrcweir     aSalShlData.mpFrameProc = WinSubclassWindow( hWndFrame, SalFrameSubClassWndProc);
717cdf0e10cSrcweir 
718cdf0e10cSrcweir     // init OS/2 frame data
719cdf0e10cSrcweir     pFrame->mhAB            = pInst->mhAB;
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     // YD 18/08 under OS/2, invisible frames have size 0,0 at 0,0, so
722cdf0e10cSrcweir     // we need to set an initial size/position manually
723cdf0e10cSrcweir     SWP aSWP;
724cdf0e10cSrcweir     memset( &aSWP, 0, sizeof( aSWP ) );
725cdf0e10cSrcweir     WinQueryTaskSizePos( pInst->mhAB, 0, &aSWP );
726cdf0e10cSrcweir     WinSetWindowPos( hWndFrame, NULL, aSWP.x, aSWP.y, aSWP.cx, aSWP.cy,
727cdf0e10cSrcweir                      SWP_MOVE | SWP_SIZE);
728cdf0e10cSrcweir 
729cdf0e10cSrcweir #ifdef ENABLE_IME
730cdf0e10cSrcweir     // Input-Context einstellen
731cdf0e10cSrcweir     SalIMEData* pIMEData = GetSalIMEData();
732cdf0e10cSrcweir     if ( pIMEData )
733cdf0e10cSrcweir     {
734cdf0e10cSrcweir         pFrame->mhIMEContext = 0;
735cdf0e10cSrcweir         if ( 0 != pIMEData->mpAssocIME( hWndClient, pFrame->mhIMEContext, &pFrame->mhDefIMEContext ) )
736cdf0e10cSrcweir             pFrame->mhDefIMEContext = 0;
737cdf0e10cSrcweir     }
738cdf0e10cSrcweir     else
739cdf0e10cSrcweir     {
740cdf0e10cSrcweir         pFrame->mhIMEContext = 0;
741cdf0e10cSrcweir         pFrame->mhDefIMEContext = 0;
742cdf0e10cSrcweir     }
743cdf0e10cSrcweir #endif
744cdf0e10cSrcweir 
745cdf0e10cSrcweir     RECTL rectl;
746cdf0e10cSrcweir     _WinQueryWindowRect( hWndClient, &rectl );
747cdf0e10cSrcweir     pFrame->mnWidth  = rectl.xRight;
748cdf0e10cSrcweir     pFrame->mnHeight = rectl.yBottom;
749cdf0e10cSrcweir     debug_printf( "ImplSalCreateFrame %dx%d\n", pFrame->mnWidth, pFrame->mnHeight);
750cdf0e10cSrcweir     ImplSaveFrameState( pFrame );
751cdf0e10cSrcweir     pFrame->mbDefPos = TRUE;
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 	UpdateFrameGeometry( hWndFrame, pFrame );
754cdf0e10cSrcweir 
755cdf0e10cSrcweir     if( pFrame->mnShowState == SWP_SHOWMAXIMIZED )
756cdf0e10cSrcweir 	{
757cdf0e10cSrcweir 		// #96084 set a useful internal window size because
758cdf0e10cSrcweir 		// the window will not be maximized (and the size updated) before show()
759cdf0e10cSrcweir         SetMaximizedFrameGeometry( hWndFrame, pFrame );
760cdf0e10cSrcweir 	}
761cdf0e10cSrcweir 
762cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
763cdf0e10cSrcweir 	dumpWindowInfo( "<ImplSalCreateFrame (exit)", hWndFrame);
764cdf0e10cSrcweir #endif
765cdf0e10cSrcweir 
766cdf0e10cSrcweir     return pFrame;
767cdf0e10cSrcweir }
768cdf0e10cSrcweir 
769cdf0e10cSrcweir // =======================================================================
770cdf0e10cSrcweir 
Os2SalFrame()771cdf0e10cSrcweir Os2SalFrame::Os2SalFrame()
772cdf0e10cSrcweir {
773cdf0e10cSrcweir     SalData* pSalData = GetSalData();
774cdf0e10cSrcweir 
775cdf0e10cSrcweir     mbGraphics          = NULL;
776cdf0e10cSrcweir     mhPointer           = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE );
777cdf0e10cSrcweir     mpGraphics          = NULL;
778cdf0e10cSrcweir     mpInst              = NULL;
779cdf0e10cSrcweir     mbFullScreen        = FALSE;
780cdf0e10cSrcweir     mbAllwayOnTop       = FALSE;
781cdf0e10cSrcweir     mbVisible           = FALSE;
782cdf0e10cSrcweir     mbMinHide           = FALSE;
783cdf0e10cSrcweir     mbInShow            = FALSE;
784cdf0e10cSrcweir     mbRestoreMaximize   = FALSE;
785cdf0e10cSrcweir     mbInMoveMsg         = FALSE;
786cdf0e10cSrcweir     mbInSizeMsg         = FALSE;
787cdf0e10cSrcweir     mbDefPos            = TRUE;
788cdf0e10cSrcweir     mbOverwriteState    = TRUE;
789cdf0e10cSrcweir     mbHandleIME         = FALSE;
790cdf0e10cSrcweir     mbConversionMode    = FALSE;
791cdf0e10cSrcweir     mbCandidateMode     = FALSE;
792cdf0e10cSrcweir     mbCaption           = FALSE;
793cdf0e10cSrcweir     //mhDefIMEContext     = 0;
794cdf0e10cSrcweir     mpGraphics          = NULL;
795cdf0e10cSrcweir     mnShowState         = SWP_SHOWNORMAL;
796cdf0e10cSrcweir     mnWidth             = 0;
797cdf0e10cSrcweir     mnHeight            = 0;
798cdf0e10cSrcweir     mnMinWidth          = 0;
799cdf0e10cSrcweir     mnMinHeight         = 0;
800cdf0e10cSrcweir     mnMaxWidth          = SHRT_MAX;
801cdf0e10cSrcweir     mnMaxHeight         = SHRT_MAX;
802cdf0e10cSrcweir     mnInputLang         = 0;
803cdf0e10cSrcweir     mnKeyboardHandle    = 0;
804cdf0e10cSrcweir     mbGraphics          = FALSE;
805cdf0e10cSrcweir     mbCaption           = FALSE;
806cdf0e10cSrcweir     mbBorder            = FALSE;
807cdf0e10cSrcweir     mbFixBorder         = FALSE;
808cdf0e10cSrcweir     mbSizeBorder        = FALSE;
809cdf0e10cSrcweir     mbFullScreen        = FALSE;
810cdf0e10cSrcweir     //mbPresentation      = FALSE;
811cdf0e10cSrcweir     mbInShow            = FALSE;
812cdf0e10cSrcweir     mbRestoreMaximize   = FALSE;
813cdf0e10cSrcweir     mbInMoveMsg         = FALSE;
814cdf0e10cSrcweir     mbInSizeMsg         = FALSE;
815cdf0e10cSrcweir     //mbFullScreenToolWin = FALSE;
816cdf0e10cSrcweir     mbDefPos            = TRUE;
817cdf0e10cSrcweir     mbOverwriteState    = TRUE;
818cdf0e10cSrcweir     //mbIME               = FALSE;
819cdf0e10cSrcweir     mbHandleIME         = FALSE;
820cdf0e10cSrcweir     //mbSpezIME           = FALSE;
821cdf0e10cSrcweir     //mbAtCursorIME       = FALSE;
822cdf0e10cSrcweir     mbCandidateMode     = FALSE;
823cdf0e10cSrcweir     mbFloatWin          = FALSE;
824cdf0e10cSrcweir     mbNoIcon            = FALSE;
825cdf0e10cSrcweir     //mSelectedhMenu      = 0;
826cdf0e10cSrcweir     //mLastActivatedhMenu = 0;
827cdf0e10cSrcweir 	mpParentFrame		= NULL;
828cdf0e10cSrcweir 
829cdf0e10cSrcweir     memset( &maState, 0, sizeof( SalFrameState ) );
830cdf0e10cSrcweir     maSysData.nSize     = sizeof( SystemEnvData );
831cdf0e10cSrcweir     memset( &maGeometry, 0, sizeof( maGeometry ) );
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     // insert frame in framelist
834cdf0e10cSrcweir     mpNextFrame = pSalData->mpFirstFrame;
835cdf0e10cSrcweir     pSalData->mpFirstFrame = this;
836cdf0e10cSrcweir }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir // -----------------------------------------------------------------------
839cdf0e10cSrcweir 
~Os2SalFrame()840cdf0e10cSrcweir Os2SalFrame::~Os2SalFrame()
841cdf0e10cSrcweir {
842cdf0e10cSrcweir     SalData* pSalData = GetSalData();
843cdf0e10cSrcweir 
844cdf0e10cSrcweir     // destroy DC
845cdf0e10cSrcweir     if ( mpGraphics )
846cdf0e10cSrcweir     {
847cdf0e10cSrcweir         ImplSalDeInitGraphics( mpGraphics );
848cdf0e10cSrcweir         WinReleasePS( mpGraphics->mhPS );
849cdf0e10cSrcweir         delete mpGraphics;
850cdf0e10cSrcweir     }
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     // destroy system frame
853cdf0e10cSrcweir     WinDestroyWindow( mhWndFrame );
854cdf0e10cSrcweir 
855cdf0e10cSrcweir     // remove frame from framelist
856cdf0e10cSrcweir     if ( this == pSalData->mpFirstFrame )
857cdf0e10cSrcweir         pSalData->mpFirstFrame = mpNextFrame;
858cdf0e10cSrcweir     else
859cdf0e10cSrcweir     {
860cdf0e10cSrcweir         Os2SalFrame* pTempFrame = pSalData->mpFirstFrame;
861cdf0e10cSrcweir         while ( pTempFrame->mpNextFrame != this )
862cdf0e10cSrcweir             pTempFrame = pTempFrame->mpNextFrame;
863cdf0e10cSrcweir 
864cdf0e10cSrcweir         pTempFrame->mpNextFrame = mpNextFrame;
865cdf0e10cSrcweir     }
866cdf0e10cSrcweir }
867cdf0e10cSrcweir 
868cdf0e10cSrcweir // -----------------------------------------------------------------------
869cdf0e10cSrcweir 
ImplWinGetDC(HWND hWnd)870cdf0e10cSrcweir static HDC ImplWinGetDC( HWND hWnd )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     HDC hDC = WinQueryWindowDC( hWnd );
873cdf0e10cSrcweir     if ( !hDC )
874cdf0e10cSrcweir         hDC = WinOpenWindowDC( hWnd );
875cdf0e10cSrcweir     return hDC;
876cdf0e10cSrcweir }
877cdf0e10cSrcweir 
878cdf0e10cSrcweir // -----------------------------------------------------------------------
879cdf0e10cSrcweir 
GetGraphics()880cdf0e10cSrcweir SalGraphics* Os2SalFrame::GetGraphics()
881cdf0e10cSrcweir {
882cdf0e10cSrcweir     if ( mbGraphics )
883cdf0e10cSrcweir         return NULL;
884cdf0e10cSrcweir 
885cdf0e10cSrcweir     if ( !mpGraphics )
886cdf0e10cSrcweir     {
887cdf0e10cSrcweir         SalData* pSalData = GetSalData();
888cdf0e10cSrcweir         mpGraphics = new Os2SalGraphics;
889cdf0e10cSrcweir         mpGraphics->mhPS      = WinGetPS( mhWndClient );
890cdf0e10cSrcweir         mpGraphics->mhDC      = ImplWinGetDC( mhWndClient );
891cdf0e10cSrcweir         mpGraphics->mhWnd     = mhWndClient;
892cdf0e10cSrcweir         mpGraphics->mnHeight  = mnHeight;
893cdf0e10cSrcweir         mpGraphics->mbPrinter = FALSE;
894cdf0e10cSrcweir         mpGraphics->mbVirDev  = FALSE;
895cdf0e10cSrcweir         mpGraphics->mbWindow  = TRUE;
896cdf0e10cSrcweir         mpGraphics->mbScreen  = TRUE;
897cdf0e10cSrcweir         ImplSalInitGraphics( mpGraphics );
898cdf0e10cSrcweir         mbGraphics = TRUE;
899cdf0e10cSrcweir     }
900cdf0e10cSrcweir     else
901cdf0e10cSrcweir         mbGraphics = TRUE;
902cdf0e10cSrcweir 
903cdf0e10cSrcweir     return mpGraphics;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir // -----------------------------------------------------------------------
907cdf0e10cSrcweir 
ReleaseGraphics(SalGraphics *)908cdf0e10cSrcweir void Os2SalFrame::ReleaseGraphics( SalGraphics* )
909cdf0e10cSrcweir {
910cdf0e10cSrcweir     mbGraphics = FALSE;
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
913cdf0e10cSrcweir // -----------------------------------------------------------------------
914cdf0e10cSrcweir 
PostEvent(void * pData)915fc9fd3f1SPedro Giffuni sal_Bool Os2SalFrame::PostEvent( void* pData )
916cdf0e10cSrcweir {
917fc9fd3f1SPedro Giffuni     return (sal_Bool)WinPostMsg( mhWndClient, SAL_MSG_USEREVENT, 0, (MPARAM)pData );
918cdf0e10cSrcweir }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir // -----------------------------------------------------------------------
921cdf0e10cSrcweir 
SetTitle(const XubString & rTitle)922cdf0e10cSrcweir void Os2SalFrame::SetTitle( const XubString& rTitle )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir     // set window title
925cdf0e10cSrcweir 	ByteString title( rTitle, gsl_getSystemTextEncoding() );
926cdf0e10cSrcweir 	debug_printf("Os2SalFrame::SetTitle %x '%s'\n", mhWndFrame, title.GetBuffer() );
927cdf0e10cSrcweir     WinSetWindowText( mhWndFrame, title.GetBuffer() );
928cdf0e10cSrcweir }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir // -----------------------------------------------------------------------
931cdf0e10cSrcweir 
SetIcon(USHORT nIcon)932cdf0e10cSrcweir void Os2SalFrame::SetIcon( USHORT nIcon )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir 	debug_printf("Os2SalFrame::SetIcon\n");
935cdf0e10cSrcweir 
936cdf0e10cSrcweir     // If we have a window without an Icon (for example a dialog), ignore this call
937cdf0e10cSrcweir     if ( mbNoIcon )
938cdf0e10cSrcweir         return;
939cdf0e10cSrcweir 
940cdf0e10cSrcweir     // 0 means default (class) icon
941cdf0e10cSrcweir     HPOINTER hIcon = NULL;
942cdf0e10cSrcweir     if ( !nIcon )
943cdf0e10cSrcweir         nIcon = 1;
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     ImplLoadSalIcon( nIcon, hIcon );
946cdf0e10cSrcweir 
947cdf0e10cSrcweir     DBG_ASSERT( hIcon , "Os2SalFrame::SetIcon(): Could not load icon !" );
948cdf0e10cSrcweir 
949cdf0e10cSrcweir     // Icon setzen
950cdf0e10cSrcweir 	WinSendMsg( mhWndFrame, WM_SETICON, (MPARAM)hIcon, (MPARAM)0 );
951cdf0e10cSrcweir }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir // -----------------------------------------------------------------------
954cdf0e10cSrcweir 
GetParent() const955cdf0e10cSrcweir SalFrame* Os2SalFrame::GetParent() const
956cdf0e10cSrcweir {
957cdf0e10cSrcweir 	//debug_printf("Os2SalFrame::GetParent\n");
958cdf0e10cSrcweir     return GetWindowPtr( WinQueryWindow(mhWndFrame, QW_OWNER) );
959cdf0e10cSrcweir }
960cdf0e10cSrcweir 
961cdf0e10cSrcweir // -----------------------------------------------------------------------
962cdf0e10cSrcweir 
ImplSalShow(HWND hWnd,ULONG bVisible,ULONG bNoActivate)963cdf0e10cSrcweir static void ImplSalShow( HWND hWnd, ULONG bVisible, ULONG bNoActivate )
964cdf0e10cSrcweir {
965cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
966cdf0e10cSrcweir     if ( !pFrame )
967cdf0e10cSrcweir         return;
968cdf0e10cSrcweir 
969cdf0e10cSrcweir     if ( bVisible )
970cdf0e10cSrcweir     {
971cdf0e10cSrcweir         pFrame->mbDefPos = FALSE;
972cdf0e10cSrcweir         pFrame->mbOverwriteState = TRUE;
973cdf0e10cSrcweir         pFrame->mbInShow = TRUE;
974cdf0e10cSrcweir 
975cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
976cdf0e10cSrcweir 		debug_printf( "ImplSalShow hwnd %x visible flag %d, no activate: flag %d\n", hWnd, bVisible, bNoActivate);
977cdf0e10cSrcweir #endif
978cdf0e10cSrcweir 
979cdf0e10cSrcweir         if( bNoActivate )
980cdf0e10cSrcweir 			WinSetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_SHOW);
981cdf0e10cSrcweir         else
982cdf0e10cSrcweir             WinSetWindowPos(hWnd, NULL, 0, 0, 0, 0, pFrame->mnShowState);
983cdf0e10cSrcweir 
984cdf0e10cSrcweir         pFrame->mbInShow = FALSE;
985cdf0e10cSrcweir 
986cdf0e10cSrcweir         // Direct Paint only, if we get the SolarMutx
987cdf0e10cSrcweir         if ( ImplSalYieldMutexTryToAcquire() )
988cdf0e10cSrcweir         {
989cdf0e10cSrcweir             WinUpdateWindow( hWnd );
990cdf0e10cSrcweir             ImplSalYieldMutexRelease();
991cdf0e10cSrcweir         }
992cdf0e10cSrcweir     }
993cdf0e10cSrcweir     else
994cdf0e10cSrcweir     {
995cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
996cdf0e10cSrcweir 		debug_printf( "ImplSalShow hwnd %x HIDE\n");
997cdf0e10cSrcweir #endif
998cdf0e10cSrcweir 		WinSetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_HIDE);
999cdf0e10cSrcweir     }
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir // -----------------------------------------------------------------------
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir 
SetExtendedFrameStyle(SalExtStyle nExtStyle)1006cdf0e10cSrcweir void Os2SalFrame::SetExtendedFrameStyle( SalExtStyle nExtStyle )
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir // -----------------------------------------------------------------------
1011cdf0e10cSrcweir 
Show(sal_Bool bVisible,sal_Bool bNoActivate)1012fc9fd3f1SPedro Giffuni void Os2SalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir     // Post this Message to the window, because this only works
1015cdf0e10cSrcweir     // in the thread of the window, which has create this window.
1016cdf0e10cSrcweir     // We post this message to avoid deadlocks
1017cdf0e10cSrcweir     if ( GetSalData()->mnAppThreadId != GetCurrentThreadId() )
1018cdf0e10cSrcweir         WinPostMsg( mhWndFrame, SAL_MSG_SHOW, (MPARAM)bVisible, (MPARAM)bNoActivate );
1019cdf0e10cSrcweir     else
1020cdf0e10cSrcweir         ImplSalShow( mhWndFrame, bVisible, bNoActivate );
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir // -----------------------------------------------------------------------
1024cdf0e10cSrcweir 
Enable(sal_Bool bEnable)1025fc9fd3f1SPedro Giffuni void Os2SalFrame::Enable( sal_Bool bEnable )
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir     WinEnableWindow( mhWndFrame, bEnable );
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir // -----------------------------------------------------------------------
1031cdf0e10cSrcweir 
SetMinClientSize(long nWidth,long nHeight)1032cdf0e10cSrcweir void Os2SalFrame::SetMinClientSize( long nWidth, long nHeight )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir     debug_printf("Os2SalFrame::SetMinClientSize\n");
1035cdf0e10cSrcweir     mnMinWidth  = nWidth;
1036cdf0e10cSrcweir     mnMinHeight = nHeight;
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir 
SetMaxClientSize(long nWidth,long nHeight)1039cdf0e10cSrcweir void Os2SalFrame::SetMaxClientSize( long nWidth, long nHeight )
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir     debug_printf("Os2SalFrame::SetMaxClientSize\n");
1042cdf0e10cSrcweir     mnMaxWidth  = nWidth;
1043cdf0e10cSrcweir     mnMaxHeight = nHeight;
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir // -----------------------------------------------------------------------
1047cdf0e10cSrcweir 
SetPosSize(long nX,long nY,long nWidth,long nHeight,USHORT nFlags)1048cdf0e10cSrcweir void Os2SalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight,
1049cdf0e10cSrcweir                                                    USHORT nFlags )
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir     // calculation frame size
1052cdf0e10cSrcweir     USHORT 	nEvent = 0;
1053cdf0e10cSrcweir 	ULONG	nPosFlags = 0;
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1056cdf0e10cSrcweir 	//dumpWindowInfo( "-Os2SalFrame::SetPosSize", mhWndFrame);
1057cdf0e10cSrcweir 	debug_printf( ">Os2SalFrame::SetPosSize go to %d,%d (%dx%d) VCL\n",nX,nY,nWidth,nHeight);
1058cdf0e10cSrcweir #endif
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 	SWP aSWP;
1061cdf0e10cSrcweir 	_WinQueryWindowPos( this, &aSWP );
1062fc9fd3f1SPedro Giffuni     sal_Bool bVisible = WinIsWindowVisible( mhWndFrame );
1063cdf0e10cSrcweir     if ( !bVisible )
1064cdf0e10cSrcweir     {
1065cdf0e10cSrcweir         if ( mbFloatWin )
1066cdf0e10cSrcweir 			mnShowState = SWP_SHOW;
1067cdf0e10cSrcweir         else
1068cdf0e10cSrcweir 			mnShowState = SWP_SHOWNORMAL;
1069cdf0e10cSrcweir     }
1070cdf0e10cSrcweir     else
1071cdf0e10cSrcweir     {
1072cdf0e10cSrcweir         if ( (aSWP.fl & SWP_MINIMIZE) || (aSWP.fl & SWP_MAXIMIZE) )
1073cdf0e10cSrcweir 			WinSetWindowPos(mhWndFrame, NULL, 0, 0, 0, 0, SWP_RESTORE );
1074cdf0e10cSrcweir     }
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir     if ( (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)) ) {
1077cdf0e10cSrcweir         nPosFlags |= SWP_MOVE;
1078cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1079cdf0e10cSrcweir 		debug_printf( "-Os2SalFrame::SetPosSize MOVE to %d,%d\n", nX, nY);
1080cdf0e10cSrcweir #endif
1081cdf0e10cSrcweir         //DBG_ASSERT( nX && nY, " Windowposition of (0,0) requested!" );
1082cdf0e10cSrcweir         nEvent = SALEVENT_MOVE;
1083cdf0e10cSrcweir 	}
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir     if ( (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) ) {
1086cdf0e10cSrcweir         nPosFlags |= SWP_SIZE;
1087cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1088cdf0e10cSrcweir 		debug_printf( "-Os2SalFrame::SetPosSize SIZE to %d,%d\n", nWidth,nHeight);
1089cdf0e10cSrcweir #endif
1090cdf0e10cSrcweir         nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE;
1091cdf0e10cSrcweir 	}
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir     // Default-Position, dann zentrieren, ansonsten Position beibehalten
1094cdf0e10cSrcweir     if ( mbDefPos  && !(nPosFlags & SWP_MOVE))
1095cdf0e10cSrcweir     {
1096cdf0e10cSrcweir         // calculate bottom left corner of frame
1097cdf0e10cSrcweir         mbDefPos = FALSE;
1098cdf0e10cSrcweir 		nPosFlags |= SWP_MOVE | SWP_CENTER;
1099cdf0e10cSrcweir         nEvent = SALEVENT_MOVERESIZE;
1100cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 10
1101cdf0e10cSrcweir 		debug_printf( "-Os2SalFrame::SetPosSize CENTER\n");
1102cdf0e10cSrcweir 		debug_printf( "-Os2SalFrame::SetPosSize default position to %d,%d\n", nX, nY);
1103cdf0e10cSrcweir #endif
1104cdf0e10cSrcweir     }
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir     // Adjust Window in the screen
1107fc9fd3f1SPedro Giffuni     sal_Bool bCheckOffScreen = TRUE;
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir     // but don't do this for floaters or ownerdraw windows that are currently moved interactively
1110cdf0e10cSrcweir     if( (mnStyle & SAL_FRAME_STYLE_FLOAT) && !(mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) )
1111cdf0e10cSrcweir         bCheckOffScreen = FALSE;
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     if( mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION )
1114cdf0e10cSrcweir     {
1115cdf0e10cSrcweir         // may be the window is currently being moved (mouse is captured), then no check is required
1116cdf0e10cSrcweir         if( mhWndClient == WinQueryCapture( HWND_DESKTOP) )
1117cdf0e10cSrcweir             bCheckOffScreen = FALSE;
1118cdf0e10cSrcweir         else
1119cdf0e10cSrcweir             bCheckOffScreen = TRUE;
1120cdf0e10cSrcweir     }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir     if( bCheckOffScreen )
1123cdf0e10cSrcweir     {
1124cdf0e10cSrcweir         if ( nX+nWidth > nScreenWidth )
1125cdf0e10cSrcweir             nX = nScreenWidth - nWidth;
1126cdf0e10cSrcweir         if ( nY+nHeight > nScreenHeight )
1127cdf0e10cSrcweir             nY = nScreenHeight - nHeight;
1128cdf0e10cSrcweir         if ( nX < 0 )
1129cdf0e10cSrcweir             nX = 0;
1130cdf0e10cSrcweir         if ( nY < 0 )
1131cdf0e10cSrcweir             nY = 0;
1132cdf0e10cSrcweir     }
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir     // bring floating windows always to top
1135cdf0e10cSrcweir     // do not change zorder, otherwise tooltips will bring main window to top (ticket:14)
1136cdf0e10cSrcweir     //if( (mnStyle & SAL_FRAME_STYLE_FLOAT) )
1137cdf0e10cSrcweir     //    nPosFlags |= SWP_ZORDER; // do not change z-order
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir     // set new position
1140cdf0e10cSrcweir     _WinSetWindowPos( this, HWND_TOP, nX, nY, nWidth, nHeight, nPosFlags); // | SWP_RESTORE
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir     UpdateFrameGeometry( mhWndFrame, this );
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir     // Notification -- really ???
1145cdf0e10cSrcweir     if( nEvent )
1146cdf0e10cSrcweir         CallCallback( nEvent, NULL );
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1149cdf0e10cSrcweir 	dumpWindowInfo( "<Os2SalFrame::SetPosSize (exit)", mhWndFrame);
1150cdf0e10cSrcweir #endif
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir // -----------------------------------------------------------------------
1155cdf0e10cSrcweir 
SetParent(SalFrame * pNewParent)1156cdf0e10cSrcweir void Os2SalFrame::SetParent( SalFrame* pNewParent )
1157cdf0e10cSrcweir {
1158cdf0e10cSrcweir     APIRET rc;
1159cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
1160cdf0e10cSrcweir     debug_printf("Os2SalFrame::SetParent mhWndFrame 0x%08x to 0x%08x\n",
1161cdf0e10cSrcweir 			static_cast<Os2SalFrame*>(this)->mhWndFrame,
1162cdf0e10cSrcweir 			static_cast<Os2SalFrame*>(pNewParent)->mhWndClient);
1163cdf0e10cSrcweir #endif
1164cdf0e10cSrcweir     Os2SalFrame::mbInReparent = TRUE;
1165cdf0e10cSrcweir     //rc = WinSetParent(static_cast<Os2SalFrame*>(this)->mhWndFrame,
1166cdf0e10cSrcweir     //                  static_cast<Os2SalFrame*>(pNewParent)->mhWndClient, TRUE);
1167cdf0e10cSrcweir     rc = WinSetOwner(static_cast<Os2SalFrame*>(this)->mhWndFrame,
1168cdf0e10cSrcweir                       static_cast<Os2SalFrame*>(pNewParent)->mhWndClient);
1169cdf0e10cSrcweir 	mpParentFrame = static_cast<Os2SalFrame*>(pNewParent);
1170cdf0e10cSrcweir     Os2SalFrame::mbInReparent = FALSE;
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir 
SetPluginParent(SystemParentData * pNewParent)1173cdf0e10cSrcweir bool Os2SalFrame::SetPluginParent( SystemParentData* pNewParent )
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir     APIRET rc;
1176cdf0e10cSrcweir     if ( pNewParent->hWnd == 0 )
1177cdf0e10cSrcweir     {
1178cdf0e10cSrcweir         pNewParent->hWnd = HWND_DESKTOP;
1179cdf0e10cSrcweir     }
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir     Os2SalFrame::mbInReparent = TRUE;
1182cdf0e10cSrcweir     rc = WinSetOwner(static_cast<Os2SalFrame*>(this)->mhWndFrame,
1183cdf0e10cSrcweir                       pNewParent->hWnd);
1184cdf0e10cSrcweir     Os2SalFrame::mbInReparent = FALSE;
1185cdf0e10cSrcweir     return true;
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir // -----------------------------------------------------------------------
1190cdf0e10cSrcweir 
GetWorkArea(RECTL & rRect)1191cdf0e10cSrcweir void Os2SalFrame::GetWorkArea( RECTL &rRect )
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir     rRect.xLeft     = rRect.yTop = 0;
1194cdf0e10cSrcweir     rRect.xRight    = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN )-1;
1195cdf0e10cSrcweir     rRect.yBottom   = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN )-1;
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir // -----------------------------------------------------------------------
1199cdf0e10cSrcweir 
GetWorkArea(Rectangle & rRect)1200cdf0e10cSrcweir void Os2SalFrame::GetWorkArea( Rectangle &rRect )
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir     RECTL aRect;
1203cdf0e10cSrcweir 	GetWorkArea( aRect);
1204cdf0e10cSrcweir     rRect.nLeft     = aRect.xLeft;
1205cdf0e10cSrcweir     rRect.nRight    = aRect.xRight; // win -1;
1206cdf0e10cSrcweir     rRect.nTop      = aRect.yTop;
1207cdf0e10cSrcweir     rRect.nBottom   = aRect.yBottom; // win -1;
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir // -----------------------------------------------------------------------
1211cdf0e10cSrcweir 
GetClientSize(long & rWidth,long & rHeight)1212cdf0e10cSrcweir void Os2SalFrame::GetClientSize( long& rWidth, long& rHeight )
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir     rWidth  = maGeometry.nWidth;
1215cdf0e10cSrcweir     rHeight = maGeometry.nHeight;
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir // -----------------------------------------------------------------------
1219cdf0e10cSrcweir 
SetWindowState(const SalFrameState * pState)1220cdf0e10cSrcweir void Os2SalFrame::SetWindowState( const SalFrameState* pState )
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir 	LONG	nX;
1223cdf0e10cSrcweir 	LONG 	nY;
1224cdf0e10cSrcweir 	LONG 	nWidth;
1225cdf0e10cSrcweir 	LONG 	nHeight;
1226cdf0e10cSrcweir 	ULONG	nPosSize = 0;
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
1229cdf0e10cSrcweir 	debug_printf("Os2SalFrame::SetWindowState\n");
1230cdf0e10cSrcweir 	debug_printf("Os2SalFrame::SetWindowState %08x (%dx%d) at %d,%d VCL\n",
1231cdf0e10cSrcweir 		mhWndFrame,
1232cdf0e10cSrcweir 		pState->mnWidth,pState->mnHeight,pState->mnX,pState->mnY);
1233cdf0e10cSrcweir #endif
1234cdf0e10cSrcweir 
1235fc9fd3f1SPedro Giffuni     sal_Bool bVisible = WinIsWindowVisible( mhWndFrame );
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir     // get screen coordinates
1238cdf0e10cSrcweir     SWP	aSWP;
1239cdf0e10cSrcweir     WinQueryWindowPos( mhWndFrame, &aSWP );
1240cdf0e10cSrcweir 	LONG nFrameX, nFrameY, nCaptionY;
1241cdf0e10cSrcweir 	ImplSalCalcFrameSize( this, nFrameX, nFrameY, nCaptionY );
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir     long nTopDeco = nFrameY + nCaptionY;
1244cdf0e10cSrcweir     long nLeftDeco = nFrameX;
1245cdf0e10cSrcweir     long nBottomDeco = nFrameY;
1246cdf0e10cSrcweir     long nRightDeco = nFrameX;
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir     // Fenster-Position/Groesse in den Bildschirm einpassen
1249cdf0e10cSrcweir     if ((pState->mnMask & (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y)) )
1250cdf0e10cSrcweir         nPosSize |= SWP_MOVE;
1251cdf0e10cSrcweir     if ((pState->mnMask & (SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT)) )
1252cdf0e10cSrcweir         nPosSize |= SWP_SIZE;
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     if ( pState->mnMask & SAL_FRAMESTATE_MASK_X )
1255cdf0e10cSrcweir         nX = (int)pState->mnX - nLeftDeco;
1256cdf0e10cSrcweir     else
1257cdf0e10cSrcweir         nX = aSWP.x;
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir 	// keep Y inverted since height is still unknown, will invert later
1260cdf0e10cSrcweir     if ( pState->mnMask & SAL_FRAMESTATE_MASK_Y )
1261cdf0e10cSrcweir         nY = (int)pState->mnY - nTopDeco;
1262cdf0e10cSrcweir     else
1263cdf0e10cSrcweir         nY = nScreenHeight - (aSWP.y+aSWP.cy);
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir     if ( pState->mnMask & SAL_FRAMESTATE_MASK_WIDTH )
1266cdf0e10cSrcweir         nWidth = (int)pState->mnWidth + nLeftDeco + nRightDeco;
1267cdf0e10cSrcweir     else
1268cdf0e10cSrcweir         nWidth = aSWP.cx;
1269cdf0e10cSrcweir     if ( pState->mnMask & SAL_FRAMESTATE_MASK_HEIGHT )
1270cdf0e10cSrcweir         nHeight = (int)pState->mnHeight + nTopDeco + nBottomDeco;
1271cdf0e10cSrcweir     else
1272cdf0e10cSrcweir         nHeight = aSWP.cy;
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
1275cdf0e10cSrcweir 	debug_printf("Os2SalFrame::SetWindowState (%dx%d) at %d,%d\n", nWidth,nHeight,nX,nY);
1276cdf0e10cSrcweir #endif
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir     // Adjust Window in the screen:
1279cdf0e10cSrcweir     // if it does not fit into the screen do nothing, ie default pos/size will be used
1280cdf0e10cSrcweir     // if there is an overlap with the screen border move the window while keeping its size
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir     //if( nWidth > nScreenWidth || nHeight > nScreenHeight )
1283cdf0e10cSrcweir     //    nPosSize |= (SWP_NOMOVE | SWP_NOSIZE);
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir     if ( nX+nWidth > nScreenWidth )
1286cdf0e10cSrcweir         nX = (nScreenWidth) - nWidth;
1287cdf0e10cSrcweir     if ( nY+nHeight > nScreenHeight )
1288cdf0e10cSrcweir         nY = (nScreenHeight) - nHeight;
1289cdf0e10cSrcweir     if ( nX < 0 )
1290cdf0e10cSrcweir         nX = 0;
1291cdf0e10cSrcweir     if ( nY < 0 )
1292cdf0e10cSrcweir         nY = 0;
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir     // Restore-Position setzen
1295cdf0e10cSrcweir 	SWP aPlacement;
1296cdf0e10cSrcweir 	WinQueryWindowPos( mhWndFrame, &aPlacement );
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir     // Status setzen
1299cdf0e10cSrcweir 	bVisible = WinIsWindowVisible( mhWndFrame);
1300fc9fd3f1SPedro Giffuni 	sal_Bool bUpdateHiddenFramePos = FALSE;
1301cdf0e10cSrcweir     if ( !bVisible )
1302cdf0e10cSrcweir     {
1303cdf0e10cSrcweir         aPlacement.fl = SWP_HIDE;
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir         if ( mbOverwriteState )
1306cdf0e10cSrcweir         {
1307cdf0e10cSrcweir             if ( pState->mnMask & SAL_FRAMESTATE_MASK_STATE )
1308cdf0e10cSrcweir             {
1309cdf0e10cSrcweir                 if ( pState->mnState & SAL_FRAMESTATE_MINIMIZED )
1310cdf0e10cSrcweir                     mnShowState = SWP_SHOWMINIMIZED;
1311cdf0e10cSrcweir                 else if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED )
1312cdf0e10cSrcweir 				{
1313cdf0e10cSrcweir                     mnShowState = SWP_SHOWMAXIMIZED;
1314cdf0e10cSrcweir 					bUpdateHiddenFramePos = TRUE;
1315cdf0e10cSrcweir 				}
1316cdf0e10cSrcweir                 else if ( pState->mnState & SAL_FRAMESTATE_NORMAL )
1317cdf0e10cSrcweir                     mnShowState = SWP_SHOWNORMAL;
1318cdf0e10cSrcweir             }
1319cdf0e10cSrcweir         }
1320cdf0e10cSrcweir     }
1321cdf0e10cSrcweir     else
1322cdf0e10cSrcweir     {
1323cdf0e10cSrcweir         if ( pState->mnMask & SAL_FRAMESTATE_MASK_STATE )
1324cdf0e10cSrcweir         {
1325cdf0e10cSrcweir             if ( pState->mnState & SAL_FRAMESTATE_MINIMIZED )
1326cdf0e10cSrcweir             {
1327cdf0e10cSrcweir                 //if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED )
1328cdf0e10cSrcweir                 //    aPlacement.flags |= WPF_RESTORETOMAXIMIZED;
1329cdf0e10cSrcweir                 aPlacement.fl = SWP_SHOWMINIMIZED;
1330cdf0e10cSrcweir             }
1331cdf0e10cSrcweir             else if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED )
1332cdf0e10cSrcweir                 aPlacement.fl = SWP_SHOWMAXIMIZED;
1333cdf0e10cSrcweir             else if ( pState->mnState & SAL_FRAMESTATE_NORMAL )
1334cdf0e10cSrcweir                 aPlacement.fl = SWP_RESTORE;
1335cdf0e10cSrcweir         }
1336cdf0e10cSrcweir     }
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir     // Wenn Fenster nicht minimiert/maximiert ist oder nicht optisch
1339cdf0e10cSrcweir     // umgesetzt werden muss, dann SetWindowPos() benutzen, da
1340cdf0e10cSrcweir     // SetWindowPlacement() die TaskBar mit einrechnet
1341cdf0e10cSrcweir     if ( !(aPlacement.fl & SWP_MINIMIZE)
1342cdf0e10cSrcweir 		 && !( aPlacement.fl & SWP_MAXIMIZE )
1343cdf0e10cSrcweir 	 	 && (!bVisible || (aPlacement.fl == SWP_RESTORE)) )
1344cdf0e10cSrcweir     {
1345cdf0e10cSrcweir 		if( bUpdateHiddenFramePos )
1346cdf0e10cSrcweir 		{
1347cdf0e10cSrcweir 			// #96084 set a useful internal window size because
1348cdf0e10cSrcweir 			// the window will not be maximized (and the size updated) before show()
1349cdf0e10cSrcweir             SetMaximizedFrameGeometry( mhWndFrame, this );
1350cdf0e10cSrcweir 		}
1351cdf0e10cSrcweir 		else
1352cdf0e10cSrcweir 			WinSetWindowPos( mhWndFrame, 0, nX,
1353cdf0e10cSrcweir 				nScreenHeight - (nY+nHeight), nWidth, nHeight, nPosSize);
1354cdf0e10cSrcweir     }
1355cdf0e10cSrcweir     else
1356cdf0e10cSrcweir     {
1357cdf0e10cSrcweir         if( (nPosSize & (SWP_MOVE|SWP_SIZE)) )
1358cdf0e10cSrcweir         {
1359cdf0e10cSrcweir 			aPlacement.x = nX;
1360cdf0e10cSrcweir 			aPlacement.y = nScreenHeight-(nY+nHeight);
1361cdf0e10cSrcweir 			aPlacement.cx = nWidth;
1362cdf0e10cSrcweir 			aPlacement.cy = nHeight;
1363cdf0e10cSrcweir         }
1364cdf0e10cSrcweir 		WinSetWindowPos( mhWndFrame, 0, aPlacement.x, aPlacement.y,
1365cdf0e10cSrcweir 						 aPlacement.cx, aPlacement.cy, aPlacement.fl );
1366cdf0e10cSrcweir     }
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
1369cdf0e10cSrcweir 	debug_printf("Os2SalFrame::SetWindowState DONE\n");
1370cdf0e10cSrcweir #endif
1371cdf0e10cSrcweir }
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir // -----------------------------------------------------------------------
1374cdf0e10cSrcweir 
GetWindowState(SalFrameState * pState)1375fc9fd3f1SPedro Giffuni sal_Bool Os2SalFrame::GetWindowState( SalFrameState* pState )
1376cdf0e10cSrcweir {
1377cdf0e10cSrcweir     if ( maState.mnWidth && maState.mnHeight )
1378cdf0e10cSrcweir     {
1379cdf0e10cSrcweir         *pState = maState;
1380cdf0e10cSrcweir         // #94144# allow Minimize again, should be masked out when read from configuration
1381cdf0e10cSrcweir         // 91625 - Don't save minimize
1382cdf0e10cSrcweir         //if ( !(pState->mnState & SAL_FRAMESTATE_MAXIMIZED) )
1383cdf0e10cSrcweir         if ( !(pState->mnState & (SAL_FRAMESTATE_MINIMIZED | SAL_FRAMESTATE_MAXIMIZED)) )
1384cdf0e10cSrcweir             pState->mnState |= SAL_FRAMESTATE_NORMAL;
1385cdf0e10cSrcweir         return TRUE;
1386cdf0e10cSrcweir     }
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir     return FALSE;
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir // -----------------------------------------------------------------------
1392cdf0e10cSrcweir 
SetScreenNumber(unsigned int nNewScreen)1393cdf0e10cSrcweir void Os2SalFrame::SetScreenNumber( unsigned int nNewScreen )
1394cdf0e10cSrcweir {
1395cdf0e10cSrcweir #if 0
1396cdf0e10cSrcweir     WinSalSystem* pSys = static_cast<WinSalSystem*>(ImplGetSalSystem());
1397cdf0e10cSrcweir     if( pSys )
1398cdf0e10cSrcweir     {
1399cdf0e10cSrcweir         const std::vector<WinSalSystem::DisplayMonitor>& rMonitors =
1400cdf0e10cSrcweir             pSys->getMonitors();
1401cdf0e10cSrcweir         size_t nMon = rMonitors.size();
1402cdf0e10cSrcweir         if( nNewScreen < nMon )
1403cdf0e10cSrcweir         {
1404cdf0e10cSrcweir             Point aOldMonPos, aNewMonPos( rMonitors[nNewScreen].m_aArea.TopLeft() );
1405cdf0e10cSrcweir             Point aCurPos( maGeometry.nX, maGeometry.nY );
1406cdf0e10cSrcweir             for( size_t i = 0; i < nMon; i++ )
1407cdf0e10cSrcweir             {
1408cdf0e10cSrcweir                 if( rMonitors[i].m_aArea.IsInside( aCurPos ) )
1409cdf0e10cSrcweir                 {
1410cdf0e10cSrcweir                     aOldMonPos = rMonitors[i].m_aArea.TopLeft();
1411cdf0e10cSrcweir                     break;
1412cdf0e10cSrcweir                 }
1413cdf0e10cSrcweir             }
1414cdf0e10cSrcweir             mnDisplay = nNewScreen;
1415cdf0e10cSrcweir             maGeometry.nScreenNumber = nNewScreen;
1416cdf0e10cSrcweir             SetPosSize( aNewMonPos.X() + (maGeometry.nX - aOldMonPos.X()),
1417cdf0e10cSrcweir                         aNewMonPos.Y() + (maGeometry.nY - aOldMonPos.Y()),
1418cdf0e10cSrcweir                         0, 0,
1419cdf0e10cSrcweir                         SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y );
1420cdf0e10cSrcweir         }
1421cdf0e10cSrcweir     }
1422cdf0e10cSrcweir #endif
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir // -----------------------------------------------------------------------
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir // native menu implementation - currently empty
DrawMenuBar()1428cdf0e10cSrcweir void Os2SalFrame::DrawMenuBar()
1429cdf0e10cSrcweir {
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir 
SetMenu(SalMenu * pSalMenu)1432cdf0e10cSrcweir void Os2SalFrame::SetMenu( SalMenu* pSalMenu )
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir // -----------------------------------------------------------------------
1437cdf0e10cSrcweir 
ShowFullScreen(sal_Bool bFullScreen,sal_Int32 nDisplay)1438fc9fd3f1SPedro Giffuni void Os2SalFrame::ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay )
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir     if ( mbFullScreen == bFullScreen )
1441cdf0e10cSrcweir         return;
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir     mbFullScreen = bFullScreen;
1444cdf0e10cSrcweir     if ( bFullScreen )
1445cdf0e10cSrcweir     {
1446cdf0e10cSrcweir         // save old position
1447cdf0e10cSrcweir         memset( &maFullScreenRect, 0, sizeof( SWP ) );
1448cdf0e10cSrcweir         _WinQueryWindowPos( this, &maFullScreenRect );
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir         // set window to screen size
1451cdf0e10cSrcweir         ImplSalFrameFullScreenPos( this, TRUE );
1452cdf0e10cSrcweir     }
1453cdf0e10cSrcweir     else
1454cdf0e10cSrcweir     {
1455cdf0e10cSrcweir         _WinSetWindowPos( this,
1456cdf0e10cSrcweir                          0,
1457cdf0e10cSrcweir                          maFullScreenRect.x, maFullScreenRect.y,
1458cdf0e10cSrcweir                          maFullScreenRect.cx, maFullScreenRect.cy,
1459cdf0e10cSrcweir                          SWP_MOVE | SWP_SIZE );
1460cdf0e10cSrcweir     }
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir // -----------------------------------------------------------------------
1464cdf0e10cSrcweir 
StartPresentation(sal_Bool bStart)1465fc9fd3f1SPedro Giffuni void Os2SalFrame::StartPresentation( sal_Bool bStart )
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir     // SysSetObjectData("<WP_DESKTOP>","Autolockup=no"); oder OS2.INI: PM_Lockup
1468cdf0e10cSrcweir }
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir // -----------------------------------------------------------------------
1471cdf0e10cSrcweir 
SetAlwaysOnTop(sal_Bool bOnTop)1472fc9fd3f1SPedro Giffuni void Os2SalFrame::SetAlwaysOnTop( sal_Bool bOnTop )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir     mbAllwayOnTop = bOnTop;
1475cdf0e10cSrcweir #if 0
1476cdf0e10cSrcweir     HWND hWnd;
1477cdf0e10cSrcweir     if ( bOnTop )
1478cdf0e10cSrcweir         hWnd = HWND_TOPMOST;
1479cdf0e10cSrcweir     else
1480cdf0e10cSrcweir         hWnd = HWND_NOTOPMOST;
1481cdf0e10cSrcweir     SetWindowPos( mhWnd, hWnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
1482cdf0e10cSrcweir #endif
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir // -----------------------------------------------------------------------
1487cdf0e10cSrcweir 
ImplSalToTop(HWND hWnd,ULONG nFlags)1488cdf0e10cSrcweir static void ImplSalToTop( HWND hWnd, ULONG nFlags )
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
1491cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
1492cdf0e10cSrcweir 	debug_printf("ImplSalToTop hWnd %08x, nFlags %x\n", hWnd, nFlags);
1493cdf0e10cSrcweir #endif
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir 	// if window is minimized, first restore it
1496cdf0e10cSrcweir 	SWP aSWP;
1497cdf0e10cSrcweir 	WinQueryWindowPos( hWnd, &aSWP );
1498cdf0e10cSrcweir 	if ( aSWP.fl & SWP_MINIMIZE )
1499cdf0e10cSrcweir 		WinSetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_RESTORE );
1500cdf0e10cSrcweir 
1501cdf0e10cSrcweir     if ( nFlags & SAL_FRAME_TOTOP_FOREGROUNDTASK )
1502cdf0e10cSrcweir 		WinSetWindowPos( pFrame->mhWndFrame, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir     if ( nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN )
1505cdf0e10cSrcweir     {
1506cdf0e10cSrcweir 		ULONG	nStyle;
1507cdf0e10cSrcweir         if ( pFrame->mbRestoreMaximize )
1508cdf0e10cSrcweir             nStyle = SWP_MAXIMIZE;
1509cdf0e10cSrcweir         else
1510cdf0e10cSrcweir             nStyle = SWP_RESTORE;
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir 		WinSetWindowPos( pFrame->mhWndFrame, NULL, 0, 0, 0, 0, nStyle );
1513cdf0e10cSrcweir 	}
1514cdf0e10cSrcweir     WinSetFocus( HWND_DESKTOP, pFrame->mhWndClient );
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir // -----------------------------------------------------------------------
1518cdf0e10cSrcweir 
ToTop(USHORT nFlags)1519cdf0e10cSrcweir void Os2SalFrame::ToTop( USHORT nFlags )
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir 	nFlags &= ~SAL_FRAME_TOTOP_GRABFOCUS;	// this flag is not needed on win32
1522cdf0e10cSrcweir     // Post this Message to the window, because this only works
1523cdf0e10cSrcweir     // in the thread of the window, which has create this window.
1524cdf0e10cSrcweir     // We post this message to avoid deadlocks
1525cdf0e10cSrcweir     if ( GetSalData()->mnAppThreadId != GetCurrentThreadId() )
1526cdf0e10cSrcweir         WinPostMsg( mhWndFrame, SAL_MSG_TOTOP, (MPARAM)nFlags, 0 );
1527cdf0e10cSrcweir     else
1528cdf0e10cSrcweir         ImplSalToTop( mhWndFrame, nFlags );
1529cdf0e10cSrcweir }
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir // -----------------------------------------------------------------------
1532cdf0e10cSrcweir 
SetPointer(PointerStyle ePointerStyle)1533cdf0e10cSrcweir void Os2SalFrame::SetPointer( PointerStyle ePointerStyle )
1534cdf0e10cSrcweir {
1535cdf0e10cSrcweir     struct ImplPtrData
1536cdf0e10cSrcweir     {
1537cdf0e10cSrcweir         HPOINTER	mhPointer;
1538cdf0e10cSrcweir         ULONG       mnSysId;
1539cdf0e10cSrcweir         ULONG       mnOwnId;
1540cdf0e10cSrcweir     };
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir     static ImplPtrData aImplPtrTab[POINTER_COUNT] =
1543cdf0e10cSrcweir     {
1544cdf0e10cSrcweir     { 0, SPTR_ARROW, 0 },                           // POINTER_ARROW
1545cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_NULL },               // POINTER_NULL
1546cdf0e10cSrcweir     { 0, SPTR_WAIT, 0 },                            // POINTER_WAIT
1547cdf0e10cSrcweir     { 0, SPTR_TEXT, 0 },                            // POINTER_BEAM
1548cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_HELP },               // POINTER_HELP
1549cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_CROSS },              // POINTER_CROSS
1550cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVE },               // POINTER_MOVE
1551cdf0e10cSrcweir     { 0, SPTR_SIZENS, 0 },                          // POINTER_NSIZE
1552cdf0e10cSrcweir     { 0, SPTR_SIZENS, 0 },                          // POINTER_SSIZE
1553cdf0e10cSrcweir     { 0, SPTR_SIZEWE, 0 },                          // POINTER_WSIZE
1554cdf0e10cSrcweir     { 0, SPTR_SIZEWE, 0 },                          // POINTER_ESIZE
1555cdf0e10cSrcweir     { 0, SPTR_SIZENWSE, 0 },                        // POINTER_NWSIZE
1556cdf0e10cSrcweir     { 0, SPTR_SIZENESW, 0 },                        // POINTER_NESIZE
1557cdf0e10cSrcweir     { 0, SPTR_SIZENESW, 0 },                        // POINTER_SWSIZE
1558cdf0e10cSrcweir     { 0, SPTR_SIZENWSE, 0 },                        // POINTER_SESIZE
1559cdf0e10cSrcweir     { 0, SPTR_SIZENS, 0 },                          // POINTER_WINDOW_NSIZE
1560cdf0e10cSrcweir     { 0, SPTR_SIZENS, 0 },                          // POINTER_WINDOW_SSIZE
1561cdf0e10cSrcweir     { 0, SPTR_SIZEWE, 0 },                          // POINTER_WINDOW_WSIZE
1562cdf0e10cSrcweir     { 0, SPTR_SIZEWE, 0 },                          // POINTER_WINDOW_ESIZE
1563cdf0e10cSrcweir     { 0, SPTR_SIZENWSE, 0 },                        // POINTER_WINDOW_NWSIZE
1564cdf0e10cSrcweir     { 0, SPTR_SIZENESW, 0 },                        // POINTER_WINDOW_NESIZE
1565cdf0e10cSrcweir     { 0, SPTR_SIZENESW, 0 },                        // POINTER_WINDOW_SWSIZE
1566cdf0e10cSrcweir     { 0, SPTR_SIZENWSE, 0 },                        // POINTER_WINDOW_SESIZE
1567cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_HSPLIT },             // POINTER_HSPLIT
1568cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_VSPLIT },             // POINTER_VSPLIT
1569cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_HSIZEBAR },           // POINTER_HSIZEBAR
1570cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_VSIZEBAR },           // POINTER_VSIZEBAR
1571cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_HAND },               // POINTER_HAND
1572cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_REFHAND },            // POINTER_REFHAND
1573cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_PEN },                // POINTER_PEN
1574cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MAGNIFY },            // POINTER_MAGNIFY
1575cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_FILL },               // POINTER_FILL
1576cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_ROTATE },             // POINTER_ROTATE
1577cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_HSHEAR },             // POINTER_HSHEAR
1578cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_VSHEAR },             // POINTER_VSHEAR
1579cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MIRROR },             // POINTER_MIRROR
1580cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_CROOK },              // POINTER_CROOK
1581cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_CROP },               // POINTER_CROP
1582cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEPOINT },          // POINTER_MOVEPOINT
1583cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEBEZIERWEIGHT },   // POINTER_MOVEBEZIERWEIGHT
1584cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEDATA },           // POINTER_MOVEDATA
1585cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_COPYDATA },           // POINTER_COPYDATA
1586cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_LINKDATA },           // POINTER_LINKDATA
1587cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEDATALINK },       // POINTER_MOVEDATALINK
1588cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_COPYDATALINK },       // POINTER_COPYDATALINK
1589cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEFILE },           // POINTER_MOVEFILE
1590cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_COPYFILE },           // POINTER_COPYFILE
1591cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_LINKFILE },           // POINTER_LINKFILE
1592cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEFILELINK },       // POINTER_MOVEFILELINK
1593cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_COPYFILELINK },       // POINTER_COPYFILELINK
1594cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_MOVEFILES },          // POINTER_MOVEFILES
1595cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_COPYFILES },          // POINTER_COPYFILES
1596cdf0e10cSrcweir     { 0, SPTR_ILLEGAL, 0 },                         // POINTER_NOTALLOWED
1597cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_LINE },          // POINTER_DRAW_LINE
1598cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_RECT },          // POINTER_DRAW_RECT
1599cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_POLYGON },       // POINTER_DRAW_POLYGON
1600cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_BEZIER },        // POINTER_DRAW_BEZIER
1601cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_ARC },           // POINTER_DRAW_ARC
1602cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_PIE },           // POINTER_DRAW_PIE
1603cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_CIRCLECUT },     // POINTER_DRAW_CIRCLECUT
1604cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_ELLIPSE },       // POINTER_DRAW_ELLIPSE
1605cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_FREEHAND },      // POINTER_DRAW_FREEHAND
1606cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_CONNECT },       // POINTER_DRAW_CONNECT
1607cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_TEXT },          // POINTER_DRAW_TEXT
1608cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DRAW_CAPTION },       // POINTER_DRAW_CAPTION
1609cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_CHART },              // POINTER_CHART
1610cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_DETECTIVE },          // POINTER_DETECTIVE
1611cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_PIVOT_COL },          // POINTER_PIVOT_COL
1612cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_PIVOT_ROW },          // POINTER_PIVOT_ROW
1613cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_PIVOT_FIELD },        // POINTER_PIVOT_FIELD
1614cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_CHAIN },              // POINTER_CHAIN
1615cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_CHAIN_NOTALLOWED },   // POINTER_CHAIN_NOTALLOWED
1616cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TIMEEVENT_MOVE },     // POINTER_TIMEEVENT_MOVE
1617cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TIMEEVENT_SIZE },     // POINTER_TIMEEVENT_SIZE
1618cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_N },       // POINTER_AUTOSCROLL_N
1619cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_S },       // POINTER_AUTOSCROLL_S
1620cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_W },       // POINTER_AUTOSCROLL_W
1621cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_E },       // POINTER_AUTOSCROLL_E
1622cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NW },      // POINTER_AUTOSCROLL_NW
1623cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NE },      // POINTER_AUTOSCROLL_NE
1624cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_SW },      // POINTER_AUTOSCROLL_SW
1625cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_SE },      // POINTER_AUTOSCROLL_SE
1626cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NS },      // POINTER_AUTOSCROLL_NS
1627cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_WE },      // POINTER_AUTOSCROLL_WE
1628cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NSWE },     // POINTER_AUTOSCROLL_NSWE
1629cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_AIRBRUSH },           // POINTER_AIRBRUSH
1630cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TEXT_VERTICAL },      // POINTER_TEXT_VERTICAL
1631cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_PIVOT_DELETE },       // POINTER_PIVOT_DELETE
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir     // --> FME 2004-07-30 #i32329# Enhanced table selection
1634cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TAB_SELECT_S },       // POINTER_TAB_SELECT_S
1635cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TAB_SELECT_E },       // POINTER_TAB_SELECT_E
1636cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TAB_SELECT_SE },      // POINTER_TAB_SELECT_SE
1637cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TAB_SELECT_W },       // POINTER_TAB_SELECT_W
1638cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_TAB_SELECT_SW },      // POINTER_TAB_SELECT_SW
1639cdf0e10cSrcweir     // <--
1640cdf0e10cSrcweir 
1641cdf0e10cSrcweir     // --> FME 2004-08-16 #i20119# Paintbrush tool
1642cdf0e10cSrcweir     { 0, 0, SAL_RESID_POINTER_PAINTBRUSH }          // POINTER_PAINTBRUSH
1643cdf0e10cSrcweir     // <--
1644cdf0e10cSrcweir     };
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir #if POINTER_COUNT != 94
1647cdf0e10cSrcweir #error New Pointer must be defined!
1648cdf0e10cSrcweir #endif
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir 	//debug_printf("Os2SalFrame::SetPointer\n");
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir     // Mousepointer loaded ?
1653cdf0e10cSrcweir     if ( !aImplPtrTab[ePointerStyle].mhPointer )
1654cdf0e10cSrcweir     {
1655cdf0e10cSrcweir         if ( aImplPtrTab[ePointerStyle].mnOwnId )
1656cdf0e10cSrcweir             aImplPtrTab[ePointerStyle].mhPointer = ImplLoadSalCursor( (ULONG)aImplPtrTab[ePointerStyle].mnOwnId );
1657cdf0e10cSrcweir         else
1658cdf0e10cSrcweir             aImplPtrTab[ePointerStyle].mhPointer = WinQuerySysPointer( HWND_DESKTOP, aImplPtrTab[ePointerStyle].mnSysId, FALSE );
1659cdf0e10cSrcweir     }
1660cdf0e10cSrcweir 	if (aImplPtrTab[ePointerStyle].mhPointer == 0) {
1661cdf0e10cSrcweir 		debug_printf( "SetPointer ePointerStyle %d unknown\n", ePointerStyle);
1662cdf0e10cSrcweir 		aImplPtrTab[ePointerStyle].mhPointer = SPTR_ICONERROR;
1663cdf0e10cSrcweir 	}
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir     // Unterscheidet sich der Mauspointer, dann den neuen setzen
1666cdf0e10cSrcweir     if ( mhPointer != aImplPtrTab[ePointerStyle].mhPointer )
1667cdf0e10cSrcweir     {
1668cdf0e10cSrcweir         mhPointer = aImplPtrTab[ePointerStyle].mhPointer;
1669cdf0e10cSrcweir         WinSetPointer( HWND_DESKTOP, mhPointer );
1670cdf0e10cSrcweir     }
1671cdf0e10cSrcweir }
1672cdf0e10cSrcweir 
1673cdf0e10cSrcweir // -----------------------------------------------------------------------
1674cdf0e10cSrcweir 
CaptureMouse(sal_Bool bCapture)1675fc9fd3f1SPedro Giffuni void Os2SalFrame::CaptureMouse( sal_Bool bCapture )
1676cdf0e10cSrcweir {
1677cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
1678cdf0e10cSrcweir 	_bCapture=bCapture;
1679cdf0e10cSrcweir 	debug_printf("Os2SalFrame::CaptureMouse bCapture %d\n", bCapture);
1680cdf0e10cSrcweir #endif
1681cdf0e10cSrcweir     if ( bCapture )
1682cdf0e10cSrcweir         WinSetCapture( HWND_DESKTOP, mhWndClient );
1683cdf0e10cSrcweir     else
1684cdf0e10cSrcweir         WinSetCapture( HWND_DESKTOP, 0 );
1685cdf0e10cSrcweir }
1686cdf0e10cSrcweir 
1687cdf0e10cSrcweir // -----------------------------------------------------------------------
1688cdf0e10cSrcweir 
SetPointerPos(long nX,long nY)1689cdf0e10cSrcweir void Os2SalFrame::SetPointerPos( long nX, long nY )
1690cdf0e10cSrcweir {
1691cdf0e10cSrcweir     POINTL aPt;
1692cdf0e10cSrcweir     aPt.x = nX;
1693cdf0e10cSrcweir     aPt.y = mnHeight - nY - 1;  // convert sal coords to sys
1694cdf0e10cSrcweir     WinMapWindowPoints( mhWndClient, HWND_DESKTOP, &aPt, 1 );
1695cdf0e10cSrcweir     WinSetPointerPos( HWND_DESKTOP, aPt.x, aPt.y );
1696cdf0e10cSrcweir }
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir // -----------------------------------------------------------------------
1699cdf0e10cSrcweir 
Flush()1700cdf0e10cSrcweir void Os2SalFrame::Flush()
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir }
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir // -----------------------------------------------------------------------
1705cdf0e10cSrcweir 
Sync()1706cdf0e10cSrcweir void Os2SalFrame::Sync()
1707cdf0e10cSrcweir {
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir // -----------------------------------------------------------------------
1711cdf0e10cSrcweir 
SetInputContext(SalInputContext * pContext)1712cdf0e10cSrcweir void Os2SalFrame::SetInputContext( SalInputContext* pContext )
1713cdf0e10cSrcweir {
1714cdf0e10cSrcweir #ifdef ENABLE_IME
1715cdf0e10cSrcweir     SalIMEData* pIMEData = GetSalIMEData();
1716cdf0e10cSrcweir     if ( pIMEData )
1717cdf0e10cSrcweir     {
1718cdf0e10cSrcweir         HWND hWnd = mhWndClient;
1719cdf0e10cSrcweir         HIMI hIMI = 0;
1720cdf0e10cSrcweir         pIMEData->mpGetIME( hWnd, &hIMI );
1721cdf0e10cSrcweir         if ( hIMI )
1722cdf0e10cSrcweir         {
1723cdf0e10cSrcweir             ULONG nInputMode;
1724cdf0e10cSrcweir             ULONG nConversionMode;
1725cdf0e10cSrcweir             if ( 0 == pIMEData->mpQueryIMEMode( hIMI, &nInputMode, &nConversionMode ) )
1726cdf0e10cSrcweir             {
1727cdf0e10cSrcweir                 if ( pContext->mnOptions & SAL_INPUTCONTEXT_TEXT )
1728cdf0e10cSrcweir                 {
1729cdf0e10cSrcweir                     nInputMode &= ~IMI_IM_IME_DISABLE;
1730cdf0e10cSrcweir                     if ( pContext->mnOptions & SAL_INPUTCONTEXT_EXTTEXTINPUT_OFF )
1731cdf0e10cSrcweir                         nInputMode &= ~IMI_IM_IME_ON;
1732cdf0e10cSrcweir // !!! Da derzeit ueber das OS2-IME-UI der IME-Mode nicht einschaltbar ist !!!
1733cdf0e10cSrcweir //                    if ( SAL_INPUTCONTEXT_EXTTEXTINPUT_ON )
1734cdf0e10cSrcweir                         nInputMode |= IMI_IM_IME_ON;
1735cdf0e10cSrcweir                 }
1736cdf0e10cSrcweir                 else
1737cdf0e10cSrcweir                     nInputMode |= IMI_IM_IME_DISABLE;
1738cdf0e10cSrcweir                 pIMEData->mpSetIMEMode( hIMI, nInputMode, nConversionMode );
1739cdf0e10cSrcweir             }
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir             pIMEData->mpReleaseIME( hWnd, hIMI );
1742cdf0e10cSrcweir         }
1743cdf0e10cSrcweir     }
1744cdf0e10cSrcweir #endif
1745cdf0e10cSrcweir }
1746cdf0e10cSrcweir 
1747cdf0e10cSrcweir // -----------------------------------------------------------------------
1748cdf0e10cSrcweir #if 0
1749cdf0e10cSrcweir void Os2SalFrame::UpdateExtTextInputArea()
1750cdf0e10cSrcweir {
1751cdf0e10cSrcweir #ifdef ENABLE_IME
1752cdf0e10cSrcweir #endif
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir #endif
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir // -----------------------------------------------------------------------
1757cdf0e10cSrcweir 
EndExtTextInput(USHORT nFlags)1758cdf0e10cSrcweir void Os2SalFrame::EndExtTextInput( USHORT nFlags )
1759cdf0e10cSrcweir {
1760cdf0e10cSrcweir #ifdef ENABLE_IME
1761cdf0e10cSrcweir     SalIMEData* pIMEData = GetSalIMEData();
1762cdf0e10cSrcweir     if ( pIMEData )
1763cdf0e10cSrcweir     {
1764cdf0e10cSrcweir         HWND hWnd = mhWndClient;
1765cdf0e10cSrcweir         HIMI hIMI = 0;
1766cdf0e10cSrcweir         pIMEData->mpGetIME( hWnd, &hIMI );
1767cdf0e10cSrcweir         if ( hIMI )
1768cdf0e10cSrcweir         {
1769cdf0e10cSrcweir             ULONG nIndex;
1770cdf0e10cSrcweir             if ( nFlags & SAL_FRAME_ENDEXTTEXTINPUT_COMPLETE )
1771cdf0e10cSrcweir                 nIndex = CNV_COMPLETE;
1772cdf0e10cSrcweir             else
1773cdf0e10cSrcweir                 nIndex = CNV_CANCEL;
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir             pIMEData->mpRequestIME( hIMI, REQ_CONVERSIONSTRING, nIndex, 0 );
1776cdf0e10cSrcweir             pIMEData->mpReleaseIME( hWnd, hIMI );
1777cdf0e10cSrcweir         }
1778cdf0e10cSrcweir     }
1779cdf0e10cSrcweir #endif
1780cdf0e10cSrcweir }
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir // -----------------------------------------------------------------------
1783cdf0e10cSrcweir 
GetKeyName(USHORT nCode)1784cdf0e10cSrcweir XubString Os2SalFrame::GetKeyName( USHORT nCode )
1785cdf0e10cSrcweir {
1786cdf0e10cSrcweir     if ( eImplKeyboardLanguage == LANGUAGE_DONTKNOW )
1787cdf0e10cSrcweir         eImplKeyboardLanguage = MsLangId::getSystemLanguage();
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir     XubString        aKeyCode;
1790cdf0e10cSrcweir     XubString        aCode;
1791cdf0e10cSrcweir     const sal_Unicode**    pLangTab = ImplGetLangTab( eImplKeyboardLanguage );
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir     if ( nCode & KEY_SHIFT )
1794cdf0e10cSrcweir         aKeyCode = pLangTab[LSTR_KEY_SHIFT];
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir     if ( nCode & KEY_MOD1 )
1797cdf0e10cSrcweir     {
1798cdf0e10cSrcweir         if ( aKeyCode.Len() == 0 )
1799cdf0e10cSrcweir             aKeyCode = pLangTab[LSTR_KEY_CTRL];
1800cdf0e10cSrcweir         else
1801cdf0e10cSrcweir         {
1802cdf0e10cSrcweir             aKeyCode += '+';
1803cdf0e10cSrcweir             aKeyCode += pLangTab[LSTR_KEY_CTRL];
1804cdf0e10cSrcweir         }
1805cdf0e10cSrcweir     }
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir     if ( nCode & KEY_MOD2 )
1808cdf0e10cSrcweir     {
1809cdf0e10cSrcweir         if ( aKeyCode.Len() == 0 )
1810cdf0e10cSrcweir             aKeyCode = pLangTab[LSTR_KEY_ALT];
1811cdf0e10cSrcweir         else
1812cdf0e10cSrcweir         {
1813cdf0e10cSrcweir             aKeyCode += '+';
1814cdf0e10cSrcweir             aKeyCode += pLangTab[LSTR_KEY_ALT];
1815cdf0e10cSrcweir         }
1816cdf0e10cSrcweir     }
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir     USHORT nKeyCode = nCode & 0x0FFF;
1819cdf0e10cSrcweir     if ( (nKeyCode >= KEY_0) && (nKeyCode <= KEY_9) )
1820cdf0e10cSrcweir         aCode = sal::static_int_cast<sal_Char>('0' + (nKeyCode - KEY_0));
1821cdf0e10cSrcweir     else if ( (nKeyCode >= KEY_A) && (nKeyCode <= KEY_Z) )
1822cdf0e10cSrcweir         aCode = sal::static_int_cast<sal_Char>('A' + (nKeyCode - KEY_A));
1823cdf0e10cSrcweir     else if ( (nKeyCode >= KEY_F1) && (nKeyCode <= KEY_F26) )
1824cdf0e10cSrcweir     {
1825cdf0e10cSrcweir 		aCode += 'F';
1826cdf0e10cSrcweir         if ( (nKeyCode >= KEY_F1) && (nKeyCode <= KEY_F9) )
1827cdf0e10cSrcweir         {
1828cdf0e10cSrcweir             aCode += sal::static_int_cast<sal_Char>('1' + (nKeyCode - KEY_F1));
1829cdf0e10cSrcweir         }
1830cdf0e10cSrcweir         else if ( (nKeyCode >= KEY_F10) && (nKeyCode <= KEY_F19) )
1831cdf0e10cSrcweir         {
1832cdf0e10cSrcweir             aCode += '1';
1833cdf0e10cSrcweir             aCode += sal::static_int_cast<sal_Char>('0' + (nKeyCode - KEY_F10));
1834cdf0e10cSrcweir         }
1835cdf0e10cSrcweir         else
1836cdf0e10cSrcweir         {
1837cdf0e10cSrcweir             aCode += '2';
1838cdf0e10cSrcweir             aCode += sal::static_int_cast<sal_Char>('0' + (nKeyCode - KEY_F20));
1839cdf0e10cSrcweir         }
1840cdf0e10cSrcweir     }
1841cdf0e10cSrcweir     else
1842cdf0e10cSrcweir     {
1843cdf0e10cSrcweir 		switch ( nKeyCode )
1844cdf0e10cSrcweir 		{
1845cdf0e10cSrcweir 			case KEY_DOWN:
1846cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_DOWN];
1847cdf0e10cSrcweir 				break;
1848cdf0e10cSrcweir 			case KEY_UP:
1849cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_UP];
1850cdf0e10cSrcweir 				break;
1851cdf0e10cSrcweir 			case KEY_LEFT:
1852cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_LEFT];
1853cdf0e10cSrcweir 				break;
1854cdf0e10cSrcweir 			case KEY_RIGHT:
1855cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_RIGHT];
1856cdf0e10cSrcweir 				break;
1857cdf0e10cSrcweir 			case KEY_HOME:
1858cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_HOME];
1859cdf0e10cSrcweir 				break;
1860cdf0e10cSrcweir 			case KEY_END:
1861cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_END];
1862cdf0e10cSrcweir 				break;
1863cdf0e10cSrcweir 			case KEY_PAGEUP:
1864cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_PAGEUP];
1865cdf0e10cSrcweir 				break;
1866cdf0e10cSrcweir 			case KEY_PAGEDOWN:
1867cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_PAGEDOWN];
1868cdf0e10cSrcweir 				break;
1869cdf0e10cSrcweir 			case KEY_RETURN:
1870cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_RETURN];
1871cdf0e10cSrcweir 				break;
1872cdf0e10cSrcweir 			case KEY_ESCAPE:
1873cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_ESC];
1874cdf0e10cSrcweir 				break;
1875cdf0e10cSrcweir 			case KEY_TAB:
1876cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_TAB];
1877cdf0e10cSrcweir 				break;
1878cdf0e10cSrcweir 			case KEY_BACKSPACE:
1879cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_BACKSPACE];
1880cdf0e10cSrcweir 				break;
1881cdf0e10cSrcweir 			case KEY_SPACE:
1882cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_SPACE];
1883cdf0e10cSrcweir 				break;
1884cdf0e10cSrcweir 			case KEY_INSERT:
1885cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_INSERT];
1886cdf0e10cSrcweir 				break;
1887cdf0e10cSrcweir 			case KEY_DELETE:
1888cdf0e10cSrcweir 				aCode = pLangTab[LSTR_KEY_DELETE];
1889cdf0e10cSrcweir 				break;
1890cdf0e10cSrcweir 
1891cdf0e10cSrcweir 			case KEY_ADD:
1892cdf0e10cSrcweir 				aCode += '+';
1893cdf0e10cSrcweir 				break;
1894cdf0e10cSrcweir 			case KEY_SUBTRACT:
1895cdf0e10cSrcweir 				aCode += '-';
1896cdf0e10cSrcweir 				break;
1897cdf0e10cSrcweir 			case KEY_MULTIPLY:
1898cdf0e10cSrcweir 				aCode += '*';
1899cdf0e10cSrcweir 				break;
1900cdf0e10cSrcweir 			case KEY_DIVIDE:
1901cdf0e10cSrcweir 				aCode += '/';
1902cdf0e10cSrcweir 				break;
1903cdf0e10cSrcweir 			case KEY_POINT:
1904cdf0e10cSrcweir 				aCode += '.';
1905cdf0e10cSrcweir 				break;
1906cdf0e10cSrcweir 			case KEY_COMMA:
1907cdf0e10cSrcweir 				aCode += ',';
1908cdf0e10cSrcweir 				break;
1909cdf0e10cSrcweir 			case KEY_LESS:
1910cdf0e10cSrcweir 				aCode += '<';
1911cdf0e10cSrcweir 				break;
1912cdf0e10cSrcweir 			case KEY_GREATER:
1913cdf0e10cSrcweir 				aCode += '>';
1914cdf0e10cSrcweir 				break;
1915cdf0e10cSrcweir 			case KEY_EQUAL:
1916cdf0e10cSrcweir 				aCode += '=';
1917cdf0e10cSrcweir 				break;
1918cdf0e10cSrcweir 		}
1919cdf0e10cSrcweir 	}
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir     if ( aCode.Len() )
1922cdf0e10cSrcweir     {
1923cdf0e10cSrcweir         if ( aKeyCode.Len() == 0 )
1924cdf0e10cSrcweir             aKeyCode = aCode;
1925cdf0e10cSrcweir         else
1926cdf0e10cSrcweir         {
1927cdf0e10cSrcweir             aKeyCode += '+';
1928cdf0e10cSrcweir             aKeyCode += aCode;
1929cdf0e10cSrcweir         }
1930cdf0e10cSrcweir     }
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir     return aKeyCode;
1933cdf0e10cSrcweir }
1934cdf0e10cSrcweir 
1935cdf0e10cSrcweir // -----------------------------------------------------------------------
1936cdf0e10cSrcweir 
GetSymbolKeyName(const XubString &,USHORT nKeyCode)1937cdf0e10cSrcweir XubString Os2SalFrame::GetSymbolKeyName( const XubString&, USHORT nKeyCode )
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir     return GetKeyName( nKeyCode );
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir 
1942cdf0e10cSrcweir // -----------------------------------------------------------------------
1943cdf0e10cSrcweir 
ImplOS2ColorToSal(long nOS2Color)1944cdf0e10cSrcweir inline long ImplOS2ColorToSal( long nOS2Color )
1945cdf0e10cSrcweir {
1946fc9fd3f1SPedro Giffuni     return MAKE_SALCOLOR( (PM_BYTE)( nOS2Color>>16), (PM_BYTE)(nOS2Color>>8), (PM_BYTE)nOS2Color );
1947cdf0e10cSrcweir }
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir // -----------------------------------------------------------------------
1950cdf0e10cSrcweir 
ImplMouseSysValueToSAL(int iSysValue,USHORT & rCode,USHORT & rClicks,sal_Bool & rDown)1951fc9fd3f1SPedro Giffuni static USHORT ImplMouseSysValueToSAL( int iSysValue, USHORT& rCode, USHORT& rClicks, sal_Bool& rDown )
1952cdf0e10cSrcweir {
1953cdf0e10cSrcweir     LONG lValue = WinQuerySysValue( HWND_DESKTOP, iSysValue );
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir     rCode   = 0;
1956cdf0e10cSrcweir     rClicks = 1;
1957cdf0e10cSrcweir     rDown   = TRUE;
1958cdf0e10cSrcweir 
1959cdf0e10cSrcweir     switch ( lValue & 0xFFFF )
1960cdf0e10cSrcweir     {
1961cdf0e10cSrcweir         case WM_BUTTON1UP:
1962cdf0e10cSrcweir         case WM_BUTTON1CLICK:
1963cdf0e10cSrcweir             rCode = MOUSE_LEFT;
1964cdf0e10cSrcweir             rDown = FALSE;
1965cdf0e10cSrcweir             break;
1966cdf0e10cSrcweir         case WM_BUTTON1DOWN:
1967cdf0e10cSrcweir         case WM_BUTTON1MOTIONSTART:
1968cdf0e10cSrcweir             rCode = MOUSE_LEFT;
1969cdf0e10cSrcweir             break;
1970cdf0e10cSrcweir         case WM_BUTTON1DBLCLK:
1971cdf0e10cSrcweir             rCode = MOUSE_LEFT;
1972cdf0e10cSrcweir             rClicks = 2;
1973cdf0e10cSrcweir             break;
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir         case WM_BUTTON2UP:
1976cdf0e10cSrcweir         case WM_BUTTON2CLICK:
1977cdf0e10cSrcweir             rCode = MOUSE_RIGHT;
1978cdf0e10cSrcweir             rDown = FALSE;
1979cdf0e10cSrcweir             break;
1980cdf0e10cSrcweir         case WM_BUTTON2DOWN:
1981cdf0e10cSrcweir         case WM_BUTTON2MOTIONSTART:
1982cdf0e10cSrcweir             rCode = MOUSE_RIGHT;
1983cdf0e10cSrcweir             break;
1984cdf0e10cSrcweir         case WM_BUTTON2DBLCLK:
1985cdf0e10cSrcweir             rCode = MOUSE_RIGHT;
1986cdf0e10cSrcweir             rClicks = 2;
1987cdf0e10cSrcweir             break;
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir         case WM_BUTTON3UP:
1990cdf0e10cSrcweir         case WM_BUTTON3CLICK:
1991cdf0e10cSrcweir             rCode = MOUSE_MIDDLE;
1992cdf0e10cSrcweir             rDown = FALSE;
1993cdf0e10cSrcweir             break;
1994cdf0e10cSrcweir         case WM_BUTTON3DOWN:
1995cdf0e10cSrcweir         case WM_BUTTON3MOTIONSTART:
1996cdf0e10cSrcweir             rCode = MOUSE_MIDDLE;
1997cdf0e10cSrcweir             break;
1998cdf0e10cSrcweir         case WM_BUTTON3DBLCLK:
1999cdf0e10cSrcweir             rCode = MOUSE_MIDDLE;
2000cdf0e10cSrcweir             rClicks = 2;
2001cdf0e10cSrcweir             break;
2002cdf0e10cSrcweir     }
2003cdf0e10cSrcweir 
2004cdf0e10cSrcweir     if ( !rCode )
2005cdf0e10cSrcweir         return FALSE;
2006cdf0e10cSrcweir 
2007cdf0e10cSrcweir     lValue = (lValue & 0xFFFF0000) >> 16;
2008cdf0e10cSrcweir     if ( lValue != 0xFFFF )
2009cdf0e10cSrcweir     {
2010cdf0e10cSrcweir         if ( lValue & KC_SHIFT )
2011cdf0e10cSrcweir             rCode |= KEY_SHIFT;
2012cdf0e10cSrcweir         if ( lValue & KC_CTRL )
2013cdf0e10cSrcweir             rCode |= KEY_MOD1;
2014cdf0e10cSrcweir         if ( lValue & KC_ALT )
2015cdf0e10cSrcweir             rCode |= KEY_MOD2;
2016cdf0e10cSrcweir     }
2017cdf0e10cSrcweir 
2018cdf0e10cSrcweir     return TRUE;
2019cdf0e10cSrcweir }
2020cdf0e10cSrcweir 
2021cdf0e10cSrcweir // -----------------------------------------------------------------------
2022cdf0e10cSrcweir 
ImplSalIsSameColor(const Color & rColor1,const Color & rColor2)2023fc9fd3f1SPedro Giffuni static sal_Bool ImplSalIsSameColor( const Color& rColor1, const Color& rColor2 )
2024cdf0e10cSrcweir {
2025cdf0e10cSrcweir     ULONG nWrong = 0;
2026cdf0e10cSrcweir     nWrong += Abs( (short)rColor1.GetRed()-(short)rColor2.GetRed() );
2027cdf0e10cSrcweir     nWrong += Abs( (short)rColor1.GetGreen()-(short)rColor2.GetGreen() );
2028cdf0e10cSrcweir     nWrong += Abs( (short)rColor1.GetBlue()-(short)rColor2.GetBlue() );
2029cdf0e10cSrcweir     return (nWrong < 30);
2030cdf0e10cSrcweir }
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir // -----------------------------------------------------------------------
2033cdf0e10cSrcweir 
ImplOS2NameFontToVCLFont(const char * pFontName,Font & rFont)2034fc9fd3f1SPedro Giffuni static sal_Bool ImplOS2NameFontToVCLFont( const char* pFontName, Font& rFont )
2035cdf0e10cSrcweir {
2036cdf0e10cSrcweir     char aNumBuf[10];
2037cdf0e10cSrcweir     int  nNumBufLen = 0;
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir     while ( *pFontName && (*pFontName != '.') &&
2040cdf0e10cSrcweir             (nNumBufLen < sizeof(aNumBuf)-1) )
2041cdf0e10cSrcweir     {
2042cdf0e10cSrcweir         aNumBuf[nNumBufLen] = *pFontName;
2043cdf0e10cSrcweir         nNumBufLen++;
2044cdf0e10cSrcweir         pFontName++;
2045cdf0e10cSrcweir     }
2046cdf0e10cSrcweir     aNumBuf[nNumBufLen] = '\0';
2047cdf0e10cSrcweir 
2048cdf0e10cSrcweir     pFontName++;
2049cdf0e10cSrcweir     while ( *pFontName == ' ' )
2050cdf0e10cSrcweir         pFontName++;
2051cdf0e10cSrcweir 
2052cdf0e10cSrcweir     int nFontHeight = atoi( aNumBuf );
2053cdf0e10cSrcweir     int nFontNameLen = strlen( pFontName );
2054cdf0e10cSrcweir     if ( nFontHeight && nFontNameLen )
2055cdf0e10cSrcweir     {
2056cdf0e10cSrcweir         rFont.SetFamily( FAMILY_DONTKNOW );
2057cdf0e10cSrcweir         rFont.SetWeight( WEIGHT_NORMAL );
2058cdf0e10cSrcweir         rFont.SetItalic( ITALIC_NONE );
2059cdf0e10cSrcweir 		// search for a style embedded in the name, e.g. 'WarpSans Bold'
2060cdf0e10cSrcweir 		// because we need to split the style from the family name
2061cdf0e10cSrcweir 		if (strstr( pFontName, " Bold")
2062cdf0e10cSrcweir 			|| strstr( pFontName, " Italic")
2063cdf0e10cSrcweir 			|| strstr( pFontName, "-Normal"))
2064cdf0e10cSrcweir 		{
2065cdf0e10cSrcweir 			char* fontName = strdup( pFontName);
2066cdf0e10cSrcweir 			char* style = strstr( fontName, " Bold");
2067cdf0e10cSrcweir 			if (style)
2068cdf0e10cSrcweir 				rFont.SetWeight( WEIGHT_BOLD );
2069cdf0e10cSrcweir 
2070cdf0e10cSrcweir 			if (!style)
2071cdf0e10cSrcweir 				style = strstr( fontName, " Italic");
2072cdf0e10cSrcweir 			if (style)
2073cdf0e10cSrcweir 				rFont.SetItalic( ITALIC_NORMAL );
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir 			if (!style)
2076cdf0e10cSrcweir 				style = strstr( fontName, "-Normal");
2077cdf0e10cSrcweir 			// store style, skip whitespace char
2078cdf0e10cSrcweir 			rFont.SetStyleName( ::rtl::OStringToOUString ( style+1, gsl_getSystemTextEncoding()) );
2079cdf0e10cSrcweir 			// truncate name
2080cdf0e10cSrcweir 			*style = 0;
2081cdf0e10cSrcweir 			// store family name
2082cdf0e10cSrcweir 			rFont.SetName( ::rtl::OStringToOUString ( fontName, gsl_getSystemTextEncoding()) );
2083cdf0e10cSrcweir 			free( fontName);
2084cdf0e10cSrcweir 		}
2085cdf0e10cSrcweir 		else
2086cdf0e10cSrcweir 		{
2087cdf0e10cSrcweir 			rFont.SetName( ::rtl::OStringToOUString (pFontName, gsl_getSystemTextEncoding()) );
2088cdf0e10cSrcweir 			rFont.SetStyleName( ::rtl::OStringToOUString ("", gsl_getSystemTextEncoding()) );
2089cdf0e10cSrcweir 		}
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir         rFont.SetSize( Size( 0, nFontHeight ) );
2092cdf0e10cSrcweir         return TRUE;
2093cdf0e10cSrcweir     }
2094cdf0e10cSrcweir     else
2095cdf0e10cSrcweir         return FALSE;
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir // -----------------------------------------------------------------------
2099cdf0e10cSrcweir 
UpdateSettings(AllSettings & rSettings)2100cdf0e10cSrcweir void Os2SalFrame::UpdateSettings( AllSettings& rSettings )
2101cdf0e10cSrcweir {
2102cdf0e10cSrcweir     static char aControlPanel[] = "PM_ControlPanel";
2103cdf0e10cSrcweir     static char aSystemFonts[]  = "PM_SystemFonts";
2104cdf0e10cSrcweir     char aDummyStr[] = "";
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir     // --- Mouse setting ---
2107cdf0e10cSrcweir     USHORT  nCode;
2108cdf0e10cSrcweir     USHORT  nClicks;
2109fc9fd3f1SPedro Giffuni     sal_Bool    bDown;
2110cdf0e10cSrcweir     MouseSettings aMouseSettings = rSettings.GetMouseSettings();
2111cdf0e10cSrcweir     aMouseSettings.SetDoubleClickTime( WinQuerySysValue( HWND_DESKTOP, SV_DBLCLKTIME ) );
2112cdf0e10cSrcweir     if ( ImplMouseSysValueToSAL( SV_BEGINDRAG, nCode, nClicks, bDown ) )
2113cdf0e10cSrcweir         aMouseSettings.SetStartDragCode( nCode );
2114cdf0e10cSrcweir     if ( ImplMouseSysValueToSAL( SV_CONTEXTMENU, nCode, nClicks, bDown ) )
2115cdf0e10cSrcweir     {
2116cdf0e10cSrcweir         aMouseSettings.SetContextMenuCode( nCode );
2117cdf0e10cSrcweir         aMouseSettings.SetContextMenuClicks( nClicks );
2118cdf0e10cSrcweir         aMouseSettings.SetContextMenuDown( bDown );
2119cdf0e10cSrcweir     }
2120cdf0e10cSrcweir     aMouseSettings.SetButtonStartRepeat( WinQuerySysValue( HWND_DESKTOP, SV_FIRSTSCROLLRATE ) );
2121cdf0e10cSrcweir     aMouseSettings.SetButtonRepeat( WinQuerySysValue( HWND_DESKTOP, SV_SCROLLRATE ) );
2122cdf0e10cSrcweir     rSettings.SetMouseSettings( aMouseSettings );
2123cdf0e10cSrcweir 
2124cdf0e10cSrcweir     // --- Style settings ---
2125cdf0e10cSrcweir     StyleSettings aStyleSettings = rSettings.GetStyleSettings();
2126cdf0e10cSrcweir     // General settings
2127cdf0e10cSrcweir     LONG    nDisplayTime = PrfQueryProfileInt( HINI_PROFILE, (PSZ)aControlPanel, (PSZ)"LogoDisplayTime", -1 );
2128cdf0e10cSrcweir     ULONG   nSalDisplayTime;
2129cdf0e10cSrcweir     if ( nDisplayTime < 0 )
2130cdf0e10cSrcweir         nSalDisplayTime = LOGO_DISPLAYTIME_STARTTIME;
2131cdf0e10cSrcweir     else if ( !nDisplayTime )
2132cdf0e10cSrcweir         nSalDisplayTime = LOGO_DISPLAYTIME_NOLOGO;
2133cdf0e10cSrcweir     else
2134cdf0e10cSrcweir         nSalDisplayTime = (ULONG)nDisplayTime;
2135cdf0e10cSrcweir     aStyleSettings.SetLogoDisplayTime( nSalDisplayTime );
2136cdf0e10cSrcweir 
2137cdf0e10cSrcweir     aStyleSettings.SetCursorBlinkTime( WinQuerySysValue( HWND_DESKTOP, SV_CURSORRATE ) );
2138cdf0e10cSrcweir     ULONG nDragFullOptions = aStyleSettings.GetDragFullOptions();
2139cdf0e10cSrcweir     if ( WinQuerySysValue( HWND_DESKTOP, SV_DYNAMICDRAG ) )
2140cdf0e10cSrcweir         nDragFullOptions |= DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE | DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT;
2141cdf0e10cSrcweir     else
2142cdf0e10cSrcweir         nDragFullOptions &= ~(DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE | DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT);
2143cdf0e10cSrcweir     aStyleSettings.SetDragFullOptions( nDragFullOptions );
2144cdf0e10cSrcweir 
2145cdf0e10cSrcweir     // Size settings
2146cdf0e10cSrcweir     aStyleSettings.SetScrollBarSize( WinQuerySysValue( HWND_DESKTOP, SV_CYHSCROLL ) );
2147cdf0e10cSrcweir     aStyleSettings.SetTitleHeight( WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) );
2148cdf0e10cSrcweir 
2149cdf0e10cSrcweir     // Color settings
2150cdf0e10cSrcweir     aStyleSettings.SetFaceColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONMIDDLE, 0 ) ) );
2151cdf0e10cSrcweir     aStyleSettings.SetInactiveTabColor( aStyleSettings.GetFaceColor() );
2152cdf0e10cSrcweir     aStyleSettings.SetLightColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONLIGHT, 0 ) ) );
2153cdf0e10cSrcweir     aStyleSettings.SetLightBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONMIDDLE, 0 ) ) );
2154cdf0e10cSrcweir     aStyleSettings.SetShadowColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONDARK, 0 ) ) );
2155cdf0e10cSrcweir     aStyleSettings.SetDarkShadowColor( Color( COL_BLACK ) );
2156cdf0e10cSrcweir     aStyleSettings.SetDialogColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0 ) ) );
2157cdf0e10cSrcweir     aStyleSettings.SetButtonTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUTEXT, 0 ) ) );
2158cdf0e10cSrcweir     aStyleSettings.SetActiveColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ACTIVETITLE, 0 ) ) );
2159cdf0e10cSrcweir     aStyleSettings.SetActiveTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ACTIVETITLETEXT, 0 ) ) );
2160cdf0e10cSrcweir     aStyleSettings.SetActiveBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ACTIVEBORDER, 0 ) ) );
2161cdf0e10cSrcweir     aStyleSettings.SetDeactiveColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_INACTIVETITLE, 0 ) ) );
2162cdf0e10cSrcweir     aStyleSettings.SetDeactiveTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_INACTIVETITLETEXT, 0 ) ) );
2163cdf0e10cSrcweir     aStyleSettings.SetDeactiveBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_INACTIVEBORDER, 0 ) ) );
2164cdf0e10cSrcweir     aStyleSettings.SetMenuColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENU, 0 ) ) );
2165cdf0e10cSrcweir     aStyleSettings.SetMenuTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUTEXT, 0 ) ) );
2166cdf0e10cSrcweir     aStyleSettings.SetMenuBarTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUTEXT, 0 ) ) );
2167cdf0e10cSrcweir     aStyleSettings.SetDialogTextColor( aStyleSettings.GetButtonTextColor() );
2168cdf0e10cSrcweir     aStyleSettings.SetRadioCheckTextColor( aStyleSettings.GetButtonTextColor() );
2169cdf0e10cSrcweir     aStyleSettings.SetGroupTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_WINDOWSTATICTEXT, 0 ) ) );
2170cdf0e10cSrcweir     aStyleSettings.SetLabelTextColor( aStyleSettings.GetGroupTextColor() );
2171cdf0e10cSrcweir     aStyleSettings.SetInfoTextColor( aStyleSettings.GetGroupTextColor() );
2172cdf0e10cSrcweir     aStyleSettings.SetWindowColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_WINDOW, 0 ) ) );
2173cdf0e10cSrcweir     aStyleSettings.SetActiveTabColor( aStyleSettings.GetWindowColor() );
2174cdf0e10cSrcweir     aStyleSettings.SetWindowTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_WINDOWTEXT, 0 ) ) );
2175cdf0e10cSrcweir     aStyleSettings.SetFieldColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_ENTRYFIELD, 0 ) ) );
2176cdf0e10cSrcweir     aStyleSettings.SetFieldTextColor( aStyleSettings.GetWindowTextColor() );
2177cdf0e10cSrcweir     aStyleSettings.SetDisableColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUDISABLEDTEXT, 0 ) ) );
2178cdf0e10cSrcweir     aStyleSettings.SetHighlightColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_HILITEBACKGROUND, 0 ) ) );
2179cdf0e10cSrcweir     aStyleSettings.SetHighlightTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_HILITEFOREGROUND, 0 ) ) );
2180cdf0e10cSrcweir     Color aMenuHighColor = ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUHILITEBGND, 0 ) );
2181cdf0e10cSrcweir     if ( ImplSalIsSameColor( aMenuHighColor, aStyleSettings.GetMenuColor() ) )
2182cdf0e10cSrcweir     {
2183cdf0e10cSrcweir         aStyleSettings.SetMenuHighlightColor( Color( COL_BLUE ) );
2184cdf0e10cSrcweir         aStyleSettings.SetMenuHighlightTextColor( Color( COL_WHITE ) );
2185cdf0e10cSrcweir     }
2186cdf0e10cSrcweir     else
2187cdf0e10cSrcweir     {
2188cdf0e10cSrcweir         aStyleSettings.SetMenuHighlightColor( aMenuHighColor );
2189cdf0e10cSrcweir         aStyleSettings.SetMenuHighlightTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP, SYSCLR_MENUHILITE, 0 ) ) );
2190cdf0e10cSrcweir     }
2191cdf0e10cSrcweir     // Checked-Color berechnen
2192cdf0e10cSrcweir     Color   aColor1 = aStyleSettings.GetFaceColor();
2193cdf0e10cSrcweir     Color   aColor2 = aStyleSettings.GetLightColor();
2194fc9fd3f1SPedro Giffuni     PM_BYTE    nRed    = (PM_BYTE)(((USHORT)aColor1.GetRed()   + (USHORT)aColor2.GetRed())/2);
2195fc9fd3f1SPedro Giffuni     PM_BYTE    nGreen  = (PM_BYTE)(((USHORT)aColor1.GetGreen() + (USHORT)aColor2.GetGreen())/2);
2196fc9fd3f1SPedro Giffuni     PM_BYTE    nBlue   = (PM_BYTE)(((USHORT)aColor1.GetBlue()  + (USHORT)aColor2.GetBlue())/2);
2197cdf0e10cSrcweir     aStyleSettings.SetCheckedColor( Color( nRed, nGreen, nBlue ) );
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir     // Fonts updaten
2200cdf0e10cSrcweir     Font    aFont;
2201cdf0e10cSrcweir     char    aFontNameBuf[255];
2202cdf0e10cSrcweir     aFont = aStyleSettings.GetMenuFont();
2203cdf0e10cSrcweir     if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"Menus", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 )
2204cdf0e10cSrcweir     {
2205cdf0e10cSrcweir         if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) ) {
2206cdf0e10cSrcweir #if 0
2207cdf0e10cSrcweir 			// Add Workplace Sans if not already listed
2208cdf0e10cSrcweir             if ( aFont.GetName().Search( (sal_Unicode*)L"WorkPlace Sans" ) == STRING_NOTFOUND )
2209cdf0e10cSrcweir             {
2210cdf0e10cSrcweir                 XubString aFontName = aFont.GetName();
2211cdf0e10cSrcweir                 aFontName.Insert( (sal_Unicode*)L"WorkPlace Sans;", 0 );
2212cdf0e10cSrcweir                 aFont.SetName( aFontName );
2213cdf0e10cSrcweir                 aFont.SetSize( Size( 0, 9 ) );
2214cdf0e10cSrcweir             }
2215cdf0e10cSrcweir #endif
2216cdf0e10cSrcweir             aStyleSettings.SetMenuFont( aFont );
2217cdf0e10cSrcweir 		}
2218cdf0e10cSrcweir     }
2219cdf0e10cSrcweir     aFont = aStyleSettings.GetIconFont();
2220cdf0e10cSrcweir     if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"IconText", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 )
2221cdf0e10cSrcweir     {
2222cdf0e10cSrcweir         if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) )
2223cdf0e10cSrcweir             aStyleSettings.SetIconFont( aFont );
2224cdf0e10cSrcweir     }
2225cdf0e10cSrcweir     aFont = aStyleSettings.GetTitleFont();
2226cdf0e10cSrcweir     if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"WindowTitles", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 )
2227cdf0e10cSrcweir     {
2228cdf0e10cSrcweir         if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) )
2229cdf0e10cSrcweir         {
2230cdf0e10cSrcweir             // Add Workplace Sans if not already listed
2231cdf0e10cSrcweir             if ( aFont.GetName().Search( (sal_Unicode*)L"WorkPlace Sans" ) == STRING_NOTFOUND )
2232cdf0e10cSrcweir             {
2233cdf0e10cSrcweir                 XubString aFontName = aFont.GetName();
2234cdf0e10cSrcweir                 aFontName.Insert( (sal_Unicode*)L"WorkPlace Sans;", 0 );
2235cdf0e10cSrcweir                 aFont.SetName( aFontName );
2236cdf0e10cSrcweir                 aFont.SetSize( Size( 0, 9 ) );
2237cdf0e10cSrcweir 				aFont.SetWeight( WEIGHT_BOLD );
2238cdf0e10cSrcweir 				aFont.SetItalic( ITALIC_NONE );
2239cdf0e10cSrcweir             }
2240cdf0e10cSrcweir             aStyleSettings.SetTitleFont( aFont );
2241cdf0e10cSrcweir             aStyleSettings.SetFloatTitleFont( aFont );
2242cdf0e10cSrcweir         }
2243cdf0e10cSrcweir     }
2244cdf0e10cSrcweir     aFont = aStyleSettings.GetAppFont();
2245cdf0e10cSrcweir     if ( PrfQueryProfileString( HINI_PROFILE, (PSZ)aSystemFonts, (PSZ)"WindowText", aDummyStr, aFontNameBuf, sizeof( aFontNameBuf ) ) > 5 )
2246cdf0e10cSrcweir     {
2247cdf0e10cSrcweir         if ( ImplOS2NameFontToVCLFont( aFontNameBuf, aFont ) )
2248cdf0e10cSrcweir         {
2249cdf0e10cSrcweir             Font aHelpFont = aFont;
2250cdf0e10cSrcweir             aHelpFont.SetName( (sal_Unicode*)L"Helv;WarpSans" );
2251cdf0e10cSrcweir             aHelpFont.SetSize( Size( 0, 8 ) );
2252cdf0e10cSrcweir             aHelpFont.SetWeight( WEIGHT_NORMAL );
2253cdf0e10cSrcweir             aHelpFont.SetItalic( ITALIC_NONE );
2254cdf0e10cSrcweir             aStyleSettings.SetHelpFont( aHelpFont );
2255cdf0e10cSrcweir 
2256cdf0e10cSrcweir             // Add Workplace Sans if not already listed
2257cdf0e10cSrcweir             if ( aFont.GetName().Search( (sal_Unicode*)L"WorkPlace Sans" ) == STRING_NOTFOUND )
2258cdf0e10cSrcweir             {
2259cdf0e10cSrcweir                 XubString aFontName = aFont.GetName();
2260cdf0e10cSrcweir                 aFontName.Insert( (sal_Unicode*)L"WorkPlace Sans;", 0 );
2261cdf0e10cSrcweir                 aFont.SetName( aFontName );
2262cdf0e10cSrcweir                 aFont.SetSize( Size( 0, 9 ) );
2263cdf0e10cSrcweir             }
2264cdf0e10cSrcweir             aStyleSettings.SetAppFont( aFont );
2265cdf0e10cSrcweir             aStyleSettings.SetToolFont( aFont );
2266cdf0e10cSrcweir             aStyleSettings.SetLabelFont( aFont );
2267cdf0e10cSrcweir             aStyleSettings.SetInfoFont( aFont );
2268cdf0e10cSrcweir             aStyleSettings.SetRadioCheckFont( aFont );
2269cdf0e10cSrcweir             aStyleSettings.SetPushButtonFont( aFont );
2270cdf0e10cSrcweir             aStyleSettings.SetFieldFont( aFont );
2271cdf0e10cSrcweir             aStyleSettings.SetGroupFont( aFont );
2272cdf0e10cSrcweir         }
2273cdf0e10cSrcweir     }
2274cdf0e10cSrcweir 
2275cdf0e10cSrcweir     rSettings.SetStyleSettings( aStyleSettings );
2276cdf0e10cSrcweir }
2277cdf0e10cSrcweir 
2278cdf0e10cSrcweir // -----------------------------------------------------------------------
2279cdf0e10cSrcweir 
SnapShot()2280cdf0e10cSrcweir SalBitmap* Os2SalFrame::SnapShot()
2281cdf0e10cSrcweir {
2282cdf0e10cSrcweir debug_printf("Os2SalFrame::SnapShot\n");
2283cdf0e10cSrcweir return NULL;
2284cdf0e10cSrcweir }
2285cdf0e10cSrcweir 
2286cdf0e10cSrcweir // -----------------------------------------------------------------------
2287cdf0e10cSrcweir 
GetSystemData() const2288cdf0e10cSrcweir const SystemEnvData* Os2SalFrame::GetSystemData() const
2289cdf0e10cSrcweir {
2290cdf0e10cSrcweir     return &maSysData;
2291cdf0e10cSrcweir }
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir // -----------------------------------------------------------------------
2294cdf0e10cSrcweir 
Beep(SoundType eSoundType)2295cdf0e10cSrcweir void Os2SalFrame::Beep( SoundType eSoundType )
2296cdf0e10cSrcweir {
2297cdf0e10cSrcweir     static ULONG aImplSoundTab[5] =
2298cdf0e10cSrcweir     {
2299cdf0e10cSrcweir         WA_NOTE,                        // SOUND_DEFAULT
2300cdf0e10cSrcweir         WA_NOTE,                        // SOUND_INFO
2301cdf0e10cSrcweir         WA_WARNING,                     // SOUND_WARNING
2302cdf0e10cSrcweir         WA_ERROR,                       // SOUND_ERROR
2303cdf0e10cSrcweir         WA_NOTE                         // SOUND_QUERY
2304cdf0e10cSrcweir     };
2305cdf0e10cSrcweir 
2306cdf0e10cSrcweir #if 0
2307cdf0e10cSrcweir #if SOUND_COUNT != 5
2308cdf0e10cSrcweir #error New Sound must be defined!
2309cdf0e10cSrcweir #endif
2310cdf0e10cSrcweir #endif
2311cdf0e10cSrcweir 
2312cdf0e10cSrcweir 	debug_printf("Os2SalFrame::Beep %d\n", eSoundType);
2313cdf0e10cSrcweir     WinAlarm( HWND_DESKTOP, aImplSoundTab[eSoundType] );
2314cdf0e10cSrcweir }
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir // -----------------------------------------------------------------------
2317cdf0e10cSrcweir 
GetPointerState()2318cdf0e10cSrcweir SalFrame::SalPointerState Os2SalFrame::GetPointerState()
2319cdf0e10cSrcweir {
2320cdf0e10cSrcweir     SalPointerState aState;
2321cdf0e10cSrcweir     aState.mnState = 0;
2322cdf0e10cSrcweir 
2323cdf0e10cSrcweir     // MausModus feststellen und setzen
2324cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON1 ) & 0x8000 )
2325cdf0e10cSrcweir         aState.mnState |= MOUSE_LEFT;
2326cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON2 ) & 0x8000 )
2327cdf0e10cSrcweir         aState.mnState |= MOUSE_RIGHT;
2328cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON3 ) & 0x8000 )
2329cdf0e10cSrcweir         aState.mnState |= MOUSE_MIDDLE;
2330cdf0e10cSrcweir     // Modifier-Tasten setzen
2331cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_SHIFT ) & 0x8000 )
2332cdf0e10cSrcweir         aState.mnState |= KEY_SHIFT;
2333cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 )
2334cdf0e10cSrcweir         aState.mnState |= KEY_MOD1;
2335cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_ALT ) & 0x8000 )
2336cdf0e10cSrcweir         aState.mnState |= KEY_MOD2;
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir     POINTL pt;
2339cdf0e10cSrcweir     _WinQueryPointerPos( HWND_DESKTOP, &pt );
2340cdf0e10cSrcweir 
2341cdf0e10cSrcweir     aState.maPos = Point( pt.x - maGeometry.nX, pt.y - maGeometry.nY );
2342cdf0e10cSrcweir     return aState;
2343cdf0e10cSrcweir }
2344cdf0e10cSrcweir 
2345cdf0e10cSrcweir // -----------------------------------------------------------------------
2346cdf0e10cSrcweir 
SetBackgroundBitmap(SalBitmap *)2347cdf0e10cSrcweir void Os2SalFrame::SetBackgroundBitmap( SalBitmap* )
2348cdf0e10cSrcweir {
2349cdf0e10cSrcweir }
2350cdf0e10cSrcweir 
2351cdf0e10cSrcweir // -----------------------------------------------------------------------
2352cdf0e10cSrcweir 
SalTestMouseLeave()2353cdf0e10cSrcweir void SalTestMouseLeave()
2354cdf0e10cSrcweir {
2355cdf0e10cSrcweir     SalData* pSalData = GetSalData();
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir     if ( pSalData->mhWantLeaveMsg && !::WinQueryCapture( HWND_DESKTOP ) )
2358cdf0e10cSrcweir     {
2359cdf0e10cSrcweir         POINTL aPt;
2360cdf0e10cSrcweir         WinQueryPointerPos( HWND_DESKTOP, &aPt );
2361cdf0e10cSrcweir         if ( pSalData->mhWantLeaveMsg != WinWindowFromPoint( HWND_DESKTOP, &aPt, TRUE ) )
2362cdf0e10cSrcweir             WinSendMsg( pSalData->mhWantLeaveMsg, SAL_MSG_MOUSELEAVE, 0, MPFROM2SHORT( aPt.x, aPt.y ) );
2363cdf0e10cSrcweir     }
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir // -----------------------------------------------------------------------
2367cdf0e10cSrcweir 
ImplHandleMouseMsg(HWND hWnd,UINT nMsg,MPARAM nMP1,MPARAM nMP2)2368cdf0e10cSrcweir static long ImplHandleMouseMsg( HWND hWnd,
2369cdf0e10cSrcweir                                 UINT nMsg, MPARAM nMP1, MPARAM nMP2 )
2370cdf0e10cSrcweir {
2371cdf0e10cSrcweir     SalMouseEvent   aMouseEvt;
2372cdf0e10cSrcweir     long            nRet;
2373cdf0e10cSrcweir     USHORT          nEvent;
2374fc9fd3f1SPedro Giffuni     sal_Bool            bCall = TRUE;
2375cdf0e10cSrcweir     USHORT          nFlags = SHORT2FROMMP( nMP2 );
2376cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
2377cdf0e10cSrcweir     if ( !pFrame )
2378cdf0e10cSrcweir         return 0;
2379cdf0e10cSrcweir 
2380cdf0e10cSrcweir     aMouseEvt.mnX       = (short)SHORT1FROMMP( nMP1 );
2381cdf0e10cSrcweir     aMouseEvt.mnY       = pFrame->mnHeight - (short)SHORT2FROMMP( nMP1 ) - 1;
2382cdf0e10cSrcweir     aMouseEvt.mnCode    = 0;
2383cdf0e10cSrcweir     aMouseEvt.mnTime    = WinQueryMsgTime( pFrame->mhAB );
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir     // MausModus feststellen und setzen
2386cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON1 ) & 0x8000 )
2387cdf0e10cSrcweir         aMouseEvt.mnCode |= MOUSE_LEFT;
2388cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON2 ) & 0x8000 )
2389cdf0e10cSrcweir         aMouseEvt.mnCode |= MOUSE_RIGHT;
2390cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON3 ) & 0x8000 )
2391cdf0e10cSrcweir         aMouseEvt.mnCode |= MOUSE_MIDDLE;
2392cdf0e10cSrcweir     // Modifier-Tasten setzen
2393cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_SHIFT ) & 0x8000 )
2394cdf0e10cSrcweir         aMouseEvt.mnCode |= KEY_SHIFT;
2395cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 )
2396cdf0e10cSrcweir         aMouseEvt.mnCode |= KEY_MOD1;
2397cdf0e10cSrcweir     if ( WinGetKeyState( HWND_DESKTOP, VK_ALT ) & 0x8000 )
2398cdf0e10cSrcweir         aMouseEvt.mnCode |= KEY_MOD2;
2399cdf0e10cSrcweir 
2400cdf0e10cSrcweir     switch ( nMsg )
2401cdf0e10cSrcweir     {
2402cdf0e10cSrcweir         case WM_MOUSEMOVE:
2403cdf0e10cSrcweir             {
2404cdf0e10cSrcweir             SalData* pSalData = GetSalData();
2405cdf0e10cSrcweir 
2406cdf0e10cSrcweir             // Da bei Druecken von Modifier-Tasten die MouseEvents
2407cdf0e10cSrcweir             // nicht zusammengefast werden (da diese durch KeyEvents
2408cdf0e10cSrcweir             // unterbrochen werden), machen wir dieses hier selber
2409cdf0e10cSrcweir             if ( aMouseEvt.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2) )
2410cdf0e10cSrcweir             {
2411cdf0e10cSrcweir                 QMSG aTempMsg;
2412cdf0e10cSrcweir                 if ( WinPeekMsg( pSalData->mhAB, &aTempMsg,
2413cdf0e10cSrcweir                                  pFrame->mhWndClient,
2414cdf0e10cSrcweir                                  WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE ) )
2415cdf0e10cSrcweir                 {
2416cdf0e10cSrcweir                     if ( (aTempMsg.msg == WM_MOUSEMOVE) &&
2417cdf0e10cSrcweir                          (aTempMsg.mp2 == nMP2) )
2418cdf0e10cSrcweir                         return 1;
2419cdf0e10cSrcweir                 }
2420cdf0e10cSrcweir             }
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir             // Test for MouseLeave
2423cdf0e10cSrcweir             if ( pSalData->mhWantLeaveMsg &&
2424cdf0e10cSrcweir                 (pSalData->mhWantLeaveMsg != pFrame->mhWndClient) )
2425cdf0e10cSrcweir             {
2426cdf0e10cSrcweir                 POINTL aMousePoint;
2427cdf0e10cSrcweir                 WinQueryMsgPos( pFrame->mhAB, &aMousePoint );
2428cdf0e10cSrcweir                 WinSendMsg( pSalData->mhWantLeaveMsg,
2429cdf0e10cSrcweir                             SAL_MSG_MOUSELEAVE,
2430cdf0e10cSrcweir                             0, MPFROM2SHORT( aMousePoint.x, aMousePoint.y ) );
2431cdf0e10cSrcweir             }
2432cdf0e10cSrcweir             pSalData->mhWantLeaveMsg = pFrame->mhWndClient;
2433cdf0e10cSrcweir             // Start MouseLeave-Timer
2434cdf0e10cSrcweir             if ( !pSalData->mpMouseLeaveTimer )
2435cdf0e10cSrcweir             {
2436cdf0e10cSrcweir                 pSalData->mpMouseLeaveTimer = new AutoTimer;
2437cdf0e10cSrcweir                 pSalData->mpMouseLeaveTimer->SetTimeout( SAL_MOUSELEAVE_TIMEOUT );
2438cdf0e10cSrcweir                 pSalData->mpMouseLeaveTimer->Start();
2439cdf0e10cSrcweir                 // We dont need to set a timeout handler, because we test
2440cdf0e10cSrcweir                 // for mouseleave in the timeout callback
2441cdf0e10cSrcweir             }
2442cdf0e10cSrcweir             aMouseEvt.mnButton = 0;
2443cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEMOVE;
2444cdf0e10cSrcweir             }
2445cdf0e10cSrcweir             break;
2446cdf0e10cSrcweir 
2447cdf0e10cSrcweir         case SAL_MSG_MOUSELEAVE:
2448cdf0e10cSrcweir             {
2449cdf0e10cSrcweir             SalData* pSalData = GetSalData();
2450cdf0e10cSrcweir             if ( pSalData->mhWantLeaveMsg == pFrame->mhWndClient )
2451cdf0e10cSrcweir             {
2452cdf0e10cSrcweir                 pSalData->mhWantLeaveMsg = 0;
2453cdf0e10cSrcweir                 if ( pSalData->mpMouseLeaveTimer )
2454cdf0e10cSrcweir                 {
2455cdf0e10cSrcweir                     delete pSalData->mpMouseLeaveTimer;
2456cdf0e10cSrcweir                     pSalData->mpMouseLeaveTimer = NULL;
2457cdf0e10cSrcweir                 }
2458cdf0e10cSrcweir 
2459cdf0e10cSrcweir                 // Mouse-Coordinaates are relativ to the screen
2460cdf0e10cSrcweir                 POINTL aPt;
2461cdf0e10cSrcweir                 aPt.x = (short)SHORT1FROMMP( nMP2 );
2462cdf0e10cSrcweir                 aPt.y = (short)SHORT2FROMMP( nMP2 );
2463cdf0e10cSrcweir                 WinMapWindowPoints( HWND_DESKTOP, pFrame->mhWndClient, &aPt, 1 );
2464cdf0e10cSrcweir                 aPt.y = pFrame->mnHeight - aPt.y - 1;
2465cdf0e10cSrcweir                 aMouseEvt.mnX = aPt.x;
2466cdf0e10cSrcweir                 aMouseEvt.mnY = aPt.y;
2467cdf0e10cSrcweir                 aMouseEvt.mnButton = 0;
2468cdf0e10cSrcweir                 nEvent = SALEVENT_MOUSELEAVE;
2469cdf0e10cSrcweir             }
2470cdf0e10cSrcweir             else
2471cdf0e10cSrcweir                 bCall = FALSE;
2472cdf0e10cSrcweir             }
2473cdf0e10cSrcweir             break;
2474cdf0e10cSrcweir 
2475cdf0e10cSrcweir         case WM_BUTTON1DBLCLK:
2476cdf0e10cSrcweir         case WM_BUTTON1DOWN:
2477cdf0e10cSrcweir             aMouseEvt.mnButton = MOUSE_LEFT;
2478cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEBUTTONDOWN;
2479cdf0e10cSrcweir             break;
2480cdf0e10cSrcweir 
2481cdf0e10cSrcweir         case WM_BUTTON2DBLCLK:
2482cdf0e10cSrcweir         case WM_BUTTON2DOWN:
2483cdf0e10cSrcweir             aMouseEvt.mnButton = MOUSE_RIGHT;
2484cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEBUTTONDOWN;
2485cdf0e10cSrcweir             break;
2486cdf0e10cSrcweir 
2487cdf0e10cSrcweir         case WM_BUTTON3DBLCLK:
2488cdf0e10cSrcweir         case WM_BUTTON3DOWN:
2489cdf0e10cSrcweir             aMouseEvt.mnButton = MOUSE_MIDDLE;
2490cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEBUTTONDOWN;
2491cdf0e10cSrcweir             break;
2492cdf0e10cSrcweir 
2493cdf0e10cSrcweir         case WM_BUTTON1UP:
2494cdf0e10cSrcweir             aMouseEvt.mnButton = MOUSE_LEFT;
2495cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEBUTTONUP;
2496cdf0e10cSrcweir             break;
2497cdf0e10cSrcweir 
2498cdf0e10cSrcweir         case WM_BUTTON2UP:
2499cdf0e10cSrcweir             aMouseEvt.mnButton = MOUSE_RIGHT;
2500cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEBUTTONUP;
2501cdf0e10cSrcweir             break;
2502cdf0e10cSrcweir 
2503cdf0e10cSrcweir         case WM_BUTTON3UP:
2504cdf0e10cSrcweir             aMouseEvt.mnButton = MOUSE_MIDDLE;
2505cdf0e10cSrcweir             nEvent = SALEVENT_MOUSEBUTTONUP;
2506cdf0e10cSrcweir             break;
2507cdf0e10cSrcweir     }
2508cdf0e10cSrcweir 
2509cdf0e10cSrcweir 	// check if this window was destroyed - this might happen if we are the help window
2510cdf0e10cSrcweir 	// and sent a mouse leave message to the application which killed the help window, ie ourself
2511cdf0e10cSrcweir 	if( !WinIsWindow( pFrame->mhAB, hWnd ) )
2512cdf0e10cSrcweir 		return 0;
2513cdf0e10cSrcweir 
2514cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2515cdf0e10cSrcweir 	//if (_bCapture)
2516cdf0e10cSrcweir 		debug_printf("ImplHandleMouseMsg mouse %d,%d\n",aMouseEvt.mnX,aMouseEvt.mnY);
2517cdf0e10cSrcweir #endif
2518cdf0e10cSrcweir 
2519cdf0e10cSrcweir     if ( bCall )
2520cdf0e10cSrcweir     {
2521cdf0e10cSrcweir         if ( nEvent == SALEVENT_MOUSEBUTTONDOWN )
2522cdf0e10cSrcweir             WinUpdateWindow( pFrame->mhWndClient );
2523cdf0e10cSrcweir 
2524cdf0e10cSrcweir         // --- RTL --- (mirror mouse pos)
2525cdf0e10cSrcweir         //if( Application::GetSettings().GetLayoutRTL() )
2526cdf0e10cSrcweir         //    aMouseEvt.mnX = pFrame->maGeometry.nWidth-1-aMouseEvt.mnX;
2527cdf0e10cSrcweir 
2528cdf0e10cSrcweir         nRet = pFrame->CallCallback( nEvent, &aMouseEvt );
2529cdf0e10cSrcweir         if ( nMsg == WM_MOUSEMOVE )
2530cdf0e10cSrcweir         {
2531cdf0e10cSrcweir             WinSetPointer( HWND_DESKTOP, pFrame->mhPointer );
2532cdf0e10cSrcweir             nRet = TRUE;
2533cdf0e10cSrcweir         }
2534cdf0e10cSrcweir     }
2535cdf0e10cSrcweir     else
2536cdf0e10cSrcweir         nRet = 0;
2537cdf0e10cSrcweir 
2538cdf0e10cSrcweir     return nRet;
2539cdf0e10cSrcweir }
2540cdf0e10cSrcweir 
2541cdf0e10cSrcweir // -----------------------------------------------------------------------
2542cdf0e10cSrcweir 
ImplHandleWheelMsg(HWND hWnd,UINT nMsg,MPARAM nMP1,MPARAM nMP2)2543cdf0e10cSrcweir static long ImplHandleWheelMsg( HWND hWnd, UINT nMsg, MPARAM nMP1, MPARAM nMP2 )
2544cdf0e10cSrcweir {
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir     ImplSalYieldMutexAcquireWithWait();
2547cdf0e10cSrcweir 
2548cdf0e10cSrcweir     long        nRet = 0;
2549cdf0e10cSrcweir     Os2SalFrame*   pFrame = GetWindowPtr( hWnd );
2550cdf0e10cSrcweir     if ( pFrame )
2551cdf0e10cSrcweir     {
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir 		// Mouse-Coordinaates are relativ to the screen
2554cdf0e10cSrcweir 		POINTL aPt;
2555cdf0e10cSrcweir 		WinQueryMsgPos( pFrame->mhAB, &aPt );
2556cdf0e10cSrcweir 		WinMapWindowPoints( HWND_DESKTOP, pFrame->mhWndClient, &aPt, 1 );
2557cdf0e10cSrcweir 		aPt.y = pFrame->mnHeight - aPt.y - 1;
2558cdf0e10cSrcweir 
2559cdf0e10cSrcweir         SalWheelMouseEvent aWheelEvt;
2560cdf0e10cSrcweir 		aWheelEvt.mnTime    		= WinQueryMsgTime( pFrame->mhAB );
2561cdf0e10cSrcweir         aWheelEvt.mnX           	= aPt.x;
2562cdf0e10cSrcweir         aWheelEvt.mnY           	= aPt.y;
2563cdf0e10cSrcweir         aWheelEvt.mnCode       	 	= 0;
2564cdf0e10cSrcweir 		bool bNeg = (SHORT2FROMMP(nMP2) == SB_LINEDOWN || SHORT2FROMMP(nMP2) == SB_PAGEDOWN );
2565cdf0e10cSrcweir 		aWheelEvt.mnDelta			= bNeg ? -120 : 120;
2566cdf0e10cSrcweir 		aWheelEvt.mnNotchDelta		= bNeg ? -1 : 1;
2567cdf0e10cSrcweir 		if (SHORT2FROMMP(nMP2) == SB_PAGEUP || SHORT2FROMMP(nMP2) == SB_PAGEDOWN)
2568cdf0e10cSrcweir 			aWheelEvt.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL;
2569cdf0e10cSrcweir 		else
2570cdf0e10cSrcweir 			aWheelEvt.mnScrollLines = 1;
2571cdf0e10cSrcweir 
2572cdf0e10cSrcweir         if( nMsg == WM_HSCROLL )
2573cdf0e10cSrcweir             aWheelEvt.mbHorz        = TRUE;
2574cdf0e10cSrcweir 
2575cdf0e10cSrcweir 		// Modifier-Tasten setzen
2576cdf0e10cSrcweir 		if ( WinGetKeyState( HWND_DESKTOP, VK_SHIFT ) & 0x8000 )
2577cdf0e10cSrcweir 			aWheelEvt.mnCode |= KEY_SHIFT;
2578cdf0e10cSrcweir 		if ( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 )
2579cdf0e10cSrcweir 			aWheelEvt.mnCode |= KEY_MOD1;
2580cdf0e10cSrcweir 		if ( WinGetKeyState( HWND_DESKTOP, VK_ALT ) & 0x8000 )
2581cdf0e10cSrcweir 			aWheelEvt.mnCode |= KEY_MOD2;
2582cdf0e10cSrcweir 
2583cdf0e10cSrcweir         nRet = pFrame->CallCallback( SALEVENT_WHEELMOUSE, &aWheelEvt );
2584cdf0e10cSrcweir     }
2585cdf0e10cSrcweir 
2586cdf0e10cSrcweir     ImplSalYieldMutexRelease();
2587cdf0e10cSrcweir 
2588cdf0e10cSrcweir     return nRet;
2589cdf0e10cSrcweir }
2590cdf0e10cSrcweir 
2591cdf0e10cSrcweir 
2592cdf0e10cSrcweir // -----------------------------------------------------------------------
2593cdf0e10cSrcweir 
ImplSalGetKeyCode(Os2SalFrame * pFrame,MPARAM aMP1,MPARAM aMP2)2594cdf0e10cSrcweir static USHORT ImplSalGetKeyCode( Os2SalFrame* pFrame, MPARAM aMP1, MPARAM aMP2 )
2595cdf0e10cSrcweir {
2596cdf0e10cSrcweir     USHORT  nKeyFlags   = SHORT1FROMMP( aMP1 );
2597cdf0e10cSrcweir     UCHAR   nCharCode   = (UCHAR)SHORT1FROMMP( aMP2 );
2598cdf0e10cSrcweir     USHORT  nKeyCode    = (UCHAR)SHORT2FROMMP( aMP2 );
2599cdf0e10cSrcweir     UCHAR   nScanCode   = (UCHAR)CHAR4FROMMP( aMP1 );
2600cdf0e10cSrcweir 	USHORT	rSVCode = 0;
2601cdf0e10cSrcweir 
2602cdf0e10cSrcweir     // Ist virtueller KeyCode gesetzt und befindet sich der KeyCode in der
2603cdf0e10cSrcweir     // Tabelle, dann mappen
2604cdf0e10cSrcweir     if ( (nKeyFlags & KC_VIRTUALKEY) && (nKeyCode < KEY_TAB_SIZE) )
2605cdf0e10cSrcweir         rSVCode = aImplTranslateKeyTab[nKeyCode];
2606cdf0e10cSrcweir 
2607cdf0e10cSrcweir     // Wenn kein KeyCode ermittelt werden konnte, versuchen wir aus dem
2608cdf0e10cSrcweir     // CharCode einen zu erzeugen
2609cdf0e10cSrcweir     if ( !rSVCode && nCharCode )
2610cdf0e10cSrcweir     {
2611cdf0e10cSrcweir         // Bei 0-9, a-z und A-Z auch KeyCode setzen
2612cdf0e10cSrcweir         if ( (nCharCode >= '0') && (nCharCode <= '9') && (!rSVCode || !(nKeyFlags & KC_SHIFT)) )
2613cdf0e10cSrcweir             rSVCode = KEYGROUP_NUM + (nCharCode-'0');
2614cdf0e10cSrcweir         else if ( (nCharCode >= 'a') && (nCharCode <= 'z') )
2615cdf0e10cSrcweir             rSVCode = KEYGROUP_ALPHA + (nCharCode-'a');
2616cdf0e10cSrcweir         else if ( (nCharCode >= 'A') && (nCharCode <= 'Z') )
2617cdf0e10cSrcweir             rSVCode = KEYGROUP_ALPHA + (nCharCode-'A');
2618cdf0e10cSrcweir         else
2619cdf0e10cSrcweir         {
2620cdf0e10cSrcweir             switch ( nCharCode )
2621cdf0e10cSrcweir             {
2622cdf0e10cSrcweir                 case '+':
2623cdf0e10cSrcweir                     rSVCode = KEY_ADD;
2624cdf0e10cSrcweir                     break;
2625cdf0e10cSrcweir                 case '-':
2626cdf0e10cSrcweir                     rSVCode = KEY_SUBTRACT;
2627cdf0e10cSrcweir                     break;
2628cdf0e10cSrcweir                 case '*':
2629cdf0e10cSrcweir                     rSVCode = KEY_MULTIPLY;
2630cdf0e10cSrcweir                     break;
2631cdf0e10cSrcweir                 case '/':
2632cdf0e10cSrcweir                     rSVCode = KEY_DIVIDE;
2633cdf0e10cSrcweir                     break;
2634cdf0e10cSrcweir                 case '.':
2635cdf0e10cSrcweir                     rSVCode = KEY_POINT;
2636cdf0e10cSrcweir                     break;
2637cdf0e10cSrcweir                 case ',':
2638cdf0e10cSrcweir                     rSVCode = KEY_COMMA;
2639cdf0e10cSrcweir                     break;
2640cdf0e10cSrcweir                 case '<':
2641cdf0e10cSrcweir                     rSVCode = KEY_LESS;
2642cdf0e10cSrcweir                     break;
2643cdf0e10cSrcweir                 case '>':
2644cdf0e10cSrcweir                     rSVCode = KEY_GREATER;
2645cdf0e10cSrcweir                     break;
2646cdf0e10cSrcweir                 case '=':
2647cdf0e10cSrcweir                     rSVCode = KEY_EQUAL;
2648cdf0e10cSrcweir                     break;
2649cdf0e10cSrcweir             }
2650cdf0e10cSrcweir         }
2651cdf0e10cSrcweir     }
2652cdf0e10cSrcweir 
2653cdf0e10cSrcweir     // "Numlock-Hack": we want to get correct keycodes from the numpad
2654cdf0e10cSrcweir     if ( (nCharCode >= '0') && (nCharCode <= '9') && !(nKeyFlags & KC_SHIFT) )
2655cdf0e10cSrcweir         rSVCode = KEYGROUP_NUM + (nCharCode-'0');
2656cdf0e10cSrcweir     if ( nCharCode == ',' )
2657cdf0e10cSrcweir         rSVCode = KEY_COMMA;
2658cdf0e10cSrcweir     if ( nCharCode == '.' )
2659cdf0e10cSrcweir         rSVCode = KEY_POINT;
2660cdf0e10cSrcweir 
2661cdf0e10cSrcweir     return rSVCode;
2662cdf0e10cSrcweir }
2663cdf0e10cSrcweir 
2664cdf0e10cSrcweir // -----------------------------------------------------------------------
2665cdf0e10cSrcweir 
ImplUpdateInputLang(Os2SalFrame * pFrame)2666cdf0e10cSrcweir static void ImplUpdateInputLang( Os2SalFrame* pFrame )
2667cdf0e10cSrcweir {
2668fc9fd3f1SPedro Giffuni     sal_Bool 	bLanguageChange = FALSE;
2669cdf0e10cSrcweir     ULONG 	nLang = 0;
2670cdf0e10cSrcweir 	APIRET	rc;
2671cdf0e10cSrcweir 	UconvObject  uconv_object = NULL;
2672cdf0e10cSrcweir 	LocaleObject locale_object = NULL;
2673cdf0e10cSrcweir 	UniChar		*pinfo_item;
2674cdf0e10cSrcweir 
2675cdf0e10cSrcweir 	// we do not support change of input language while working,
2676cdf0e10cSrcweir 	// so exit if already defined (mnInputLang is a static class field)
2677cdf0e10cSrcweir 	if (pFrame->mnInputLang)
2678cdf0e10cSrcweir 		return;
2679cdf0e10cSrcweir 
2680cdf0e10cSrcweir 	// get current locale
2681cdf0e10cSrcweir 	rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"", &locale_object);
2682cdf0e10cSrcweir 	// get Win32 locale id and sublanguage (hex uni string)
2683cdf0e10cSrcweir 	rc = UniQueryLocaleItem(locale_object, LOCI_xWinLocale, &pinfo_item);
2684cdf0e10cSrcweir 	// convert uni string to integer
2685cdf0e10cSrcweir 	rc = UniStrtoul(locale_object, pinfo_item, &pinfo_item, 16, &nLang);
2686cdf0e10cSrcweir 	rc = UniFreeMem(pinfo_item);
2687cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2688cdf0e10cSrcweir 	debug_printf("ImplUpdateInputLang nLang %04x\n", nLang);
2689cdf0e10cSrcweir 	char         char_buffer[256];
2690cdf0e10cSrcweir 	rc = UniCreateUconvObject((UniChar *)L"", &uconv_object);
2691cdf0e10cSrcweir 	rc = UniQueryLocaleItem(locale_object, LOCI_sKeyboard, &pinfo_item);
2692cdf0e10cSrcweir 	rc = UniStrFromUcs(uconv_object, char_buffer, pinfo_item, sizeof(char_buffer));
2693cdf0e10cSrcweir 	debug_printf("Keyboard name is: %s\n", char_buffer );
2694cdf0e10cSrcweir 	rc = UniFreeMem(pinfo_item);
2695cdf0e10cSrcweir #endif
2696cdf0e10cSrcweir 	rc = UniFreeLocaleObject(locale_object);
2697cdf0e10cSrcweir 
2698cdf0e10cSrcweir 	// keep input lang up-to-date
2699cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2700cdf0e10cSrcweir 	debug_printf("ImplUpdateInputLang pFrame %08x lang changed from %d to %d\n",
2701cdf0e10cSrcweir 		pFrame, pFrame->mnInputLang, nLang);
2702cdf0e10cSrcweir #endif
2703cdf0e10cSrcweir 	pFrame->mnInputLang = nLang;
2704cdf0e10cSrcweir }
2705cdf0e10cSrcweir 
2706cdf0e10cSrcweir 
ImplGetCharCode(Os2SalFrame * pFrame,USHORT nKeyFlags,sal_Char nCharCode,UCHAR nScanCode)2707cdf0e10cSrcweir static sal_Unicode ImplGetCharCode( Os2SalFrame* pFrame, USHORT nKeyFlags,
2708cdf0e10cSrcweir 									sal_Char nCharCode, UCHAR nScanCode )
2709cdf0e10cSrcweir {
2710cdf0e10cSrcweir     ImplUpdateInputLang( pFrame );
2711cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2712cdf0e10cSrcweir     debug_printf("ImplGetCharCode nCharCode %c, %04x\n", nCharCode, nCharCode);
2713cdf0e10cSrcweir #endif
2714cdf0e10cSrcweir     return OUString( &nCharCode, 1, gsl_getSystemTextEncoding()).toChar();
2715cdf0e10cSrcweir }
2716cdf0e10cSrcweir 
2717cdf0e10cSrcweir // -----------------------------------------------------------------------
2718cdf0e10cSrcweir 
GetInputLanguage()2719cdf0e10cSrcweir LanguageType Os2SalFrame::GetInputLanguage()
2720cdf0e10cSrcweir {
2721cdf0e10cSrcweir     if( !mnInputLang )
2722cdf0e10cSrcweir         ImplUpdateInputLang( this );
2723cdf0e10cSrcweir 
2724cdf0e10cSrcweir     if( !mnInputLang )
2725cdf0e10cSrcweir         return LANGUAGE_DONTKNOW;
2726cdf0e10cSrcweir     else
2727cdf0e10cSrcweir         return (LanguageType) mnInputLang;
2728cdf0e10cSrcweir }
2729cdf0e10cSrcweir 
2730cdf0e10cSrcweir // -----------------------------------------------------------------------
2731cdf0e10cSrcweir 
MapUnicodeToKeyCode(sal_Unicode,LanguageType,KeyCode &)2732fc9fd3f1SPedro Giffuni sal_Bool Os2SalFrame::MapUnicodeToKeyCode( sal_Unicode , LanguageType , KeyCode& )
2733cdf0e10cSrcweir {
2734cdf0e10cSrcweir     // not supported yet
2735cdf0e10cSrcweir     return FALSE;
2736cdf0e10cSrcweir }
2737cdf0e10cSrcweir 
2738cdf0e10cSrcweir // -----------------------------------------------------------------------
2739cdf0e10cSrcweir 
ImplConvertKey(Os2SalFrame * pFrame,MPARAM aMP1,MPARAM aMP2)2740cdf0e10cSrcweir static sal_Unicode ImplConvertKey( Os2SalFrame* pFrame, MPARAM aMP1, MPARAM aMP2 )
2741cdf0e10cSrcweir {
2742cdf0e10cSrcweir     USHORT  nKeyFlags   = SHORT1FROMMP( aMP1 );
2743cdf0e10cSrcweir     UCHAR   nCharCode   = (UCHAR)SHORT1FROMMP( aMP2 );
2744cdf0e10cSrcweir     USHORT  nKeyCode    = (UCHAR)SHORT2FROMMP( aMP2 );
2745cdf0e10cSrcweir     UCHAR   nScanCode   = (UCHAR)CHAR4FROMMP( aMP1 );
2746cdf0e10cSrcweir 	sal_Unicode	rSVCharCode = 0;
2747cdf0e10cSrcweir 
2748cdf0e10cSrcweir     // Ist Character-Code gesetzt
2749cdf0e10cSrcweir     // !!! Bei CTRL/ALT ist KC_CHAR nicht gesetzt, jedoch moechten wir
2750cdf0e10cSrcweir     // !!! dann auch einen CharCode und machen die Behandlung deshalb
2751cdf0e10cSrcweir     // !!! selber
2752cdf0e10cSrcweir     if ( (nKeyFlags & KC_CHAR) || (nKeyFlags & KC_CTRL) || (nKeyFlags & KC_ALT) )
2753cdf0e10cSrcweir         rSVCharCode = ImplGetCharCode( pFrame, nKeyFlags, nCharCode, nScanCode);
2754cdf0e10cSrcweir 
2755cdf0e10cSrcweir 	// ret unicode
2756cdf0e10cSrcweir 	return rSVCharCode;
2757cdf0e10cSrcweir }
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir // -----------------------------------------------------------------------
2760cdf0e10cSrcweir 
ImplHandleKeyMsg(HWND hWnd,UINT nMsg,MPARAM nMP1,MPARAM nMP2)2761cdf0e10cSrcweir static long ImplHandleKeyMsg( HWND hWnd,
2762cdf0e10cSrcweir                               UINT nMsg, MPARAM nMP1, MPARAM nMP2 )
2763cdf0e10cSrcweir {
2764cdf0e10cSrcweir     static USHORT   nLastOS2KeyChar = 0;
2765cdf0e10cSrcweir     static sal_Unicode   nLastChar       = 0;
2766cdf0e10cSrcweir     USHORT          nRepeat         = CHAR3FROMMP( nMP1 ) - 1;
2767cdf0e10cSrcweir     SHORT           nFlags          = SHORT1FROMMP( nMP1 );
2768cdf0e10cSrcweir     USHORT          nModCode        = 0;
2769cdf0e10cSrcweir     USHORT          nSVCode         = 0;
2770cdf0e10cSrcweir     USHORT          nOS2KeyCode     = (UCHAR)SHORT2FROMMP( nMP2 );
2771cdf0e10cSrcweir     sal_Unicode		nSVCharCode     = 0;
2772cdf0e10cSrcweir     long            nRet            = 0;
2773cdf0e10cSrcweir 
2774cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
2775cdf0e10cSrcweir     if ( !pFrame )
2776cdf0e10cSrcweir         return 0;
2777cdf0e10cSrcweir 
2778cdf0e10cSrcweir     // determine modifiers
2779cdf0e10cSrcweir     if ( nFlags & KC_SHIFT )
2780cdf0e10cSrcweir         nModCode |= KEY_SHIFT;
2781cdf0e10cSrcweir     if ( nFlags & KC_CTRL )
2782cdf0e10cSrcweir         nModCode |= KEY_MOD1;
2783cdf0e10cSrcweir     if ( nFlags & KC_ALT )
2784cdf0e10cSrcweir         nModCode |= KEY_MOD2;
2785cdf0e10cSrcweir 
2786cdf0e10cSrcweir     // Bei Shift, Control und Alt schicken wir einen KeyModChange-Event
2787cdf0e10cSrcweir     if ( (nOS2KeyCode == VK_SHIFT) || (nOS2KeyCode == VK_CTRL) ||
2788cdf0e10cSrcweir          (nOS2KeyCode == VK_ALT) || (nOS2KeyCode == VK_ALTGRAF) )
2789cdf0e10cSrcweir     {
2790cdf0e10cSrcweir         SalKeyModEvent aModEvt;
2791cdf0e10cSrcweir         aModEvt.mnTime = WinQueryMsgTime( pFrame->mhAB );
2792cdf0e10cSrcweir         aModEvt.mnCode = nModCode;
2793cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2794cdf0e10cSrcweir 		debug_printf("SALEVENT_KEYMODCHANGE\n");
2795cdf0e10cSrcweir #endif
2796cdf0e10cSrcweir         nRet = pFrame->CallCallback( SALEVENT_KEYMODCHANGE, &aModEvt );
2797cdf0e10cSrcweir     }
2798cdf0e10cSrcweir     else
2799cdf0e10cSrcweir     {
2800cdf0e10cSrcweir 		nSVCode = ImplSalGetKeyCode( pFrame, nMP1, nMP2 );
2801cdf0e10cSrcweir         nSVCharCode = ImplConvertKey( pFrame, nMP1, nMP2 );
2802cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2803cdf0e10cSrcweir 		debug_printf("nSVCode %04x nSVCharCode %04x\n",nSVCode,nSVCharCode );
2804cdf0e10cSrcweir #endif
2805cdf0e10cSrcweir 
2806cdf0e10cSrcweir         // Fuer Java muessen wir bei KeyUp einen CharCode liefern
2807cdf0e10cSrcweir         if ( nFlags & KC_KEYUP )
2808cdf0e10cSrcweir         {
2809cdf0e10cSrcweir             if ( !nSVCharCode )
2810cdf0e10cSrcweir             {
2811cdf0e10cSrcweir                 if ( nLastOS2KeyChar == nOS2KeyCode )
2812cdf0e10cSrcweir                 {
2813cdf0e10cSrcweir                     nSVCharCode     = nLastChar;
2814cdf0e10cSrcweir                     nLastOS2KeyChar = 0;
2815cdf0e10cSrcweir                     nLastChar       = 0;
2816cdf0e10cSrcweir                 }
2817cdf0e10cSrcweir             }
2818cdf0e10cSrcweir             else
2819cdf0e10cSrcweir             {
2820cdf0e10cSrcweir                 nLastOS2KeyChar = 0;
2821cdf0e10cSrcweir                 nLastChar       = 0;
2822cdf0e10cSrcweir             }
2823cdf0e10cSrcweir         }
2824cdf0e10cSrcweir         else
2825cdf0e10cSrcweir         {
2826cdf0e10cSrcweir             nLastOS2KeyChar = nOS2KeyCode;
2827cdf0e10cSrcweir             nLastChar       = nSVCharCode;
2828cdf0e10cSrcweir         }
2829cdf0e10cSrcweir 
2830cdf0e10cSrcweir         if ( nSVCode || nSVCharCode )
2831cdf0e10cSrcweir         {
2832cdf0e10cSrcweir             SalKeyEvent aKeyEvt;
2833cdf0e10cSrcweir             aKeyEvt.mnCode      = nSVCode;
2834cdf0e10cSrcweir             aKeyEvt.mnTime      = WinQueryMsgTime( pFrame->mhAB );
2835cdf0e10cSrcweir             aKeyEvt.mnCode     |= nModCode;
2836cdf0e10cSrcweir             aKeyEvt.mnCharCode  = nSVCharCode;
2837cdf0e10cSrcweir             aKeyEvt.mnRepeat    = nRepeat;
2838cdf0e10cSrcweir 
2839cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
2840cdf0e10cSrcweir 			debug_printf( (nFlags & KC_KEYUP) ? "SALEVENT_KEYUP\n" : "SALEVENT_KEYINPUT\n");
2841cdf0e10cSrcweir #endif
2842cdf0e10cSrcweir             nRet = pFrame->CallCallback( (nFlags & KC_KEYUP) ? SALEVENT_KEYUP : SALEVENT_KEYINPUT,
2843cdf0e10cSrcweir                                                &aKeyEvt );
2844cdf0e10cSrcweir         }
2845cdf0e10cSrcweir     }
2846cdf0e10cSrcweir 
2847cdf0e10cSrcweir     return nRet;
2848cdf0e10cSrcweir }
2849cdf0e10cSrcweir 
2850cdf0e10cSrcweir // -----------------------------------------------------------------------
2851cdf0e10cSrcweir 
ImplHandlePaintMsg(HWND hWnd)2852cdf0e10cSrcweir static bool ImplHandlePaintMsg( HWND hWnd )
2853cdf0e10cSrcweir {
2854fc9fd3f1SPedro Giffuni     sal_Bool bMutex = FALSE;
2855cdf0e10cSrcweir 
2856cdf0e10cSrcweir     if ( ImplSalYieldMutexTryToAcquire() )
2857cdf0e10cSrcweir         bMutex = TRUE;
2858cdf0e10cSrcweir 
2859cdf0e10cSrcweir     // if we don't get the mutex, we can also change the clip region,
2860cdf0e10cSrcweir     // because other threads doesn't use the mutex from the main
2861cdf0e10cSrcweir     // thread --> see GetGraphics()
2862cdf0e10cSrcweir 
2863cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
2864cdf0e10cSrcweir     if ( pFrame )
2865cdf0e10cSrcweir     {
2866cdf0e10cSrcweir         // Laut Window-Doku soll man erst abfragen, ob ueberhaupt eine
2867cdf0e10cSrcweir         // Paint-Region anliegt
2868cdf0e10cSrcweir         if ( WinQueryUpdateRect( hWnd, NULL ) )
2869cdf0e10cSrcweir         {
2870cdf0e10cSrcweir             // Call BeginPaint/EndPaint to query the rect and send
2871cdf0e10cSrcweir             // this Notofication to rect
2872cdf0e10cSrcweir 			HPS     hPS;
2873cdf0e10cSrcweir 			RECTL   aUpdateRect;
2874cdf0e10cSrcweir 			hPS = WinBeginPaint( hWnd, NULLHANDLE, &aUpdateRect );
2875cdf0e10cSrcweir 			WinEndPaint( hPS );
2876cdf0e10cSrcweir 
2877cdf0e10cSrcweir             // Paint
2878cdf0e10cSrcweir             if ( bMutex )
2879cdf0e10cSrcweir             {
2880cdf0e10cSrcweir 		SalPaintEvent aPEvt( aUpdateRect.xLeft, pFrame->mnHeight - aUpdateRect.yTop, aUpdateRect.xRight- aUpdateRect.xLeft, aUpdateRect.yTop - aUpdateRect.yBottom );
2881cdf0e10cSrcweir 
2882cdf0e10cSrcweir                 pFrame->CallCallback( SALEVENT_PAINT, &aPEvt );
2883cdf0e10cSrcweir             }
2884cdf0e10cSrcweir             else
2885cdf0e10cSrcweir             {
2886cdf0e10cSrcweir                 RECTL* pRect = new RECTL;
2887cdf0e10cSrcweir                 WinCopyRect( pFrame->mhAB, pRect, &aUpdateRect );
2888cdf0e10cSrcweir                 WinPostMsg( hWnd, SAL_MSG_POSTPAINT, (MPARAM)pRect, 0 );
2889cdf0e10cSrcweir             }
2890cdf0e10cSrcweir 		}
2891cdf0e10cSrcweir 	}
2892cdf0e10cSrcweir 
2893cdf0e10cSrcweir     if ( bMutex )
2894cdf0e10cSrcweir         ImplSalYieldMutexRelease();
2895cdf0e10cSrcweir 
2896cdf0e10cSrcweir 	return bMutex ? true : false;
2897cdf0e10cSrcweir }
2898cdf0e10cSrcweir 
2899cdf0e10cSrcweir // -----------------------------------------------------------------------
2900cdf0e10cSrcweir 
ImplHandlePaintMsg2(HWND hWnd,RECTL * pRect)2901cdf0e10cSrcweir static void ImplHandlePaintMsg2( HWND hWnd, RECTL* pRect )
2902cdf0e10cSrcweir {
2903cdf0e10cSrcweir     // Paint
2904cdf0e10cSrcweir     if ( ImplSalYieldMutexTryToAcquire() )
2905cdf0e10cSrcweir     {
2906cdf0e10cSrcweir         Os2SalFrame* pFrame = GetWindowPtr( hWnd );
2907cdf0e10cSrcweir         if ( pFrame )
2908cdf0e10cSrcweir         {
2909cdf0e10cSrcweir             SalPaintEvent aPEvt( pRect->xLeft, pFrame->mnHeight - pRect->yTop, pRect->xRight - pRect->xLeft, pRect->yTop - pRect->yBottom );
2910cdf0e10cSrcweir             pFrame->CallCallback( SALEVENT_PAINT, &aPEvt );
2911cdf0e10cSrcweir         }
2912cdf0e10cSrcweir         ImplSalYieldMutexRelease();
2913cdf0e10cSrcweir         delete pRect;
2914cdf0e10cSrcweir     }
2915cdf0e10cSrcweir     else
2916cdf0e10cSrcweir         WinPostMsg( hWnd, SAL_MSG_POSTPAINT, (MPARAM)pRect, 0 );
2917cdf0e10cSrcweir }
2918cdf0e10cSrcweir 
2919cdf0e10cSrcweir // -----------------------------------------------------------------------
2920cdf0e10cSrcweir 
SetMaximizedFrameGeometry(HWND hWnd,Os2SalFrame * pFrame)2921cdf0e10cSrcweir static void SetMaximizedFrameGeometry( HWND hWnd, Os2SalFrame* pFrame )
2922cdf0e10cSrcweir {
2923cdf0e10cSrcweir     // calculate and set frame geometry of a maximized window - useful if the window is still hidden
2924cdf0e10cSrcweir 
2925cdf0e10cSrcweir     RECTL aRect;
2926cdf0e10cSrcweir     pFrame->GetWorkArea( aRect);
2927cdf0e10cSrcweir 
2928cdf0e10cSrcweir     // a maximized window has no other borders than the caption
2929cdf0e10cSrcweir     pFrame->maGeometry.nLeftDecoration = pFrame->maGeometry.nRightDecoration = pFrame->maGeometry.nBottomDecoration = 0;
2930cdf0e10cSrcweir     pFrame->maGeometry.nTopDecoration = pFrame->mbCaption ? WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) : 0;
2931cdf0e10cSrcweir 
2932cdf0e10cSrcweir     aRect.yTop += pFrame->maGeometry.nTopDecoration;
2933cdf0e10cSrcweir     pFrame->maGeometry.nX = aRect.xLeft;
2934cdf0e10cSrcweir     pFrame->maGeometry.nY = aRect.yBottom;
2935cdf0e10cSrcweir     pFrame->maGeometry.nWidth = aRect.xRight - aRect.xLeft + 1;
2936cdf0e10cSrcweir     pFrame->maGeometry.nHeight = aRect.yBottom - aRect.yTop + 1;
2937cdf0e10cSrcweir }
2938cdf0e10cSrcweir 
UpdateFrameGeometry(HWND hWnd,Os2SalFrame * pFrame)2939cdf0e10cSrcweir static void UpdateFrameGeometry( HWND hWnd, Os2SalFrame* pFrame )
2940cdf0e10cSrcweir {
2941cdf0e10cSrcweir     if( !pFrame )
2942cdf0e10cSrcweir         return;
2943cdf0e10cSrcweir 
2944cdf0e10cSrcweir 	//SalFrame has a
2945cdf0e10cSrcweir 	//maGeometry member that holds absolute screen positions (and needs to be
2946cdf0e10cSrcweir 	//updated if the window is moved by the way).
2947cdf0e10cSrcweir 
2948cdf0e10cSrcweir 	// reset data
2949cdf0e10cSrcweir     memset(&pFrame->maGeometry, 0, sizeof(SalFrameGeometry) );
2950cdf0e10cSrcweir 
2951cdf0e10cSrcweir 	SWP	swp;
2952cdf0e10cSrcweir 	LONG nFrameX, nFrameY, nCaptionY;
2953cdf0e10cSrcweir 
2954cdf0e10cSrcweir 	// get frame size
2955cdf0e10cSrcweir 	WinQueryWindowPos(pFrame->mhWndFrame, &swp);
2956cdf0e10cSrcweir 	if (swp.fl & SWP_MINIMIZE)
2957cdf0e10cSrcweir       return;
2958cdf0e10cSrcweir 
2959cdf0e10cSrcweir 	// map from client area to screen
2960cdf0e10cSrcweir     ImplSalCalcFrameSize( pFrame, nFrameX, nFrameY, nCaptionY);
2961cdf0e10cSrcweir     pFrame->maGeometry.nTopDecoration = nFrameY + nCaptionY;
2962cdf0e10cSrcweir     pFrame->maGeometry.nLeftDecoration = nFrameX;
2963cdf0e10cSrcweir     pFrame->maGeometry.nRightDecoration = nFrameX;
2964cdf0e10cSrcweir 	pFrame->maGeometry.nBottomDecoration = nFrameY;
2965cdf0e10cSrcweir 
2966cdf0e10cSrcweir 	// position of client area, not of frame corner!
2967cdf0e10cSrcweir     pFrame->maGeometry.nX = swp.x + nFrameX;
2968cdf0e10cSrcweir     pFrame->maGeometry.nY = nScreenHeight - (swp.y + swp.cy) + nFrameY + nCaptionY;
2969cdf0e10cSrcweir 
2970cdf0e10cSrcweir     int nWidth  = swp.cx - pFrame->maGeometry.nRightDecoration - pFrame->maGeometry.nLeftDecoration;
2971cdf0e10cSrcweir     int nHeight = swp.cy - pFrame->maGeometry.nBottomDecoration - pFrame->maGeometry.nTopDecoration;
2972cdf0e10cSrcweir 
2973cdf0e10cSrcweir     // clamp to zero
2974cdf0e10cSrcweir     pFrame->maGeometry.nHeight = nHeight < 0 ? 0 : nHeight;
2975cdf0e10cSrcweir     pFrame->maGeometry.nWidth = nWidth < 0 ? 0 : nWidth;
2976cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>0
2977cdf0e10cSrcweir 	debug_printf( "UpdateFrameGeometry: hwnd %x, frame %x at %d,%d (%dx%d)\n",
2978cdf0e10cSrcweir 		hWnd, pFrame->mhWndFrame,
2979cdf0e10cSrcweir 		pFrame->maGeometry.nX, pFrame->maGeometry.nY,
2980cdf0e10cSrcweir 		pFrame->maGeometry.nWidth,pFrame->maGeometry.nHeight);
2981cdf0e10cSrcweir #endif
2982cdf0e10cSrcweir }
2983cdf0e10cSrcweir 
2984cdf0e10cSrcweir // -----------------------------------------------------------------------
2985cdf0e10cSrcweir 
ImplHandleMoveMsg(HWND hWnd)2986cdf0e10cSrcweir static void ImplHandleMoveMsg( HWND hWnd)
2987cdf0e10cSrcweir {
2988cdf0e10cSrcweir     if ( ImplSalYieldMutexTryToAcquire() )
2989cdf0e10cSrcweir     {
2990cdf0e10cSrcweir         Os2SalFrame* pFrame = GetWindowPtr( hWnd );
2991cdf0e10cSrcweir         if ( pFrame )
2992cdf0e10cSrcweir         {
2993cdf0e10cSrcweir             UpdateFrameGeometry( hWnd, pFrame );
2994cdf0e10cSrcweir 
2995cdf0e10cSrcweir             if ( WinIsWindowVisible( hWnd ))
2996cdf0e10cSrcweir 				pFrame->mbDefPos = FALSE;
2997cdf0e10cSrcweir 
2998cdf0e10cSrcweir 			// Gegen moegliche Rekursionen sichern
2999cdf0e10cSrcweir 			if ( !pFrame->mbInMoveMsg )
3000cdf0e10cSrcweir 			{
3001cdf0e10cSrcweir 				// Fenster im FullScreenModus wieder einpassen
3002cdf0e10cSrcweir 				pFrame->mbInMoveMsg = TRUE;
3003cdf0e10cSrcweir 				if ( pFrame->mbFullScreen )
3004cdf0e10cSrcweir 					ImplSalFrameFullScreenPos( pFrame );
3005cdf0e10cSrcweir 				pFrame->mbInMoveMsg = FALSE;
3006cdf0e10cSrcweir 			}
3007cdf0e10cSrcweir 
3008cdf0e10cSrcweir 			// Status merken
3009cdf0e10cSrcweir 			ImplSaveFrameState( pFrame );
3010cdf0e10cSrcweir 
3011cdf0e10cSrcweir             // Call Hdl
3012cdf0e10cSrcweir             //#93851 if we call this handler, VCL floating windows are not updated correctly
3013cdf0e10cSrcweir             //ImplCallMoveHdl( hWnd );
3014cdf0e10cSrcweir 
3015cdf0e10cSrcweir         }
3016cdf0e10cSrcweir 
3017cdf0e10cSrcweir         ImplSalYieldMutexRelease();
3018cdf0e10cSrcweir     }
3019cdf0e10cSrcweir     else
3020cdf0e10cSrcweir 		WinPostMsg( hWnd, SAL_MSG_POSTMOVE, 0, 0 );
3021cdf0e10cSrcweir }
3022cdf0e10cSrcweir 
3023cdf0e10cSrcweir // -----------------------------------------------------------------------
3024cdf0e10cSrcweir 
ImplHandleSizeMsg(HWND hWnd,MPARAM nMP2)3025cdf0e10cSrcweir static void ImplHandleSizeMsg( HWND hWnd, MPARAM nMP2 )
3026cdf0e10cSrcweir {
3027cdf0e10cSrcweir         Os2SalFrame* pFrame = GetWindowPtr( hWnd );
3028cdf0e10cSrcweir         if ( pFrame )
3029cdf0e10cSrcweir         {
3030cdf0e10cSrcweir             UpdateFrameGeometry( hWnd, pFrame );
3031cdf0e10cSrcweir 			pFrame->mbDefPos = FALSE;
3032cdf0e10cSrcweir 			pFrame->mnWidth  = (short)SHORT1FROMMP( nMP2 );
3033cdf0e10cSrcweir 			pFrame->mnHeight = (short)SHORT2FROMMP( nMP2 );
3034cdf0e10cSrcweir 			if ( pFrame->mpGraphics )
3035cdf0e10cSrcweir 				pFrame->mpGraphics->mnHeight = (int)SHORT2FROMMP(nMP2);
3036cdf0e10cSrcweir 			// Status merken
3037cdf0e10cSrcweir 			ImplSaveFrameState( pFrame );
3038cdf0e10cSrcweir 			pFrame->CallCallback( SALEVENT_RESIZE, 0 );
3039cdf0e10cSrcweir 			if ( WinIsWindowVisible( pFrame->mhWndFrame ) && !pFrame->mbInShow )
3040cdf0e10cSrcweir 				WinUpdateWindow( pFrame->mhWndClient );
3041cdf0e10cSrcweir 		}
3042cdf0e10cSrcweir }
3043cdf0e10cSrcweir 
3044cdf0e10cSrcweir // -----------------------------------------------------------------------
3045cdf0e10cSrcweir 
ImplHandleFocusMsg(Os2SalFrame * pFrame,MPARAM nMP2)3046cdf0e10cSrcweir static long ImplHandleFocusMsg( Os2SalFrame* pFrame, MPARAM nMP2 )
3047cdf0e10cSrcweir {
3048cdf0e10cSrcweir if ( pFrame && !Os2SalFrame::mbInReparent )
3049cdf0e10cSrcweir {
3050cdf0e10cSrcweir     if ( SHORT1FROMMP( nMP2 ) )
3051cdf0e10cSrcweir     {
3052cdf0e10cSrcweir         if ( WinIsWindowVisible( pFrame->mhWndFrame ) && !pFrame->mbInShow )
3053cdf0e10cSrcweir             WinUpdateWindow( pFrame->mhWndClient );
3054cdf0e10cSrcweir         return pFrame->CallCallback( SALEVENT_GETFOCUS, 0 );
3055cdf0e10cSrcweir     }
3056cdf0e10cSrcweir     else
3057cdf0e10cSrcweir     {
3058cdf0e10cSrcweir         return pFrame->CallCallback( SALEVENT_LOSEFOCUS, 0 );
3059cdf0e10cSrcweir     }
3060cdf0e10cSrcweir }
3061cdf0e10cSrcweir }
3062cdf0e10cSrcweir 
3063cdf0e10cSrcweir // -----------------------------------------------------------------------
3064cdf0e10cSrcweir 
ImplHandleCloseMsg(HWND hWnd)3065cdf0e10cSrcweir static void ImplHandleCloseMsg( HWND hWnd )
3066cdf0e10cSrcweir {
3067cdf0e10cSrcweir     if ( ImplSalYieldMutexTryToAcquire() )
3068cdf0e10cSrcweir     {
3069cdf0e10cSrcweir         Os2SalFrame* pFrame = GetWindowPtr( hWnd );
3070cdf0e10cSrcweir         if ( pFrame )
3071cdf0e10cSrcweir         {
3072cdf0e10cSrcweir             pFrame->CallCallback( SALEVENT_CLOSE, 0 );
3073cdf0e10cSrcweir         }
3074cdf0e10cSrcweir 
3075cdf0e10cSrcweir         ImplSalYieldMutexRelease();
3076cdf0e10cSrcweir     }
3077cdf0e10cSrcweir     else
3078cdf0e10cSrcweir         WinPostMsg( hWnd, WM_CLOSE, 0, 0 );
3079cdf0e10cSrcweir }
3080cdf0e10cSrcweir 
3081cdf0e10cSrcweir // -----------------------------------------------------------------------
3082cdf0e10cSrcweir 
ImplHandleUserEvent(HWND hWnd,MPARAM nMP2)3083cdf0e10cSrcweir inline void ImplHandleUserEvent( HWND hWnd, MPARAM nMP2 )
3084cdf0e10cSrcweir {
3085cdf0e10cSrcweir     ImplSalYieldMutexAcquireWithWait();
3086cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
3087cdf0e10cSrcweir     if ( pFrame )
3088cdf0e10cSrcweir     {
3089cdf0e10cSrcweir         pFrame->CallCallback( SALEVENT_USEREVENT, (void*)nMP2 );
3090cdf0e10cSrcweir     }
3091cdf0e10cSrcweir     ImplSalYieldMutexRelease();
3092cdf0e10cSrcweir }
3093cdf0e10cSrcweir 
3094cdf0e10cSrcweir // -----------------------------------------------------------------------
3095cdf0e10cSrcweir 
SalImplHandleProcessMenu(Os2SalFrame * pFrame,ULONG nMsg,MPARAM nMP1,MPARAM nMP2)3096cdf0e10cSrcweir static int SalImplHandleProcessMenu( Os2SalFrame* pFrame, ULONG nMsg, MPARAM nMP1, MPARAM nMP2)
3097cdf0e10cSrcweir {
3098cdf0e10cSrcweir     long nRet = 0;
3099cdf0e10cSrcweir debug_printf("SalImplHandleProcessMenu\n");
3100cdf0e10cSrcweir #if 0
3101cdf0e10cSrcweir     DWORD err=0;
3102cdf0e10cSrcweir     if( !HIWORD(wParam) )
3103cdf0e10cSrcweir     {
3104cdf0e10cSrcweir         // Menu command
3105cdf0e10cSrcweir         WORD nId = LOWORD(wParam);
3106cdf0e10cSrcweir         if( nId )   // zero for separators
3107cdf0e10cSrcweir         {
3108cdf0e10cSrcweir             SalMenuEvent aMenuEvt;
3109cdf0e10cSrcweir             aMenuEvt.mnId   = nId;
3110cdf0e10cSrcweir             WinSalMenuItem *pSalMenuItem = ImplGetSalMenuItem( pFrame->mSelectedhMenu, nId, FALSE );
3111cdf0e10cSrcweir             if( pSalMenuItem )
3112cdf0e10cSrcweir                 aMenuEvt.mpMenu = pSalMenuItem->mpMenu;
3113cdf0e10cSrcweir             else
3114cdf0e10cSrcweir                 aMenuEvt.mpMenu = NULL;
3115cdf0e10cSrcweir 
3116cdf0e10cSrcweir             nRet = pFrame->CallCallback( SALEVENT_MENUCOMMAND, &aMenuEvt );
3117cdf0e10cSrcweir         }
3118cdf0e10cSrcweir     }
3119cdf0e10cSrcweir #endif
3120cdf0e10cSrcweir     //return (nRet != 0);
3121cdf0e10cSrcweir     return (nRet == 0);
3122cdf0e10cSrcweir }
3123cdf0e10cSrcweir 
3124cdf0e10cSrcweir // -----------------------------------------------------------------------
3125cdf0e10cSrcweir 
ImplHandleInputLangChange(HWND hWnd)3126cdf0e10cSrcweir static void ImplHandleInputLangChange( HWND hWnd )
3127cdf0e10cSrcweir {
3128cdf0e10cSrcweir     ImplSalYieldMutexAcquireWithWait();
3129cdf0e10cSrcweir 
3130cdf0e10cSrcweir     // Feststellen, ob wir IME unterstuetzen
3131cdf0e10cSrcweir     Os2SalFrame* pFrame = GetWindowPtr( hWnd );
3132cdf0e10cSrcweir #if 0
3133cdf0e10cSrcweir     if ( pFrame && pFrame->mbIME && pFrame->mhDefIMEContext )
3134cdf0e10cSrcweir     {
3135cdf0e10cSrcweir         HWND    hWnd = pFrame->mhWnd;
3136cdf0e10cSrcweir         HKL     hKL = (HKL)lParam;
3137cdf0e10cSrcweir         UINT    nImeProps = ImmGetProperty( hKL, IGP_PROPERTY );
3138cdf0e10cSrcweir 
3139cdf0e10cSrcweir         pFrame->mbSpezIME = (nImeProps & IME_PROP_SPECIAL_UI) != 0;
3140cdf0e10cSrcweir         pFrame->mbAtCursorIME = (nImeProps & IME_PROP_AT_CARET) != 0;
3141cdf0e10cSrcweir         pFrame->mbHandleIME = !pFrame->mbSpezIME;
3142cdf0e10cSrcweir     }
3143cdf0e10cSrcweir #endif
3144cdf0e10cSrcweir 
3145cdf0e10cSrcweir     // trigger input language and codepage update
3146cdf0e10cSrcweir     UINT nLang = pFrame->mnInputLang;
3147cdf0e10cSrcweir     ImplUpdateInputLang( pFrame );
3148cdf0e10cSrcweir 	debug_printf("ImplHandleInputLangChange new language 0x%04x\n",pFrame->mnInputLang);
3149cdf0e10cSrcweir 
3150cdf0e10cSrcweir     // notify change
3151cdf0e10cSrcweir     if( nLang != pFrame->mnInputLang )
3152cdf0e10cSrcweir         pFrame->CallCallback( SALEVENT_INPUTLANGUAGECHANGE, 0 );
3153cdf0e10cSrcweir 
3154cdf0e10cSrcweir     ImplSalYieldMutexRelease();
3155cdf0e10cSrcweir }
3156cdf0e10cSrcweir 
3157cdf0e10cSrcweir // -----------------------------------------------------------------------
3158cdf0e10cSrcweir 
3159cdf0e10cSrcweir #ifdef ENABLE_IME
3160cdf0e10cSrcweir 
ImplHandleIMEStartConversion(Os2SalFrame * pFrame)3161cdf0e10cSrcweir static long ImplHandleIMEStartConversion( Os2SalFrame* pFrame )
3162cdf0e10cSrcweir {
3163cdf0e10cSrcweir     long        nRet = FALSE;
3164cdf0e10cSrcweir     SalIMEData* pIMEData = GetSalIMEData();
3165cdf0e10cSrcweir     if ( pIMEData )
3166cdf0e10cSrcweir     {
3167cdf0e10cSrcweir         HWND hWnd = pFrame->mhWndClient;
3168cdf0e10cSrcweir         HIMI hIMI = 0;
3169cdf0e10cSrcweir         pIMEData->mpGetIME( hWnd, &hIMI );
3170cdf0e10cSrcweir         if ( hIMI )
3171cdf0e10cSrcweir         {
3172cdf0e10cSrcweir             ULONG nProp;
3173cdf0e10cSrcweir             if ( 0 != pIMEData->mpQueryIMEProperty( hIMI, QIP_PROPERTY, &nProp ) )
3174cdf0e10cSrcweir                 pFrame->mbHandleIME = FALSE;
3175cdf0e10cSrcweir             else
3176cdf0e10cSrcweir             {
3177cdf0e10cSrcweir                 pFrame->mbHandleIME = !(nProp & PRP_SPECIALUI);
3178cdf0e10cSrcweir 
3179cdf0e10cSrcweir             }
3180cdf0e10cSrcweir             if ( pFrame->mbHandleIME )
3181cdf0e10cSrcweir             {
3182cdf0e10cSrcweir /* Windows-Code, der noch nicht angepasst wurde !!!
3183cdf0e10cSrcweir                 // Cursor-Position ermitteln und aus der die Default-Position fuer
3184cdf0e10cSrcweir                 // das Composition-Fenster berechnen
3185cdf0e10cSrcweir                 SalCursorPosEvent aCursorPosEvt;
3186cdf0e10cSrcweir                 pFrame->CallCallback( pFrame->mpInst, pFrame,
3187cdf0e10cSrcweir                                             SALEVENT_CURSORPOS, (void*)&aCursorPosEvt );
3188cdf0e10cSrcweir                 COMPOSITIONFORM aForm;
3189cdf0e10cSrcweir                 memset( &aForm, 0, sizeof( aForm ) );
3190cdf0e10cSrcweir                 if ( !aCursorPosEvt.mnWidth || !aCursorPosEvt.mnHeight )
3191cdf0e10cSrcweir                     aForm.dwStyle |= CFS_DEFAULT;
3192cdf0e10cSrcweir                 else
3193cdf0e10cSrcweir                 {
3194cdf0e10cSrcweir                     aForm.dwStyle          |= CFS_POINT;
3195cdf0e10cSrcweir                     aForm.ptCurrentPos.x    = aCursorPosEvt.mnX;
3196cdf0e10cSrcweir                     aForm.ptCurrentPos.y    = aCursorPosEvt.mnY;
3197cdf0e10cSrcweir                 }
3198cdf0e10cSrcweir                 ImmSetCompositionWindow( hIMC, &aForm );
3199cdf0e10cSrcweir 
3200cdf0e10cSrcweir                 // Den InputContect-Font ermitteln und diesem dem Composition-Fenster
3201cdf0e10cSrcweir                 // bekannt machen
3202cdf0e10cSrcweir */
3203cdf0e10cSrcweir 
3204cdf0e10cSrcweir                 pFrame->mbConversionMode = TRUE;
3205cdf0e10cSrcweir                 pFrame->CallCallback( SALEVENT_STARTEXTTEXTINPUT, (void*)NULL );
3206cdf0e10cSrcweir                 nRet = TRUE;
3207cdf0e10cSrcweir             }
3208cdf0e10cSrcweir 
3209cdf0e10cSrcweir             pIMEData->mpReleaseIME( hWnd, hIMI );
3210cdf0e10cSrcweir         }
3211cdf0e10cSrcweir     }
3212cdf0e10cSrcweir 
3213cdf0e10cSrcweir     return nRet;
3214cdf0e10cSrcweir }
3215cdf0e10cSrcweir 
3216cdf0e10cSrcweir // -----------------------------------------------------------------------
3217cdf0e10cSrcweir 
ImplHandleIMEConversion(Os2SalFrame * pFrame,MPARAM nMP2Param)3218cdf0e10cSrcweir static long ImplHandleIMEConversion( Os2SalFrame* pFrame, MPARAM nMP2Param )
3219cdf0e10cSrcweir {
3220cdf0e10cSrcweir     long        nRet = FALSE;
3221cdf0e10cSrcweir     SalIMEData* pIMEData = GetSalIMEData();
3222cdf0e10cSrcweir     if ( pIMEData )
3223cdf0e10cSrcweir     {
3224cdf0e10cSrcweir         HWND        hWnd = pFrame->mhWndClient;
3225cdf0e10cSrcweir         HIMI        hIMI = 0;
3226cdf0e10cSrcweir         ULONG    nMP2 = (ULONG)nMP2Param;
3227cdf0e10cSrcweir         pIMEData->mpGetIME( hWnd, &hIMI );
3228cdf0e10cSrcweir         if ( hIMI )
3229cdf0e10cSrcweir         {
3230cdf0e10cSrcweir             if ( nMP2 & (IMR_RESULT_RESULTSTRING |
3231cdf0e10cSrcweir                          IMR_CONV_CONVERSIONSTRING | IMR_CONV_CONVERSIONATTR |
3232cdf0e10cSrcweir                          IMR_CONV_CURSORPOS | IMR_CONV_CURSORATTR) )
3233cdf0e10cSrcweir             {
3234cdf0e10cSrcweir                 SalExtTextInputEvent aEvt;
3235cdf0e10cSrcweir                 aEvt.mnTime             = WinQueryMsgTime( pFrame->mhAB );
3236cdf0e10cSrcweir                 aEvt.mpTextAttr         = NULL;
3237cdf0e10cSrcweir                 aEvt.mnCursorPos        = 0;
3238cdf0e10cSrcweir                 aEvt.mnDeltaStart       = 0;
3239cdf0e10cSrcweir                 aEvt.mbOnlyCursor       = FALSE;
3240cdf0e10cSrcweir                 aEvt.mbCursorVisible    = TRUE;
3241cdf0e10cSrcweir 
3242cdf0e10cSrcweir                 ULONG    nBufLen = 0;
3243cdf0e10cSrcweir                 xub_Unicode*     pBuf = NULL;
3244cdf0e10cSrcweir                 ULONG    nAttrBufLen = 0;
3245cdf0e10cSrcweir                 PM_BYTE*    pAttrBuf = NULL;
3246fc9fd3f1SPedro Giffuni                 sal_Bool        bLastCursor = FALSE;
3247cdf0e10cSrcweir                 if ( nMP2 & IMR_RESULT_RESULTSTRING )
3248cdf0e10cSrcweir                 {
3249cdf0e10cSrcweir                     pIMEData->mpGetResultString( hIMI, IMR_RESULT_RESULTSTRING, 0, &nBufLen );
3250cdf0e10cSrcweir                     if ( nBufLen > 0 )
3251cdf0e10cSrcweir                     {
3252cdf0e10cSrcweir                         pBuf = new xub_Unicode[nBufLen];
3253cdf0e10cSrcweir                         pIMEData->mpGetResultString( hIMI, IMR_RESULT_RESULTSTRING, pBuf, &nBufLen );
3254cdf0e10cSrcweir                     }
3255cdf0e10cSrcweir 
3256cdf0e10cSrcweir                     bLastCursor = TRUE;
3257cdf0e10cSrcweir                     aEvt.mbCursorVisible = TRUE;
3258cdf0e10cSrcweir                 }
3259cdf0e10cSrcweir                 else if ( nMP2 & (IMR_CONV_CONVERSIONSTRING | IMR_CONV_CONVERSIONATTR |
3260cdf0e10cSrcweir                                   IMR_CONV_CURSORPOS | IMR_CONV_CURSORATTR) )
3261cdf0e10cSrcweir                 {
3262cdf0e10cSrcweir                     pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONSTRING, 0, &nBufLen );
3263cdf0e10cSrcweir                     if ( nBufLen > 0 )
3264cdf0e10cSrcweir                     {
3265cdf0e10cSrcweir                         pBuf = new xub_Unicode[nBufLen];
3266cdf0e10cSrcweir                         pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONSTRING, pBuf, &nBufLen );
3267cdf0e10cSrcweir                     }
3268cdf0e10cSrcweir 
3269cdf0e10cSrcweir                     pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONATTR, 0, &nAttrBufLen );
3270cdf0e10cSrcweir                     if ( nAttrBufLen > 0 )
3271cdf0e10cSrcweir                     {
3272cdf0e10cSrcweir                         pAttrBuf = new PM_BYTE[nAttrBufLen];
3273cdf0e10cSrcweir                         pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONATTR, pAttrBuf, &nAttrBufLen );
3274cdf0e10cSrcweir                     }
3275cdf0e10cSrcweir 
3276cdf0e10cSrcweir /* !!! Wir bekommen derzeit nur falsche Daten, deshalb zeigen wir derzeit
3277cdf0e10cSrcweir    !!! auch keine Cursor an
3278cdf0e10cSrcweir                     ULONG nTempBufLen;
3279cdf0e10cSrcweir                     ULONG nCursorPos = 0;
3280cdf0e10cSrcweir                     ULONG nCursorAttr = 0;
3281cdf0e10cSrcweir                     ULONG nChangePos = 0;
3282cdf0e10cSrcweir                     nTempBufLen = sizeof( ULONG );
3283cdf0e10cSrcweir                     pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORPOS, &nCursorPos, &nTempBufLen );
3284cdf0e10cSrcweir                     nTempBufLen = sizeof( ULONG );
3285cdf0e10cSrcweir                     pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORATTR, &nCursorAttr, &nTempBufLen );
3286cdf0e10cSrcweir                     nTempBufLen = sizeof( ULONG );
3287cdf0e10cSrcweir                     pIMEData->mpGetConversionString( hIMI, IMR_CONV_CHANGESTART, &nChangePos, &nTempBufLen );
3288cdf0e10cSrcweir 
3289cdf0e10cSrcweir                     aEvt.mnCursorPos = nCursorPos;
3290cdf0e10cSrcweir                     aEvt.mnDeltaStart = nChangePos;
3291cdf0e10cSrcweir                     if ( nCursorAttr & CP_CURSORATTR_INVISIBLE )
3292cdf0e10cSrcweir                         aEvt.mbCursorVisible = FALSE;
3293cdf0e10cSrcweir */
3294cdf0e10cSrcweir                     aEvt.mnCursorPos = 0;
3295cdf0e10cSrcweir                     aEvt.mnDeltaStart = 0;
3296cdf0e10cSrcweir                     aEvt.mbCursorVisible = FALSE;
3297cdf0e10cSrcweir 
3298cdf0e10cSrcweir                     if ( (nMP2 == IMR_CONV_CURSORPOS) ||
3299cdf0e10cSrcweir                          (nMP2 == IMR_CONV_CURSORATTR) )
3300cdf0e10cSrcweir                         aEvt.mbOnlyCursor = TRUE;
3301cdf0e10cSrcweir                 }
3302cdf0e10cSrcweir 
3303cdf0e10cSrcweir                 USHORT* pSalAttrAry = NULL;
3304cdf0e10cSrcweir                 if ( pBuf )
3305cdf0e10cSrcweir                 {
3306cdf0e10cSrcweir                     aEvt.maText = XubString( pBuf, (USHORT)nBufLen );
3307cdf0e10cSrcweir                     delete [] pBuf;
3308cdf0e10cSrcweir                     if ( pAttrBuf )
3309cdf0e10cSrcweir                     {
3310cdf0e10cSrcweir                         USHORT nTextLen = aEvt.maText.Len();
3311cdf0e10cSrcweir                         if ( nTextLen )
3312cdf0e10cSrcweir                         {
3313cdf0e10cSrcweir                             pSalAttrAry = new USHORT[nTextLen];
3314cdf0e10cSrcweir                             memset( pSalAttrAry, 0, nTextLen*sizeof( USHORT ) );
3315cdf0e10cSrcweir                             for ( USHORT i = 0; (i < nTextLen) && (i < nAttrBufLen); i++ )
3316cdf0e10cSrcweir                             {
3317cdf0e10cSrcweir                                 PM_BYTE nOS2Attr = pAttrBuf[i];
3318cdf0e10cSrcweir                                 USHORT  nSalAttr;
3319cdf0e10cSrcweir                                 if ( nOS2Attr == CP_ATTR_TARGET_CONVERTED )
3320cdf0e10cSrcweir                                     nSalAttr = SAL_EXTTEXTINPUT_ATTR_TARGETCONVERTED | SAL_EXTTEXTINPUT_ATTR_UNDERLINE | SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT;
3321cdf0e10cSrcweir                                 else if ( nOS2Attr == CP_ATTR_CONVERTED )
3322cdf0e10cSrcweir                                     nSalAttr = SAL_EXTTEXTINPUT_ATTR_CONVERTED | SAL_EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE;
3323cdf0e10cSrcweir                                 else if ( nOS2Attr == CP_ATTR_TARGET_NOTCONVERTED )
3324cdf0e10cSrcweir                                     nSalAttr = SAL_EXTTEXTINPUT_ATTR_TARGETNOTCONVERTED | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE;
3325cdf0e10cSrcweir                                 else if ( nOS2Attr == CP_ATTR_INPUT_ERROR )
3326cdf0e10cSrcweir                                     nSalAttr = SAL_EXTTEXTINPUT_ATTR_INPUTERROR | SAL_EXTTEXTINPUT_ATTR_REDTEXT | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE;
3327cdf0e10cSrcweir                                 else /* ( nOS2Attr == CP_ATTR_INPUT ) */
3328cdf0e10cSrcweir                                     nSalAttr = SAL_EXTTEXTINPUT_ATTR_INPUT | SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE;
3329cdf0e10cSrcweir                                 pSalAttrAry[i] = nSalAttr;
3330cdf0e10cSrcweir                             }
3331cdf0e10cSrcweir                             aEvt.mpTextAttr = pSalAttrAry;
3332cdf0e10cSrcweir                         }
3333cdf0e10cSrcweir                         delete [] pAttrBuf;
3334cdf0e10cSrcweir                     }
3335cdf0e10cSrcweir                     if ( bLastCursor )
3336cdf0e10cSrcweir                         aEvt.mnCursorPos = aEvt.maText.Len();
3337cdf0e10cSrcweir                 }
3338cdf0e10cSrcweir 
3339cdf0e10cSrcweir                 pIMEData->mpReleaseIME( hWnd, hIMI );
3340cdf0e10cSrcweir 
3341cdf0e10cSrcweir                 // Handler rufen und wenn wir ein Attribute-Array haben, danach
3342cdf0e10cSrcweir                 // wieder zerstoeren
3343cdf0e10cSrcweir                 pFrame->CallCallback( SALEVENT_EXTTEXTINPUT, (void*)&aEvt );
3344cdf0e10cSrcweir                 if ( pSalAttrAry )
3345cdf0e10cSrcweir                     delete [] pSalAttrAry;
3346cdf0e10cSrcweir             }
3347cdf0e10cSrcweir             else
3348cdf0e10cSrcweir                 pIMEData->mpReleaseIME( hWnd, hIMI );
3349cdf0e10cSrcweir         }
3350cdf0e10cSrcweir 
3351cdf0e10cSrcweir         nRet = TRUE;
3352cdf0e10cSrcweir     }
3353cdf0e10cSrcweir 
3354cdf0e10cSrcweir     return nRet;
3355cdf0e10cSrcweir }
3356cdf0e10cSrcweir 
3357cdf0e10cSrcweir // -----------------------------------------------------------------------
3358cdf0e10cSrcweir 
ImplHandleIMEEndConversion(Os2SalFrame * pFrame)3359cdf0e10cSrcweir inline long ImplHandleIMEEndConversion( Os2SalFrame* pFrame )
3360cdf0e10cSrcweir {
3361cdf0e10cSrcweir     pFrame->mbConversionMode = FALSE;
3362cdf0e10cSrcweir     pFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, (void*)NULL );
3363cdf0e10cSrcweir     return TRUE;
3364cdf0e10cSrcweir }
3365cdf0e10cSrcweir 
3366cdf0e10cSrcweir // -----------------------------------------------------------------------
3367cdf0e10cSrcweir 
ImplHandleIMEOpenCandidate(Os2SalFrame * pFrame)3368cdf0e10cSrcweir static void ImplHandleIMEOpenCandidate( Os2SalFrame* pFrame )
3369cdf0e10cSrcweir {
3370cdf0e10cSrcweir     pFrame->mbCandidateMode = TRUE;
3371cdf0e10cSrcweir 
3372cdf0e10cSrcweir     long        nRet = FALSE;
3373cdf0e10cSrcweir     SalIMEData* pIMEData = GetSalIMEData();
3374cdf0e10cSrcweir     if ( pIMEData )
3375cdf0e10cSrcweir     {
3376cdf0e10cSrcweir         HWND        hWnd = pFrame->mhWndClient;
3377cdf0e10cSrcweir         HIMI        hIMI = 0;
3378cdf0e10cSrcweir         pIMEData->mpGetIME( hWnd, &hIMI );
3379cdf0e10cSrcweir         if ( hIMI )
3380cdf0e10cSrcweir         {
3381cdf0e10cSrcweir             ULONG nBufLen = 0;
3382cdf0e10cSrcweir             pIMEData->mpGetConversionString( hIMI, IMR_CONV_CONVERSIONSTRING, 0, &nBufLen );
3383cdf0e10cSrcweir             if ( nBufLen > 0 )
3384cdf0e10cSrcweir             {
3385cdf0e10cSrcweir /* !!! Wir bekommen derzeit nur falsche Daten steht der Cursor immer bei 0
3386cdf0e10cSrcweir                 ULONG nTempBufLen = sizeof( ULONG );
3387cdf0e10cSrcweir                 ULONG nCursorPos = 0;
3388cdf0e10cSrcweir                 pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORPOS, &nCursorPos, &nTempBufLen );
3389cdf0e10cSrcweir */
3390cdf0e10cSrcweir                 ULONG nCursorPos = 0;
3391cdf0e10cSrcweir 
3392cdf0e10cSrcweir                 SalExtTextInputPosEvent aEvt;
3393cdf0e10cSrcweir                 aEvt.mnTime         = WinQueryMsgTime( pFrame->mhAB );
3394cdf0e10cSrcweir                 aEvt.mnFirstPos     = nCursorPos;
3395cdf0e10cSrcweir                 aEvt.mnChars        = nBufLen-nCursorPos;
3396cdf0e10cSrcweir                 aEvt.mpPosAry       = new SalExtCharPos[aEvt.mnChars];
3397cdf0e10cSrcweir                 memset( aEvt.mpPosAry, 0, aEvt.mnChars*sizeof(SalExtCharPos) );
3398cdf0e10cSrcweir 
3399cdf0e10cSrcweir                 pFrame->CallCallback( SALEVENT_EXTTEXTINPUTPOS, (void*)&aEvt );
3400cdf0e10cSrcweir 
3401cdf0e10cSrcweir                 long nMinLeft   = aEvt.mpPosAry[0].mnX;
3402cdf0e10cSrcweir                 long nMinTop    = aEvt.mpPosAry[0].mnY;
3403cdf0e10cSrcweir                 long nMaxBottom = aEvt.mpPosAry[0].mnY+aEvt.mpPosAry[0].mnHeight;
3404cdf0e10cSrcweir                 long nMaxRight  = nMinLeft;
3405cdf0e10cSrcweir                 USHORT i = 0;
3406cdf0e10cSrcweir                 while ( i < aEvt.mnChars )
3407cdf0e10cSrcweir                 {
3408cdf0e10cSrcweir                     // Solange wir uns auf der gleichen Zeile bewegen,
3409cdf0e10cSrcweir                     // ermitteln wir die Rechteck-Grenzen
3410cdf0e10cSrcweir                     if ( !aEvt.mpPosAry[i].mnHeight ||
3411cdf0e10cSrcweir                          (aEvt.mpPosAry[i].mnY < nMaxBottom-1) )
3412cdf0e10cSrcweir                     {
3413cdf0e10cSrcweir                         if ( aEvt.mpPosAry[i].mnX < nMinLeft )
3414cdf0e10cSrcweir                             nMinLeft = aEvt.mpPosAry[i].mnX;
3415cdf0e10cSrcweir                         if ( aEvt.mpPosAry[i].mnX+aEvt.mpPosAry[0].mnWidth > nMaxRight )
3416cdf0e10cSrcweir                             nMaxRight = aEvt.mpPosAry[i].mnX+aEvt.mpPosAry[0].mnWidth;
3417cdf0e10cSrcweir                         if ( aEvt.mpPosAry[i].mnY < nMinTop )
3418cdf0e10cSrcweir                             nMinTop = aEvt.mpPosAry[i].mnY;
3419cdf0e10cSrcweir                         i++;
3420cdf0e10cSrcweir                     }
3421cdf0e10cSrcweir                     else
3422cdf0e10cSrcweir                         break;
3423cdf0e10cSrcweir                 }
3424cdf0e10cSrcweir 
3425cdf0e10cSrcweir                 CANDIDATEPOS aForm;
3426cdf0e10cSrcweir                 aForm.ulIndex           = 0;
3427cdf0e10cSrcweir                 aForm.ulStyle           = CPS_EXCLUDE;
3428cdf0e10cSrcweir                 aForm.ptCurrentPos.x    = aEvt.mpPosAry[0].mnX;
3429cdf0e10cSrcweir                 aForm.ptCurrentPos.y    = pFrame->mnHeight - (nMaxBottom+1) - 1;
3430cdf0e10cSrcweir                 aForm.rcArea.xLeft      = nMinLeft;
3431cdf0e10cSrcweir                 aForm.rcArea.yBottom    = pFrame->mnHeight - nMaxBottom - 1;
3432cdf0e10cSrcweir                 aForm.rcArea.xRight     = nMaxRight+1;
3433cdf0e10cSrcweir                 aForm.rcArea.yTop       = pFrame->mnHeight - nMinTop - 1;
3434cdf0e10cSrcweir                 pIMEData->mpSetCandidateWin( hIMI, &aForm );
3435cdf0e10cSrcweir 
3436cdf0e10cSrcweir                 delete aEvt.mpPosAry;
3437cdf0e10cSrcweir             }
3438cdf0e10cSrcweir 
3439cdf0e10cSrcweir             pIMEData->mpReleaseIME( hWnd, hIMI );
3440cdf0e10cSrcweir         }
3441cdf0e10cSrcweir     }
3442cdf0e10cSrcweir }
3443cdf0e10cSrcweir 
3444cdf0e10cSrcweir // -----------------------------------------------------------------------
3445cdf0e10cSrcweir 
ImplHandleIMECloseCandidate(Os2SalFrame * pFrame)3446cdf0e10cSrcweir inline void ImplHandleIMECloseCandidate( Os2SalFrame* pFrame )
3447cdf0e10cSrcweir {
3448cdf0e10cSrcweir     pFrame->mbCandidateMode = FALSE;
3449cdf0e10cSrcweir }
3450cdf0e10cSrcweir 
3451cdf0e10cSrcweir #endif
3452cdf0e10cSrcweir 
3453cdf0e10cSrcweir // -----------------------------------------------------------------------
3454cdf0e10cSrcweir 
SalFrameWndProc(HWND hWnd,ULONG nMsg,MPARAM nMP1,MPARAM nMP2)3455cdf0e10cSrcweir MRESULT EXPENTRY SalFrameWndProc( HWND hWnd, ULONG nMsg,
3456cdf0e10cSrcweir                                   MPARAM nMP1, MPARAM nMP2 )
3457cdf0e10cSrcweir {
3458cdf0e10cSrcweir     Os2SalFrame*   	pFrame      = (Os2SalFrame*)GetWindowPtr( hWnd );
3459cdf0e10cSrcweir     MRESULT     	nRet        = (MRESULT)0;
3460fc9fd3f1SPedro Giffuni     sal_Bool        	bDef     	= TRUE;
3461cdf0e10cSrcweir 	bool 			bCheckTimers= false;
3462cdf0e10cSrcweir 
3463cdf0e10cSrcweir #if OSL_DEBUG_LEVEL>10
3464cdf0e10cSrcweir     if (nMsg!=WM_TIMER && nMsg!=WM_MOUSEMOVE)
3465cdf0e10cSrcweir         debug_printf( "SalFrameWndProc hWnd 0x%x nMsg 0x%x\n", hWnd, nMsg);
3466cdf0e10cSrcweir #endif
3467cdf0e10cSrcweir 
3468cdf0e10cSrcweir     switch( nMsg )
3469cdf0e10cSrcweir     {
3470cdf0e10cSrcweir         case WM_MOUSEMOVE:
3471cdf0e10cSrcweir         case WM_BUTTON1DOWN:
3472cdf0e10cSrcweir         case WM_BUTTON2DOWN:
3473cdf0e10cSrcweir         case WM_BUTTON3DOWN:
3474cdf0e10cSrcweir         case WM_BUTTON1DBLCLK:
3475cdf0e10cSrcweir         case WM_BUTTON2DBLCLK:
3476cdf0e10cSrcweir         case WM_BUTTON3DBLCLK:
3477cdf0e10cSrcweir         case WM_BUTTON1UP:
3478cdf0e10cSrcweir         case WM_BUTTON2UP:
3479cdf0e10cSrcweir         case WM_BUTTON3UP:
3480cdf0e10cSrcweir         case SAL_MSG_MOUSELEAVE:
3481cdf0e10cSrcweir             // ButtonUp/Down nie an die WinDefWindowProc weiterleiten, weil sonst
3482cdf0e10cSrcweir             // die Message an den Owner weitergeleitet wird
3483cdf0e10cSrcweir             ImplSalYieldMutexAcquireWithWait();
3484cdf0e10cSrcweir             bDef = !ImplHandleMouseMsg( hWnd, nMsg, nMP1, nMP2 );
3485cdf0e10cSrcweir             ImplSalYieldMutexRelease();
3486cdf0e10cSrcweir             break;
3487cdf0e10cSrcweir 
3488cdf0e10cSrcweir         case WM_CHAR:
3489cdf0e10cSrcweir             if ( pFrame->mbConversionMode )
3490cdf0e10cSrcweir                 bDef = FALSE;
3491cdf0e10cSrcweir             else
3492cdf0e10cSrcweir                 bDef = !ImplHandleKeyMsg( hWnd, nMsg, nMP1, nMP2 );
3493cdf0e10cSrcweir             break;
3494cdf0e10cSrcweir 
3495cdf0e10cSrcweir         case WM_ERASEBACKGROUND:
3496cdf0e10cSrcweir             nRet = (MRESULT)FALSE;
3497cdf0e10cSrcweir             bDef = FALSE;
3498cdf0e10cSrcweir             break;
3499cdf0e10cSrcweir 
3500cdf0e10cSrcweir         case WM_PAINT:
3501cdf0e10cSrcweir             bCheckTimers = ImplHandlePaintMsg( hWnd );
3502cdf0e10cSrcweir             bDef = FALSE;
3503cdf0e10cSrcweir             break;
3504cdf0e10cSrcweir         case SAL_MSG_POSTPAINT:
3505cdf0e10cSrcweir         	ImplHandlePaintMsg2( hWnd, (RECTL*)nMP1 );
3506cdf0e10cSrcweir 			bCheckTimers = true;
3507cdf0e10cSrcweir         	bDef = FALSE;
3508cdf0e10cSrcweir 			break;
3509cdf0e10cSrcweir 
3510cdf0e10cSrcweir         case WM_MOVE:
3511cdf0e10cSrcweir         case SAL_MSG_POSTMOVE:
3512cdf0e10cSrcweir             ImplHandleMoveMsg( hWnd );
3513cdf0e10cSrcweir             bDef = FALSE;
3514cdf0e10cSrcweir             break;
3515cdf0e10cSrcweir 
3516cdf0e10cSrcweir         case WM_SIZE:
3517cdf0e10cSrcweir             if ( ImplSalYieldMutexTryToAcquire() )
3518cdf0e10cSrcweir             {
3519cdf0e10cSrcweir                 ImplHandleSizeMsg( hWnd, nMP2 );
3520cdf0e10cSrcweir                 ImplSalYieldMutexRelease();
3521cdf0e10cSrcweir             }
3522cdf0e10cSrcweir             else
3523cdf0e10cSrcweir                 WinPostMsg( hWnd, SAL_MSG_POSTSIZE, nMP1, nMP2 );
3524cdf0e10cSrcweir             break;
3525cdf0e10cSrcweir         case SAL_MSG_POSTSIZE:
3526cdf0e10cSrcweir             ImplHandleSizeMsg( hWnd, nMP2 );
3527cdf0e10cSrcweir             break;
3528cdf0e10cSrcweir 		case WM_MINMAXFRAME:
3529cdf0e10cSrcweir             if ( ImplSalYieldMutexTryToAcquire() )
3530cdf0e10cSrcweir             {
3531cdf0e10cSrcweir 				PSWP pswp = (PSWP) nMP1;
3532cdf0e10cSrcweir                 ImplHandleSizeMsg( hWnd, MPFROM2SHORT( pswp->cx, pswp->cy) );
3533cdf0e10cSrcweir                 ImplSalYieldMutexRelease();
3534cdf0e10cSrcweir             }
3535cdf0e10cSrcweir             else
3536cdf0e10cSrcweir                 WinPostMsg( hWnd, SAL_MSG_POSTSIZE, 0, nMP2 );
3537cdf0e10cSrcweir 			break;
3538cdf0e10cSrcweir 
3539cdf0e10cSrcweir         case WM_CALCVALIDRECTS:
3540cdf0e10cSrcweir             return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
3541cdf0e10cSrcweir 
3542cdf0e10cSrcweir         case WM_SETFOCUS:
3543cdf0e10cSrcweir             if ( ImplSalYieldMutexTryToAcquire() )
3544cdf0e10cSrcweir             {
3545cdf0e10cSrcweir                 ImplHandleFocusMsg( pFrame, nMP2 );
3546cdf0e10cSrcweir                 ImplSalYieldMutexRelease();
3547cdf0e10cSrcweir             }
3548cdf0e10cSrcweir             else
3549cdf0e10cSrcweir                 WinPostMsg( hWnd, SAL_MSG_POSTFOCUS, 0, nMP2 );
3550cdf0e10cSrcweir             break;
3551cdf0e10cSrcweir         case SAL_MSG_POSTFOCUS:
3552cdf0e10cSrcweir             ImplHandleFocusMsg( pFrame, nMP2 );
3553cdf0e10cSrcweir             break;
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir         case WM_TRANSLATEACCEL:
3556cdf0e10cSrcweir             {
3557cdf0e10cSrcweir             // Da uns OS/2 zu viele Tasten abfaegnt, unternehmen wir etwas,
3558cdf0e10cSrcweir             // damit wir Shift+F1, Shift+F10 und Shift+Enter bekommen
3559cdf0e10cSrcweir             PQMSG   pMsg        = (PQMSG)nMP1;
3560cdf0e10cSrcweir             USHORT  nKeyFlags   = SHORT1FROMMP( pMsg->mp1 );
3561cdf0e10cSrcweir             USHORT  nKeyCode    = (UCHAR)SHORT2FROMMP( pMsg->mp2 );
3562cdf0e10cSrcweir 
3563cdf0e10cSrcweir             if ( !(nKeyFlags & KC_KEYUP) && (nKeyFlags & KC_VIRTUALKEY) &&
3564cdf0e10cSrcweir                  (nKeyFlags & KC_SHIFT) && (nKeyCode != VK_ESC) )
3565cdf0e10cSrcweir                 return (MRESULT)FALSE;
3566cdf0e10cSrcweir 
3567cdf0e10cSrcweir             if ( nKeyCode == VK_F1 )
3568cdf0e10cSrcweir                 return (MRESULT)FALSE;
3569cdf0e10cSrcweir             }
3570cdf0e10cSrcweir             break;
3571cdf0e10cSrcweir 
3572cdf0e10cSrcweir         case WM_CREATE:
3573cdf0e10cSrcweir             {
3574cdf0e10cSrcweir 				HWND hWndFrame = WinQueryWindow(hWnd, QW_PARENT);
3575cdf0e10cSrcweir 				if (hWndFrame == 0)
3576cdf0e10cSrcweir 					debug_printf(" WARNING NULL FRAME!!\n");
3577cdf0e10cSrcweir 				SalData* pSalData = GetSalData();
3578cdf0e10cSrcweir 				// Window-Instanz am Windowhandle speichern
3579cdf0e10cSrcweir 				pFrame = pSalData->mpCreateFrame;
3580cdf0e10cSrcweir 				pSalData->mpCreateFrame = NULL;
3581cdf0e10cSrcweir 				SetWindowPtr( hWnd, pFrame );
3582cdf0e10cSrcweir 				SetWindowPtr( hWndFrame, pFrame);
3583cdf0e10cSrcweir 				// HWND schon hier setzen, da schon auf den Instanzdaten
3584cdf0e10cSrcweir 				// gearbeitet werden kann, wenn Messages waehrend
3585cdf0e10cSrcweir 				// CreateWindow() gesendet werden
3586cdf0e10cSrcweir 				pFrame->mhWndClient = hWnd;
3587cdf0e10cSrcweir 				pFrame->mhWndFrame = hWndFrame;
3588cdf0e10cSrcweir 				pFrame->maSysData.hWnd = hWnd;
3589cdf0e10cSrcweir             }
3590cdf0e10cSrcweir             break;
3591cdf0e10cSrcweir 
3592cdf0e10cSrcweir         case WM_CLOSE:
3593cdf0e10cSrcweir             ImplHandleCloseMsg( hWnd );
3594cdf0e10cSrcweir             bDef = FALSE;
3595cdf0e10cSrcweir             break;
3596cdf0e10cSrcweir 
3597cdf0e10cSrcweir         case WM_SYSVALUECHANGED:
3598cdf0e10cSrcweir             if ( pFrame->mbFullScreen )
3599cdf0e10cSrcweir                 ImplSalFrameFullScreenPos( pFrame );
3600cdf0e10cSrcweir             // kein break, da der Rest auch noch verarbeitet werden soll
3601cdf0e10cSrcweir         case PL_ALTERED:
3602cdf0e10cSrcweir         case WM_SYSCOLORCHANGE:
3603cdf0e10cSrcweir             ImplSalYieldMutexAcquire();
3604cdf0e10cSrcweir             pFrame->CallCallback( SALEVENT_SETTINGSCHANGED, 0 );
3605cdf0e10cSrcweir             ImplSalYieldMutexRelease();
3606cdf0e10cSrcweir             break;
3607cdf0e10cSrcweir 
3608cdf0e10cSrcweir         case SAL_MSG_USEREVENT:
3609cdf0e10cSrcweir             ImplHandleUserEvent( hWnd, nMP2 );
3610cdf0e10cSrcweir             bDef = FALSE;
3611cdf0e10cSrcweir             break;
3612cdf0e10cSrcweir         case SAL_MSG_TOTOP:
3613cdf0e10cSrcweir             ImplSalToTop( hWnd, (ULONG)nMP1 );
3614cdf0e10cSrcweir             bDef = FALSE;
3615cdf0e10cSrcweir             break;
3616cdf0e10cSrcweir         case SAL_MSG_SHOW:
3617cdf0e10cSrcweir             ImplSalShow( hWnd, (ULONG)nMP1, (ULONG)nMP2 );
3618cdf0e10cSrcweir             bDef = FALSE;
3619cdf0e10cSrcweir             break;
3620cdf0e10cSrcweir 
3621cdf0e10cSrcweir 		case WM_KBDLAYERCHANGED:
3622cdf0e10cSrcweir 			debug_printf("hWnd 0x%08x WM_KBDLAYERCHANGED\n", hWnd);
3623cdf0e10cSrcweir             ImplHandleInputLangChange( hWnd );
3624cdf0e10cSrcweir             break;
3625cdf0e10cSrcweir 
3626cdf0e10cSrcweir 		case WM_HSCROLL:
3627cdf0e10cSrcweir 		case WM_VSCROLL:
3628cdf0e10cSrcweir 			ImplHandleWheelMsg( hWnd, nMsg, nMP1, nMP2 );
3629cdf0e10cSrcweir             bDef = FALSE;
3630cdf0e10cSrcweir 			break;
3631cdf0e10cSrcweir 
3632cdf0e10cSrcweir         case WM_COMMAND:
3633cdf0e10cSrcweir         case SAL_MSG_SYSPROCESSMENU:
3634cdf0e10cSrcweir             if ( SalImplHandleProcessMenu( pFrame, nMsg, nMP1, nMP2 ) )
3635cdf0e10cSrcweir             {
3636cdf0e10cSrcweir                 bDef = FALSE;
3637cdf0e10cSrcweir                 nRet = (MRESULT)1;
3638cdf0e10cSrcweir             }
3639cdf0e10cSrcweir             break;
3640cdf0e10cSrcweir 
3641cdf0e10cSrcweir #ifdef ENABLE_IME
3642cdf0e10cSrcweir         case WM_IMEREQUEST:
3643cdf0e10cSrcweir             if ( (ULONG)nMP1 == IMR_CONVRESULT )
3644cdf0e10cSrcweir             {
3645cdf0e10cSrcweir                 if ( pFrame->mbHandleIME )
3646cdf0e10cSrcweir                 {
3647cdf0e10cSrcweir                     // Nur im Conversionmodus akzeptieren wir den IME-Input
3648cdf0e10cSrcweir                     if ( pFrame->mbConversionMode )
3649cdf0e10cSrcweir                     {
3650cdf0e10cSrcweir                         ImplSalYieldMutexAcquire();
3651cdf0e10cSrcweir                         if ( ImplHandleIMEConversion( pFrame, nMP2 ) )
3652cdf0e10cSrcweir                         {
3653cdf0e10cSrcweir                             bDef = FALSE;
3654cdf0e10cSrcweir                             nRet = (MRESULT)TRUE;
3655cdf0e10cSrcweir                         }
3656cdf0e10cSrcweir                         ImplSalYieldMutexRelease();
3657cdf0e10cSrcweir                     }
3658cdf0e10cSrcweir                 }
3659cdf0e10cSrcweir             }
3660cdf0e10cSrcweir             else if ( (ULONG)nMP1 == IMR_CANDIDATE )
3661cdf0e10cSrcweir             {
3662cdf0e10cSrcweir                 if ( pFrame->mbHandleIME )
3663cdf0e10cSrcweir                 {
3664cdf0e10cSrcweir                     ImplSalYieldMutexAcquire();
3665cdf0e10cSrcweir                     if ( (ULONG)nMP2 & IMR_CANDIDATE_SHOW )
3666cdf0e10cSrcweir                         ImplHandleIMEOpenCandidate( pFrame );
3667cdf0e10cSrcweir                     else if ( (ULONG)nMP2 & IMR_CANDIDATE_HIDE )
3668cdf0e10cSrcweir                         ImplHandleIMECloseCandidate( pFrame );
3669cdf0e10cSrcweir                     ImplSalYieldMutexRelease();
3670cdf0e10cSrcweir                 }
3671cdf0e10cSrcweir             }
3672cdf0e10cSrcweir             break;
3673cdf0e10cSrcweir 
3674cdf0e10cSrcweir         case WM_IMENOTIFY:
3675cdf0e10cSrcweir             if ( (ULONG)nMP1 == IMN_STARTCONVERSION )
3676cdf0e10cSrcweir             {
3677cdf0e10cSrcweir                 ImplSalYieldMutexAcquire();
3678cdf0e10cSrcweir                 if ( ImplHandleIMEStartConversion( pFrame ) )
3679cdf0e10cSrcweir                 {
3680cdf0e10cSrcweir                     bDef = FALSE;
3681cdf0e10cSrcweir                     nRet = (MRESULT)TRUE;
3682cdf0e10cSrcweir                 }
3683cdf0e10cSrcweir                 ImplSalYieldMutexRelease();
3684cdf0e10cSrcweir             }
3685cdf0e10cSrcweir             else if ( (ULONG)nMP1 == IMN_ENDCONVERSION )
3686cdf0e10cSrcweir             {
3687cdf0e10cSrcweir                 if ( pFrame->mbHandleIME )
3688cdf0e10cSrcweir                 {
3689cdf0e10cSrcweir                     ImplSalYieldMutexAcquire();
3690cdf0e10cSrcweir                     if ( ImplHandleIMEEndConversion( pFrame ) )
3691cdf0e10cSrcweir                     {
3692cdf0e10cSrcweir                         bDef = FALSE;
3693cdf0e10cSrcweir                         nRet = (MRESULT)TRUE;
3694cdf0e10cSrcweir                     }
3695cdf0e10cSrcweir                     ImplSalYieldMutexRelease();
3696cdf0e10cSrcweir                 }
3697cdf0e10cSrcweir             }
3698cdf0e10cSrcweir             break;
3699cdf0e10cSrcweir #endif
3700cdf0e10cSrcweir     }
3701cdf0e10cSrcweir 
3702cdf0e10cSrcweir 	if( bCheckTimers )
3703cdf0e10cSrcweir 	{
3704cdf0e10cSrcweir 		SalData* pSalData = GetSalData();
3705cdf0e10cSrcweir 		if( pSalData->mnNextTimerTime )
3706cdf0e10cSrcweir 		{
3707cdf0e10cSrcweir 			ULONG nCurTime;
3708cdf0e10cSrcweir 			DosQuerySysInfo( QSV_MS_COUNT, QSV_MS_COUNT, (PVOID)&nCurTime, sizeof(ULONG));
3709cdf0e10cSrcweir 			if( pSalData->mnNextTimerTime < nCurTime )
3710cdf0e10cSrcweir 			{
3711cdf0e10cSrcweir 				QMSG aMsg;
3712cdf0e10cSrcweir 				if (!WinPeekMsg( pFrame->mhAB, &aMsg, 0, WM_PAINT, WM_PAINT, PM_NOREMOVE ) )
3713cdf0e10cSrcweir 					WinPostMsg( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_POSTTIMER, 0, (MPARAM)nCurTime );
3714cdf0e10cSrcweir 			}
3715cdf0e10cSrcweir 		}
3716cdf0e10cSrcweir 	}
3717cdf0e10cSrcweir 
3718cdf0e10cSrcweir     if ( bDef )
3719cdf0e10cSrcweir         nRet = WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 );
3720cdf0e10cSrcweir 
3721cdf0e10cSrcweir     return nRet;
3722cdf0e10cSrcweir }
3723cdf0e10cSrcweir 
3724cdf0e10cSrcweir // -----------------------------------------------------------------------
3725cdf0e10cSrcweir 
ResetClipRegion()3726cdf0e10cSrcweir void Os2SalFrame::ResetClipRegion()
3727cdf0e10cSrcweir {
3728cdf0e10cSrcweir }
3729cdf0e10cSrcweir 
BeginSetClipRegion(ULONG)3730cdf0e10cSrcweir void Os2SalFrame::BeginSetClipRegion( ULONG )
3731cdf0e10cSrcweir {
3732cdf0e10cSrcweir }
3733cdf0e10cSrcweir 
UnionClipRegion(long,long,long,long)3734cdf0e10cSrcweir void Os2SalFrame::UnionClipRegion( long, long, long, long )
3735cdf0e10cSrcweir {
3736cdf0e10cSrcweir }
3737cdf0e10cSrcweir 
EndSetClipRegion()3738cdf0e10cSrcweir void Os2SalFrame::EndSetClipRegion()
3739cdf0e10cSrcweir {
3740cdf0e10cSrcweir }
3741cdf0e10cSrcweir 
3742cdf0e10cSrcweir // -----------------------------------------------------------------------
3743cdf0e10cSrcweir 
SalFrameSubClassWndProc(HWND hWnd,ULONG nMsg,MPARAM nMP1,MPARAM nMP2)3744cdf0e10cSrcweir MRESULT EXPENTRY SalFrameSubClassWndProc( HWND hWnd, ULONG nMsg,
3745cdf0e10cSrcweir                                   MPARAM nMP1, MPARAM nMP2 )
3746cdf0e10cSrcweir {
3747cdf0e10cSrcweir     MRESULT mReturn = 0L;
3748cdf0e10cSrcweir 
3749cdf0e10cSrcweir     // ticket#124 min size of 132 px is too much
3750cdf0e10cSrcweir     if (nMsg == WM_QUERYTRACKINFO) {
3751cdf0e10cSrcweir 	PTRACKINFO pti;
3752cdf0e10cSrcweir 	// first, let PM initialize TRACKINFO
3753cdf0e10cSrcweir 	mReturn = aSalShlData.mpFrameProc( hWnd, nMsg, nMP1, nMP2 );
3754cdf0e10cSrcweir 	// now change default min size
3755cdf0e10cSrcweir 	pti = (PTRACKINFO) nMP2;
3756cdf0e10cSrcweir 	pti->ptlMinTrackSize.x = 64L;
3757cdf0e10cSrcweir 	// now return to PM
3758cdf0e10cSrcweir 	return mReturn;
3759cdf0e10cSrcweir     }
3760cdf0e10cSrcweir 
3761cdf0e10cSrcweir     return aSalShlData.mpFrameProc( hWnd, nMsg, nMP1, nMP2 );
3762cdf0e10cSrcweir }
3763cdf0e10cSrcweir 
3764cdf0e10cSrcweir // -----------------------------------------------------------------------
3765