1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salframe.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
38 // =======================================================================
40 #define _SV_SALFRAME_CXX
43 #include <tools/debug.hxx>
46 #define private public
48 #ifndef _SV_SALLANG_HXX
49 #include <sallang.hxx>
51 #ifndef _SV_SALIDS_HRC
54 #include <saldata.hxx>
58 #include <vcl/timer.hxx>
59 #include <vcl/settings.hxx>
60 #ifndef _SV_KEYCOES_HXX
61 #include <vcl/keycodes.hxx>
65 #if OSL_DEBUG_LEVEL>10
66 extern "C" int debug_printf(const char *f
, ...);
68 static BOOL _bCapture
;
71 #define debug_printf( ...) { 1; }
74 // =======================================================================
76 HPOINTER
ImplLoadPointer( ULONG nId
);
78 static void SetMaximizedFrameGeometry( HWND hWnd
, Os2SalFrame
* pFrame
);
79 static void UpdateFrameGeometry( HWND hWnd
, Os2SalFrame
* pFrame
);
80 static void ImplSalCalcFrameSize( HWND hWnd
,
81 LONG
& nFrameX
, LONG
& nFrameY
, LONG
& nCaptionY
);
82 static void ImplSalCalcFrameSize( const Os2SalFrame
* pFrame
,
83 LONG
& nFrameX
, LONG
& nFrameY
, LONG
& nCaptionY
);
84 MRESULT EXPENTRY
SalFrameSubClassWndProc( HWND hWnd
, ULONG nMsg
,
85 MPARAM nMP1
, MPARAM nMP2
);
87 // =======================================================================
89 static LanguageType eImplKeyboardLanguage
= LANGUAGE_DONTKNOW
;
90 BOOL
Os2SalFrame::mbInReparent
= FALSE
;
91 ULONG
Os2SalFrame::mnInputLang
= 0;
93 // =======================================================================
96 #define SWP_CENTER (SWP_NOAUTOCLOSE<<4)
97 #define SWP_SHOWMAXIMIZED (SWP_ACTIVATE | SWP_SHOW | SWP_MAXIMIZE)
98 #define SWP_SHOWMINIMIZED (SWP_ACTIVATE | SWP_SHOW | SWP_MINIMIZE)
99 #define SWP_SHOWNORMAL (SWP_ACTIVATE | SWP_SHOW | SWP_RESTORE)
101 static LONG nScreenHeight
= WinQuerySysValue( HWND_DESKTOP
, SV_CYSCREEN
);
102 static LONG nScreenWidth
= WinQuerySysValue( HWND_DESKTOP
, SV_CXSCREEN
);
104 BOOL APIENTRY
_WinQueryWindowRect( HWND hwnd
, PRECTL prclDest
)
106 BOOL rc
= WinQueryWindowRect( hwnd
, prclDest
);
107 ULONG tmp
= prclDest
->yBottom
;
108 prclDest
->yBottom
= prclDest
->yTop
;
109 prclDest
->yTop
= tmp
;
113 BOOL APIENTRY
_WinQueryPointerPos (HWND hwndDesktop
, PPOINTL pptl
)
115 BOOL rc
= WinQueryPointerPos( hwndDesktop
, pptl
);
116 pptl
->y
= nScreenHeight
- pptl
->y
;
120 BOOL APIENTRY
_WinQueryWindowPos( Os2SalFrame
* pFrame
, PSWP pswp
)
123 BOOL rc
= WinQueryWindowPos( pFrame
->mhWndFrame
, pswp
);
125 #if OSL_DEBUG_LEVEL>1
126 debug_printf( "> WinQueryWindowPos hwnd %x at %d,%d (%dx%d)\n",
127 pFrame
->mhWndFrame
, pswp
->x
, pswp
->y
, pswp
->cx
, pswp
->cy
);
130 Os2SalFrame
* pParentFrame
= pFrame
->mpParentFrame
;
132 //YD adjust to owner coordinates
135 POINTL ptlOwner
= {0};
137 // coords are relative to screen, map to parent frame client area
138 ptlOwner
.x
= pswp
->x
;
139 ptlOwner
.y
= pswp
->y
;
140 WinMapWindowPoints( HWND_DESKTOP
, pParentFrame
->mhWndClient
, &ptlOwner
, 1);
141 pswp
->x
= ptlOwner
.x
;
142 pswp
->y
= ptlOwner
.y
;
143 // get parent client area size
144 WinQueryWindowPos( pParentFrame
->mhWndClient
, &swpOwner
);
147 // no owner info, use DESKTOP????
148 swpOwner
.cx
= nScreenWidth
;
149 swpOwner
.cy
= nScreenHeight
;
152 // invert Y coordinate
153 pswp
->y
= swpOwner
.cy
- (pswp
->y
+ pswp
->cy
);
155 #if OSL_DEBUG_LEVEL>1
156 debug_printf( "< WinQueryWindowPos hwnd %x at %d,%d (%dx%d)\n",
157 pFrame
->mhWndFrame
, pswp
->x
, pswp
->y
, pswp
->cx
, pswp
->cy
);
162 BOOL APIENTRY
_WinSetWindowPos( Os2SalFrame
* pFrame
, HWND hwndInsertBehind
, LONG x
, LONG y
,
163 LONG cx
, LONG cy
, ULONG fl
)
166 POINTL ptlOwner
= {0};
169 #if OSL_DEBUG_LEVEL>1
170 debug_printf( ">WinSetWindowPos hwnd %x at %d,%d (%dx%d) fl 0x%08x\n",
171 pFrame
->mhWndFrame
, x
, y
, cx
, cy
, fl
);
174 // first resize window if requested
175 if ( (fl
& SWP_SIZE
) ) {
176 ULONG flag
= SWP_SIZE
;
178 LONG frameFrameX
, frameFrameY
, frameCaptionY
;
180 ImplSalCalcFrameSize( pFrame
, frameFrameX
, frameFrameY
, frameCaptionY
);
181 // if we change y size, we need to move the window down
182 // because os2 window origin is lower left corner
183 if (pFrame
->maGeometry
.nHeight
!= cy
) {
185 WinQueryWindowPos( pFrame
->mhWndFrame
, &aSWP
);
187 nY
= aSWP
.y
- (cy
+ 2*frameFrameY
+ frameCaptionY
- aSWP
.cy
);
190 WinSetWindowPos( pFrame
->mhWndFrame
, NULL
, nX
, nY
,
191 cx
+2*frameFrameX
, cy
+2*frameFrameY
+frameCaptionY
, flag
);
194 else // otherwise get current size
197 WinQueryWindowPos( pFrame
->mhWndClient
, &swp
);
202 // get parent window handle
203 Os2SalFrame
* pParentFrame
= pFrame
->mpParentFrame
;
205 // use desktop if parent is not defined
206 hParent
= pParentFrame
? pParentFrame
->mhWndClient
: HWND_DESKTOP
;
207 // if parent is not visible, use desktop as reference
208 hParent
= WinIsWindowVisible( hParent
) ? hParent
: HWND_DESKTOP
;
210 WinQueryWindowPos( hParent
, &swpOwner
);
212 //YD adjust to owner coordinates only when moving and not centering
213 //if (!(fl & SWP_CENTER) && (fl & SWP_MOVE))
217 // if SWP_CENTER is specified, change position to parent center
218 if (fl
& SWP_CENTER
) {
219 ptlOwner
.x
= (swpOwner
.cx
- cx
) / 2;
220 ptlOwner
.y
= (swpOwner
.cy
- cy
) / 2;
221 #if OSL_DEBUG_LEVEL>0
222 debug_printf( "_WinSetWindowPos SWP_CENTER\n");
224 fl
= fl
& ~SWP_CENTER
;
226 // coords are relative to parent frame client area, map to screen
227 // map Y to OS/2 system coordinates
229 ptlOwner
.y
= swpOwner
.cy
- (y
+ cy
);
231 #if OSL_DEBUG_LEVEL>0
232 debug_printf( "_WinSetWindowPos owner 0x%x at %d,%d (%dx%d) OS2\n",
233 hParent
, ptlOwner
.x
, ptlOwner
.y
, swpOwner
.cx
, swpOwner
.cy
);
236 // map from client area to screen
237 WinMapWindowPoints( hParent
, HWND_DESKTOP
, &ptlOwner
, 1);
241 #if OSL_DEBUG_LEVEL>0
242 debug_printf( "_WinSetWindowPos owner 0x%x at %d,%d (%dx%d) MAPPED OS2\n",
243 hParent
, ptlOwner
.x
, ptlOwner
.y
, swpOwner
.cx
, swpOwner
.cy
);
247 #if OSL_DEBUG_LEVEL>0
248 debug_printf( "<WinSetWindowPos hwnd %x at %d,%d (%dx%d) fl=%x\n",
249 pFrame
->mhWndFrame
, x
, y
, cx
, cy
, fl
);
251 return WinSetWindowPos( pFrame
->mhWndFrame
, hwndInsertBehind
, x
, y
, 0, 0, fl
);
254 // =======================================================================
256 #if OSL_DEBUG_LEVEL > 0
257 static void dumpWindowInfo( char* fnc
, HWND hwnd
)
264 _WinQueryWindowPos( hwnd
, &aSWP
);
266 WinQueryWindowText(hwnd
, sizeof(szTitle
), szTitle
);
267 debug_printf( "%s: window %08x at %d,%d (size %dx%d) '%s'\n", fnc
, hwnd
,
268 aSWP
.x
, aSWP
.y
, aSWP
.cx
, aSWP
.cy
, szTitle
);
269 hwnd2
= WinQueryWindow(hwnd
, QW_PARENT
);
270 _WinQueryWindowPos( hwnd2
, &aSWP
);
272 WinQueryWindowText(hwnd2
, sizeof(szTitle
), szTitle
);
273 debug_printf( "%s: parent %08x at %d,%d (size %dx%d) '%s'\n", fnc
, hwnd2
,
274 aSWP
.x
, aSWP
.y
, aSWP
.cx
, aSWP
.cy
, szTitle
);
275 hwnd2
= WinQueryWindow(hwnd
, QW_OWNER
);
276 _WinQueryWindowPos( hwnd2
, &aSWP
);
278 WinQueryWindowText(hwnd2
, sizeof(szTitle
), szTitle
);
279 debug_printf( "%s: owner %08x at %d,%d (size %dx%d) '%s'\n", fnc
, hwnd2
,
280 aSWP
.x
, aSWP
.y
, aSWP
.cx
, aSWP
.cy
, szTitle
);
285 // =======================================================================
289 struct ImplSalIMEProc
295 #define SAL_IME_PROC_COUNT 12
297 // -----------------------------------------------------------------------
299 static SalIMEData
* GetSalIMEData()
301 SalData
* pSalData
= GetSalData();
303 if ( !pSalData
->mbIMEInit
)
305 pSalData
->mbIMEInit
= TRUE
;
308 if ( 0 == DosLoadModule( NULL
, 0, "OS2IM", &hMod
) )
310 SalIMEData
* pIMEData
= new SalIMEData
;
312 ImplSalIMEProc aProcAry
[SAL_IME_PROC_COUNT
] =
314 { 101, (PFN
*)&(pIMEData
->mpAssocIME
) },
315 { 104, (PFN
*)&(pIMEData
->mpGetIME
) },
316 { 106, (PFN
*)&(pIMEData
->mpReleaseIME
) },
317 { 117, (PFN
*)&(pIMEData
->mpSetConversionFont
) },
318 { 144, (PFN
*)&(pIMEData
->mpSetConversionFontSize
) },
319 { 118, (PFN
*)&(pIMEData
->mpGetConversionString
) },
320 { 122, (PFN
*)&(pIMEData
->mpGetResultString
) },
321 { 115, (PFN
*)&(pIMEData
->mpSetCandidateWin
) },
322 { 130, (PFN
*)&(pIMEData
->mpQueryIMEProperty
) },
323 { 131, (PFN
*)&(pIMEData
->mpRequestIME
) },
324 { 128, (PFN
*)&(pIMEData
->mpSetIMEMode
) },
325 { 127, (PFN
*)&(pIMEData
->mpQueryIMEMode
) }
328 pIMEData
->mhModIME
= hMod
;
329 for ( USHORT i
= 0; i
< SAL_IME_PROC_COUNT
; i
++ )
331 if ( 0 != DosQueryProcAddr( pIMEData
->mhModIME
, aProcAry
[i
].nOrd
, 0, aProcAry
[i
].pProc
) )
340 DosFreeModule( pIMEData
->mhModIME
);
344 pSalData
->mpIMEData
= pIMEData
;
348 return pSalData
->mpIMEData
;
351 // -----------------------------------------------------------------------
353 void ImplReleaseSALIMEData()
355 SalData
* pSalData
= GetSalData();
357 if ( pSalData
->mpIMEData
)
359 DosFreeModule( pSalData
->mpIMEData
->mhModIME
);
360 delete pSalData
->mpIMEData
;
366 // =======================================================================
368 static void ImplSaveFrameState( Os2SalFrame
* pFrame
)
370 // Position, Groesse und Status fuer GetWindowState() merken
371 if ( !pFrame
->mbFullScreen
)
374 BOOL bVisible
= WinIsWindowVisible( pFrame
->mhWndFrame
);
376 // Query actual state (maState uses screen coords)
377 WinQueryWindowPos( pFrame
->mhWndFrame
, &aSWP
);
379 if ( aSWP
.fl
& SWP_MINIMIZE
)
381 #if OSL_DEBUG_LEVEL>0
382 debug_printf("Os2SalFrame::GetWindowState %08x SAL_FRAMESTATE_MINIMIZED\n",
385 pFrame
->maState
.mnState
|= SAL_FRAMESTATE_MINIMIZED
;
387 pFrame
->mnShowState
= SWP_SHOWMAXIMIZED
;
389 else if ( aSWP
.fl
& SWP_MAXIMIZE
)
391 #if OSL_DEBUG_LEVEL>0
392 debug_printf("Os2SalFrame::GetWindowState %08x SAL_FRAMESTATE_MAXIMIZED\n",
395 pFrame
->maState
.mnState
&= ~SAL_FRAMESTATE_MINIMIZED
;
396 pFrame
->maState
.mnState
|= SAL_FRAMESTATE_MAXIMIZED
;
398 pFrame
->mnShowState
= SWP_SHOWMINIMIZED
;
399 pFrame
->mbRestoreMaximize
= TRUE
;
403 LONG nFrameX
, nFrameY
, nCaptionY
;
404 ImplSalCalcFrameSize( pFrame
, nFrameX
, nFrameY
, nCaptionY
);
405 // to be consistent with Unix, the frame state is without(!) decoration
406 long nTopDeco
= nFrameY
+ nCaptionY
;
407 long nLeftDeco
= nFrameX
;
408 long nBottomDeco
= nFrameY
;
409 long nRightDeco
= nFrameX
;
411 pFrame
->maState
.mnState
&= ~(SAL_FRAMESTATE_MINIMIZED
| SAL_FRAMESTATE_MAXIMIZED
);
412 // subtract decoration, store screen coords
413 pFrame
->maState
.mnX
= aSWP
.x
+nLeftDeco
;
414 pFrame
->maState
.mnY
= nScreenHeight
- (aSWP
.y
+aSWP
.cy
)+nTopDeco
;
415 pFrame
->maState
.mnWidth
= aSWP
.cx
-nLeftDeco
-nRightDeco
;
416 pFrame
->maState
.mnHeight
= aSWP
.cy
-nTopDeco
-nBottomDeco
;
417 #if OSL_DEBUG_LEVEL>0
418 debug_printf("Os2SalFrame::GetWindowState %08x (%dx%d) at %d,%d VCL\n",
420 pFrame
->maState
.mnWidth
,pFrame
->maState
.mnHeight
,pFrame
->maState
.mnX
,pFrame
->maState
.mnY
);
423 pFrame
->mnShowState
= SWP_SHOWNORMAL
;
424 pFrame
->mbRestoreMaximize
= FALSE
;
425 //debug_printf( "ImplSaveFrameState: window %08x at %d,%d (size %dx%d)\n",
426 // pFrame->mhWndFrame,
427 // pFrame->maState.mnX, pFrame->maState.mnY, pFrame->maState.mnWidth, pFrame->maState.mnHeight);
432 // -----------------------------------------------------------------------
434 long ImplSalCallbackDummy( void*, SalFrame
*, USHORT
, const void* )
439 // -----------------------------------------------------------------------
441 static void ImplSalCalcFrameSize( HWND hWnd
,
442 LONG
& nFrameX
, LONG
& nFrameY
, LONG
& nCaptionY
)
444 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
447 return ImplSalCalcFrameSize( pFrame
, nFrameX
, nFrameY
, nCaptionY
);
450 static void ImplSalCalcFrameSize( const Os2SalFrame
* pFrame
,
451 LONG
& nFrameX
, LONG
& nFrameY
, LONG
& nCaptionY
)
453 if ( pFrame
->mbSizeBorder
)
455 nFrameX
= WinQuerySysValue( HWND_DESKTOP
, SV_CXSIZEBORDER
);
456 nFrameY
= WinQuerySysValue( HWND_DESKTOP
, SV_CYSIZEBORDER
);
458 else if ( pFrame
->mbFixBorder
)
460 nFrameX
= WinQuerySysValue( HWND_DESKTOP
, SV_CXDLGFRAME
);
461 nFrameY
= WinQuerySysValue( HWND_DESKTOP
, SV_CYDLGFRAME
);
463 else if ( pFrame
->mbBorder
)
465 nFrameX
= WinQuerySysValue( HWND_DESKTOP
, SV_CXBORDER
);
466 nFrameY
= WinQuerySysValue( HWND_DESKTOP
, SV_CYBORDER
);
473 if ( pFrame
->mbCaption
)
474 nCaptionY
= WinQuerySysValue( HWND_DESKTOP
, SV_CYTITLEBAR
);
478 #if OSL_DEBUG_LEVEL>0
480 debug_printf("ImplSalCalcFrameSize 0x%08x x=%d y=%d t=%d\n", pFrame
->mhWndFrame
, nFrameX
, nFrameY
, nCaptionY
);
484 // -----------------------------------------------------------------------
486 static void ImplSalCalcFullScreenSize( const Os2SalFrame
* pFrame
,
487 LONG
& rX
, LONG
& rY
, LONG
& rDX
, LONG
& rDY
)
489 // set window to screen size
490 LONG nFrameX
, nFrameY
, nCaptionY
;
491 LONG rScreenDX
= WinQuerySysValue( HWND_DESKTOP
, SV_CXSCREEN
);
492 LONG rScreenDY
= WinQuerySysValue( HWND_DESKTOP
, SV_CYSCREEN
);
494 // Framegroessen berechnen
495 ImplSalCalcFrameSize( pFrame
, nFrameX
, nFrameY
, nCaptionY
);
498 rY
= -(nFrameY
+nCaptionY
);
499 rDX
= rScreenDX
+(nFrameX
*2);
500 rDY
= rScreenDY
+(nFrameY
*2)+nCaptionY
;
503 // -----------------------------------------------------------------------
505 static void ImplSalFrameFullScreenPos( Os2SalFrame
* pFrame
, BOOL bAlways
= FALSE
)
508 _WinQueryWindowPos( pFrame
, &aSWP
);
509 if ( bAlways
|| !(aSWP
.fl
& SWP_MINIMIZE
) )
511 // set window to screen size
516 ImplSalCalcFullScreenSize( pFrame
, nX
, nY
, nWidth
, nHeight
);
517 _WinSetWindowPos( pFrame
, 0,
518 nX
, nY
, nWidth
, nHeight
,
519 SWP_MOVE
| SWP_SIZE
);
523 // -----------------------------------------------------------------------
525 // Uebersetzungstabelle von System-Keycodes in StarView-Keycodes
526 #define KEY_TAB_SIZE (VK_ENDDRAG+1)
528 static USHORT aImplTranslateKeyTab
[KEY_TAB_SIZE
] =
530 // StarView-Code System-Code Index
532 0, // VK_BUTTON1 0x01
533 0, // VK_BUTTON2 0x02
534 0, // VK_BUTTON3 0x03
536 KEY_BACKSPACE
, // VK_BACKSPACE 0x05
537 KEY_TAB
, // VK_TAB 0x06
538 KEY_TAB
, // VK_BACKTAB 0x07
539 KEY_RETURN
, // VK_NEWLINE 0x08
543 0, // VK_ALTGRAF 0x0C
545 0, // VK_CAPSLOCK 0x0E
546 KEY_ESCAPE
, // VK_ESC 0x0F
547 KEY_SPACE
, // VK_SPACE 0x10
548 KEY_PAGEUP
, // VK_PAGEUP 0x11
549 KEY_PAGEDOWN
, // VK_PAGEDOWN 0x12
550 KEY_END
, // VK_END 0x13
551 KEY_HOME
, // VK_HOME 0x14
552 KEY_LEFT
, // VK_LEFT 0x15
553 KEY_UP
, // VK_UP 0x16
554 KEY_RIGHT
, // VK_RIGHT 0x17
555 KEY_DOWN
, // VK_DOWN 0x18
556 0, // VK_PRINTSCRN 0x19
557 KEY_INSERT
, // VK_INSERT 0x1A
558 KEY_DELETE
, // VK_DELETE 0x1B
559 0, // VK_SCRLLOCK 0x1C
560 0, // VK_NUMLOCK 0x1D
561 KEY_RETURN
, // VK_ENTER 0x1E
563 KEY_F1
, // VK_F1 0x20
564 KEY_F2
, // VK_F2 0x21
565 KEY_F3
, // VK_F3 0x22
566 KEY_F4
, // VK_F4 0x23
567 KEY_F5
, // VK_F5 0x24
568 KEY_F6
, // VK_F6 0x25
569 KEY_F7
, // VK_F7 0x26
570 KEY_F8
, // VK_F8 0x27
571 KEY_F9
, // VK_F9 0x28
572 KEY_F10
, // VK_F10 0x29
573 KEY_F11
, // VK_F11 0x2A
574 KEY_F12
, // VK_F12 0x2B
575 KEY_F13
, // VK_F13 0x2C
576 KEY_F14
, // VK_F14 0x2D
577 KEY_F15
, // VK_F15 0x2E
578 KEY_F16
, // VK_F16 0x2F
579 KEY_F17
, // VK_F17 0x30
580 KEY_F18
, // VK_F18 0x31
581 KEY_F19
, // VK_F19 0x32
582 KEY_F20
, // VK_F20 0x33
583 KEY_F21
, // VK_F21 0x34
584 KEY_F22
, // VK_F22 0x35
585 KEY_F23
, // VK_F23 0x36
586 KEY_F24
, // VK_F24 0x37
590 // =======================================================================
592 SalFrame
* ImplSalCreateFrame( Os2SalInstance
* pInst
, HWND hWndParent
, ULONG nSalFrameStyle
)
594 SalData
* pSalData
= GetSalData();
595 Os2SalFrame
* pFrame
= new Os2SalFrame
;
598 ULONG nFrameFlags
= FCF_NOBYTEALIGN
| FCF_SCREENALIGN
;
599 ULONG nFrameStyle
= 0;
600 ULONG nClientStyle
= WS_CLIPSIBLINGS
;
601 BOOL bSubFrame
= FALSE
;
603 #if OSL_DEBUG_LEVEL>0
604 debug_printf(">ImplSalCreateFrame hWndParent 0x%x, nSalFrameStyle 0x%x\n", hWndParent
, nSalFrameStyle
);
610 pFrame
->mbNoIcon
= TRUE
;
613 // determine creation data (bei Moveable nehmen wir DLG-Border, damit
614 // es besser aussieht)
615 if ( nSalFrameStyle
& SAL_FRAME_STYLE_CLOSEABLE
)
616 nFrameFlags
|= FCF_CLOSEBUTTON
;
618 if ( nSalFrameStyle
& SAL_FRAME_STYLE_MOVEABLE
) {
619 pFrame
->mbCaption
= TRUE
;
620 nFrameStyle
= WS_ANIMATE
;
621 nFrameFlags
|= FCF_SYSMENU
| FCF_TITLEBAR
| FCF_DLGBORDER
;
623 nFrameFlags
|= FCF_MINBUTTON
;
625 if ( nSalFrameStyle
& SAL_FRAME_STYLE_SIZEABLE
)
627 pFrame
->mbSizeBorder
= TRUE
;
628 nFrameFlags
|= FCF_SIZEBORDER
;
630 nFrameFlags
|= FCF_MAXBUTTON
;
633 pFrame
->mbFixBorder
= TRUE
;
635 // add task list style if not a tool window
636 if ( !(nSalFrameStyle
& SAL_FRAME_STYLE_TOOLWINDOW
) ) {
637 nFrameFlags
|= FCF_TASKLIST
;
641 if( nSalFrameStyle
& SAL_FRAME_STYLE_TOOLWINDOW
)
643 pFrame
->mbNoIcon
= TRUE
;
644 // YD gives small caption -> nExSysStyle |= WS_EX_TOOLWINDOW;
647 if ( nSalFrameStyle
& SAL_FRAME_STYLE_FLOAT
)
649 //nExSysStyle |= WS_EX_TOOLWINDOW;
650 pFrame
->mbFloatWin
= TRUE
;
652 //if( nSalFrameStyle & SAL_FRAME_STYLE_TOOLTIP )
653 // nExSysStyle |= WS_EX_TOPMOST;
656 pFrame
->mnStyle
= nSalFrameStyle
;
658 // determine show style
659 pFrame
->mnShowState
= SWP_SHOWNORMAL
;
662 //YD FIXME this is a potential bug with multiple threads and cuncurrent
663 //window creation, because this field is accessed in
664 //WM_CREATE to get window data,
665 pSalData
->mpCreateFrame
= pFrame
;
667 //YD FIXME if SAL_FRAME_CHILD is specified, use hWndParent as parent handle...
668 hWndFrame
= WinCreateStdWindow( HWND_DESKTOP
, nFrameStyle
, &nFrameFlags
,
669 (PSZ
)(bSubFrame
? SAL_SUBFRAME_CLASSNAME
: SAL_FRAME_CLASSNAME
),
671 nClientStyle
, 0, 0, &hWndClient
);
672 debug_printf("ImplSalCreateFrame hWndParent 0x%x, hWndFrame 0x%x, hWndClient 0x%x\n", hWndParent
, hWndFrame
, hWndClient
);
679 // Parent setzen (Owner)
680 if ( hWndParent
!= 0 && hWndParent
!= HWND_DESKTOP
)
681 WinSetOwner( hWndFrame
, hWndParent
);
683 Os2SalFrame
* pParentFrame
= GetWindowPtr( hWndParent
);
685 pFrame
->mpParentFrame
= pParentFrame
;
687 // Icon setzen (YD win32 does it in the class registration)
688 if ( nFrameFlags
& FCF_MINBUTTON
)
689 WinSendMsg( hWndFrame
, WM_SETICON
, (MPARAM
)pInst
->mhAppIcon
, (MPARAM
)0 );
691 // If we have an Window with an Caption Bar and without
692 // an MaximizeBox, we change the SystemMenu
693 if ( (nFrameFlags
& (FCF_TITLEBAR
| FCF_MAXBUTTON
)) == (FCF_TITLEBAR
) )
695 HWND hSysMenu
= WinWindowFromID( hWndFrame
, FID_SYSMENU
);
698 if ( !(nFrameFlags
& (FCF_MINBUTTON
| FCF_MAXBUTTON
)) )
699 WinEnableMenuItem(hSysMenu
, SC_RESTORE
, FALSE
);
700 if ( !(nFrameFlags
& FCF_MINBUTTON
) )
701 WinEnableMenuItem(hSysMenu
, SC_MINIMIZE
, FALSE
);
702 if ( !(nFrameFlags
& FCF_MAXBUTTON
) )
703 WinEnableMenuItem(hSysMenu
, SC_MAXIMIZE
, FALSE
);
704 if ( !(nFrameFlags
& FCF_SIZEBORDER
) )
705 WinEnableMenuItem(hSysMenu
, SC_SIZE
, FALSE
);
708 if ( (nFrameFlags
& FCF_SYSMENU
) && !(nSalFrameStyle
& SAL_FRAME_STYLE_CLOSEABLE
) )
710 HWND hSysMenu
= WinWindowFromID( hWndFrame
, FID_SYSMENU
);
713 WinEnableMenuItem(hSysMenu
, SC_CLOSE
, FALSE
);
717 // ticket#124 subclass frame window: we need to intercept TRACK message
718 aSalShlData
.mpFrameProc
= WinSubclassWindow( hWndFrame
, SalFrameSubClassWndProc
);
720 // init OS/2 frame data
721 pFrame
->mhAB
= pInst
->mhAB
;
723 // YD 18/08 under OS/2, invisible frames have size 0,0 at 0,0, so
724 // we need to set an initial size/position manually
726 memset( &aSWP
, 0, sizeof( aSWP
) );
727 WinQueryTaskSizePos( pInst
->mhAB
, 0, &aSWP
);
728 WinSetWindowPos( hWndFrame
, NULL
, aSWP
.x
, aSWP
.y
, aSWP
.cx
, aSWP
.cy
,
729 SWP_MOVE
| SWP_SIZE
);
732 // Input-Context einstellen
733 SalIMEData
* pIMEData
= GetSalIMEData();
736 pFrame
->mhIMEContext
= 0;
737 if ( 0 != pIMEData
->mpAssocIME( hWndClient
, pFrame
->mhIMEContext
, &pFrame
->mhDefIMEContext
) )
738 pFrame
->mhDefIMEContext
= 0;
742 pFrame
->mhIMEContext
= 0;
743 pFrame
->mhDefIMEContext
= 0;
748 _WinQueryWindowRect( hWndClient
, &rectl
);
749 pFrame
->mnWidth
= rectl
.xRight
;
750 pFrame
->mnHeight
= rectl
.yBottom
;
751 debug_printf( "ImplSalCreateFrame %dx%d\n", pFrame
->mnWidth
, pFrame
->mnHeight
);
752 ImplSaveFrameState( pFrame
);
753 pFrame
->mbDefPos
= TRUE
;
755 UpdateFrameGeometry( hWndFrame
, pFrame
);
757 if( pFrame
->mnShowState
== SWP_SHOWMAXIMIZED
)
759 // #96084 set a useful internal window size because
760 // the window will not be maximized (and the size updated) before show()
761 SetMaximizedFrameGeometry( hWndFrame
, pFrame
);
764 #if OSL_DEBUG_LEVEL > 1
765 dumpWindowInfo( "<ImplSalCreateFrame (exit)", hWndFrame
);
771 // =======================================================================
773 Os2SalFrame::Os2SalFrame()
775 SalData
* pSalData
= GetSalData();
778 mhPointer
= WinQuerySysPointer( HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
781 mbFullScreen
= FALSE
;
782 mbAllwayOnTop
= FALSE
;
786 mbRestoreMaximize
= FALSE
;
790 mbOverwriteState
= TRUE
;
792 mbConversionMode
= FALSE
;
793 mbCandidateMode
= FALSE
;
795 //mhDefIMEContext = 0;
797 mnShowState
= SWP_SHOWNORMAL
;
802 mnMaxWidth
= SHRT_MAX
;
803 mnMaxHeight
= SHRT_MAX
;
805 mnKeyboardHandle
= 0;
810 mbSizeBorder
= FALSE
;
811 mbFullScreen
= FALSE
;
812 //mbPresentation = FALSE;
814 mbRestoreMaximize
= FALSE
;
817 //mbFullScreenToolWin = FALSE;
819 mbOverwriteState
= TRUE
;
823 //mbAtCursorIME = FALSE;
824 mbCandidateMode
= FALSE
;
827 //mSelectedhMenu = 0;
828 //mLastActivatedhMenu = 0;
829 mpParentFrame
= NULL
;
831 memset( &maState
, 0, sizeof( SalFrameState
) );
832 maSysData
.nSize
= sizeof( SystemEnvData
);
833 memset( &maGeometry
, 0, sizeof( maGeometry
) );
835 // insert frame in framelist
836 mpNextFrame
= pSalData
->mpFirstFrame
;
837 pSalData
->mpFirstFrame
= this;
840 // -----------------------------------------------------------------------
842 Os2SalFrame::~Os2SalFrame()
844 SalData
* pSalData
= GetSalData();
849 ImplSalDeInitGraphics( mpGraphics
);
850 WinReleasePS( mpGraphics
->mhPS
);
854 // destroy system frame
855 WinDestroyWindow( mhWndFrame
);
857 // remove frame from framelist
858 if ( this == pSalData
->mpFirstFrame
)
859 pSalData
->mpFirstFrame
= mpNextFrame
;
862 Os2SalFrame
* pTempFrame
= pSalData
->mpFirstFrame
;
863 while ( pTempFrame
->mpNextFrame
!= this )
864 pTempFrame
= pTempFrame
->mpNextFrame
;
866 pTempFrame
->mpNextFrame
= mpNextFrame
;
870 // -----------------------------------------------------------------------
872 static HDC
ImplWinGetDC( HWND hWnd
)
874 HDC hDC
= WinQueryWindowDC( hWnd
);
876 hDC
= WinOpenWindowDC( hWnd
);
880 // -----------------------------------------------------------------------
882 SalGraphics
* Os2SalFrame::GetGraphics()
889 SalData
* pSalData
= GetSalData();
890 mpGraphics
= new Os2SalGraphics
;
891 mpGraphics
->mhPS
= WinGetPS( mhWndClient
);
892 mpGraphics
->mhDC
= ImplWinGetDC( mhWndClient
);
893 mpGraphics
->mhWnd
= mhWndClient
;
894 mpGraphics
->mnHeight
= mnHeight
;
895 mpGraphics
->mbPrinter
= FALSE
;
896 mpGraphics
->mbVirDev
= FALSE
;
897 mpGraphics
->mbWindow
= TRUE
;
898 mpGraphics
->mbScreen
= TRUE
;
899 ImplSalInitGraphics( mpGraphics
);
908 // -----------------------------------------------------------------------
910 void Os2SalFrame::ReleaseGraphics( SalGraphics
* )
915 // -----------------------------------------------------------------------
917 BOOL
Os2SalFrame::PostEvent( void* pData
)
919 return (BOOL
)WinPostMsg( mhWndClient
, SAL_MSG_USEREVENT
, 0, (MPARAM
)pData
);
922 // -----------------------------------------------------------------------
924 void Os2SalFrame::SetTitle( const XubString
& rTitle
)
927 ByteString
title( rTitle
, gsl_getSystemTextEncoding() );
928 debug_printf("Os2SalFrame::SetTitle %x '%s'\n", mhWndFrame
, title
.GetBuffer() );
929 WinSetWindowText( mhWndFrame
, title
.GetBuffer() );
932 // -----------------------------------------------------------------------
934 void Os2SalFrame::SetIcon( USHORT nIcon
)
936 debug_printf("Os2SalFrame::SetIcon\n");
938 // If we have a window without an Icon (for example a dialog), ignore this call
942 // 0 means default (class) icon
943 HPOINTER hIcon
= NULL
;
947 ImplLoadSalIcon( nIcon
, hIcon
);
949 DBG_ASSERT( hIcon
, "Os2SalFrame::SetIcon(): Could not load icon !" );
952 WinSendMsg( mhWndFrame
, WM_SETICON
, (MPARAM
)hIcon
, (MPARAM
)0 );
955 // -----------------------------------------------------------------------
957 SalFrame
* Os2SalFrame::GetParent() const
959 //debug_printf("Os2SalFrame::GetParent\n");
960 return GetWindowPtr( WinQueryWindow(mhWndFrame
, QW_OWNER
) );
963 // -----------------------------------------------------------------------
965 static void ImplSalShow( HWND hWnd
, ULONG bVisible
, ULONG bNoActivate
)
967 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
973 pFrame
->mbDefPos
= FALSE
;
974 pFrame
->mbOverwriteState
= TRUE
;
975 pFrame
->mbInShow
= TRUE
;
977 #if OSL_DEBUG_LEVEL > 0
978 debug_printf( "ImplSalShow hwnd %x visible flag %d, no activate: flag %d\n", hWnd
, bVisible
, bNoActivate
);
982 WinSetWindowPos(hWnd
, NULL
, 0, 0, 0, 0, SWP_SHOW
);
984 WinSetWindowPos(hWnd
, NULL
, 0, 0, 0, 0, pFrame
->mnShowState
);
986 pFrame
->mbInShow
= FALSE
;
988 // Direct Paint only, if we get the SolarMutx
989 if ( ImplSalYieldMutexTryToAcquire() )
991 WinUpdateWindow( hWnd
);
992 ImplSalYieldMutexRelease();
997 #if OSL_DEBUG_LEVEL > 0
998 debug_printf( "ImplSalShow hwnd %x HIDE\n");
1000 WinSetWindowPos(hWnd
, NULL
, 0, 0, 0, 0, SWP_HIDE
);
1005 // -----------------------------------------------------------------------
1008 void Os2SalFrame::SetExtendedFrameStyle( SalExtStyle nExtStyle
)
1012 // -----------------------------------------------------------------------
1014 void Os2SalFrame::Show( BOOL bVisible
, BOOL bNoActivate
)
1016 // Post this Message to the window, because this only works
1017 // in the thread of the window, which has create this window.
1018 // We post this message to avoid deadlocks
1019 if ( GetSalData()->mnAppThreadId
!= GetCurrentThreadId() )
1020 WinPostMsg( mhWndFrame
, SAL_MSG_SHOW
, (MPARAM
)bVisible
, (MPARAM
)bNoActivate
);
1022 ImplSalShow( mhWndFrame
, bVisible
, bNoActivate
);
1025 // -----------------------------------------------------------------------
1027 void Os2SalFrame::Enable( BOOL bEnable
)
1029 WinEnableWindow( mhWndFrame
, bEnable
);
1032 // -----------------------------------------------------------------------
1034 void Os2SalFrame::SetMinClientSize( long nWidth
, long nHeight
)
1036 debug_printf("Os2SalFrame::SetMinClientSize\n");
1037 mnMinWidth
= nWidth
;
1038 mnMinHeight
= nHeight
;
1041 void Os2SalFrame::SetMaxClientSize( long nWidth
, long nHeight
)
1043 debug_printf("Os2SalFrame::SetMaxClientSize\n");
1044 mnMaxWidth
= nWidth
;
1045 mnMaxHeight
= nHeight
;
1048 // -----------------------------------------------------------------------
1050 void Os2SalFrame::SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
,
1053 // calculation frame size
1055 ULONG nPosFlags
= 0;
1057 #if OSL_DEBUG_LEVEL > 0
1058 //dumpWindowInfo( "-Os2SalFrame::SetPosSize", mhWndFrame);
1059 debug_printf( ">Os2SalFrame::SetPosSize go to %d,%d (%dx%d) VCL\n",nX
,nY
,nWidth
,nHeight
);
1063 _WinQueryWindowPos( this, &aSWP
);
1064 BOOL bVisible
= WinIsWindowVisible( mhWndFrame
);
1068 mnShowState
= SWP_SHOW
;
1070 mnShowState
= SWP_SHOWNORMAL
;
1074 if ( (aSWP
.fl
& SWP_MINIMIZE
) || (aSWP
.fl
& SWP_MAXIMIZE
) )
1075 WinSetWindowPos(mhWndFrame
, NULL
, 0, 0, 0, 0, SWP_RESTORE
);
1078 if ( (nFlags
& (SAL_FRAME_POSSIZE_X
| SAL_FRAME_POSSIZE_Y
)) ) {
1079 nPosFlags
|= SWP_MOVE
;
1080 #if OSL_DEBUG_LEVEL > 0
1081 debug_printf( "-Os2SalFrame::SetPosSize MOVE to %d,%d\n", nX
, nY
);
1083 //DBG_ASSERT( nX && nY, " Windowposition of (0,0) requested!" );
1084 nEvent
= SALEVENT_MOVE
;
1087 if ( (nFlags
& (SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
)) ) {
1088 nPosFlags
|= SWP_SIZE
;
1089 #if OSL_DEBUG_LEVEL > 0
1090 debug_printf( "-Os2SalFrame::SetPosSize SIZE to %d,%d\n", nWidth
,nHeight
);
1092 nEvent
= (nEvent
== SALEVENT_MOVE
) ? SALEVENT_MOVERESIZE
: SALEVENT_RESIZE
;
1095 // Default-Position, dann zentrieren, ansonsten Position beibehalten
1096 if ( mbDefPos
&& !(nPosFlags
& SWP_MOVE
))
1098 // calculate bottom left corner of frame
1100 nPosFlags
|= SWP_MOVE
| SWP_CENTER
;
1101 nEvent
= SALEVENT_MOVERESIZE
;
1102 #if OSL_DEBUG_LEVEL > 10
1103 debug_printf( "-Os2SalFrame::SetPosSize CENTER\n");
1104 debug_printf( "-Os2SalFrame::SetPosSize default position to %d,%d\n", nX
, nY
);
1108 // Adjust Window in the screen
1109 BOOL bCheckOffScreen
= TRUE
;
1111 // but don't do this for floaters or ownerdraw windows that are currently moved interactively
1112 if( (mnStyle
& SAL_FRAME_STYLE_FLOAT
) && !(mnStyle
& SAL_FRAME_STYLE_OWNERDRAWDECORATION
) )
1113 bCheckOffScreen
= FALSE
;
1115 if( mnStyle
& SAL_FRAME_STYLE_OWNERDRAWDECORATION
)
1117 // may be the window is currently being moved (mouse is captured), then no check is required
1118 if( mhWndClient
== WinQueryCapture( HWND_DESKTOP
) )
1119 bCheckOffScreen
= FALSE
;
1121 bCheckOffScreen
= TRUE
;
1124 if( bCheckOffScreen
)
1126 if ( nX
+nWidth
> nScreenWidth
)
1127 nX
= nScreenWidth
- nWidth
;
1128 if ( nY
+nHeight
> nScreenHeight
)
1129 nY
= nScreenHeight
- nHeight
;
1136 // bring floating windows always to top
1137 // do not change zorder, otherwise tooltips will bring main window to top (ticket:14)
1138 //if( (mnStyle & SAL_FRAME_STYLE_FLOAT) )
1139 // nPosFlags |= SWP_ZORDER; // do not change z-order
1142 _WinSetWindowPos( this, HWND_TOP
, nX
, nY
, nWidth
, nHeight
, nPosFlags
); // | SWP_RESTORE
1144 UpdateFrameGeometry( mhWndFrame
, this );
1146 // Notification -- really ???
1148 CallCallback( nEvent
, NULL
);
1150 #if OSL_DEBUG_LEVEL > 0
1151 dumpWindowInfo( "<Os2SalFrame::SetPosSize (exit)", mhWndFrame
);
1156 // -----------------------------------------------------------------------
1158 void Os2SalFrame::SetParent( SalFrame
* pNewParent
)
1161 #if OSL_DEBUG_LEVEL>0
1162 debug_printf("Os2SalFrame::SetParent mhWndFrame 0x%08x to 0x%08x\n",
1163 static_cast<Os2SalFrame
*>(this)->mhWndFrame
,
1164 static_cast<Os2SalFrame
*>(pNewParent
)->mhWndClient
);
1166 Os2SalFrame::mbInReparent
= TRUE
;
1167 //rc = WinSetParent(static_cast<Os2SalFrame*>(this)->mhWndFrame,
1168 // static_cast<Os2SalFrame*>(pNewParent)->mhWndClient, TRUE);
1169 rc
= WinSetOwner(static_cast<Os2SalFrame
*>(this)->mhWndFrame
,
1170 static_cast<Os2SalFrame
*>(pNewParent
)->mhWndClient
);
1171 mpParentFrame
= static_cast<Os2SalFrame
*>(pNewParent
);
1172 Os2SalFrame::mbInReparent
= FALSE
;
1175 bool Os2SalFrame::SetPluginParent( SystemParentData
* pNewParent
)
1178 if ( pNewParent
->hWnd
== 0 )
1180 pNewParent
->hWnd
= HWND_DESKTOP
;
1183 Os2SalFrame::mbInReparent
= TRUE
;
1184 rc
= WinSetOwner(static_cast<Os2SalFrame
*>(this)->mhWndFrame
,
1186 Os2SalFrame::mbInReparent
= FALSE
;
1191 // -----------------------------------------------------------------------
1193 void Os2SalFrame::GetWorkArea( RECTL
&rRect
)
1195 rRect
.xLeft
= rRect
.yTop
= 0;
1196 rRect
.xRight
= WinQuerySysValue( HWND_DESKTOP
, SV_CXSCREEN
)-1;
1197 rRect
.yBottom
= WinQuerySysValue( HWND_DESKTOP
, SV_CYSCREEN
)-1;
1200 // -----------------------------------------------------------------------
1202 void Os2SalFrame::GetWorkArea( Rectangle
&rRect
)
1205 GetWorkArea( aRect
);
1206 rRect
.nLeft
= aRect
.xLeft
;
1207 rRect
.nRight
= aRect
.xRight
; // win -1;
1208 rRect
.nTop
= aRect
.yTop
;
1209 rRect
.nBottom
= aRect
.yBottom
; // win -1;
1212 // -----------------------------------------------------------------------
1214 void Os2SalFrame::GetClientSize( long& rWidth
, long& rHeight
)
1216 rWidth
= maGeometry
.nWidth
;
1217 rHeight
= maGeometry
.nHeight
;
1220 // -----------------------------------------------------------------------
1222 void Os2SalFrame::SetWindowState( const SalFrameState
* pState
)
1230 #if OSL_DEBUG_LEVEL>0
1231 debug_printf("Os2SalFrame::SetWindowState\n");
1232 debug_printf("Os2SalFrame::SetWindowState %08x (%dx%d) at %d,%d VCL\n",
1234 pState
->mnWidth
,pState
->mnHeight
,pState
->mnX
,pState
->mnY
);
1237 BOOL bVisible
= WinIsWindowVisible( mhWndFrame
);
1239 // get screen coordinates
1241 WinQueryWindowPos( mhWndFrame
, &aSWP
);
1242 LONG nFrameX
, nFrameY
, nCaptionY
;
1243 ImplSalCalcFrameSize( this, nFrameX
, nFrameY
, nCaptionY
);
1245 long nTopDeco
= nFrameY
+ nCaptionY
;
1246 long nLeftDeco
= nFrameX
;
1247 long nBottomDeco
= nFrameY
;
1248 long nRightDeco
= nFrameX
;
1250 // Fenster-Position/Groesse in den Bildschirm einpassen
1251 if ((pState
->mnMask
& (SAL_FRAMESTATE_MASK_X
| SAL_FRAMESTATE_MASK_Y
)) )
1252 nPosSize
|= SWP_MOVE
;
1253 if ((pState
->mnMask
& (SAL_FRAMESTATE_MASK_WIDTH
| SAL_FRAMESTATE_MASK_HEIGHT
)) )
1254 nPosSize
|= SWP_SIZE
;
1256 if ( pState
->mnMask
& SAL_FRAMESTATE_MASK_X
)
1257 nX
= (int)pState
->mnX
- nLeftDeco
;
1261 // keep Y inverted since height is still unknown, will invert later
1262 if ( pState
->mnMask
& SAL_FRAMESTATE_MASK_Y
)
1263 nY
= (int)pState
->mnY
- nTopDeco
;
1265 nY
= nScreenHeight
- (aSWP
.y
+aSWP
.cy
);
1267 if ( pState
->mnMask
& SAL_FRAMESTATE_MASK_WIDTH
)
1268 nWidth
= (int)pState
->mnWidth
+ nLeftDeco
+ nRightDeco
;
1271 if ( pState
->mnMask
& SAL_FRAMESTATE_MASK_HEIGHT
)
1272 nHeight
= (int)pState
->mnHeight
+ nTopDeco
+ nBottomDeco
;
1276 #if OSL_DEBUG_LEVEL>0
1277 debug_printf("Os2SalFrame::SetWindowState (%dx%d) at %d,%d\n", nWidth
,nHeight
,nX
,nY
);
1280 // Adjust Window in the screen:
1281 // if it does not fit into the screen do nothing, ie default pos/size will be used
1282 // if there is an overlap with the screen border move the window while keeping its size
1284 //if( nWidth > nScreenWidth || nHeight > nScreenHeight )
1285 // nPosSize |= (SWP_NOMOVE | SWP_NOSIZE);
1287 if ( nX
+nWidth
> nScreenWidth
)
1288 nX
= (nScreenWidth
) - nWidth
;
1289 if ( nY
+nHeight
> nScreenHeight
)
1290 nY
= (nScreenHeight
) - nHeight
;
1296 // Restore-Position setzen
1298 WinQueryWindowPos( mhWndFrame
, &aPlacement
);
1301 bVisible
= WinIsWindowVisible( mhWndFrame
);
1302 BOOL bUpdateHiddenFramePos
= FALSE
;
1305 aPlacement
.fl
= SWP_HIDE
;
1307 if ( mbOverwriteState
)
1309 if ( pState
->mnMask
& SAL_FRAMESTATE_MASK_STATE
)
1311 if ( pState
->mnState
& SAL_FRAMESTATE_MINIMIZED
)
1312 mnShowState
= SWP_SHOWMINIMIZED
;
1313 else if ( pState
->mnState
& SAL_FRAMESTATE_MAXIMIZED
)
1315 mnShowState
= SWP_SHOWMAXIMIZED
;
1316 bUpdateHiddenFramePos
= TRUE
;
1318 else if ( pState
->mnState
& SAL_FRAMESTATE_NORMAL
)
1319 mnShowState
= SWP_SHOWNORMAL
;
1325 if ( pState
->mnMask
& SAL_FRAMESTATE_MASK_STATE
)
1327 if ( pState
->mnState
& SAL_FRAMESTATE_MINIMIZED
)
1329 //if ( pState->mnState & SAL_FRAMESTATE_MAXIMIZED )
1330 // aPlacement.flags |= WPF_RESTORETOMAXIMIZED;
1331 aPlacement
.fl
= SWP_SHOWMINIMIZED
;
1333 else if ( pState
->mnState
& SAL_FRAMESTATE_MAXIMIZED
)
1334 aPlacement
.fl
= SWP_SHOWMAXIMIZED
;
1335 else if ( pState
->mnState
& SAL_FRAMESTATE_NORMAL
)
1336 aPlacement
.fl
= SWP_RESTORE
;
1340 // Wenn Fenster nicht minimiert/maximiert ist oder nicht optisch
1341 // umgesetzt werden muss, dann SetWindowPos() benutzen, da
1342 // SetWindowPlacement() die TaskBar mit einrechnet
1343 if ( !(aPlacement
.fl
& SWP_MINIMIZE
)
1344 && !( aPlacement
.fl
& SWP_MAXIMIZE
)
1345 && (!bVisible
|| (aPlacement
.fl
== SWP_RESTORE
)) )
1347 if( bUpdateHiddenFramePos
)
1349 // #96084 set a useful internal window size because
1350 // the window will not be maximized (and the size updated) before show()
1351 SetMaximizedFrameGeometry( mhWndFrame
, this );
1354 WinSetWindowPos( mhWndFrame
, 0, nX
,
1355 nScreenHeight
- (nY
+nHeight
), nWidth
, nHeight
, nPosSize
);
1359 if( (nPosSize
& (SWP_MOVE
|SWP_SIZE
)) )
1362 aPlacement
.y
= nScreenHeight
-(nY
+nHeight
);
1363 aPlacement
.cx
= nWidth
;
1364 aPlacement
.cy
= nHeight
;
1366 WinSetWindowPos( mhWndFrame
, 0, aPlacement
.x
, aPlacement
.y
,
1367 aPlacement
.cx
, aPlacement
.cy
, aPlacement
.fl
);
1370 #if OSL_DEBUG_LEVEL>0
1371 debug_printf("Os2SalFrame::SetWindowState DONE\n");
1375 // -----------------------------------------------------------------------
1377 BOOL
Os2SalFrame::GetWindowState( SalFrameState
* pState
)
1379 if ( maState
.mnWidth
&& maState
.mnHeight
)
1382 // #94144# allow Minimize again, should be masked out when read from configuration
1383 // 91625 - Don't save minimize
1384 //if ( !(pState->mnState & SAL_FRAMESTATE_MAXIMIZED) )
1385 if ( !(pState
->mnState
& (SAL_FRAMESTATE_MINIMIZED
| SAL_FRAMESTATE_MAXIMIZED
)) )
1386 pState
->mnState
|= SAL_FRAMESTATE_NORMAL
;
1393 // -----------------------------------------------------------------------
1395 void Os2SalFrame::SetScreenNumber( unsigned int nNewScreen
)
1398 WinSalSystem
* pSys
= static_cast<WinSalSystem
*>(ImplGetSalSystem());
1401 const std::vector
<WinSalSystem::DisplayMonitor
>& rMonitors
=
1402 pSys
->getMonitors();
1403 size_t nMon
= rMonitors
.size();
1404 if( nNewScreen
< nMon
)
1406 Point aOldMonPos
, aNewMonPos( rMonitors
[nNewScreen
].m_aArea
.TopLeft() );
1407 Point
aCurPos( maGeometry
.nX
, maGeometry
.nY
);
1408 for( size_t i
= 0; i
< nMon
; i
++ )
1410 if( rMonitors
[i
].m_aArea
.IsInside( aCurPos
) )
1412 aOldMonPos
= rMonitors
[i
].m_aArea
.TopLeft();
1416 mnDisplay
= nNewScreen
;
1417 maGeometry
.nScreenNumber
= nNewScreen
;
1418 SetPosSize( aNewMonPos
.X() + (maGeometry
.nX
- aOldMonPos
.X()),
1419 aNewMonPos
.Y() + (maGeometry
.nY
- aOldMonPos
.Y()),
1421 SAL_FRAME_POSSIZE_X
| SAL_FRAME_POSSIZE_Y
);
1427 // -----------------------------------------------------------------------
1429 // native menu implementation - currently empty
1430 void Os2SalFrame::DrawMenuBar()
1434 void Os2SalFrame::SetMenu( SalMenu
* pSalMenu
)
1438 // -----------------------------------------------------------------------
1440 void Os2SalFrame::ShowFullScreen( BOOL bFullScreen
, sal_Int32 nDisplay
)
1442 if ( mbFullScreen
== bFullScreen
)
1445 mbFullScreen
= bFullScreen
;
1448 // save old position
1449 memset( &maFullScreenRect
, 0, sizeof( SWP
) );
1450 _WinQueryWindowPos( this, &maFullScreenRect
);
1452 // set window to screen size
1453 ImplSalFrameFullScreenPos( this, TRUE
);
1457 _WinSetWindowPos( this,
1459 maFullScreenRect
.x
, maFullScreenRect
.y
,
1460 maFullScreenRect
.cx
, maFullScreenRect
.cy
,
1461 SWP_MOVE
| SWP_SIZE
);
1465 // -----------------------------------------------------------------------
1467 void Os2SalFrame::StartPresentation( BOOL bStart
)
1469 // SysSetObjectData("<WP_DESKTOP>","Autolockup=no"); oder OS2.INI: PM_Lockup
1472 // -----------------------------------------------------------------------
1474 void Os2SalFrame::SetAlwaysOnTop( BOOL bOnTop
)
1476 mbAllwayOnTop
= bOnTop
;
1480 hWnd
= HWND_TOPMOST
;
1482 hWnd
= HWND_NOTOPMOST
;
1483 SetWindowPos( mhWnd
, hWnd
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
1488 // -----------------------------------------------------------------------
1490 static void ImplSalToTop( HWND hWnd
, ULONG nFlags
)
1492 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
1493 #if OSL_DEBUG_LEVEL>0
1494 debug_printf("ImplSalToTop hWnd %08x, nFlags %x\n", hWnd
, nFlags
);
1497 // if window is minimized, first restore it
1499 WinQueryWindowPos( hWnd
, &aSWP
);
1500 if ( aSWP
.fl
& SWP_MINIMIZE
)
1501 WinSetWindowPos( hWnd
, NULL
, 0, 0, 0, 0, SWP_RESTORE
);
1503 if ( nFlags
& SAL_FRAME_TOTOP_FOREGROUNDTASK
)
1504 WinSetWindowPos( pFrame
->mhWndFrame
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
1506 if ( nFlags
& SAL_FRAME_TOTOP_RESTOREWHENMIN
)
1509 if ( pFrame
->mbRestoreMaximize
)
1510 nStyle
= SWP_MAXIMIZE
;
1512 nStyle
= SWP_RESTORE
;
1514 WinSetWindowPos( pFrame
->mhWndFrame
, NULL
, 0, 0, 0, 0, nStyle
);
1516 WinSetFocus( HWND_DESKTOP
, pFrame
->mhWndClient
);
1519 // -----------------------------------------------------------------------
1521 void Os2SalFrame::ToTop( USHORT nFlags
)
1523 nFlags
&= ~SAL_FRAME_TOTOP_GRABFOCUS
; // this flag is not needed on win32
1524 // Post this Message to the window, because this only works
1525 // in the thread of the window, which has create this window.
1526 // We post this message to avoid deadlocks
1527 if ( GetSalData()->mnAppThreadId
!= GetCurrentThreadId() )
1528 WinPostMsg( mhWndFrame
, SAL_MSG_TOTOP
, (MPARAM
)nFlags
, 0 );
1530 ImplSalToTop( mhWndFrame
, nFlags
);
1533 // -----------------------------------------------------------------------
1535 void Os2SalFrame::SetPointer( PointerStyle ePointerStyle
)
1544 static ImplPtrData aImplPtrTab
[POINTER_COUNT
] =
1546 { 0, SPTR_ARROW
, 0 }, // POINTER_ARROW
1547 { 0, 0, SAL_RESID_POINTER_NULL
}, // POINTER_NULL
1548 { 0, SPTR_WAIT
, 0 }, // POINTER_WAIT
1549 { 0, SPTR_TEXT
, 0 }, // POINTER_BEAM
1550 { 0, 0, SAL_RESID_POINTER_HELP
}, // POINTER_HELP
1551 { 0, 0, SAL_RESID_POINTER_CROSS
}, // POINTER_CROSS
1552 { 0, 0, SAL_RESID_POINTER_MOVE
}, // POINTER_MOVE
1553 { 0, SPTR_SIZENS
, 0 }, // POINTER_NSIZE
1554 { 0, SPTR_SIZENS
, 0 }, // POINTER_SSIZE
1555 { 0, SPTR_SIZEWE
, 0 }, // POINTER_WSIZE
1556 { 0, SPTR_SIZEWE
, 0 }, // POINTER_ESIZE
1557 { 0, SPTR_SIZENWSE
, 0 }, // POINTER_NWSIZE
1558 { 0, SPTR_SIZENESW
, 0 }, // POINTER_NESIZE
1559 { 0, SPTR_SIZENESW
, 0 }, // POINTER_SWSIZE
1560 { 0, SPTR_SIZENWSE
, 0 }, // POINTER_SESIZE
1561 { 0, SPTR_SIZENS
, 0 }, // POINTER_WINDOW_NSIZE
1562 { 0, SPTR_SIZENS
, 0 }, // POINTER_WINDOW_SSIZE
1563 { 0, SPTR_SIZEWE
, 0 }, // POINTER_WINDOW_WSIZE
1564 { 0, SPTR_SIZEWE
, 0 }, // POINTER_WINDOW_ESIZE
1565 { 0, SPTR_SIZENWSE
, 0 }, // POINTER_WINDOW_NWSIZE
1566 { 0, SPTR_SIZENESW
, 0 }, // POINTER_WINDOW_NESIZE
1567 { 0, SPTR_SIZENESW
, 0 }, // POINTER_WINDOW_SWSIZE
1568 { 0, SPTR_SIZENWSE
, 0 }, // POINTER_WINDOW_SESIZE
1569 { 0, 0, SAL_RESID_POINTER_HSPLIT
}, // POINTER_HSPLIT
1570 { 0, 0, SAL_RESID_POINTER_VSPLIT
}, // POINTER_VSPLIT
1571 { 0, 0, SAL_RESID_POINTER_HSIZEBAR
}, // POINTER_HSIZEBAR
1572 { 0, 0, SAL_RESID_POINTER_VSIZEBAR
}, // POINTER_VSIZEBAR
1573 { 0, 0, SAL_RESID_POINTER_HAND
}, // POINTER_HAND
1574 { 0, 0, SAL_RESID_POINTER_REFHAND
}, // POINTER_REFHAND
1575 { 0, 0, SAL_RESID_POINTER_PEN
}, // POINTER_PEN
1576 { 0, 0, SAL_RESID_POINTER_MAGNIFY
}, // POINTER_MAGNIFY
1577 { 0, 0, SAL_RESID_POINTER_FILL
}, // POINTER_FILL
1578 { 0, 0, SAL_RESID_POINTER_ROTATE
}, // POINTER_ROTATE
1579 { 0, 0, SAL_RESID_POINTER_HSHEAR
}, // POINTER_HSHEAR
1580 { 0, 0, SAL_RESID_POINTER_VSHEAR
}, // POINTER_VSHEAR
1581 { 0, 0, SAL_RESID_POINTER_MIRROR
}, // POINTER_MIRROR
1582 { 0, 0, SAL_RESID_POINTER_CROOK
}, // POINTER_CROOK
1583 { 0, 0, SAL_RESID_POINTER_CROP
}, // POINTER_CROP
1584 { 0, 0, SAL_RESID_POINTER_MOVEPOINT
}, // POINTER_MOVEPOINT
1585 { 0, 0, SAL_RESID_POINTER_MOVEBEZIERWEIGHT
}, // POINTER_MOVEBEZIERWEIGHT
1586 { 0, 0, SAL_RESID_POINTER_MOVEDATA
}, // POINTER_MOVEDATA
1587 { 0, 0, SAL_RESID_POINTER_COPYDATA
}, // POINTER_COPYDATA
1588 { 0, 0, SAL_RESID_POINTER_LINKDATA
}, // POINTER_LINKDATA
1589 { 0, 0, SAL_RESID_POINTER_MOVEDATALINK
}, // POINTER_MOVEDATALINK
1590 { 0, 0, SAL_RESID_POINTER_COPYDATALINK
}, // POINTER_COPYDATALINK
1591 { 0, 0, SAL_RESID_POINTER_MOVEFILE
}, // POINTER_MOVEFILE
1592 { 0, 0, SAL_RESID_POINTER_COPYFILE
}, // POINTER_COPYFILE
1593 { 0, 0, SAL_RESID_POINTER_LINKFILE
}, // POINTER_LINKFILE
1594 { 0, 0, SAL_RESID_POINTER_MOVEFILELINK
}, // POINTER_MOVEFILELINK
1595 { 0, 0, SAL_RESID_POINTER_COPYFILELINK
}, // POINTER_COPYFILELINK
1596 { 0, 0, SAL_RESID_POINTER_MOVEFILES
}, // POINTER_MOVEFILES
1597 { 0, 0, SAL_RESID_POINTER_COPYFILES
}, // POINTER_COPYFILES
1598 { 0, SPTR_ILLEGAL
, 0 }, // POINTER_NOTALLOWED
1599 { 0, 0, SAL_RESID_POINTER_DRAW_LINE
}, // POINTER_DRAW_LINE
1600 { 0, 0, SAL_RESID_POINTER_DRAW_RECT
}, // POINTER_DRAW_RECT
1601 { 0, 0, SAL_RESID_POINTER_DRAW_POLYGON
}, // POINTER_DRAW_POLYGON
1602 { 0, 0, SAL_RESID_POINTER_DRAW_BEZIER
}, // POINTER_DRAW_BEZIER
1603 { 0, 0, SAL_RESID_POINTER_DRAW_ARC
}, // POINTER_DRAW_ARC
1604 { 0, 0, SAL_RESID_POINTER_DRAW_PIE
}, // POINTER_DRAW_PIE
1605 { 0, 0, SAL_RESID_POINTER_DRAW_CIRCLECUT
}, // POINTER_DRAW_CIRCLECUT
1606 { 0, 0, SAL_RESID_POINTER_DRAW_ELLIPSE
}, // POINTER_DRAW_ELLIPSE
1607 { 0, 0, SAL_RESID_POINTER_DRAW_FREEHAND
}, // POINTER_DRAW_FREEHAND
1608 { 0, 0, SAL_RESID_POINTER_DRAW_CONNECT
}, // POINTER_DRAW_CONNECT
1609 { 0, 0, SAL_RESID_POINTER_DRAW_TEXT
}, // POINTER_DRAW_TEXT
1610 { 0, 0, SAL_RESID_POINTER_DRAW_CAPTION
}, // POINTER_DRAW_CAPTION
1611 { 0, 0, SAL_RESID_POINTER_CHART
}, // POINTER_CHART
1612 { 0, 0, SAL_RESID_POINTER_DETECTIVE
}, // POINTER_DETECTIVE
1613 { 0, 0, SAL_RESID_POINTER_PIVOT_COL
}, // POINTER_PIVOT_COL
1614 { 0, 0, SAL_RESID_POINTER_PIVOT_ROW
}, // POINTER_PIVOT_ROW
1615 { 0, 0, SAL_RESID_POINTER_PIVOT_FIELD
}, // POINTER_PIVOT_FIELD
1616 { 0, 0, SAL_RESID_POINTER_CHAIN
}, // POINTER_CHAIN
1617 { 0, 0, SAL_RESID_POINTER_CHAIN_NOTALLOWED
}, // POINTER_CHAIN_NOTALLOWED
1618 { 0, 0, SAL_RESID_POINTER_TIMEEVENT_MOVE
}, // POINTER_TIMEEVENT_MOVE
1619 { 0, 0, SAL_RESID_POINTER_TIMEEVENT_SIZE
}, // POINTER_TIMEEVENT_SIZE
1620 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_N
}, // POINTER_AUTOSCROLL_N
1621 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_S
}, // POINTER_AUTOSCROLL_S
1622 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_W
}, // POINTER_AUTOSCROLL_W
1623 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_E
}, // POINTER_AUTOSCROLL_E
1624 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NW
}, // POINTER_AUTOSCROLL_NW
1625 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NE
}, // POINTER_AUTOSCROLL_NE
1626 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_SW
}, // POINTER_AUTOSCROLL_SW
1627 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_SE
}, // POINTER_AUTOSCROLL_SE
1628 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NS
}, // POINTER_AUTOSCROLL_NS
1629 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_WE
}, // POINTER_AUTOSCROLL_WE
1630 { 0, 0, SAL_RESID_POINTER_AUTOSCROLL_NSWE
}, // POINTER_AUTOSCROLL_NSWE
1631 { 0, 0, SAL_RESID_POINTER_AIRBRUSH
}, // POINTER_AIRBRUSH
1632 { 0, 0, SAL_RESID_POINTER_TEXT_VERTICAL
}, // POINTER_TEXT_VERTICAL
1633 { 0, 0, SAL_RESID_POINTER_PIVOT_DELETE
}, // POINTER_PIVOT_DELETE
1635 // --> FME 2004-07-30 #i32329# Enhanced table selection
1636 { 0, 0, SAL_RESID_POINTER_TAB_SELECT_S
}, // POINTER_TAB_SELECT_S
1637 { 0, 0, SAL_RESID_POINTER_TAB_SELECT_E
}, // POINTER_TAB_SELECT_E
1638 { 0, 0, SAL_RESID_POINTER_TAB_SELECT_SE
}, // POINTER_TAB_SELECT_SE
1639 { 0, 0, SAL_RESID_POINTER_TAB_SELECT_W
}, // POINTER_TAB_SELECT_W
1640 { 0, 0, SAL_RESID_POINTER_TAB_SELECT_SW
}, // POINTER_TAB_SELECT_SW
1643 // --> FME 2004-08-16 #i20119# Paintbrush tool
1644 { 0, 0, SAL_RESID_POINTER_PAINTBRUSH
} // POINTER_PAINTBRUSH
1648 #if POINTER_COUNT != 94
1649 #error New Pointer must be defined!
1652 //debug_printf("Os2SalFrame::SetPointer\n");
1654 // Mousepointer loaded ?
1655 if ( !aImplPtrTab
[ePointerStyle
].mhPointer
)
1657 if ( aImplPtrTab
[ePointerStyle
].mnOwnId
)
1658 aImplPtrTab
[ePointerStyle
].mhPointer
= ImplLoadSalCursor( (ULONG
)aImplPtrTab
[ePointerStyle
].mnOwnId
);
1660 aImplPtrTab
[ePointerStyle
].mhPointer
= WinQuerySysPointer( HWND_DESKTOP
, aImplPtrTab
[ePointerStyle
].mnSysId
, FALSE
);
1662 if (aImplPtrTab
[ePointerStyle
].mhPointer
== 0) {
1663 debug_printf( "SetPointer ePointerStyle %d unknown\n", ePointerStyle
);
1664 aImplPtrTab
[ePointerStyle
].mhPointer
= SPTR_ICONERROR
;
1667 // Unterscheidet sich der Mauspointer, dann den neuen setzen
1668 if ( mhPointer
!= aImplPtrTab
[ePointerStyle
].mhPointer
)
1670 mhPointer
= aImplPtrTab
[ePointerStyle
].mhPointer
;
1671 WinSetPointer( HWND_DESKTOP
, mhPointer
);
1675 // -----------------------------------------------------------------------
1677 void Os2SalFrame::CaptureMouse( BOOL bCapture
)
1679 #if OSL_DEBUG_LEVEL>10
1681 debug_printf("Os2SalFrame::CaptureMouse bCapture %d\n", bCapture
);
1684 WinSetCapture( HWND_DESKTOP
, mhWndClient
);
1686 WinSetCapture( HWND_DESKTOP
, 0 );
1689 // -----------------------------------------------------------------------
1691 void Os2SalFrame::SetPointerPos( long nX
, long nY
)
1695 aPt
.y
= mnHeight
- nY
- 1; // convert sal coords to sys
1696 WinMapWindowPoints( mhWndClient
, HWND_DESKTOP
, &aPt
, 1 );
1697 WinSetPointerPos( HWND_DESKTOP
, aPt
.x
, aPt
.y
);
1700 // -----------------------------------------------------------------------
1702 void Os2SalFrame::Flush()
1706 // -----------------------------------------------------------------------
1708 void Os2SalFrame::Sync()
1712 // -----------------------------------------------------------------------
1714 void Os2SalFrame::SetInputContext( SalInputContext
* pContext
)
1717 SalIMEData
* pIMEData
= GetSalIMEData();
1720 HWND hWnd
= mhWndClient
;
1722 pIMEData
->mpGetIME( hWnd
, &hIMI
);
1726 ULONG nConversionMode
;
1727 if ( 0 == pIMEData
->mpQueryIMEMode( hIMI
, &nInputMode
, &nConversionMode
) )
1729 if ( pContext
->mnOptions
& SAL_INPUTCONTEXT_TEXT
)
1731 nInputMode
&= ~IMI_IM_IME_DISABLE
;
1732 if ( pContext
->mnOptions
& SAL_INPUTCONTEXT_EXTTEXTINPUT_OFF
)
1733 nInputMode
&= ~IMI_IM_IME_ON
;
1734 // !!! Da derzeit ueber das OS2-IME-UI der IME-Mode nicht einschaltbar ist !!!
1735 // if ( SAL_INPUTCONTEXT_EXTTEXTINPUT_ON )
1736 nInputMode
|= IMI_IM_IME_ON
;
1739 nInputMode
|= IMI_IM_IME_DISABLE
;
1740 pIMEData
->mpSetIMEMode( hIMI
, nInputMode
, nConversionMode
);
1743 pIMEData
->mpReleaseIME( hWnd
, hIMI
);
1749 // -----------------------------------------------------------------------
1751 void Os2SalFrame::UpdateExtTextInputArea()
1758 // -----------------------------------------------------------------------
1760 void Os2SalFrame::EndExtTextInput( USHORT nFlags
)
1763 SalIMEData
* pIMEData
= GetSalIMEData();
1766 HWND hWnd
= mhWndClient
;
1768 pIMEData
->mpGetIME( hWnd
, &hIMI
);
1772 if ( nFlags
& SAL_FRAME_ENDEXTTEXTINPUT_COMPLETE
)
1773 nIndex
= CNV_COMPLETE
;
1775 nIndex
= CNV_CANCEL
;
1777 pIMEData
->mpRequestIME( hIMI
, REQ_CONVERSIONSTRING
, nIndex
, 0 );
1778 pIMEData
->mpReleaseIME( hWnd
, hIMI
);
1784 // -----------------------------------------------------------------------
1786 XubString
Os2SalFrame::GetKeyName( USHORT nCode
)
1788 if ( eImplKeyboardLanguage
== LANGUAGE_DONTKNOW
)
1789 eImplKeyboardLanguage
= MsLangId::getSystemLanguage();
1793 const sal_Unicode
** pLangTab
= ImplGetLangTab( eImplKeyboardLanguage
);
1795 if ( nCode
& KEY_SHIFT
)
1796 aKeyCode
= pLangTab
[LSTR_KEY_SHIFT
];
1798 if ( nCode
& KEY_MOD1
)
1800 if ( aKeyCode
.Len() == 0 )
1801 aKeyCode
= pLangTab
[LSTR_KEY_CTRL
];
1805 aKeyCode
+= pLangTab
[LSTR_KEY_CTRL
];
1809 if ( nCode
& KEY_MOD2
)
1811 if ( aKeyCode
.Len() == 0 )
1812 aKeyCode
= pLangTab
[LSTR_KEY_ALT
];
1816 aKeyCode
+= pLangTab
[LSTR_KEY_ALT
];
1820 USHORT nKeyCode
= nCode
& 0x0FFF;
1821 if ( (nKeyCode
>= KEY_0
) && (nKeyCode
<= KEY_9
) )
1822 aCode
= sal::static_int_cast
<sal_Char
>('0' + (nKeyCode
- KEY_0
));
1823 else if ( (nKeyCode
>= KEY_A
) && (nKeyCode
<= KEY_Z
) )
1824 aCode
= sal::static_int_cast
<sal_Char
>('A' + (nKeyCode
- KEY_A
));
1825 else if ( (nKeyCode
>= KEY_F1
) && (nKeyCode
<= KEY_F26
) )
1828 if ( (nKeyCode
>= KEY_F1
) && (nKeyCode
<= KEY_F9
) )
1830 aCode
+= sal::static_int_cast
<sal_Char
>('1' + (nKeyCode
- KEY_F1
));
1832 else if ( (nKeyCode
>= KEY_F10
) && (nKeyCode
<= KEY_F19
) )
1835 aCode
+= sal::static_int_cast
<sal_Char
>('0' + (nKeyCode
- KEY_F10
));
1840 aCode
+= sal::static_int_cast
<sal_Char
>('0' + (nKeyCode
- KEY_F20
));
1848 aCode
= pLangTab
[LSTR_KEY_DOWN
];
1851 aCode
= pLangTab
[LSTR_KEY_UP
];
1854 aCode
= pLangTab
[LSTR_KEY_LEFT
];
1857 aCode
= pLangTab
[LSTR_KEY_RIGHT
];
1860 aCode
= pLangTab
[LSTR_KEY_HOME
];
1863 aCode
= pLangTab
[LSTR_KEY_END
];
1866 aCode
= pLangTab
[LSTR_KEY_PAGEUP
];
1869 aCode
= pLangTab
[LSTR_KEY_PAGEDOWN
];
1872 aCode
= pLangTab
[LSTR_KEY_RETURN
];
1875 aCode
= pLangTab
[LSTR_KEY_ESC
];
1878 aCode
= pLangTab
[LSTR_KEY_TAB
];
1881 aCode
= pLangTab
[LSTR_KEY_BACKSPACE
];
1884 aCode
= pLangTab
[LSTR_KEY_SPACE
];
1887 aCode
= pLangTab
[LSTR_KEY_INSERT
];
1890 aCode
= pLangTab
[LSTR_KEY_DELETE
];
1925 if ( aKeyCode
.Len() == 0 )
1937 // -----------------------------------------------------------------------
1939 XubString
Os2SalFrame::GetSymbolKeyName( const XubString
&, USHORT nKeyCode
)
1941 return GetKeyName( nKeyCode
);
1944 // -----------------------------------------------------------------------
1946 inline long ImplOS2ColorToSal( long nOS2Color
)
1948 return MAKE_SALCOLOR( (BYTE
)( nOS2Color
>>16), (BYTE
)(nOS2Color
>>8), (BYTE
)nOS2Color
);
1951 // -----------------------------------------------------------------------
1953 static USHORT
ImplMouseSysValueToSAL( int iSysValue
, USHORT
& rCode
, USHORT
& rClicks
, BOOL
& rDown
)
1955 LONG lValue
= WinQuerySysValue( HWND_DESKTOP
, iSysValue
);
1961 switch ( lValue
& 0xFFFF )
1964 case WM_BUTTON1CLICK
:
1968 case WM_BUTTON1DOWN
:
1969 case WM_BUTTON1MOTIONSTART
:
1972 case WM_BUTTON1DBLCLK
:
1978 case WM_BUTTON2CLICK
:
1979 rCode
= MOUSE_RIGHT
;
1982 case WM_BUTTON2DOWN
:
1983 case WM_BUTTON2MOTIONSTART
:
1984 rCode
= MOUSE_RIGHT
;
1986 case WM_BUTTON2DBLCLK
:
1987 rCode
= MOUSE_RIGHT
;
1992 case WM_BUTTON3CLICK
:
1993 rCode
= MOUSE_MIDDLE
;
1996 case WM_BUTTON3DOWN
:
1997 case WM_BUTTON3MOTIONSTART
:
1998 rCode
= MOUSE_MIDDLE
;
2000 case WM_BUTTON3DBLCLK
:
2001 rCode
= MOUSE_MIDDLE
;
2009 lValue
= (lValue
& 0xFFFF0000) >> 16;
2010 if ( lValue
!= 0xFFFF )
2012 if ( lValue
& KC_SHIFT
)
2014 if ( lValue
& KC_CTRL
)
2016 if ( lValue
& KC_ALT
)
2023 // -----------------------------------------------------------------------
2025 static BOOL
ImplSalIsSameColor( const Color
& rColor1
, const Color
& rColor2
)
2028 nWrong
+= Abs( (short)rColor1
.GetRed()-(short)rColor2
.GetRed() );
2029 nWrong
+= Abs( (short)rColor1
.GetGreen()-(short)rColor2
.GetGreen() );
2030 nWrong
+= Abs( (short)rColor1
.GetBlue()-(short)rColor2
.GetBlue() );
2031 return (nWrong
< 30);
2034 // -----------------------------------------------------------------------
2036 static BOOL
ImplOS2NameFontToVCLFont( const char* pFontName
, Font
& rFont
)
2041 while ( *pFontName
&& (*pFontName
!= '.') &&
2042 (nNumBufLen
< sizeof(aNumBuf
)-1) )
2044 aNumBuf
[nNumBufLen
] = *pFontName
;
2048 aNumBuf
[nNumBufLen
] = '\0';
2051 while ( *pFontName
== ' ' )
2054 int nFontHeight
= atoi( aNumBuf
);
2055 int nFontNameLen
= strlen( pFontName
);
2056 if ( nFontHeight
&& nFontNameLen
)
2058 rFont
.SetFamily( FAMILY_DONTKNOW
);
2059 rFont
.SetWeight( WEIGHT_NORMAL
);
2060 rFont
.SetItalic( ITALIC_NONE
);
2061 // search for a style embedded in the name, e.g. 'WarpSans Bold'
2062 // because we need to split the style from the family name
2063 if (strstr( pFontName
, " Bold")
2064 || strstr( pFontName
, " Italic")
2065 || strstr( pFontName
, "-Normal"))
2067 char* fontName
= strdup( pFontName
);
2068 char* style
= strstr( fontName
, " Bold");
2070 rFont
.SetWeight( WEIGHT_BOLD
);
2073 style
= strstr( fontName
, " Italic");
2075 rFont
.SetItalic( ITALIC_NORMAL
);
2078 style
= strstr( fontName
, "-Normal");
2079 // store style, skip whitespace char
2080 rFont
.SetStyleName( ::rtl::OStringToOUString ( style
+1, gsl_getSystemTextEncoding()) );
2083 // store family name
2084 rFont
.SetName( ::rtl::OStringToOUString ( fontName
, gsl_getSystemTextEncoding()) );
2089 rFont
.SetName( ::rtl::OStringToOUString (pFontName
, gsl_getSystemTextEncoding()) );
2090 rFont
.SetStyleName( ::rtl::OStringToOUString ("", gsl_getSystemTextEncoding()) );
2093 rFont
.SetSize( Size( 0, nFontHeight
) );
2100 // -----------------------------------------------------------------------
2102 void Os2SalFrame::UpdateSettings( AllSettings
& rSettings
)
2104 static char aControlPanel
[] = "PM_ControlPanel";
2105 static char aSystemFonts
[] = "PM_SystemFonts";
2106 char aDummyStr
[] = "";
2108 // --- Mouse setting ---
2112 MouseSettings aMouseSettings
= rSettings
.GetMouseSettings();
2113 aMouseSettings
.SetDoubleClickTime( WinQuerySysValue( HWND_DESKTOP
, SV_DBLCLKTIME
) );
2114 if ( ImplMouseSysValueToSAL( SV_BEGINDRAG
, nCode
, nClicks
, bDown
) )
2115 aMouseSettings
.SetStartDragCode( nCode
);
2116 if ( ImplMouseSysValueToSAL( SV_CONTEXTMENU
, nCode
, nClicks
, bDown
) )
2118 aMouseSettings
.SetContextMenuCode( nCode
);
2119 aMouseSettings
.SetContextMenuClicks( nClicks
);
2120 aMouseSettings
.SetContextMenuDown( bDown
);
2122 aMouseSettings
.SetButtonStartRepeat( WinQuerySysValue( HWND_DESKTOP
, SV_FIRSTSCROLLRATE
) );
2123 aMouseSettings
.SetButtonRepeat( WinQuerySysValue( HWND_DESKTOP
, SV_SCROLLRATE
) );
2124 rSettings
.SetMouseSettings( aMouseSettings
);
2126 // --- Style settings ---
2127 StyleSettings aStyleSettings
= rSettings
.GetStyleSettings();
2128 BOOL bCompBorder
= (aStyleSettings
.GetOptions() & (STYLE_OPTION_MACSTYLE
| STYLE_OPTION_UNIXSTYLE
)) == 0;
2131 LONG nDisplayTime
= PrfQueryProfileInt( HINI_PROFILE
, (PSZ
)aControlPanel
, (PSZ
)"LogoDisplayTime", -1 );
2132 ULONG nSalDisplayTime
;
2133 if ( nDisplayTime
< 0 )
2134 nSalDisplayTime
= LOGO_DISPLAYTIME_STARTTIME
;
2135 else if ( !nDisplayTime
)
2136 nSalDisplayTime
= LOGO_DISPLAYTIME_NOLOGO
;
2138 nSalDisplayTime
= (ULONG
)nDisplayTime
;
2139 aStyleSettings
.SetLogoDisplayTime( nSalDisplayTime
);
2141 aStyleSettings
.SetCursorBlinkTime( WinQuerySysValue( HWND_DESKTOP
, SV_CURSORRATE
) );
2142 ULONG nDragFullOptions
= aStyleSettings
.GetDragFullOptions();
2143 if ( WinQuerySysValue( HWND_DESKTOP
, SV_DYNAMICDRAG
) )
2144 nDragFullOptions
|= DRAGFULL_OPTION_WINDOWMOVE
| DRAGFULL_OPTION_WINDOWSIZE
| DRAGFULL_OPTION_DOCKING
| DRAGFULL_OPTION_SPLIT
;
2146 nDragFullOptions
&= ~(DRAGFULL_OPTION_WINDOWMOVE
| DRAGFULL_OPTION_WINDOWSIZE
| DRAGFULL_OPTION_DOCKING
| DRAGFULL_OPTION_SPLIT
);
2147 aStyleSettings
.SetDragFullOptions( nDragFullOptions
);
2150 aStyleSettings
.SetScrollBarSize( WinQuerySysValue( HWND_DESKTOP
, SV_CYHSCROLL
) );
2153 aStyleSettings
.SetTitleHeight( WinQuerySysValue( HWND_DESKTOP
, SV_CYTITLEBAR
) );
2159 aStyleSettings
.SetFaceColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_BUTTONMIDDLE
, 0 ) ) );
2160 aStyleSettings
.SetInactiveTabColor( aStyleSettings
.GetFaceColor() );
2161 aStyleSettings
.SetLightColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_BUTTONLIGHT
, 0 ) ) );
2162 aStyleSettings
.SetLightBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_BUTTONMIDDLE
, 0 ) ) );
2163 aStyleSettings
.SetShadowColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_BUTTONDARK
, 0 ) ) );
2164 aStyleSettings
.SetDarkShadowColor( Color( COL_BLACK
) );
2165 aStyleSettings
.SetDialogColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_DIALOGBACKGROUND
, 0 ) ) );
2166 aStyleSettings
.SetButtonTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENUTEXT
, 0 ) ) );
2167 aStyleSettings
.SetActiveColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_ACTIVETITLE
, 0 ) ) );
2168 aStyleSettings
.SetActiveTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_ACTIVETITLETEXT
, 0 ) ) );
2169 aStyleSettings
.SetActiveBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_ACTIVEBORDER
, 0 ) ) );
2170 aStyleSettings
.SetDeactiveColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_INACTIVETITLE
, 0 ) ) );
2171 aStyleSettings
.SetDeactiveTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_INACTIVETITLETEXT
, 0 ) ) );
2172 aStyleSettings
.SetDeactiveBorderColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_INACTIVEBORDER
, 0 ) ) );
2173 aStyleSettings
.SetMenuColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENU
, 0 ) ) );
2174 aStyleSettings
.SetMenuTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENUTEXT
, 0 ) ) );
2175 aStyleSettings
.SetMenuBarTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENUTEXT
, 0 ) ) );
2177 aStyleSettings
.SetDialogTextColor( aStyleSettings
.GetButtonTextColor() );
2178 aStyleSettings
.SetRadioCheckTextColor( aStyleSettings
.GetButtonTextColor() );
2179 aStyleSettings
.SetGroupTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_WINDOWSTATICTEXT
, 0 ) ) );
2180 aStyleSettings
.SetLabelTextColor( aStyleSettings
.GetGroupTextColor() );
2181 aStyleSettings
.SetInfoTextColor( aStyleSettings
.GetGroupTextColor() );
2182 aStyleSettings
.SetWindowColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_WINDOW
, 0 ) ) );
2183 aStyleSettings
.SetActiveTabColor( aStyleSettings
.GetWindowColor() );
2184 aStyleSettings
.SetWindowTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_WINDOWTEXT
, 0 ) ) );
2185 aStyleSettings
.SetFieldColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_ENTRYFIELD
, 0 ) ) );
2186 aStyleSettings
.SetFieldTextColor( aStyleSettings
.GetWindowTextColor() );
2187 aStyleSettings
.SetDisableColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENUDISABLEDTEXT
, 0 ) ) );
2188 aStyleSettings
.SetHighlightColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_HILITEBACKGROUND
, 0 ) ) );
2189 aStyleSettings
.SetHighlightTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_HILITEFOREGROUND
, 0 ) ) );
2190 Color aMenuHighColor
= ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENUHILITEBGND
, 0 ) );
2191 if ( ImplSalIsSameColor( aMenuHighColor
, aStyleSettings
.GetMenuColor() ) )
2195 aStyleSettings
.SetMenuHighlightColor( Color( COL_BLUE
) );
2196 aStyleSettings
.SetMenuHighlightTextColor( Color( COL_WHITE
) );
2201 aStyleSettings
.SetMenuHighlightColor( aMenuHighColor
);
2202 aStyleSettings
.SetMenuHighlightTextColor( ImplOS2ColorToSal( WinQuerySysColor( HWND_DESKTOP
, SYSCLR_MENUHILITE
, 0 ) ) );
2204 // Checked-Color berechnen
2205 Color aColor1
= aStyleSettings
.GetFaceColor();
2206 Color aColor2
= aStyleSettings
.GetLightColor();
2207 BYTE nRed
= (BYTE
)(((USHORT
)aColor1
.GetRed() + (USHORT
)aColor2
.GetRed())/2);
2208 BYTE nGreen
= (BYTE
)(((USHORT
)aColor1
.GetGreen() + (USHORT
)aColor2
.GetGreen())/2);
2209 BYTE nBlue
= (BYTE
)(((USHORT
)aColor1
.GetBlue() + (USHORT
)aColor2
.GetBlue())/2);
2210 aStyleSettings
.SetCheckedColor( Color( nRed
, nGreen
, nBlue
) );
2214 char aFontNameBuf
[255];
2215 aFont
= aStyleSettings
.GetMenuFont();
2216 if ( PrfQueryProfileString( HINI_PROFILE
, (PSZ
)aSystemFonts
, (PSZ
)"Menus", aDummyStr
, aFontNameBuf
, sizeof( aFontNameBuf
) ) > 5 )
2218 if ( ImplOS2NameFontToVCLFont( aFontNameBuf
, aFont
) ) {
2220 // Add Workplace Sans if not already listed
2221 if ( aFont
.GetName().Search( (sal_Unicode
*)L
"WorkPlace Sans" ) == STRING_NOTFOUND
)
2223 XubString aFontName
= aFont
.GetName();
2224 aFontName
.Insert( (sal_Unicode
*)L
"WorkPlace Sans;", 0 );
2225 aFont
.SetName( aFontName
);
2226 aFont
.SetSize( Size( 0, 9 ) );
2229 aStyleSettings
.SetMenuFont( aFont
);
2232 aFont
= aStyleSettings
.GetIconFont();
2233 if ( PrfQueryProfileString( HINI_PROFILE
, (PSZ
)aSystemFonts
, (PSZ
)"IconText", aDummyStr
, aFontNameBuf
, sizeof( aFontNameBuf
) ) > 5 )
2235 if ( ImplOS2NameFontToVCLFont( aFontNameBuf
, aFont
) )
2236 aStyleSettings
.SetIconFont( aFont
);
2238 aFont
= aStyleSettings
.GetTitleFont();
2239 if ( PrfQueryProfileString( HINI_PROFILE
, (PSZ
)aSystemFonts
, (PSZ
)"WindowTitles", aDummyStr
, aFontNameBuf
, sizeof( aFontNameBuf
) ) > 5 )
2241 if ( ImplOS2NameFontToVCLFont( aFontNameBuf
, aFont
) )
2243 // Add Workplace Sans if not already listed
2244 if ( aFont
.GetName().Search( (sal_Unicode
*)L
"WorkPlace Sans" ) == STRING_NOTFOUND
)
2246 XubString aFontName
= aFont
.GetName();
2247 aFontName
.Insert( (sal_Unicode
*)L
"WorkPlace Sans;", 0 );
2248 aFont
.SetName( aFontName
);
2249 aFont
.SetSize( Size( 0, 9 ) );
2250 aFont
.SetWeight( WEIGHT_BOLD
);
2251 aFont
.SetItalic( ITALIC_NONE
);
2253 aStyleSettings
.SetTitleFont( aFont
);
2254 aStyleSettings
.SetFloatTitleFont( aFont
);
2257 aFont
= aStyleSettings
.GetAppFont();
2258 if ( PrfQueryProfileString( HINI_PROFILE
, (PSZ
)aSystemFonts
, (PSZ
)"WindowText", aDummyStr
, aFontNameBuf
, sizeof( aFontNameBuf
) ) > 5 )
2260 if ( ImplOS2NameFontToVCLFont( aFontNameBuf
, aFont
) )
2262 Font aHelpFont
= aFont
;
2263 aHelpFont
.SetName( (sal_Unicode
*)L
"Helv;WarpSans" );
2264 aHelpFont
.SetSize( Size( 0, 8 ) );
2265 aHelpFont
.SetWeight( WEIGHT_NORMAL
);
2266 aHelpFont
.SetItalic( ITALIC_NONE
);
2267 aStyleSettings
.SetHelpFont( aHelpFont
);
2269 // Add Workplace Sans if not already listed
2270 if ( aFont
.GetName().Search( (sal_Unicode
*)L
"WorkPlace Sans" ) == STRING_NOTFOUND
)
2272 XubString aFontName
= aFont
.GetName();
2273 aFontName
.Insert( (sal_Unicode
*)L
"WorkPlace Sans;", 0 );
2274 aFont
.SetName( aFontName
);
2275 aFont
.SetSize( Size( 0, 9 ) );
2277 aStyleSettings
.SetAppFont( aFont
);
2278 aStyleSettings
.SetToolFont( aFont
);
2279 aStyleSettings
.SetLabelFont( aFont
);
2280 aStyleSettings
.SetInfoFont( aFont
);
2281 aStyleSettings
.SetRadioCheckFont( aFont
);
2282 aStyleSettings
.SetPushButtonFont( aFont
);
2283 aStyleSettings
.SetFieldFont( aFont
);
2284 aStyleSettings
.SetGroupFont( aFont
);
2288 rSettings
.SetStyleSettings( aStyleSettings
);
2291 // -----------------------------------------------------------------------
2293 SalBitmap
* Os2SalFrame::SnapShot()
2295 debug_printf("Os2SalFrame::SnapShot\n");
2299 // -----------------------------------------------------------------------
2301 const SystemEnvData
* Os2SalFrame::GetSystemData() const
2306 // -----------------------------------------------------------------------
2308 void Os2SalFrame::Beep( SoundType eSoundType
)
2310 static ULONG aImplSoundTab
[5] =
2312 WA_NOTE
, // SOUND_DEFAULT
2313 WA_NOTE
, // SOUND_INFO
2314 WA_WARNING
, // SOUND_WARNING
2315 WA_ERROR
, // SOUND_ERROR
2316 WA_NOTE
// SOUND_QUERY
2320 #if SOUND_COUNT != 5
2321 #error New Sound must be defined!
2325 debug_printf("Os2SalFrame::Beep %d\n", eSoundType
);
2326 WinAlarm( HWND_DESKTOP
, aImplSoundTab
[eSoundType
] );
2329 // -----------------------------------------------------------------------
2331 SalFrame::SalPointerState
Os2SalFrame::GetPointerState()
2333 SalPointerState aState
;
2336 // MausModus feststellen und setzen
2337 if ( WinGetKeyState( HWND_DESKTOP
, VK_BUTTON1
) & 0x8000 )
2338 aState
.mnState
|= MOUSE_LEFT
;
2339 if ( WinGetKeyState( HWND_DESKTOP
, VK_BUTTON2
) & 0x8000 )
2340 aState
.mnState
|= MOUSE_RIGHT
;
2341 if ( WinGetKeyState( HWND_DESKTOP
, VK_BUTTON3
) & 0x8000 )
2342 aState
.mnState
|= MOUSE_MIDDLE
;
2343 // Modifier-Tasten setzen
2344 if ( WinGetKeyState( HWND_DESKTOP
, VK_SHIFT
) & 0x8000 )
2345 aState
.mnState
|= KEY_SHIFT
;
2346 if ( WinGetKeyState( HWND_DESKTOP
, VK_CTRL
) & 0x8000 )
2347 aState
.mnState
|= KEY_MOD1
;
2348 if ( WinGetKeyState( HWND_DESKTOP
, VK_ALT
) & 0x8000 )
2349 aState
.mnState
|= KEY_MOD2
;
2352 _WinQueryPointerPos( HWND_DESKTOP
, &pt
);
2354 aState
.maPos
= Point( pt
.x
- maGeometry
.nX
, pt
.y
- maGeometry
.nY
);
2358 // -----------------------------------------------------------------------
2360 SalFrame::SalIndicatorState
Os2SalFrame::GetIndicatorState()
2362 SalIndicatorState aState
;
2367 void Os2SalFrame::SimulateKeyPress( USHORT
/*nKeyCode*/ )
2371 // -----------------------------------------------------------------------
2373 void Os2SalFrame::SetBackgroundBitmap( SalBitmap
* )
2377 // -----------------------------------------------------------------------
2379 void SalTestMouseLeave()
2381 SalData
* pSalData
= GetSalData();
2383 if ( pSalData
->mhWantLeaveMsg
&& !::WinQueryCapture( HWND_DESKTOP
) )
2386 WinQueryPointerPos( HWND_DESKTOP
, &aPt
);
2387 if ( pSalData
->mhWantLeaveMsg
!= WinWindowFromPoint( HWND_DESKTOP
, &aPt
, TRUE
) )
2388 WinSendMsg( pSalData
->mhWantLeaveMsg
, SAL_MSG_MOUSELEAVE
, 0, MPFROM2SHORT( aPt
.x
, aPt
.y
) );
2392 // -----------------------------------------------------------------------
2394 static long ImplHandleMouseMsg( HWND hWnd
,
2395 UINT nMsg
, MPARAM nMP1
, MPARAM nMP2
)
2397 SalMouseEvent aMouseEvt
;
2401 USHORT nFlags
= SHORT2FROMMP( nMP2
);
2402 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
2406 aMouseEvt
.mnX
= (short)SHORT1FROMMP( nMP1
);
2407 aMouseEvt
.mnY
= pFrame
->mnHeight
- (short)SHORT2FROMMP( nMP1
) - 1;
2408 aMouseEvt
.mnCode
= 0;
2409 aMouseEvt
.mnTime
= WinQueryMsgTime( pFrame
->mhAB
);
2411 // MausModus feststellen und setzen
2412 if ( WinGetKeyState( HWND_DESKTOP
, VK_BUTTON1
) & 0x8000 )
2413 aMouseEvt
.mnCode
|= MOUSE_LEFT
;
2414 if ( WinGetKeyState( HWND_DESKTOP
, VK_BUTTON2
) & 0x8000 )
2415 aMouseEvt
.mnCode
|= MOUSE_RIGHT
;
2416 if ( WinGetKeyState( HWND_DESKTOP
, VK_BUTTON3
) & 0x8000 )
2417 aMouseEvt
.mnCode
|= MOUSE_MIDDLE
;
2418 // Modifier-Tasten setzen
2419 if ( WinGetKeyState( HWND_DESKTOP
, VK_SHIFT
) & 0x8000 )
2420 aMouseEvt
.mnCode
|= KEY_SHIFT
;
2421 if ( WinGetKeyState( HWND_DESKTOP
, VK_CTRL
) & 0x8000 )
2422 aMouseEvt
.mnCode
|= KEY_MOD1
;
2423 if ( WinGetKeyState( HWND_DESKTOP
, VK_ALT
) & 0x8000 )
2424 aMouseEvt
.mnCode
|= KEY_MOD2
;
2430 SalData
* pSalData
= GetSalData();
2432 // Da bei Druecken von Modifier-Tasten die MouseEvents
2433 // nicht zusammengefast werden (da diese durch KeyEvents
2434 // unterbrochen werden), machen wir dieses hier selber
2435 if ( aMouseEvt
.mnCode
& (KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
) )
2438 if ( WinPeekMsg( pSalData
->mhAB
, &aTempMsg
,
2439 pFrame
->mhWndClient
,
2440 WM_MOUSEFIRST
, WM_MOUSELAST
, PM_NOREMOVE
) )
2442 if ( (aTempMsg
.msg
== WM_MOUSEMOVE
) &&
2443 (aTempMsg
.mp2
== nMP2
) )
2448 // Test for MouseLeave
2449 if ( pSalData
->mhWantLeaveMsg
&&
2450 (pSalData
->mhWantLeaveMsg
!= pFrame
->mhWndClient
) )
2453 WinQueryMsgPos( pFrame
->mhAB
, &aMousePoint
);
2454 WinSendMsg( pSalData
->mhWantLeaveMsg
,
2456 0, MPFROM2SHORT( aMousePoint
.x
, aMousePoint
.y
) );
2458 pSalData
->mhWantLeaveMsg
= pFrame
->mhWndClient
;
2459 // Start MouseLeave-Timer
2460 if ( !pSalData
->mpMouseLeaveTimer
)
2462 pSalData
->mpMouseLeaveTimer
= new AutoTimer
;
2463 pSalData
->mpMouseLeaveTimer
->SetTimeout( SAL_MOUSELEAVE_TIMEOUT
);
2464 pSalData
->mpMouseLeaveTimer
->Start();
2465 // We dont need to set a timeout handler, because we test
2466 // for mouseleave in the timeout callback
2468 aMouseEvt
.mnButton
= 0;
2469 nEvent
= SALEVENT_MOUSEMOVE
;
2473 case SAL_MSG_MOUSELEAVE
:
2475 SalData
* pSalData
= GetSalData();
2476 if ( pSalData
->mhWantLeaveMsg
== pFrame
->mhWndClient
)
2478 pSalData
->mhWantLeaveMsg
= 0;
2479 if ( pSalData
->mpMouseLeaveTimer
)
2481 delete pSalData
->mpMouseLeaveTimer
;
2482 pSalData
->mpMouseLeaveTimer
= NULL
;
2485 // Mouse-Coordinaates are relativ to the screen
2487 aPt
.x
= (short)SHORT1FROMMP( nMP2
);
2488 aPt
.y
= (short)SHORT2FROMMP( nMP2
);
2489 WinMapWindowPoints( HWND_DESKTOP
, pFrame
->mhWndClient
, &aPt
, 1 );
2490 aPt
.y
= pFrame
->mnHeight
- aPt
.y
- 1;
2491 aMouseEvt
.mnX
= aPt
.x
;
2492 aMouseEvt
.mnY
= aPt
.y
;
2493 aMouseEvt
.mnButton
= 0;
2494 nEvent
= SALEVENT_MOUSELEAVE
;
2501 case WM_BUTTON1DBLCLK
:
2502 case WM_BUTTON1DOWN
:
2503 aMouseEvt
.mnButton
= MOUSE_LEFT
;
2504 nEvent
= SALEVENT_MOUSEBUTTONDOWN
;
2507 case WM_BUTTON2DBLCLK
:
2508 case WM_BUTTON2DOWN
:
2509 aMouseEvt
.mnButton
= MOUSE_RIGHT
;
2510 nEvent
= SALEVENT_MOUSEBUTTONDOWN
;
2513 case WM_BUTTON3DBLCLK
:
2514 case WM_BUTTON3DOWN
:
2515 aMouseEvt
.mnButton
= MOUSE_MIDDLE
;
2516 nEvent
= SALEVENT_MOUSEBUTTONDOWN
;
2520 aMouseEvt
.mnButton
= MOUSE_LEFT
;
2521 nEvent
= SALEVENT_MOUSEBUTTONUP
;
2525 aMouseEvt
.mnButton
= MOUSE_RIGHT
;
2526 nEvent
= SALEVENT_MOUSEBUTTONUP
;
2530 aMouseEvt
.mnButton
= MOUSE_MIDDLE
;
2531 nEvent
= SALEVENT_MOUSEBUTTONUP
;
2535 // check if this window was destroyed - this might happen if we are the help window
2536 // and sent a mouse leave message to the application which killed the help window, ie ourself
2537 if( !WinIsWindow( pFrame
->mhAB
, hWnd
) )
2540 #if OSL_DEBUG_LEVEL>10
2542 debug_printf("ImplHandleMouseMsg mouse %d,%d\n",aMouseEvt
.mnX
,aMouseEvt
.mnY
);
2547 if ( nEvent
== SALEVENT_MOUSEBUTTONDOWN
)
2548 WinUpdateWindow( pFrame
->mhWndClient
);
2550 // --- RTL --- (mirror mouse pos)
2551 //if( Application::GetSettings().GetLayoutRTL() )
2552 // aMouseEvt.mnX = pFrame->maGeometry.nWidth-1-aMouseEvt.mnX;
2554 nRet
= pFrame
->CallCallback( nEvent
, &aMouseEvt
);
2555 if ( nMsg
== WM_MOUSEMOVE
)
2557 WinSetPointer( HWND_DESKTOP
, pFrame
->mhPointer
);
2567 // -----------------------------------------------------------------------
2569 static long ImplHandleWheelMsg( HWND hWnd
, UINT nMsg
, MPARAM nMP1
, MPARAM nMP2
)
2572 ImplSalYieldMutexAcquireWithWait();
2575 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
2579 // Mouse-Coordinaates are relativ to the screen
2581 WinQueryMsgPos( pFrame
->mhAB
, &aPt
);
2582 WinMapWindowPoints( HWND_DESKTOP
, pFrame
->mhWndClient
, &aPt
, 1 );
2583 aPt
.y
= pFrame
->mnHeight
- aPt
.y
- 1;
2585 SalWheelMouseEvent aWheelEvt
;
2586 aWheelEvt
.mnTime
= WinQueryMsgTime( pFrame
->mhAB
);
2587 aWheelEvt
.mnX
= aPt
.x
;
2588 aWheelEvt
.mnY
= aPt
.y
;
2589 aWheelEvt
.mnCode
= 0;
2590 bool bNeg
= (SHORT2FROMMP(nMP2
) == SB_LINEDOWN
|| SHORT2FROMMP(nMP2
) == SB_PAGEDOWN
);
2591 aWheelEvt
.mnDelta
= bNeg
? -120 : 120;
2592 aWheelEvt
.mnNotchDelta
= bNeg
? -1 : 1;
2593 if (SHORT2FROMMP(nMP2
) == SB_PAGEUP
|| SHORT2FROMMP(nMP2
) == SB_PAGEDOWN
)
2594 aWheelEvt
.mnScrollLines
= SAL_WHEELMOUSE_EVENT_PAGESCROLL
;
2596 aWheelEvt
.mnScrollLines
= 1;
2598 if( nMsg
== WM_HSCROLL
)
2599 aWheelEvt
.mbHorz
= TRUE
;
2601 // Modifier-Tasten setzen
2602 if ( WinGetKeyState( HWND_DESKTOP
, VK_SHIFT
) & 0x8000 )
2603 aWheelEvt
.mnCode
|= KEY_SHIFT
;
2604 if ( WinGetKeyState( HWND_DESKTOP
, VK_CTRL
) & 0x8000 )
2605 aWheelEvt
.mnCode
|= KEY_MOD1
;
2606 if ( WinGetKeyState( HWND_DESKTOP
, VK_ALT
) & 0x8000 )
2607 aWheelEvt
.mnCode
|= KEY_MOD2
;
2609 nRet
= pFrame
->CallCallback( SALEVENT_WHEELMOUSE
, &aWheelEvt
);
2612 ImplSalYieldMutexRelease();
2618 // -----------------------------------------------------------------------
2620 static USHORT
ImplSalGetKeyCode( Os2SalFrame
* pFrame
, MPARAM aMP1
, MPARAM aMP2
)
2622 USHORT nKeyFlags
= SHORT1FROMMP( aMP1
);
2623 UCHAR nCharCode
= (UCHAR
)SHORT1FROMMP( aMP2
);
2624 USHORT nKeyCode
= (UCHAR
)SHORT2FROMMP( aMP2
);
2625 UCHAR nScanCode
= (UCHAR
)CHAR4FROMMP( aMP1
);
2628 // Ist virtueller KeyCode gesetzt und befindet sich der KeyCode in der
2629 // Tabelle, dann mappen
2630 if ( (nKeyFlags
& KC_VIRTUALKEY
) && (nKeyCode
< KEY_TAB_SIZE
) )
2631 rSVCode
= aImplTranslateKeyTab
[nKeyCode
];
2633 // Wenn kein KeyCode ermittelt werden konnte, versuchen wir aus dem
2634 // CharCode einen zu erzeugen
2635 if ( !rSVCode
&& nCharCode
)
2637 // Bei 0-9, a-z und A-Z auch KeyCode setzen
2638 if ( (nCharCode
>= '0') && (nCharCode
<= '9') && (!rSVCode
|| !(nKeyFlags
& KC_SHIFT
)) )
2639 rSVCode
= KEYGROUP_NUM
+ (nCharCode
-'0');
2640 else if ( (nCharCode
>= 'a') && (nCharCode
<= 'z') )
2641 rSVCode
= KEYGROUP_ALPHA
+ (nCharCode
-'a');
2642 else if ( (nCharCode
>= 'A') && (nCharCode
<= 'Z') )
2643 rSVCode
= KEYGROUP_ALPHA
+ (nCharCode
-'A');
2646 switch ( nCharCode
)
2652 rSVCode
= KEY_SUBTRACT
;
2655 rSVCode
= KEY_MULTIPLY
;
2658 rSVCode
= KEY_DIVIDE
;
2661 rSVCode
= KEY_POINT
;
2664 rSVCode
= KEY_COMMA
;
2670 rSVCode
= KEY_GREATER
;
2673 rSVCode
= KEY_EQUAL
;
2679 // "Numlock-Hack": we want to get correct keycodes from the numpad
2680 if ( (nCharCode
>= '0') && (nCharCode
<= '9') && !(nKeyFlags
& KC_SHIFT
) )
2681 rSVCode
= KEYGROUP_NUM
+ (nCharCode
-'0');
2682 if ( nCharCode
== ',' )
2683 rSVCode
= KEY_COMMA
;
2684 if ( nCharCode
== '.' )
2685 rSVCode
= KEY_POINT
;
2690 // -----------------------------------------------------------------------
2692 static void ImplUpdateInputLang( Os2SalFrame
* pFrame
)
2694 BOOL bLanguageChange
= FALSE
;
2697 UconvObject uconv_object
= NULL
;
2698 LocaleObject locale_object
= NULL
;
2699 UniChar
*pinfo_item
;
2701 // we do not support change of input language while working,
2702 // so exit if already defined (mnInputLang is a static class field)
2703 if (pFrame
->mnInputLang
)
2706 // get current locale
2707 rc
= UniCreateLocaleObject(UNI_UCS_STRING_POINTER
, (UniChar
*)L
"", &locale_object
);
2708 // get Win32 locale id and sublanguage (hex uni string)
2709 rc
= UniQueryLocaleItem(locale_object
, LOCI_xWinLocale
, &pinfo_item
);
2710 // convert uni string to integer
2711 rc
= UniStrtoul(locale_object
, pinfo_item
, &pinfo_item
, 16, &nLang
);
2712 rc
= UniFreeMem(pinfo_item
);
2713 #if OSL_DEBUG_LEVEL>10
2714 debug_printf("ImplUpdateInputLang nLang %04x\n", nLang
);
2715 char char_buffer
[256];
2716 rc
= UniCreateUconvObject((UniChar
*)L
"", &uconv_object
);
2717 rc
= UniQueryLocaleItem(locale_object
, LOCI_sKeyboard
, &pinfo_item
);
2718 rc
= UniStrFromUcs(uconv_object
, char_buffer
, pinfo_item
, sizeof(char_buffer
));
2719 debug_printf("Keyboard name is: %s\n", char_buffer
);
2720 rc
= UniFreeMem(pinfo_item
);
2722 rc
= UniFreeLocaleObject(locale_object
);
2724 // keep input lang up-to-date
2725 #if OSL_DEBUG_LEVEL>10
2726 debug_printf("ImplUpdateInputLang pFrame %08x lang changed from %d to %d\n",
2727 pFrame
, pFrame
->mnInputLang
, nLang
);
2729 pFrame
->mnInputLang
= nLang
;
2733 static sal_Unicode
ImplGetCharCode( Os2SalFrame
* pFrame
, USHORT nKeyFlags
,
2734 sal_Char nCharCode
, UCHAR nScanCode
)
2736 ImplUpdateInputLang( pFrame
);
2737 #if OSL_DEBUG_LEVEL>10
2738 debug_printf("ImplGetCharCode nCharCode %c, %04x\n", nCharCode
, nCharCode
);
2740 return OUString( &nCharCode
, 1, gsl_getSystemTextEncoding()).toChar();
2743 // -----------------------------------------------------------------------
2745 LanguageType
Os2SalFrame::GetInputLanguage()
2748 ImplUpdateInputLang( this );
2751 return LANGUAGE_DONTKNOW
;
2753 return (LanguageType
) mnInputLang
;
2756 // -----------------------------------------------------------------------
2758 BOOL
Os2SalFrame::MapUnicodeToKeyCode( sal_Unicode
, LanguageType
, KeyCode
& )
2760 // not supported yet
2764 // -----------------------------------------------------------------------
2766 static sal_Unicode
ImplConvertKey( Os2SalFrame
* pFrame
, MPARAM aMP1
, MPARAM aMP2
)
2768 USHORT nKeyFlags
= SHORT1FROMMP( aMP1
);
2769 UCHAR nCharCode
= (UCHAR
)SHORT1FROMMP( aMP2
);
2770 USHORT nKeyCode
= (UCHAR
)SHORT2FROMMP( aMP2
);
2771 UCHAR nScanCode
= (UCHAR
)CHAR4FROMMP( aMP1
);
2772 sal_Unicode rSVCharCode
= 0;
2774 // Ist Character-Code gesetzt
2775 // !!! Bei CTRL/ALT ist KC_CHAR nicht gesetzt, jedoch moechten wir
2776 // !!! dann auch einen CharCode und machen die Behandlung deshalb
2778 if ( (nKeyFlags
& KC_CHAR
) || (nKeyFlags
& KC_CTRL
) || (nKeyFlags
& KC_ALT
) )
2779 rSVCharCode
= ImplGetCharCode( pFrame
, nKeyFlags
, nCharCode
, nScanCode
);
2785 // -----------------------------------------------------------------------
2787 static long ImplHandleKeyMsg( HWND hWnd
,
2788 UINT nMsg
, MPARAM nMP1
, MPARAM nMP2
)
2790 static USHORT nLastOS2KeyChar
= 0;
2791 static sal_Unicode nLastChar
= 0;
2792 USHORT nRepeat
= CHAR3FROMMP( nMP1
) - 1;
2793 SHORT nFlags
= SHORT1FROMMP( nMP1
);
2794 USHORT nModCode
= 0;
2796 USHORT nOS2KeyCode
= (UCHAR
)SHORT2FROMMP( nMP2
);
2797 sal_Unicode nSVCharCode
= 0;
2800 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
2804 // determine modifiers
2805 if ( nFlags
& KC_SHIFT
)
2806 nModCode
|= KEY_SHIFT
;
2807 if ( nFlags
& KC_CTRL
)
2808 nModCode
|= KEY_MOD1
;
2809 if ( nFlags
& KC_ALT
)
2810 nModCode
|= KEY_MOD2
;
2812 // Bei Shift, Control und Alt schicken wir einen KeyModChange-Event
2813 if ( (nOS2KeyCode
== VK_SHIFT
) || (nOS2KeyCode
== VK_CTRL
) ||
2814 (nOS2KeyCode
== VK_ALT
) || (nOS2KeyCode
== VK_ALTGRAF
) )
2816 SalKeyModEvent aModEvt
;
2817 aModEvt
.mnTime
= WinQueryMsgTime( pFrame
->mhAB
);
2818 aModEvt
.mnCode
= nModCode
;
2819 #if OSL_DEBUG_LEVEL>10
2820 debug_printf("SALEVENT_KEYMODCHANGE\n");
2822 nRet
= pFrame
->CallCallback( SALEVENT_KEYMODCHANGE
, &aModEvt
);
2826 nSVCode
= ImplSalGetKeyCode( pFrame
, nMP1
, nMP2
);
2827 nSVCharCode
= ImplConvertKey( pFrame
, nMP1
, nMP2
);
2828 #if OSL_DEBUG_LEVEL>10
2829 debug_printf("nSVCode %04x nSVCharCode %04x\n",nSVCode
,nSVCharCode
);
2832 // Fuer Java muessen wir bei KeyUp einen CharCode liefern
2833 if ( nFlags
& KC_KEYUP
)
2837 if ( nLastOS2KeyChar
== nOS2KeyCode
)
2839 nSVCharCode
= nLastChar
;
2840 nLastOS2KeyChar
= 0;
2846 nLastOS2KeyChar
= 0;
2852 nLastOS2KeyChar
= nOS2KeyCode
;
2853 nLastChar
= nSVCharCode
;
2856 if ( nSVCode
|| nSVCharCode
)
2858 SalKeyEvent aKeyEvt
;
2859 aKeyEvt
.mnCode
= nSVCode
;
2860 aKeyEvt
.mnTime
= WinQueryMsgTime( pFrame
->mhAB
);
2861 aKeyEvt
.mnCode
|= nModCode
;
2862 aKeyEvt
.mnCharCode
= nSVCharCode
;
2863 aKeyEvt
.mnRepeat
= nRepeat
;
2865 #if OSL_DEBUG_LEVEL>10
2866 debug_printf( (nFlags
& KC_KEYUP
) ? "SALEVENT_KEYUP\n" : "SALEVENT_KEYINPUT\n");
2868 nRet
= pFrame
->CallCallback( (nFlags
& KC_KEYUP
) ? SALEVENT_KEYUP
: SALEVENT_KEYINPUT
,
2876 // -----------------------------------------------------------------------
2878 static bool ImplHandlePaintMsg( HWND hWnd
)
2880 BOOL bMutex
= FALSE
;
2882 if ( ImplSalYieldMutexTryToAcquire() )
2885 // if we don't get the mutex, we can also change the clip region,
2886 // because other threads doesn't use the mutex from the main
2887 // thread --> see GetGraphics()
2889 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
2892 // Laut Window-Doku soll man erst abfragen, ob ueberhaupt eine
2893 // Paint-Region anliegt
2894 if ( WinQueryUpdateRect( hWnd
, NULL
) )
2896 // Call BeginPaint/EndPaint to query the rect and send
2897 // this Notofication to rect
2900 hPS
= WinBeginPaint( hWnd
, NULLHANDLE
, &aUpdateRect
);
2906 SalPaintEvent
aPEvt( aUpdateRect
.xLeft
, pFrame
->mnHeight
- aUpdateRect
.yTop
, aUpdateRect
.xRight
- aUpdateRect
.xLeft
, aUpdateRect
.yTop
- aUpdateRect
.yBottom
);
2908 pFrame
->CallCallback( SALEVENT_PAINT
, &aPEvt
);
2912 RECTL
* pRect
= new RECTL
;
2913 WinCopyRect( pFrame
->mhAB
, pRect
, &aUpdateRect
);
2914 WinPostMsg( hWnd
, SAL_MSG_POSTPAINT
, (MPARAM
)pRect
, 0 );
2920 ImplSalYieldMutexRelease();
2922 return bMutex
? true : false;
2925 // -----------------------------------------------------------------------
2927 static void ImplHandlePaintMsg2( HWND hWnd
, RECTL
* pRect
)
2930 if ( ImplSalYieldMutexTryToAcquire() )
2932 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
2935 SalPaintEvent
aPEvt( pRect
->xLeft
, pFrame
->mnHeight
- pRect
->yTop
, pRect
->xRight
- pRect
->xLeft
, pRect
->yTop
- pRect
->yBottom
);
2936 pFrame
->CallCallback( SALEVENT_PAINT
, &aPEvt
);
2938 ImplSalYieldMutexRelease();
2942 WinPostMsg( hWnd
, SAL_MSG_POSTPAINT
, (MPARAM
)pRect
, 0 );
2945 // -----------------------------------------------------------------------
2947 static void SetMaximizedFrameGeometry( HWND hWnd
, Os2SalFrame
* pFrame
)
2949 // calculate and set frame geometry of a maximized window - useful if the window is still hidden
2952 pFrame
->GetWorkArea( aRect
);
2954 // a maximized window has no other borders than the caption
2955 pFrame
->maGeometry
.nLeftDecoration
= pFrame
->maGeometry
.nRightDecoration
= pFrame
->maGeometry
.nBottomDecoration
= 0;
2956 pFrame
->maGeometry
.nTopDecoration
= pFrame
->mbCaption
? WinQuerySysValue( HWND_DESKTOP
, SV_CYTITLEBAR
) : 0;
2958 aRect
.yTop
+= pFrame
->maGeometry
.nTopDecoration
;
2959 pFrame
->maGeometry
.nX
= aRect
.xLeft
;
2960 pFrame
->maGeometry
.nY
= aRect
.yBottom
;
2961 pFrame
->maGeometry
.nWidth
= aRect
.xRight
- aRect
.xLeft
+ 1;
2962 pFrame
->maGeometry
.nHeight
= aRect
.yBottom
- aRect
.yTop
+ 1;
2965 static void UpdateFrameGeometry( HWND hWnd
, Os2SalFrame
* pFrame
)
2971 //maGeometry member that holds absolute screen positions (and needs to be
2972 //updated if the window is moved by the way).
2975 memset(&pFrame
->maGeometry
, 0, sizeof(SalFrameGeometry
) );
2978 LONG nFrameX
, nFrameY
, nCaptionY
;
2981 WinQueryWindowPos(pFrame
->mhWndFrame
, &swp
);
2982 if (swp
.fl
& SWP_MINIMIZE
)
2985 // map from client area to screen
2986 ImplSalCalcFrameSize( pFrame
, nFrameX
, nFrameY
, nCaptionY
);
2987 pFrame
->maGeometry
.nTopDecoration
= nFrameY
+ nCaptionY
;
2988 pFrame
->maGeometry
.nLeftDecoration
= nFrameX
;
2989 pFrame
->maGeometry
.nRightDecoration
= nFrameX
;
2990 pFrame
->maGeometry
.nBottomDecoration
= nFrameY
;
2992 // position of client area, not of frame corner!
2993 pFrame
->maGeometry
.nX
= swp
.x
+ nFrameX
;
2994 pFrame
->maGeometry
.nY
= nScreenHeight
- (swp
.y
+ swp
.cy
) + nFrameY
+ nCaptionY
;
2996 int nWidth
= swp
.cx
- pFrame
->maGeometry
.nRightDecoration
- pFrame
->maGeometry
.nLeftDecoration
;
2997 int nHeight
= swp
.cy
- pFrame
->maGeometry
.nBottomDecoration
- pFrame
->maGeometry
.nTopDecoration
;
3000 pFrame
->maGeometry
.nHeight
= nHeight
< 0 ? 0 : nHeight
;
3001 pFrame
->maGeometry
.nWidth
= nWidth
< 0 ? 0 : nWidth
;
3002 #if OSL_DEBUG_LEVEL>0
3003 debug_printf( "UpdateFrameGeometry: hwnd %x, frame %x at %d,%d (%dx%d)\n",
3004 hWnd
, pFrame
->mhWndFrame
,
3005 pFrame
->maGeometry
.nX
, pFrame
->maGeometry
.nY
,
3006 pFrame
->maGeometry
.nWidth
,pFrame
->maGeometry
.nHeight
);
3010 // -----------------------------------------------------------------------
3012 static void ImplHandleMoveMsg( HWND hWnd
)
3014 if ( ImplSalYieldMutexTryToAcquire() )
3016 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
3019 UpdateFrameGeometry( hWnd
, pFrame
);
3021 if ( WinIsWindowVisible( hWnd
))
3022 pFrame
->mbDefPos
= FALSE
;
3024 // Gegen moegliche Rekursionen sichern
3025 if ( !pFrame
->mbInMoveMsg
)
3027 // Fenster im FullScreenModus wieder einpassen
3028 pFrame
->mbInMoveMsg
= TRUE
;
3029 if ( pFrame
->mbFullScreen
)
3030 ImplSalFrameFullScreenPos( pFrame
);
3031 pFrame
->mbInMoveMsg
= FALSE
;
3035 ImplSaveFrameState( pFrame
);
3038 //#93851 if we call this handler, VCL floating windows are not updated correctly
3039 //ImplCallMoveHdl( hWnd );
3043 ImplSalYieldMutexRelease();
3046 WinPostMsg( hWnd
, SAL_MSG_POSTMOVE
, 0, 0 );
3049 // -----------------------------------------------------------------------
3051 static long ImplHandleSizeMsg( HWND hWnd
, MPARAM nMP2
)
3055 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
3058 UpdateFrameGeometry( hWnd
, pFrame
);
3059 pFrame
->mbDefPos
= FALSE
;
3060 pFrame
->mnWidth
= (short)SHORT1FROMMP( nMP2
);
3061 pFrame
->mnHeight
= (short)SHORT2FROMMP( nMP2
);
3062 if ( pFrame
->mpGraphics
)
3063 pFrame
->mpGraphics
->mnHeight
= (int)SHORT2FROMMP(nMP2
);
3065 ImplSaveFrameState( pFrame
);
3066 nRet
= pFrame
->CallCallback( SALEVENT_RESIZE
, 0 );
3067 if ( WinIsWindowVisible( pFrame
->mhWndFrame
) && !pFrame
->mbInShow
)
3068 WinUpdateWindow( pFrame
->mhWndClient
);
3073 // -----------------------------------------------------------------------
3075 static long ImplHandleFocusMsg( Os2SalFrame
* pFrame
, MPARAM nMP2
)
3077 if ( pFrame
&& !Os2SalFrame::mbInReparent
)
3079 if ( SHORT1FROMMP( nMP2
) )
3081 if ( WinIsWindowVisible( pFrame
->mhWndFrame
) && !pFrame
->mbInShow
)
3082 WinUpdateWindow( pFrame
->mhWndClient
);
3083 return pFrame
->CallCallback( SALEVENT_GETFOCUS
, 0 );
3087 return pFrame
->CallCallback( SALEVENT_LOSEFOCUS
, 0 );
3092 // -----------------------------------------------------------------------
3094 static void ImplHandleCloseMsg( HWND hWnd
)
3096 if ( ImplSalYieldMutexTryToAcquire() )
3098 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
3101 pFrame
->CallCallback( SALEVENT_CLOSE
, 0 );
3104 ImplSalYieldMutexRelease();
3107 WinPostMsg( hWnd
, WM_CLOSE
, 0, 0 );
3110 // -----------------------------------------------------------------------
3112 inline void ImplHandleUserEvent( HWND hWnd
, MPARAM nMP2
)
3114 ImplSalYieldMutexAcquireWithWait();
3115 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
3118 pFrame
->CallCallback( SALEVENT_USEREVENT
, (void*)nMP2
);
3120 ImplSalYieldMutexRelease();
3123 // -----------------------------------------------------------------------
3125 static int SalImplHandleProcessMenu( Os2SalFrame
* pFrame
, ULONG nMsg
, MPARAM nMP1
, MPARAM nMP2
)
3128 debug_printf("SalImplHandleProcessMenu\n");
3131 if( !HIWORD(wParam
) )
3134 WORD nId
= LOWORD(wParam
);
3135 if( nId
) // zero for separators
3137 SalMenuEvent aMenuEvt
;
3138 aMenuEvt
.mnId
= nId
;
3139 WinSalMenuItem
*pSalMenuItem
= ImplGetSalMenuItem( pFrame
->mSelectedhMenu
, nId
, FALSE
);
3141 aMenuEvt
.mpMenu
= pSalMenuItem
->mpMenu
;
3143 aMenuEvt
.mpMenu
= NULL
;
3145 nRet
= pFrame
->CallCallback( SALEVENT_MENUCOMMAND
, &aMenuEvt
);
3149 //return (nRet != 0);
3153 // -----------------------------------------------------------------------
3155 static void ImplHandleInputLangChange( HWND hWnd
)
3157 ImplSalYieldMutexAcquireWithWait();
3159 // Feststellen, ob wir IME unterstuetzen
3160 Os2SalFrame
* pFrame
= GetWindowPtr( hWnd
);
3162 if ( pFrame
&& pFrame
->mbIME
&& pFrame
->mhDefIMEContext
)
3164 HWND hWnd
= pFrame
->mhWnd
;
3165 HKL hKL
= (HKL
)lParam
;
3166 UINT nImeProps
= ImmGetProperty( hKL
, IGP_PROPERTY
);
3168 pFrame
->mbSpezIME
= (nImeProps
& IME_PROP_SPECIAL_UI
) != 0;
3169 pFrame
->mbAtCursorIME
= (nImeProps
& IME_PROP_AT_CARET
) != 0;
3170 pFrame
->mbHandleIME
= !pFrame
->mbSpezIME
;
3174 // trigger input language and codepage update
3175 UINT nLang
= pFrame
->mnInputLang
;
3176 ImplUpdateInputLang( pFrame
);
3177 debug_printf("ImplHandleInputLangChange new language 0x%04x\n",pFrame
->mnInputLang
);
3180 if( nLang
!= pFrame
->mnInputLang
)
3181 pFrame
->CallCallback( SALEVENT_INPUTLANGUAGECHANGE
, 0 );
3183 ImplSalYieldMutexRelease();
3186 // -----------------------------------------------------------------------
3190 static long ImplHandleIMEStartConversion( Os2SalFrame
* pFrame
)
3193 SalIMEData
* pIMEData
= GetSalIMEData();
3196 HWND hWnd
= pFrame
->mhWndClient
;
3198 pIMEData
->mpGetIME( hWnd
, &hIMI
);
3202 if ( 0 != pIMEData
->mpQueryIMEProperty( hIMI
, QIP_PROPERTY
, &nProp
) )
3203 pFrame
->mbHandleIME
= FALSE
;
3206 pFrame
->mbHandleIME
= !(nProp
& PRP_SPECIALUI
);
3209 if ( pFrame
->mbHandleIME
)
3211 /* Windows-Code, der noch nicht angepasst wurde !!!
3212 // Cursor-Position ermitteln und aus der die Default-Position fuer
3213 // das Composition-Fenster berechnen
3214 SalCursorPosEvent aCursorPosEvt;
3215 pFrame->CallCallback( pFrame->mpInst, pFrame,
3216 SALEVENT_CURSORPOS, (void*)&aCursorPosEvt );
3217 COMPOSITIONFORM aForm;
3218 memset( &aForm, 0, sizeof( aForm ) );
3219 if ( !aCursorPosEvt.mnWidth || !aCursorPosEvt.mnHeight )
3220 aForm.dwStyle |= CFS_DEFAULT;
3223 aForm.dwStyle |= CFS_POINT;
3224 aForm.ptCurrentPos.x = aCursorPosEvt.mnX;
3225 aForm.ptCurrentPos.y = aCursorPosEvt.mnY;
3227 ImmSetCompositionWindow( hIMC, &aForm );
3229 // Den InputContect-Font ermitteln und diesem dem Composition-Fenster
3233 pFrame
->mbConversionMode
= TRUE
;
3234 pFrame
->CallCallback( SALEVENT_STARTEXTTEXTINPUT
, (void*)NULL
);
3238 pIMEData
->mpReleaseIME( hWnd
, hIMI
);
3245 // -----------------------------------------------------------------------
3247 static long ImplHandleIMEConversion( Os2SalFrame
* pFrame
, MPARAM nMP2Param
)
3250 SalIMEData
* pIMEData
= GetSalIMEData();
3253 HWND hWnd
= pFrame
->mhWndClient
;
3255 ULONG nMP2
= (ULONG
)nMP2Param
;
3256 pIMEData
->mpGetIME( hWnd
, &hIMI
);
3259 if ( nMP2
& (IMR_RESULT_RESULTSTRING
|
3260 IMR_CONV_CONVERSIONSTRING
| IMR_CONV_CONVERSIONATTR
|
3261 IMR_CONV_CURSORPOS
| IMR_CONV_CURSORATTR
) )
3263 SalExtTextInputEvent aEvt
;
3264 aEvt
.mnTime
= WinQueryMsgTime( pFrame
->mhAB
);
3265 aEvt
.mpTextAttr
= NULL
;
3266 aEvt
.mnCursorPos
= 0;
3267 aEvt
.mnDeltaStart
= 0;
3268 aEvt
.mbOnlyCursor
= FALSE
;
3269 aEvt
.mbCursorVisible
= TRUE
;
3272 xub_Unicode
* pBuf
= NULL
;
3273 ULONG nAttrBufLen
= 0;
3274 PM_BYTE
* pAttrBuf
= NULL
;
3275 BOOL bLastCursor
= FALSE
;
3276 if ( nMP2
& IMR_RESULT_RESULTSTRING
)
3278 pIMEData
->mpGetResultString( hIMI
, IMR_RESULT_RESULTSTRING
, 0, &nBufLen
);
3281 pBuf
= new xub_Unicode
[nBufLen
];
3282 pIMEData
->mpGetResultString( hIMI
, IMR_RESULT_RESULTSTRING
, pBuf
, &nBufLen
);
3286 aEvt
.mbCursorVisible
= TRUE
;
3288 else if ( nMP2
& (IMR_CONV_CONVERSIONSTRING
| IMR_CONV_CONVERSIONATTR
|
3289 IMR_CONV_CURSORPOS
| IMR_CONV_CURSORATTR
) )
3291 pIMEData
->mpGetConversionString( hIMI
, IMR_CONV_CONVERSIONSTRING
, 0, &nBufLen
);
3294 pBuf
= new xub_Unicode
[nBufLen
];
3295 pIMEData
->mpGetConversionString( hIMI
, IMR_CONV_CONVERSIONSTRING
, pBuf
, &nBufLen
);
3298 pIMEData
->mpGetConversionString( hIMI
, IMR_CONV_CONVERSIONATTR
, 0, &nAttrBufLen
);
3299 if ( nAttrBufLen
> 0 )
3301 pAttrBuf
= new PM_BYTE
[nAttrBufLen
];
3302 pIMEData
->mpGetConversionString( hIMI
, IMR_CONV_CONVERSIONATTR
, pAttrBuf
, &nAttrBufLen
);
3305 /* !!! Wir bekommen derzeit nur falsche Daten, deshalb zeigen wir derzeit
3306 !!! auch keine Cursor an
3308 ULONG nCursorPos = 0;
3309 ULONG nCursorAttr = 0;
3310 ULONG nChangePos = 0;
3311 nTempBufLen = sizeof( ULONG );
3312 pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORPOS, &nCursorPos, &nTempBufLen );
3313 nTempBufLen = sizeof( ULONG );
3314 pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORATTR, &nCursorAttr, &nTempBufLen );
3315 nTempBufLen = sizeof( ULONG );
3316 pIMEData->mpGetConversionString( hIMI, IMR_CONV_CHANGESTART, &nChangePos, &nTempBufLen );
3318 aEvt.mnCursorPos = nCursorPos;
3319 aEvt.mnDeltaStart = nChangePos;
3320 if ( nCursorAttr & CP_CURSORATTR_INVISIBLE )
3321 aEvt.mbCursorVisible = FALSE;
3323 aEvt
.mnCursorPos
= 0;
3324 aEvt
.mnDeltaStart
= 0;
3325 aEvt
.mbCursorVisible
= FALSE
;
3327 if ( (nMP2
== IMR_CONV_CURSORPOS
) ||
3328 (nMP2
== IMR_CONV_CURSORATTR
) )
3329 aEvt
.mbOnlyCursor
= TRUE
;
3332 USHORT
* pSalAttrAry
= NULL
;
3335 aEvt
.maText
= XubString( pBuf
, (USHORT
)nBufLen
);
3339 USHORT nTextLen
= aEvt
.maText
.Len();
3342 pSalAttrAry
= new USHORT
[nTextLen
];
3343 memset( pSalAttrAry
, 0, nTextLen
*sizeof( USHORT
) );
3344 for ( USHORT i
= 0; (i
< nTextLen
) && (i
< nAttrBufLen
); i
++ )
3346 PM_BYTE nOS2Attr
= pAttrBuf
[i
];
3348 if ( nOS2Attr
== CP_ATTR_TARGET_CONVERTED
)
3349 nSalAttr
= SAL_EXTTEXTINPUT_ATTR_TARGETCONVERTED
| SAL_EXTTEXTINPUT_ATTR_UNDERLINE
| SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT
;
3350 else if ( nOS2Attr
== CP_ATTR_CONVERTED
)
3351 nSalAttr
= SAL_EXTTEXTINPUT_ATTR_CONVERTED
| SAL_EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE
;
3352 else if ( nOS2Attr
== CP_ATTR_TARGET_NOTCONVERTED
)
3353 nSalAttr
= SAL_EXTTEXTINPUT_ATTR_TARGETNOTCONVERTED
| SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE
;
3354 else if ( nOS2Attr
== CP_ATTR_INPUT_ERROR
)
3355 nSalAttr
= SAL_EXTTEXTINPUT_ATTR_INPUTERROR
| SAL_EXTTEXTINPUT_ATTR_REDTEXT
| SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE
;
3356 else /* ( nOS2Attr == CP_ATTR_INPUT ) */
3357 nSalAttr
= SAL_EXTTEXTINPUT_ATTR_INPUT
| SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE
;
3358 pSalAttrAry
[i
] = nSalAttr
;
3360 aEvt
.mpTextAttr
= pSalAttrAry
;
3365 aEvt
.mnCursorPos
= aEvt
.maText
.Len();
3368 pIMEData
->mpReleaseIME( hWnd
, hIMI
);
3370 // Handler rufen und wenn wir ein Attribute-Array haben, danach
3371 // wieder zerstoeren
3372 pFrame
->CallCallback( SALEVENT_EXTTEXTINPUT
, (void*)&aEvt
);
3377 pIMEData
->mpReleaseIME( hWnd
, hIMI
);
3386 // -----------------------------------------------------------------------
3388 inline long ImplHandleIMEEndConversion( Os2SalFrame
* pFrame
)
3390 pFrame
->mbConversionMode
= FALSE
;
3391 pFrame
->CallCallback( SALEVENT_ENDEXTTEXTINPUT
, (void*)NULL
);
3395 // -----------------------------------------------------------------------
3397 static void ImplHandleIMEOpenCandidate( Os2SalFrame
* pFrame
)
3399 pFrame
->mbCandidateMode
= TRUE
;
3402 SalIMEData
* pIMEData
= GetSalIMEData();
3405 HWND hWnd
= pFrame
->mhWndClient
;
3407 pIMEData
->mpGetIME( hWnd
, &hIMI
);
3411 pIMEData
->mpGetConversionString( hIMI
, IMR_CONV_CONVERSIONSTRING
, 0, &nBufLen
);
3414 /* !!! Wir bekommen derzeit nur falsche Daten steht der Cursor immer bei 0
3415 ULONG nTempBufLen = sizeof( ULONG );
3416 ULONG nCursorPos = 0;
3417 pIMEData->mpGetConversionString( hIMI, IMR_CONV_CURSORPOS, &nCursorPos, &nTempBufLen );
3419 ULONG nCursorPos
= 0;
3421 SalExtTextInputPosEvent aEvt
;
3422 aEvt
.mnTime
= WinQueryMsgTime( pFrame
->mhAB
);
3423 aEvt
.mnFirstPos
= nCursorPos
;
3424 aEvt
.mnChars
= nBufLen
-nCursorPos
;
3425 aEvt
.mpPosAry
= new SalExtCharPos
[aEvt
.mnChars
];
3426 memset( aEvt
.mpPosAry
, 0, aEvt
.mnChars
*sizeof(SalExtCharPos
) );
3428 pFrame
->CallCallback( SALEVENT_EXTTEXTINPUTPOS
, (void*)&aEvt
);
3430 long nMinLeft
= aEvt
.mpPosAry
[0].mnX
;
3431 long nMinTop
= aEvt
.mpPosAry
[0].mnY
;
3432 long nMaxBottom
= aEvt
.mpPosAry
[0].mnY
+aEvt
.mpPosAry
[0].mnHeight
;
3433 long nMaxRight
= nMinLeft
;
3435 while ( i
< aEvt
.mnChars
)
3437 // Solange wir uns auf der gleichen Zeile bewegen,
3438 // ermitteln wir die Rechteck-Grenzen
3439 if ( !aEvt
.mpPosAry
[i
].mnHeight
||
3440 (aEvt
.mpPosAry
[i
].mnY
< nMaxBottom
-1) )
3442 if ( aEvt
.mpPosAry
[i
].mnX
< nMinLeft
)
3443 nMinLeft
= aEvt
.mpPosAry
[i
].mnX
;
3444 if ( aEvt
.mpPosAry
[i
].mnX
+aEvt
.mpPosAry
[0].mnWidth
> nMaxRight
)
3445 nMaxRight
= aEvt
.mpPosAry
[i
].mnX
+aEvt
.mpPosAry
[0].mnWidth
;
3446 if ( aEvt
.mpPosAry
[i
].mnY
< nMinTop
)
3447 nMinTop
= aEvt
.mpPosAry
[i
].mnY
;
3456 aForm
.ulStyle
= CPS_EXCLUDE
;
3457 aForm
.ptCurrentPos
.x
= aEvt
.mpPosAry
[0].mnX
;
3458 aForm
.ptCurrentPos
.y
= pFrame
->mnHeight
- (nMaxBottom
+1) - 1;
3459 aForm
.rcArea
.xLeft
= nMinLeft
;
3460 aForm
.rcArea
.yBottom
= pFrame
->mnHeight
- nMaxBottom
- 1;
3461 aForm
.rcArea
.xRight
= nMaxRight
+1;
3462 aForm
.rcArea
.yTop
= pFrame
->mnHeight
- nMinTop
- 1;
3463 pIMEData
->mpSetCandidateWin( hIMI
, &aForm
);
3465 delete aEvt
.mpPosAry
;
3468 pIMEData
->mpReleaseIME( hWnd
, hIMI
);
3473 // -----------------------------------------------------------------------
3475 inline void ImplHandleIMECloseCandidate( Os2SalFrame
* pFrame
)
3477 pFrame
->mbCandidateMode
= FALSE
;
3482 // -----------------------------------------------------------------------
3484 MRESULT EXPENTRY
SalFrameWndProc( HWND hWnd
, ULONG nMsg
,
3485 MPARAM nMP1
, MPARAM nMP2
)
3487 Os2SalFrame
* pFrame
= (Os2SalFrame
*)GetWindowPtr( hWnd
);
3488 MRESULT nRet
= (MRESULT
)0;
3490 bool bCheckTimers
= false;
3492 #if OSL_DEBUG_LEVEL>10
3493 if (nMsg
!=WM_TIMER
&& nMsg
!=WM_MOUSEMOVE
)
3494 debug_printf( "SalFrameWndProc hWnd 0x%x nMsg 0x%x\n", hWnd
, nMsg
);
3500 case WM_BUTTON1DOWN
:
3501 case WM_BUTTON2DOWN
:
3502 case WM_BUTTON3DOWN
:
3503 case WM_BUTTON1DBLCLK
:
3504 case WM_BUTTON2DBLCLK
:
3505 case WM_BUTTON3DBLCLK
:
3509 case SAL_MSG_MOUSELEAVE
:
3510 // ButtonUp/Down nie an die WinDefWindowProc weiterleiten, weil sonst
3511 // die Message an den Owner weitergeleitet wird
3512 ImplSalYieldMutexAcquireWithWait();
3513 bDef
= !ImplHandleMouseMsg( hWnd
, nMsg
, nMP1
, nMP2
);
3514 ImplSalYieldMutexRelease();
3518 if ( pFrame
->mbConversionMode
)
3521 bDef
= !ImplHandleKeyMsg( hWnd
, nMsg
, nMP1
, nMP2
);
3524 case WM_ERASEBACKGROUND
:
3525 nRet
= (MRESULT
)FALSE
;
3530 bCheckTimers
= ImplHandlePaintMsg( hWnd
);
3533 case SAL_MSG_POSTPAINT
:
3534 ImplHandlePaintMsg2( hWnd
, (RECTL
*)nMP1
);
3535 bCheckTimers
= true;
3540 case SAL_MSG_POSTMOVE
:
3541 ImplHandleMoveMsg( hWnd
);
3546 if ( ImplSalYieldMutexTryToAcquire() )
3548 ImplHandleSizeMsg( hWnd
, nMP2
);
3549 ImplSalYieldMutexRelease();
3552 WinPostMsg( hWnd
, SAL_MSG_POSTSIZE
, nMP1
, nMP2
);
3554 case SAL_MSG_POSTSIZE
:
3555 ImplHandleSizeMsg( hWnd
, nMP2
);
3557 case WM_MINMAXFRAME
:
3558 if ( ImplSalYieldMutexTryToAcquire() )
3560 PSWP pswp
= (PSWP
) nMP1
;
3561 ImplHandleSizeMsg( hWnd
, MPFROM2SHORT( pswp
->cx
, pswp
->cy
) );
3562 ImplSalYieldMutexRelease();
3565 WinPostMsg( hWnd
, SAL_MSG_POSTSIZE
, 0, nMP2
);
3568 case WM_CALCVALIDRECTS
:
3569 return (MRESULT
)(CVR_ALIGNLEFT
| CVR_ALIGNTOP
);
3572 if ( ImplSalYieldMutexTryToAcquire() )
3574 ImplHandleFocusMsg( pFrame
, nMP2
);
3575 ImplSalYieldMutexRelease();
3578 WinPostMsg( hWnd
, SAL_MSG_POSTFOCUS
, 0, nMP2
);
3580 case SAL_MSG_POSTFOCUS
:
3581 ImplHandleFocusMsg( pFrame
, nMP2
);
3584 case WM_TRANSLATEACCEL
:
3586 // Da uns OS/2 zu viele Tasten abfaegnt, unternehmen wir etwas,
3587 // damit wir Shift+F1, Shift+F10 und Shift+Enter bekommen
3588 PQMSG pMsg
= (PQMSG
)nMP1
;
3589 USHORT nKeyFlags
= SHORT1FROMMP( pMsg
->mp1
);
3590 USHORT nKeyCode
= (UCHAR
)SHORT2FROMMP( pMsg
->mp2
);
3592 if ( !(nKeyFlags
& KC_KEYUP
) && (nKeyFlags
& KC_VIRTUALKEY
) &&
3593 (nKeyFlags
& KC_SHIFT
) && (nKeyCode
!= VK_ESC
) )
3594 return (MRESULT
)FALSE
;
3596 if ( nKeyCode
== VK_F1
)
3597 return (MRESULT
)FALSE
;
3603 HWND hWndFrame
= WinQueryWindow(hWnd
, QW_PARENT
);
3605 debug_printf(" WARNING NULL FRAME!!\n");
3606 SalData
* pSalData
= GetSalData();
3607 // Window-Instanz am Windowhandle speichern
3608 pFrame
= pSalData
->mpCreateFrame
;
3609 pSalData
->mpCreateFrame
= NULL
;
3610 SetWindowPtr( hWnd
, pFrame
);
3611 SetWindowPtr( hWndFrame
, pFrame
);
3612 // HWND schon hier setzen, da schon auf den Instanzdaten
3613 // gearbeitet werden kann, wenn Messages waehrend
3614 // CreateWindow() gesendet werden
3615 pFrame
->mhWndClient
= hWnd
;
3616 pFrame
->mhWndFrame
= hWndFrame
;
3617 pFrame
->maSysData
.hWnd
= hWnd
;
3622 ImplHandleCloseMsg( hWnd
);
3626 case WM_SYSVALUECHANGED
:
3627 if ( pFrame
->mbFullScreen
)
3628 ImplSalFrameFullScreenPos( pFrame
);
3629 // kein break, da der Rest auch noch verarbeitet werden soll
3631 case WM_SYSCOLORCHANGE
:
3632 ImplSalYieldMutexAcquire();
3633 pFrame
->CallCallback( SALEVENT_SETTINGSCHANGED
, 0 );
3634 ImplSalYieldMutexRelease();
3637 case SAL_MSG_USEREVENT
:
3638 ImplHandleUserEvent( hWnd
, nMP2
);
3642 ImplSalToTop( hWnd
, (ULONG
)nMP1
);
3646 ImplSalShow( hWnd
, (ULONG
)nMP1
, (ULONG
)nMP2
);
3650 case WM_KBDLAYERCHANGED
:
3651 debug_printf("hWnd 0x%08x WM_KBDLAYERCHANGED\n", hWnd
);
3652 ImplHandleInputLangChange( hWnd
);
3657 ImplHandleWheelMsg( hWnd
, nMsg
, nMP1
, nMP2
);
3662 case SAL_MSG_SYSPROCESSMENU
:
3663 if ( SalImplHandleProcessMenu( pFrame
, nMsg
, nMP1
, nMP2
) )
3672 if ( (ULONG
)nMP1
== IMR_CONVRESULT
)
3674 if ( pFrame
->mbHandleIME
)
3676 // Nur im Conversionmodus akzeptieren wir den IME-Input
3677 if ( pFrame
->mbConversionMode
)
3679 ImplSalYieldMutexAcquire();
3680 if ( ImplHandleIMEConversion( pFrame
, nMP2
) )
3683 nRet
= (MRESULT
)TRUE
;
3685 ImplSalYieldMutexRelease();
3689 else if ( (ULONG
)nMP1
== IMR_CANDIDATE
)
3691 if ( pFrame
->mbHandleIME
)
3693 ImplSalYieldMutexAcquire();
3694 if ( (ULONG
)nMP2
& IMR_CANDIDATE_SHOW
)
3695 ImplHandleIMEOpenCandidate( pFrame
);
3696 else if ( (ULONG
)nMP2
& IMR_CANDIDATE_HIDE
)
3697 ImplHandleIMECloseCandidate( pFrame
);
3698 ImplSalYieldMutexRelease();
3704 if ( (ULONG
)nMP1
== IMN_STARTCONVERSION
)
3706 ImplSalYieldMutexAcquire();
3707 if ( ImplHandleIMEStartConversion( pFrame
) )
3710 nRet
= (MRESULT
)TRUE
;
3712 ImplSalYieldMutexRelease();
3714 else if ( (ULONG
)nMP1
== IMN_ENDCONVERSION
)
3716 if ( pFrame
->mbHandleIME
)
3718 ImplSalYieldMutexAcquire();
3719 if ( ImplHandleIMEEndConversion( pFrame
) )
3722 nRet
= (MRESULT
)TRUE
;
3724 ImplSalYieldMutexRelease();
3733 SalData
* pSalData
= GetSalData();
3734 if( pSalData
->mnNextTimerTime
)
3737 DosQuerySysInfo( QSV_MS_COUNT
, QSV_MS_COUNT
, (PVOID
)&nCurTime
, sizeof(ULONG
));
3738 if( pSalData
->mnNextTimerTime
< nCurTime
)
3741 if (!WinPeekMsg( pFrame
->mhAB
, &aMsg
, 0, WM_PAINT
, WM_PAINT
, PM_NOREMOVE
) )
3742 WinPostMsg( pSalData
->mpFirstInstance
->mhComWnd
, SAL_MSG_POSTTIMER
, 0, (MPARAM
)nCurTime
);
3748 nRet
= WinDefWindowProc( hWnd
, nMsg
, nMP1
, nMP2
);
3753 // -----------------------------------------------------------------------
3755 void Os2SalFrame::ResetClipRegion()
3759 void Os2SalFrame::BeginSetClipRegion( ULONG
)
3763 void Os2SalFrame::UnionClipRegion( long, long, long, long )
3767 void Os2SalFrame::EndSetClipRegion()
3771 // -----------------------------------------------------------------------
3773 MRESULT EXPENTRY
SalFrameSubClassWndProc( HWND hWnd
, ULONG nMsg
,
3774 MPARAM nMP1
, MPARAM nMP2
)
3776 MRESULT mReturn
= 0L;
3778 // ticket#124 min size of 132 px is too much
3779 if (nMsg
== WM_QUERYTRACKINFO
) {
3781 // first, let PM initialize TRACKINFO
3782 mReturn
= aSalShlData
.mpFrameProc( hWnd
, nMsg
, nMP1
, nMP2
);
3783 // now change default min size
3784 pti
= (PTRACKINFO
) nMP2
;
3785 pti
->ptlMinTrackSize
.x
= 64L;
3790 return aSalShlData
.mpFrameProc( hWnd
, nMsg
, nMP1
, nMP2
);
3793 // -----------------------------------------------------------------------