Changeset 3662 for trunk/src/user32/dc.cpp
- Timestamp:
- Jun 7, 2000, 4:51:33 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dc.cpp
r3641 r3662 1 /* $Id: dc.cpp,v 1.5 8 2000-06-01 11:27:56sandervl Exp $ */1 /* $Id: dc.cpp,v 1.59 2000-06-07 14:51:25 sandervl Exp $ */ 2 2 3 3 /* … … 22 22 #include <stdlib.h> 23 23 24 #include <string.h> 24 25 #include <win32type.h> 25 26 #include <win32api.h> … … 301 302 //****************************************************************************** 302 303 //****************************************************************************** 304 VOID removeClientArea(pDCData pHps) 305 { 306 POINTL point; 307 308 // This function checks to see if a client area is currently selected, if 309 // it is the origin plus the visible region of the frame are restored. 310 311 pHps->isClient = FALSE; 312 313 GreGetDCOrigin(pHps->hps, &point); 314 315 if(pHps->isClientArea) 316 { 317 dprintf2(("removeClientArea: (%d,%d) -> (%d,%d)", point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y)); 318 pHps->isClientArea = FALSE; 319 GreSetupDC(pHps->hps, 320 pHps->hrgnVis, 321 pHps->ptlOrigin.x, 322 pHps->ptlOrigin.y, 323 0, 324 SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP); 325 } 326 else dprintf(("removeClientArea: (%d,%d)", point.x, point.y)); 327 328 } 329 //****************************************************************************** 330 //****************************************************************************** 331 HRGN selectClientArea(Win32BaseWindow *window, pDCData pHps, PRECTL prclPaint) 332 { 333 // This function checks to see if the DC needs to be adjusted to a client 334 // area and makes the adjustment. 335 RECTL rcl, rcltemp; 336 HRGN hrgnRect, hrgnClip, hrgnOldClip = 0; 337 HWND hwnd; 338 LONG rc; 339 PRECT pClient = window->getClientRectPtr(); 340 PRECT pWindow = window->getWindowRect(); 341 342 if(pClient->left == 0 && pClient->top == 0 && 343 window->getClientHeight() == window->getWindowHeight() && 344 window->getClientWidth() == window->getWindowWidth()) 345 { 346 //client rectangle = frame rectangle -> no change necessary 347 //only setup the clip region 348 goto setupclipregion; 349 } 350 351 pHps->isClient = TRUE; 352 353 hwnd = window->getOS2WindowHandle(); 354 355 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&rcl); 356 357 //convert to screen coordinates 358 GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp); 359 rcl.xLeft += rcltemp.xLeft; 360 rcl.xRight += rcltemp.xLeft; 361 rcl.yTop += rcltemp.yBottom; 362 rcl.yBottom += rcltemp.yBottom; 363 364 pHps->ptlOrigin.x = rcltemp.xLeft; 365 pHps->ptlOrigin.y = rcltemp.yBottom; 366 367 dprintf2(("selectClientArea: (%d,%d) -> (%d,%d)", rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom)); 368 369 if(pHps->hrgnVis == 0) 370 pHps->hrgnVis = GreCreateRectRegion(pHps->hps, &rcl, 1); 371 372 hrgnRect = GreCreateRectRegion(pHps->hps, &rcl, 1); 373 374 // Query the visible region 375 GreCopyClipRegion(pHps->hps, pHps->hrgnVis, 0, COPYCRGN_VISRGN); 376 GpiQueryRegionBox(pHps->hps, pHps->hrgnVis, &rcltemp); 377 // And the visible region of the frame with the client rectangle 378 // to get the new visible region 379 GreCombineRegion(pHps->hps, hrgnRect, pHps->hrgnVis, hrgnRect, CRGN_AND); 380 381 // Set the new origin plus visible region in the DC 382 GreSetupDC(pHps->hps, 383 hrgnRect, 384 rcl.xLeft, 385 rcl.yBottom, 386 NULL, 387 SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP); 388 389 /* 390 GpiQueryRegionBox(pHps->hps, hrgnClip, &rcltemp); 391 GpiQueryRegionBox(pHps->hps, hrgnOldClip, &rcltemp); 392 393 GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp); 394 395 GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp); 396 397 GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_VISRGN); 398 GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp); 399 400 GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_ALLINTERSECT); 401 GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp); 402 403 GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_CLIPRGN); 404 GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp); 405 */ 406 pHps->isClientArea = TRUE; 407 408 // Destroy the region now we have finished with it. 409 GreDestroyRegion(pHps->hps, hrgnRect); 410 411 setupclipregion: 412 if(prclPaint) { 413 hrgnClip = GpiQueryClipRegion(pHps->hps); 414 if(hrgnClip) { 415 rc = GreIntersectClipRectangle(pHps->hps, prclPaint); 416 if(rc == RGN_ERROR) { 417 dprintf(("selectClientArea: GreIntersectClipRectangle returned RGN_ERROR!")); 418 } 419 } 420 else { 421 hrgnClip = GreCreateRectRegion(pHps->hps, prclPaint, 1); 422 GreSelectClipRegion(pHps->hps, hrgnClip, &hrgnOldClip); 423 } 424 } 425 426 return hrgnOldClip; 427 } 428 //****************************************************************************** 429 //****************************************************************************** 303 430 LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps) 304 431 { … … 308 435 if ((hwnd != 0) || (pHps == 0)) 309 436 { 310 if (wnd) 311 return (wnd->getClientHeight()); 312 else 313 return OSLibQueryScreenHeight(); 437 if(wnd) { 438 if(pHps && !pHps->isClientArea) { 439 return (wnd->getWindowHeight()); 440 } 441 else return (wnd->getClientHeight()); 442 } 443 else return OSLibQueryScreenHeight(); 314 444 } 315 445 else if (pHps->bitmapHandle) … … 430 560 //****************************************************************************** 431 561 //****************************************************************************** 432 #if 0433 HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)434 {435 HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;436 pDCData pHps = NULLHANDLE;437 RECTL rect;438 HPS hPS_ownDC = NULLHANDLE;439 440 if ( !lpps )441 {442 SetLastError(ERROR_INVALID_PARAMETER_W);443 return (HDC)NULLHANDLE;444 }445 446 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);447 448 #if 0449 if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC())450 {451 hPS_ownDC = wnd->getOwnDC();452 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)453 if(hPS_ownDC) {454 pHps = (pDCData)GpiQueryDCData(hPS_ownDC);455 if (!pHps)456 {457 SetLastError(ERROR_INVALID_PARAMETER_W);458 return (HDC)NULLHANDLE;459 }460 }461 }462 #endif463 464 HWND hwndClient = wnd->getOS2WindowHandle();465 HPS hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);466 467 if (!pHps)468 {469 HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);470 pHps = (pDCData)GpiQueryDCData(hps);471 }472 473 if (hPS_ownDC == 0)474 setMapMode (wnd, pHps, MM_TEXT_W);475 else476 setPageXForm (wnd, pHps);477 478 pHps->hdcType = TYPE_3;479 480 HideCaret(hwnd);481 482 if(wnd->needsEraseBkgnd()) {483 wnd->setEraseBkgnd(FALSE);484 lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) != 0);485 }486 else lpps->fErase = TRUE;487 lpps->hdc = (HDC)hps;488 489 if (!hPS_ownDC)490 {491 long height = wnd->getClientHeight();492 493 rect.yTop = height - rect.yTop;494 rect.yBottom = height - rect.yBottom;495 }496 else497 {498 rect.yTop--;499 rect.yBottom--;500 GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rect);501 }502 503 WINRECT_FROM_PMRECT(lpps->rcPaint, rect);504 dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));505 506 SetLastError(0);507 return (HDC)pHps->hps;508 }509 510 BOOL WIN32API EndPaint (HWND hwnd, const PAINTSTRUCT_W *pPaint)511 {512 pDCData pHps;513 514 dprintf (("USER32: EndPaint(%x)", hwnd));515 516 ShowCaret(hwnd);517 if (!pPaint || !pPaint->hdc )518 return TRUE;519 520 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);521 522 if (!wnd) goto exit;523 524 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)525 pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);526 if (pHps && (pHps->hdcType == TYPE_3)) {527 WinEndPaint (pHps->hps);528 }529 wnd->setEraseBkgnd(TRUE);530 531 exit:532 SetLastError(0);533 return TRUE;534 }535 #else536 562 HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps) 537 563 { … … 540 566 HPS hPS_ownDC = NULLHANDLE, hpsPaint = 0; 541 567 RECTL rectl = {0, 0, 1, 1}; 542 HRGN hrgnUpdate, hrgnOld ;568 HRGN hrgnUpdate, hrgnOld, hrgnOldClip; 543 569 LONG lComplexity; 544 570 RECTL rectlClient; 571 RECTL rectlClip; 572 573 memset(lpps, 0, sizeof(*lpps)); 545 574 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 546 575 if(!lpps || !wnd) { … … 567 596 } 568 597 if(!hpsPaint) { 569 hpsPaint = GetDCEx(hwnd, 0, DCX_CACHE_W);598 hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_WINDOW_W|DCX_USESTYLE_W)); 570 599 pHps = (pDCData)GpiQueryDCData(hpsPaint); 571 600 if (!pHps) … … 577 606 } 578 607 579 #if 0 580 HPS hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect); 581 582 if (!pHps) 583 { 584 HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL); 585 pHps = (pDCData)GpiQueryDCData(hps); 586 } 587 #endif 588 589 if (hPS_ownDC == 0) 608 if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) { 609 memset(&rectl, 0, sizeof(rectl)); 610 dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!")); 611 612 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient); 613 WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom); 614 615 hrgnOldClip = selectClientArea(wnd, pHps, &rectlClient); 616 //save old clip region (restored for CS_OWNDC windows in EndPaint) 617 wnd->SetClipRegion(hrgnOldClip); 618 lComplexity = RGN_NULL; 619 } 620 else { 621 HRGN hrgnTmp = GpiCreateRegion(pHps->hps, 1, &rectl); 622 623 WinQueryUpdateRegion(hwndClient, hrgnTmp); 624 625 RGNRECT rgnrect = {0, 12, 0, RECTDIR_LFRT_TOPBOT}; 626 RECTL rectls[12], rcltemp; 627 GpiQueryRegionRects(pHps->hps, hrgnTmp, &rcltemp, &rgnrect, &rectls[0]); 628 GpiDestroyRegion(pHps->hps, hrgnTmp); 629 630 WinValidateRect(hwndClient, &rectl, FALSE); 631 632 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient); 633 WinIntersectRect(NULL, &rectlClip, &rectl, &rectlClient); 634 WinOffsetRect(NULL, &rectlClip, -rectlClient.xLeft, -rectlClient.yBottom); 635 636 hrgnOldClip = selectClientArea(wnd, pHps, &rectlClip); 637 638 //save old clip region (restored for CS_OWNDC windows in EndPaint) 639 wnd->SetClipRegion(hrgnOldClip); 640 memcpy(&rectl, &rectlClip, sizeof(RECTL)); 641 lComplexity = RGN_RECT; 642 } 643 644 if(hPS_ownDC == 0) 590 645 setMapMode (wnd, pHps, MM_TEXT_W); 591 646 else 592 setPageXForm 647 setPageXForm(wnd, pHps); 593 648 594 649 pHps->hdcType = TYPE_3; 595 650 596 hrgnUpdate = GpiCreateRegion(pHps->hps, 1, &rectl); 597 lComplexity = WinQueryUpdateRegion(hwndClient, hrgnUpdate); 598 if(lComplexity == RGN_ERROR) { 599 dprintf (("USER32: BeginPaint update region error!!")); 600 SetLastError(ERROR_INVALID_PARAMETER_W); 601 return 0; 602 } 603 WinQueryUpdateRect(hwndClient, &rectl); 604 605 if(lComplexity != RGN_NULL) { 606 WinValidateRegion(hwndClient, hrgnUpdate, FALSE); 607 608 GpiSetClipRegion(pHps->hps, hrgnUpdate, &hrgnOld); 609 //save old clip region (restored for CS_OWNDC windows in EndPaint) 610 wnd->SetClipRegion(hrgnOld); 611 } 651 HideCaret(hwnd); 652 WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE); 612 653 613 654 if(wnd->needsEraseBkgnd() && lComplexity != RGN_NULL) { … … 631 672 } 632 673 633 HideCaret(hwnd);634 635 674 SetLastError(0); 636 675 dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom)); … … 657 696 if (pHps && (pHps->hdcType == TYPE_3)) 658 697 { 659 GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);698 removeClientArea(pHps); 660 699 if(hrgnOld) { 700 GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld); 661 701 GpiDestroyRegion(pHps->hps, hrgnOld); 662 702 } 663 703 if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) { 704 pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails 664 705 ReleaseDC(hwnd, pPaint->hdc); 665 706 } … … 671 712 pHps->hdcType = TYPE_1; 672 713 } 673 674 //// WinEndPaint (pHps->hps);675 714 } 676 715 else { … … 679 718 wnd->setEraseBkgnd(TRUE); 680 719 ShowCaret(hwnd); 720 WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE); 681 721 682 722 exit: … … 684 724 return TRUE; 685 725 } 726 //****************************************************************************** 727 //****************************************************************************** 728 int WIN32API GetClipBox( HDC hdc, PRECT lpRect) 729 { 730 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc); 731 RECTL rectl; 732 LONG lComplexity; 733 int rc; 734 735 if(!hdc || !lpRect || !pHps) { 736 dprintf(("GDI32: GetClipBox %x %x ERROR_INVALID_PARAMETER", hdc, lpRect)); 737 SetLastError(ERROR_INVALID_PARAMETER_W); 738 return ERROR_W; 739 } 740 if(pHps->isPrinter) 741 { 742 lpRect->left = 0; 743 lpRect->top = 0; 744 lpRect->right = GetDeviceCaps( hdc, HORZRES_W); 745 lpRect->bottom = GetDeviceCaps( hdc, VERTRES_W); 746 747 rc = SIMPLEREGION_W; 748 } 749 else { 750 lComplexity = GpiQueryClipBox(pHps->hps, &rectl); 751 if(lComplexity == RGN_ERROR) 752 { 753 rc = ERROR_W; 754 } 755 else 756 if(lComplexity == RGN_NULL) 757 { 758 memset(lpRect, 0, sizeof(*lpRect)); 759 rc = NULLREGION_W; 760 } 761 else { 762 lpRect->left = rectl.xLeft; 763 lpRect->right = rectl.xRight; 764 #if 0 765 lpRect->top = pHps->height - rectl.yTop; 766 lpRect->bottom = pHps->height - rectl.yBottom; 767 #else 768 //No conversion required as GpiQueryClipBox is affected by 769 //the y-inversion of the window 770 lpRect->top = rectl.yBottom; 771 lpRect->bottom = rectl.yTop; 686 772 #endif 687 //****************************************************************************** 688 //****************************************************************************** 689 int WIN32API GetClipBox( HDC arg1, PRECT arg2) 773 //Convert including/including to including/excluding 774 if(lpRect->left != lpRect->right) { 775 lpRect->right++; 776 } 777 if(lpRect->top != lpRect->bottom) { 778 lpRect->bottom++; 779 } 780 rc = (lComplexity == RGN_RECT) ? SIMPLEREGION_W : COMPLEXREGION_W; 781 } 782 } 783 dprintf(("GDI32: GetClipBox of %X returned %d\n", hdc, rc)); 784 return rc; 785 } 786 //****************************************************************************** 787 //****************************************************************************** 788 int WIN32API GetClipRgn( HDC hdc, HRGN hRgn) 690 789 { 691 790 int rc; 692 791 693 rc = O32_GetClipBox(arg1, arg2); 694 dprintf(("GDI32: GetClipBox of %X returned %d\n", arg1, rc)); 695 return(rc); 696 } 697 //****************************************************************************** 698 //****************************************************************************** 699 int WIN32API GetClipRgn( HDC hdc, HRGN hRgn) 700 { 701 dprintf(("GDI32: GetClipRgn")); 702 return O32_GetClipRgn(hdc, hRgn); 792 rc = O32_GetClipRgn(hdc, hRgn); 793 dprintf(("GDI32: GetClipRgn %x %x returned %x", hdc, hRgn, rc)); 794 return rc; 703 795 } 704 796 //****************************************************************************** … … 708 800 if (!hwnd) 709 801 { 710 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 711 return FALSE; 802 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase)); 803 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 804 return FALSE; 712 805 } 713 806 … … 717 810 if (!wnd) 718 811 { 719 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 720 return FALSE; 721 } 812 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 813 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase)); 814 return FALSE; 815 } 816 817 dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase)); 722 818 723 819 BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL); … … 781 877 //****************************************************************************** 782 878 //****************************************************************************** 783 BOOL SYSTEM GetOS2UpdateRect(HWND hwnd,LPRECT pRect)879 BOOL GetOS2UpdateRect(Win32BaseWindow *window, LPRECT pRect) 784 880 { 785 881 RECTL rectl; 786 BOOL updateRegionExists = WinQueryUpdateRect( hwnd,pRect ? &rectl:NULL);882 BOOL updateRegionExists = WinQueryUpdateRect(window->getOS2WindowHandle(),pRect ? &rectl:NULL); 787 883 788 884 if (!pRect) … … 793 889 //CB: for PM empty rect is valid 794 890 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE; 795 mapOS2ToWin32Rect( hwnd,(PRECTLOS2)&rectl,pRect);891 mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectl,pRect); 796 892 } 797 893 else … … 836 932 // isOwnDC = wnd->isOwnDC() && wnd->getOwnDC(); 837 933 isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc); 838 } 839 if (isOwnDC) 840 rc = TRUE; 841 else 842 rc = O32_ReleaseDC (0, hdc); 934 if(!isOwnDC) 935 { 936 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc); 937 if(pHps && pHps->psType == MICRO_CACHED) { 938 removeClientArea(pHps); 939 if(pHps->hrgnVis) { 940 GreDestroyRegion(pHps->hps, pHps->hrgnVis); 941 pHps->hrgnVis = 0; 942 } 943 } 944 else { 945 dprintf(("ERROR: ReleaseDC: pHps == NULL!!")); 946 DebugInt3(); 947 } 948 } 949 } 950 951 if(isOwnDC) { 952 rc = TRUE; 953 } 954 else { 955 rc = O32_ReleaseDC (0, hdc); 956 } 843 957 844 958 dprintf(("ReleaseDC %x %x", hwnd, hdc)); … … 851 965 // DCX_EXCLUDERGN (complex regions allowed) 852 966 // DCX_INTERSECTRGN (complex regions allowed) 967 // DCX_USESTYLE 968 // DCX_CLIPSIBLINGS 969 // DCX_CLIPCHILDREN 970 // DCX_PARENTCLIP 853 971 // 854 972 //TODO: WM_SETREDRAW affects drawingAllowed flag!! … … 880 998 return 0; 881 999 } 882 //SvL: Experimental change (doesn't work right) 883 #if 0 884 if(wnd->fHasParentDC() && wnd->getParent()) { 885 wnd = wnd->getParent(); 886 } 887 #endif 888 if (flags & DCX_WINDOW_W) 889 hWindow = wnd->getOS2FrameWindowHandle(); 890 else 891 hWindow = wnd->getOS2WindowHandle(); 1000 hWindow = wnd->getOS2WindowHandle(); 892 1001 } 893 1002 894 1003 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC())) 895 && !(flags & (DCX_CACHE_W | DCX_WINDOW_W)));896 897 if 1004 && !(flags & DCX_CACHE_W)); 1005 1006 if(isWindowOwnDC) 898 1007 { 899 1008 hps = wnd->getOwnDC(); … … 904 1013 goto error; 905 1014 1015 if(flags & DCX_WINDOW_W) 1016 removeClientArea(pHps); 1017 else 1018 selectClientArea(wnd, pHps, NULL); 1019 906 1020 setPageXForm (wnd, pHps); 907 908 1021 pHps->hdcType = TYPE_1; 1022 909 1023 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps)); 910 1024 return (HDC)hps; … … 914 1028 } 915 1029 916 if 1030 if(isWindowOwnDC) 917 1031 { 918 1032 SIZEL sizel = {0,0}; … … 924 1038 else 925 1039 { 926 if (hWindow == HWND_DESKTOP) 1040 if (hWindow == HWND_DESKTOP) { 927 1041 hps = WinGetScreenPS (hWindow); 928 else 929 hps = WinGetPS (hWindow); 930 1042 } 1043 else { 1044 int clipstyle = 0; 1045 int clipwnd = HWND_TOP; 1046 if(flags & (DCX_USESTYLE_W)) { 1047 int style = wnd->getStyle(); 1048 if(style & WS_CLIPCHILDREN_W) { 1049 clipstyle |= PSF_CLIPCHILDREN; 1050 } 1051 if(style & WS_CLIPSIBLINGS_W) { 1052 clipstyle |= PSF_CLIPSIBLINGS; 1053 } 1054 if(wnd->fHasParentDC()) { 1055 clipstyle |= PSF_PARENTCLIP; 1056 } 1057 } 1058 if(flags & DCX_CLIPSIBLINGS_W) { 1059 clipstyle |= PSF_CLIPSIBLINGS; 1060 } 1061 if(flags & DCX_CLIPCHILDREN_W) { 1062 clipstyle |= PSF_CLIPCHILDREN; 1063 } 1064 if(flags & DCX_PARENTCLIP_W) { 1065 clipstyle |= PSF_PARENTCLIP; 1066 } 1067 if(clipstyle) { 1068 dprintf2(("WinGetClipPS style %x", clipstyle)); 1069 hps = WinGetClipPS(hWindow, clipwnd, clipstyle); 1070 } 1071 else hps = WinGetPS (hWindow); 1072 } 931 1073 psType = MICRO_CACHED; 932 1074 } … … 937 1079 HPSToHDC (hWindow, hps, NULL, NULL); 938 1080 pHps = (pDCData)GpiQueryDCData (hps); 1081 1082 if(!(flags & DCX_WINDOW_W)) 1083 { 1084 selectClientArea(wnd, pHps, NULL); 1085 } 1086 else removeClientArea(pHps); 1087 1088 1089 setMapMode(wnd, pHps, MM_TEXT_W); 939 1090 940 1091 if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W)) … … 1037 1188 { 1038 1189 if (!hwnd) hwnd = GetDesktopWindow(); 1039 return GetDCEx (hwnd, NULL, DCX_ USESTYLE_W | DCX_WINDOW_W);1190 return GetDCEx (hwnd, NULL, DCX_WINDOW_W); 1040 1191 } 1041 1192 //****************************************************************************** … … 1091 1242 //TODO: If frame, exclude client window from update 1092 1243 if(redraw & RDW_FRAME_W) { 1093 hwnd = wnd->getOS2 FrameWindowHandle();1244 hwnd = wnd->getOS2WindowHandle(); 1094 1245 } 1095 1246 else hwnd = wnd->getOS2WindowHandle(); … … 1254 1405 } 1255 1406 //****************************************************************************** 1407 //TODO: Change for client rectangle!!!!! 1256 1408 //****************************************************************************** 1257 1409 BOOL setPMRgnIntoWinRgn (HRGN hrgnPM, HRGN hrgnWin, LONG height) … … 1313 1465 } 1314 1466 //****************************************************************************** 1315 //****************************************************************************** 1316 BOOL WIN32API ScrollDC (HDC hDC, int dx, int dy, const RECT *pScroll, 1317 const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate) 1467 //TODO: Check if this one works correctly... 1468 //****************************************************************************** 1469 BOOL WIN32API ScrollDC(HDC hDC, int dx, int dy, const RECT *pScroll, 1470 const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate) 1318 1471 { 1319 1472 BOOL rc = TRUE; 1320 1473 1321 dprintf (("USER32: ScrollDC"));1474 dprintf (("USER32: ScrollDC %x (%d,%d), %x %x %x %x", hDC, dx, dy, pScroll, pClip, hrgnUpdate, pRectUpdate)); 1322 1475 1323 1476 if (!hDC) … … 1341 1494 dy = (int)(ptl[1].y - ptl[0].y); 1342 1495 1343 RECT LscrollRect;1344 RECT LclipRect;1496 RECT scrollRect; 1497 RECT clipRect; 1345 1498 1346 1499 if (pClip) 1347 1500 { 1348 clipRect.xLeft = min (pClip->left, pClip->right); 1349 clipRect.xRight = max (pClip->left, pClip->right); 1350 clipRect.yTop = max (pClip->top, pClip->bottom); 1351 clipRect.yBottom = min (pClip->top, pClip->bottom); 1501 memcpy(&clipRect, pClip, sizeof(clipRect)); 1352 1502 1353 1503 if ((pHps->graphicsMode == GM_COMPATIBLE_W) && 1354 (clipRect. xLeft != clipRect.xRight) &&1355 (clipRect. yBottom != clipRect.yTop))1504 (clipRect.left != clipRect.right) && 1505 (clipRect.bottom != clipRect.top)) 1356 1506 { 1357 1507 if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx)) 1358 clipRect. xRight -= abs(pHps->worldXDeltaFor1Pixel);1508 clipRect.right -= abs(pHps->worldXDeltaFor1Pixel); 1359 1509 else 1360 clipRect. xLeft += abs(pHps->worldXDeltaFor1Pixel);1510 clipRect.left += abs(pHps->worldXDeltaFor1Pixel); 1361 1511 1362 1512 if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy)) 1363 clipRect. yTop-= abs(pHps->worldYDeltaFor1Pixel);1513 clipRect.bottom -= abs(pHps->worldYDeltaFor1Pixel); 1364 1514 else 1365 clipRect. yBottom+= abs(pHps->worldYDeltaFor1Pixel);1366 } 1367 GpiConvert 1368 if (clipRect. xRight < clipRect.xLeft) {1369 ULONG temp = clipRect.xLeft;1370 clipRect. xLeft = clipRect.xRight;1371 clipRect. xRight = temp;1372 } 1373 if (clipRect. yTop < clipRect.yBottom) {1374 ULONG temp = clipRect. yBottom;1375 clipRect. yBottom = clipRect.yTop;1376 clipRect. yTop= temp;1515 clipRect.top += abs(pHps->worldYDeltaFor1Pixel); 1516 } 1517 GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&clipRect); 1518 if (clipRect.right < clipRect.left) { 1519 ULONG temp = clipRect.left; 1520 clipRect.left = clipRect.right; 1521 clipRect.right = temp; 1522 } 1523 if (clipRect.bottom < clipRect.top) { 1524 ULONG temp = clipRect.top; 1525 clipRect.top = clipRect.bottom; 1526 clipRect.bottom = temp; 1377 1527 } 1378 1528 } … … 1380 1530 if (pScroll) 1381 1531 { 1382 scrollRect.xLeft = min (pScroll->left, pScroll->right); 1383 scrollRect.xRight = max (pScroll->left, pScroll->right); 1384 scrollRect.yTop = max (pScroll->top, pScroll->bottom); 1385 scrollRect.yBottom = min (pScroll->top, pScroll->bottom); 1532 memcpy(&scrollRect, pScroll, sizeof(scrollRect)); 1386 1533 1387 1534 if ((pHps->graphicsMode == GM_COMPATIBLE_W) && 1388 (scrollRect. xLeft != scrollRect.xRight) &&1389 (scrollRect. yBottom != scrollRect.yTop))1535 (scrollRect.left != scrollRect.right) && 1536 (scrollRect.top != scrollRect.bottom)) 1390 1537 { 1391 1538 if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx)) 1392 scrollRect. xRight -= abs(pHps->worldXDeltaFor1Pixel);1539 scrollRect.right -= abs(pHps->worldXDeltaFor1Pixel); 1393 1540 else 1394 scrollRect. xLeft += abs(pHps->worldXDeltaFor1Pixel);1541 scrollRect.left += abs(pHps->worldXDeltaFor1Pixel); 1395 1542 1396 1543 if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy)) 1397 scrollRect. yTop-= abs(pHps->worldYDeltaFor1Pixel);1544 scrollRect.bottom -= abs(pHps->worldYDeltaFor1Pixel); 1398 1545 else 1399 scrollRect. yBottom+= abs(pHps->worldYDeltaFor1Pixel);1546 scrollRect.top += abs(pHps->worldYDeltaFor1Pixel); 1400 1547 } 1401 1548 GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&scrollRect); 1402 if (scrollRect.xRight < scrollRect.xLeft) { 1403 ULONG temp = scrollRect.xLeft; 1404 scrollRect.xLeft = scrollRect.xRight; 1405 scrollRect.xRight = temp; 1406 } 1407 if (scrollRect.yTop < scrollRect.yBottom) { 1408 ULONG temp = scrollRect.yBottom; 1409 scrollRect.yBottom = scrollRect.yTop; 1410 scrollRect.yTop = temp; 1411 } 1412 } 1413 RECTL rectlUpdate; 1414 HRGN hrgn; 1415 1416 LONG lComplexity = WinScrollWindow (hwnd, dx, dy, (pScroll) ? &scrollRect : NULL, (pClip) ? &clipRect : NULL, hrgn, &rectlUpdate, 0); 1549 if (scrollRect.right < scrollRect.left) { 1550 ULONG temp = scrollRect.left; 1551 scrollRect.left = scrollRect.right; 1552 scrollRect.right = temp; 1553 } 1554 if (scrollRect.bottom < scrollRect.top) { 1555 ULONG temp = scrollRect.top; 1556 scrollRect.top = scrollRect.bottom; 1557 scrollRect.bottom = temp; 1558 } 1559 } 1560 RECTL rectlUpdate; 1561 HRGN hrgn; 1562 RECTL clientRect; 1563 RECTL clipOS2; 1564 RECTL scrollOS2; 1565 PRECTL pScrollOS2 = NULL; 1566 PRECTL pClipOS2 = NULL; 1567 1568 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&clientRect); 1569 1570 if(pScroll) { 1571 mapWin32ToOS2RectClientToFrame(wnd, &scrollRect, (PRECTLOS2)&scrollOS2); 1572 pScrollOS2 = &scrollOS2; 1573 1574 //Scroll rectangle relative to client area 1575 WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect); 1576 } 1577 else { 1578 pScrollOS2 = &clientRect; 1579 } 1580 1581 if(pClip) { 1582 mapWin32ToOS2RectClientToFrame(wnd, &clipRect, (PRECTLOS2)&clipOS2); 1583 pClipOS2 = &clipOS2; 1584 1585 //Clip rectangle relative to client area 1586 WinIntersectRect((HAB) 0, pClipOS2, pClipOS2, &clientRect); 1587 } 1588 else { 1589 pClipOS2 = &clientRect; 1590 } 1591 1592 LONG lComplexity = WinScrollWindow(hwnd, dx, dy, pScrollOS2, 1593 pClipOS2, hrgn, &rectlUpdate, 0); 1417 1594 if (lComplexity == RGN_ERROR) 1418 1595 { … … 1421 1598 1422 1599 RECT winRectUpdate; 1423 LONG height = wnd->getClientHeight(); 1424 1425 winRectUpdate.left = rectlUpdate.xLeft; 1426 winRectUpdate.right = rectlUpdate.xRight; 1427 winRectUpdate.top = height - rectlUpdate.yTop; 1428 winRectUpdate.bottom = height - rectlUpdate.yBottom; 1600 1601 mapOS2ToWin32Rect(wnd->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate); 1429 1602 1430 1603 if (pRectUpdate) … … 1432 1605 1433 1606 if (hrgnUpdate) 1434 rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);1607 rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->getWindowHeight()); 1435 1608 1436 1609 return (rc); … … 1438 1611 //****************************************************************************** 1439 1612 //****************************************************************************** 1440 #if 11441 BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)1442 {1443 Win32BaseWindow *window;1444 APIRET rc;1445 RECTL clientRect;1446 PRECT pClientRect;1447 RECTL scrollRect;1448 RECTL clipRect;1449 PRECTL pScrollRect = NULL;1450 PRECTL pClipRect = NULL;1451 ULONG scrollFlags = SW_INVALIDATERGN;1452 1453 window = Win32BaseWindow::GetWindowFromHandle(hwnd);1454 if(!window) {1455 dprintf(("ScrollWindow, window %x not found", hwnd));1456 return 0;1457 }1458 dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));1459 1460 pClientRect = window->getClientRectPtr();1461 clientRect.xLeft = 0;1462 clientRect.yBottom = 0;1463 clientRect.xRight = pClientRect->right - pClientRect->left;1464 clientRect.yTop = pClientRect->bottom - pClientRect->top;1465 1466 if(pScroll) {1467 mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);1468 pScrollRect = &scrollRect;1469 1470 //Scroll rectangle relative to client area1471 WinIntersectRect ((HAB) 0, pScrollRect, pScrollRect, &clientRect);1472 }1473 else scrollFlags |= SW_SCROLLCHILDREN;1474 1475 if(pClip) {1476 mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);1477 pClipRect = &clipRect;1478 1479 //Clip rectangle relative to client area1480 WinIntersectRect ((HAB) 0, pClipRect, pClipRect, &clientRect);1481 }1482 1483 dy = revertDy (window, dy);1484 1485 rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,1486 pScrollRect, pClipRect, NULLHANDLE,1487 NULL, scrollFlags);1488 1489 return (rc != RGN_ERROR);1490 }1491 #else1492 1613 BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip) 1493 1614 { … … 1497 1618 RECTL scrollRect; 1498 1619 RECTL clipRect; 1499 PRECTL pScroll Rect= NULL;1500 PRECTL pClip Rect= NULL;1620 PRECTL pScrollOS2 = NULL; 1621 PRECTL pClipOS2 = NULL; 1501 1622 ULONG scrollFlags = SW_INVALIDATERGN; 1502 1623 … … 1507 1628 } 1508 1629 dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip)); 1509 mapWin32ToOS2Rect(window,window->getClientRectPtr(),(PRECTLOS2)&clientRect); 1510 #if 0 1511 //Rectangle could be relative to parent window, so fix this 1512 if(clientRect.yBottom != 0) { 1513 clientRect.yTop -= clientRect.yBottom; 1514 clientRect.yBottom = 0; 1515 } 1516 if(clientRect.xLeft != 0) { 1517 clientRect.xRight -= clientRect.xLeft; 1518 clientRect.xLeft = 0; 1519 } 1520 #endif 1630 1631 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect); 1632 1521 1633 if(pScroll) { 1522 mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect); 1523 pScrollRect = &scrollRect; 1524 1525 //Scroll rectangle relative to client area 1526 pScrollRect->xLeft += clientRect.xLeft; 1527 pScrollRect->xRight += clientRect.xLeft; 1528 pScrollRect->yTop += clientRect.yBottom; 1529 pScrollRect->yBottom += clientRect.yBottom; 1530 WinIntersectRect ((HAB) 0, pScrollRect, pScrollRect, &clientRect); 1531 } 1532 else scrollFlags |= SW_SCROLLCHILDREN; 1634 mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect); 1635 pScrollOS2 = &scrollRect; 1636 1637 //Scroll rectangle relative to client area 1638 WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect); 1639 } 1640 else { 1641 pScrollOS2 = &clientRect; 1642 scrollFlags |= SW_SCROLLCHILDREN; 1643 } 1533 1644 1534 1645 if(pClip) { 1535 mapWin32ToOS2Rect (window,(RECT *)pClip, (PRECTLOS2)&clipRect);1536 pClip Rect= &clipRect;1646 mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect); 1647 pClipOS2 = &clipRect; 1537 1648 1538 1649 //Clip rectangle relative to client area 1539 pClipRect->xLeft += clientRect.xLeft; 1540 pClipRect->xRight += clientRect.xLeft; 1541 pClipRect->yTop += clientRect.yBottom; 1542 pClipRect->yBottom += clientRect.yBottom; 1543 WinIntersectRect ((HAB) 0, pClipRect, pClipRect, &clientRect); 1650 WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect); 1651 } 1652 else { 1653 pClipOS2 = &clientRect; 1544 1654 } 1545 1655 … … 1547 1657 1548 1658 rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy, 1549 pScroll Rect, pClipRect, NULLHANDLE,1659 pScrollOS2, pClipOS2, NULLHANDLE, 1550 1660 NULL, scrollFlags); 1551 1661 1552 1662 return (rc != RGN_ERROR); 1553 1663 } 1554 #endif1555 1664 //****************************************************************************** 1556 1665 //****************************************************************************** … … 1558 1667 HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag) 1559 1668 { 1560 Win32BaseWindow *window; 1561 APIRET rc; 1562 RECTL scrollRect; 1563 RECTL clipRect; 1564 ULONG scrollFlags = 0; 1565 int regionType = ERROR_W; 1669 Win32BaseWindow *window; 1670 APIRET rc; 1671 RECTL clientRect; 1672 RECTL scrollRect; 1673 RECTL clipRect; 1674 PRECTL pScrollOS2 = NULL; 1675 PRECTL pClipOS2 = NULL; 1676 ULONG scrollFlags = 0; 1677 int regionType = ERROR_W; 1566 1678 1567 1679 window = Win32BaseWindow::GetWindowFromHandle(hwnd); … … 1578 1690 if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlags |= SW_SCROLLCHILDREN; 1579 1691 1580 if(pScroll) mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect); 1581 if(pClip) mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect); 1692 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect); 1693 1694 if(pScroll) { 1695 mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect); 1696 pScrollOS2 = &scrollRect; 1697 1698 //Scroll rectangle relative to client area 1699 WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect); 1700 } 1701 else { 1702 pScrollOS2 = &clientRect; 1703 scrollFlags |= SW_SCROLLCHILDREN; //TODO: ????? 1704 } 1705 1706 if(pClip) { 1707 mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect); 1708 pClipOS2 = &clipRect; 1709 1710 //Clip rectangle relative to client area 1711 WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect); 1712 } 1713 else { 1714 pClipOS2 = &clientRect; 1715 } 1582 1716 1583 1717 RECTL rectlUpdate; … … 1593 1727 1594 1728 LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy, 1595 (pScroll) ? &scrollRect : NULL,1596 (pClip) ? &clipRect : NULL,1729 pScrollOS2, 1730 pClipOS2, 1597 1731 hrgn, &rectlUpdate, scrollFlags); 1598 1732 if (lComplexity == RGN_ERROR) … … 1602 1736 1603 1737 RECT winRectUpdate; 1604 LONG height = window->getClientHeight(); 1605 1606 winRectUpdate.left = rectlUpdate.xLeft; 1607 winRectUpdate.right = rectlUpdate.xRight; 1608 winRectUpdate.top = height - rectlUpdate.yTop; 1609 winRectUpdate.bottom = height - rectlUpdate.yBottom; 1738 1739 mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate); 1610 1740 1611 1741 if (pRectUpdate) … … 1613 1743 1614 1744 if (hrgnUpdate) 1615 rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height); 1616 1745 rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, window->getWindowHeight()); 1746 1747 #if 0 1617 1748 //SvL: WinScrollWindow already invalidates the area; no need to do it again 1618 1749 //(call to invalidateRect was wrong; has to include erase flag) 1619 #if 01620 1750 if ((scrollFlag & SW_INVALIDATE_W) && 1621 1751 ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
Note:
See TracChangeset
for help on using the changeset viewer.