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