Changeset 5685 for trunk/src/user32/dc.cpp
- Timestamp:
- May 11, 2001, 10:39:46 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dc.cpp
r5655 r5685 1 /* $Id: dc.cpp,v 1.9 8 2001-05-04 17:02:50sandervl Exp $ */1 /* $Id: dc.cpp,v 1.99 2001-05-11 08:39:41 sandervl Exp $ */ 2 2 3 3 /* … … 387 387 VOID removeClientArea(Win32BaseWindow *window, pDCData pHps) 388 388 { 389 POINTL point;390 391 // This function checks to see if a client area is currently selected, if392 // it is the origin plus the visible region of the frame are restored.393 394 389 pHps->isClient = FALSE; 395 396 //// dprintfOrigin(pHps->hps); 397 398 if(pHps->isClientArea) 399 { 400 dprintf2(("removeClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y)); 401 pHps->isClientArea = FALSE; 402 GreSetupDC(pHps->hps, 403 pHps->hrgnVis, 404 pHps->ptlOrigin.x, 405 pHps->ptlOrigin.y, 406 0, 407 SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP); 408 } 409 //// else dprintf2(("removeClientArea: %x (%d,%d) (%d,%d)", window->getWindowHandle(), point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y)); 410 390 pHps->isClientArea = FALSE; 411 391 } 412 392 //****************************************************************************** … … 414 394 void selectClientArea(Win32BaseWindow *window, pDCData pHps) 415 395 { 416 // This function checks to see if the DC needs to be adjusted to a client417 // area and makes the adjustment.418 RECTL rcl, rcltemp;419 HRGN hrgnRect, hrgnClip, hrgnOldClip = 0;420 HWND hwnd;421 LONG rc;422 PRECT pClient = window->getClientRectPtr();423 PRECT pWindow = window->getWindowRect();424 RECT rectWindow;425 RECTL rectWindowOS2;426 427 if(!window->isOwnDCDirty() && (pClient->left == 0 && pClient->top == 0 &&428 window->getClientHeight() == window->getWindowHeight() &&429 window->getClientWidth() == window->getWindowWidth()))430 {431 //client rectangle = frame rectangle -> no change necessary432 return;433 }434 396 pHps->isClient = TRUE; 435 436 hwnd = window->getOS2WindowHandle();437 438 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&rcl);439 440 GetWindowRect(window->getWindowHandle(), &rectWindow);441 mapWin32ToOS2Rect(GetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);442 dprintf2(("frame (%d,%d)(%d,%d) hps height %d", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop, pHps->height));443 444 //convert to screen coordinates445 GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);446 447 if(pHps->isClientArea)448 {449 //TODO: counter450 dprintf2(("WARNING: selectClientArea %x; already selected! origin (%d,%d) original origin (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, pHps->ptlOrigin.x, pHps->ptlOrigin.y));451 GetWindowRect(window->getWindowHandle(), &rectWindow);452 mapWin32ToOS2Rect(GetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);453 if(rectWindowOS2.xLeft + rcl.xLeft != rcltemp.xLeft ||454 rectWindowOS2.yBottom + rcl.yBottom != rcltemp.yBottom)455 {456 dprintf2(("WARNING: origin changed (%d,%d) instead of (%d,%d)!", rcltemp.xLeft, rcltemp.yBottom, rectWindowOS2.xLeft + rcl.xLeft, rectWindowOS2.yBottom + rcl.yBottom));457 rcl.xLeft += rectWindowOS2.xLeft;458 rcl.xRight += rectWindowOS2.xLeft;459 rcl.yTop += rectWindowOS2.yBottom;460 rcl.yBottom += rectWindowOS2.yBottom;461 }462 else return;463 }464 else {465 rcl.xLeft += rcltemp.xLeft;466 rcl.xRight += rcltemp.xLeft;467 rcl.yTop += rcltemp.yBottom;468 rcl.yBottom += rcltemp.yBottom;469 470 pHps->ptlOrigin.x = rcltemp.xLeft;471 pHps->ptlOrigin.y = rcltemp.yBottom;472 }473 dprintf2(("selectClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom));474 475 if(pHps->hrgnVis == 0)476 pHps->hrgnVis = GreCreateRectRegion(pHps->hps, &rcl, 1);477 478 hrgnRect = GreCreateRectRegion(pHps->hps, &rcl, 1);479 #if 0480 if(window->getParent())481 {482 HRGN hrgnParentClip;483 484 pClient = window->getParent()->getClientRectPtr();485 GetWindowRect(window->getParent()->getWindowHandle(), &rectWindow);486 rectWindow.right = rectWindow.left + pClient->right;487 rectWindow.left += pClient->left;488 rectWindow.bottom = rectWindow.top + pClient->bottom;489 rectWindow.top += pClient->top;490 mapWin32ToOS2Rect(GetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);491 492 hrgnParentClip = GreCreateRectRegion(pHps->hps, &rectWindowOS2, 1);493 #ifdef DEBUG494 dprintf(("Combining client & parent client regions"));495 dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnParentClip);496 dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnRect);497 #endif498 499 GreCombineRegion(pHps->hps, hrgnRect, hrgnParentClip, hrgnRect, CRGN_AND);500 GreDestroyRegion(pHps->hps, hrgnParentClip);501 }502 #endif503 504 // Query the visible region505 GreCopyClipRegion(pHps->hps, pHps->hrgnVis, 0, COPYCRGN_VISRGN);506 GpiQueryRegionBox(pHps->hps, pHps->hrgnVis, &rcltemp);507 // And the visible region of the frame with the client rectangle508 // to get the new visible region509 GreCombineRegion(pHps->hps, hrgnRect, pHps->hrgnVis, hrgnRect, CRGN_AND);510 #ifdef DEBUG511 dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnRect);512 #endif513 514 // Set the new origin plus visible region in the DC515 GreSetupDC(pHps->hps,516 hrgnRect,517 rcl.xLeft,518 rcl.yBottom,519 NULL,520 SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);521 522 // Destroy the region now we have finished with it.523 GreDestroyRegion(pHps->hps, hrgnRect);524 525 397 pHps->isClientArea = TRUE; 526 527 if(pClient->left == 0 && pClient->top == 0 &&528 window->getClientHeight() == window->getWindowHeight() &&529 window->getClientWidth() == window->getWindowWidth())530 {531 //client = frame, so no changes are necessary when switching between the two532 pHps->isClient = FALSE;533 pHps->isClientArea = FALSE;534 }535 if(window->isOwnDCDirty()) {536 window->validateOwnDC();537 setPageXForm(window, pHps);538 }539 540 //testestest541 #if 0542 GpiQueryViewingLimits(pHps->hps, &rectWindowOS2);543 dprintf2(("view limits (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));544 GpiQueryDefViewingLimits(pHps->hps, &rectWindowOS2);545 dprintf2(("def view limits (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));546 GpiQueryPageViewport(pHps->hps, &rectWindowOS2);547 dprintf2(("page viewport (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));548 549 GpiQueryBoundaryData(pHps->hps, &rectWindowOS2);550 dprintf2(("boundary data (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));551 552 GpiQueryGraphicsField(pHps->hps, &rectWindowOS2);553 dprintf2(("graphics field (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));554 555 SIZEL size;556 GpiQueryPickApertureSize(pHps->hps, &size);557 dprintf2(("page viewport (%d,%d)", size.cx, size.cy));558 559 GpiQueryPS(pHps->hps, &size);560 dprintf2(("page space (%d,%d)", size.cx, size.cy));561 #endif562 //testestest563 564 398 } 565 399 //****************************************************************************** … … 576 410 LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps) 577 411 { 578 if ((hwnd == 0) && (pHps != 0))579 hwnd = pHps->hwnd;580 581 if ((hwnd != 0) || (pHps == 0))582 {412 if ((hwnd == 0) && (pHps != 0)) 413 hwnd = pHps->hwnd; 414 415 if ((hwnd != 0) || (pHps == 0)) 416 { 583 417 if(wnd) { 584 585 586 587 elsereturn (wnd->getClientHeight());588 } 589 else 590 }591 else if (pHps->bitmapHandle)592 {593 return pHps->bitmapHeight;594 }595 else if (pHps->isMetaPS)596 {597 return 0;598 }599 else if (pHps->isPrinter)600 {601 return pHps->printPageHeight;602 }603 else604 {605 return MEM_HPS_MAX;606 }607 } 608 //****************************************************************************** 609 //****************************************************************************** 610 BOOL 418 if(pHps && !pHps->isClientArea) { 419 return (wnd->getWindowHeight()); 420 } 421 else return (wnd->getClientHeight()); 422 } 423 else return OSLibQueryScreenHeight(); 424 } 425 else if (pHps->bitmapHandle) 426 { 427 return pHps->bitmapHeight; 428 } 429 else if (pHps->isMetaPS) 430 { 431 return 0; 432 } 433 else if (pHps->isPrinter) 434 { 435 return pHps->printPageHeight; 436 } 437 else 438 { 439 return MEM_HPS_MAX; 440 } 441 } 442 //****************************************************************************** 443 //****************************************************************************** 444 BOOL WIN32API changePageXForm(pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev) 611 445 { 612 446 Win32BaseWindow *wnd; 613 447 614 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 448 if(pHps->isClient) { 449 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 450 } 451 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 615 452 return changePageXForm(wnd, pHps, pValue, x, y, pPrev); 616 453 } 617 454 //****************************************************************************** 618 455 //****************************************************************************** 619 BOOL 456 BOOL WIN32API setPageXForm(pDCData pHps) 620 457 { 621 458 Win32BaseWindow *wnd; 622 459 623 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 460 if(pHps->isClient) { 461 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 462 } 463 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 624 464 return setPageXForm(wnd, pHps); 625 465 } 626 466 //****************************************************************************** 627 467 //****************************************************************************** 628 VOID 468 VOID WIN32API removeClientArea(pDCData pHps) 629 469 { 630 470 Win32BaseWindow *wnd; 631 471 632 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 472 if(pHps->isClient) { 473 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 474 } 475 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 633 476 if(wnd) { 634 477 removeClientArea(wnd, pHps); … … 641 484 Win32BaseWindow *wnd; 642 485 643 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 486 if(pHps->isClient) { 487 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 488 } 489 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 644 490 if(wnd) { 645 491 selectClientArea(wnd, pHps); … … 652 498 Win32BaseWindow *wnd; 653 499 654 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 500 if(pHps->isClient) { 501 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 502 } 503 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 655 504 if(wnd) { 656 dprintfOrigin(pHps->hps);657 505 if(pHps->isClient) 658 506 selectClientArea(wnd, pHps); … … 661 509 //****************************************************************************** 662 510 //****************************************************************************** 663 LONG 511 LONG WIN32API clientHeight(HWND hwnd, pDCData pHps) 664 512 { 665 513 Win32BaseWindow *wnd; 666 514 667 wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd); 515 if(pHps->isClient) { 516 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 517 } 518 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 668 519 return clientHeight(wnd, hwnd, pHps); 669 520 } 670 521 //****************************************************************************** 671 522 //****************************************************************************** 672 int 523 int WIN32API setMapMode(pDCData pHps, int mode) 673 524 { 674 525 Win32BaseWindow *wnd; 675 526 676 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 527 if(pHps->isClient) { 528 wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd); 529 } 530 else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd); 677 531 return setMapMode(wnd, pHps, mode); 678 532 } … … 790 644 RECTL rectlClip; 791 645 792 if(lpps == NULL) {646 if(lpps == NULL) { 793 647 //BeginPaint does NOT change last error in this case 794 648 //(verified in NT4, SP6) 795 649 dprintf (("USER32: BeginPaint %x NULL PAINTSTRUCT pointer", hWnd)); 796 650 return 0; 797 }798 memset(lpps, 0, sizeof(*lpps));799 800 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);801 if(!wnd) {651 } 652 memset(lpps, 0, sizeof(*lpps)); 653 654 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 655 if(!wnd) { 802 656 dprintf (("USER32: BeginPaint %x %x: invalid window handle!!", hWnd, lpps)); 803 657 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); //(verified in NT4, SP6) 804 658 return (HDC)0; 805 }806 HWND hwndClient = wnd->getOS2WindowHandle();807 808 if(hwnd != HWND_DESKTOP && wnd->isOwnDC())809 {659 } 660 HWND hwndClient = wnd->getOS2WindowHandle(); 661 662 if(hwnd != HWND_DESKTOP && wnd->isOwnDC()) 663 { 810 664 hPS_ownDC = wnd->getOwnDC(); 811 665 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise) 812 666 if(hPS_ownDC) { 813 814 815 816 817 818 819 820 821 } 822 }823 if(!hpsPaint) {824 hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_ WINDOW_W|DCX_USESTYLE_W));667 pHps = (pDCData)GpiQueryDCData(hPS_ownDC); 668 if (!pHps) 669 { 670 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps)); 671 SetLastError(ERROR_INVALID_PARAMETER_W); 672 return (HDC)NULLHANDLE; 673 } 674 hpsPaint = hPS_ownDC; 675 } 676 } 677 if(!hpsPaint) { 678 hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_USESTYLE_W)); 825 679 pHps = (pDCData)GpiQueryDCData(hpsPaint); 826 680 if (!pHps) 827 681 { 828 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps)); 829 SetLastError(ERROR_INVALID_PARAMETER_W); 830 return (HDC)NULLHANDLE; 831 } 832 } 833 834 if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) { 682 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps)); 683 SetLastError(ERROR_INVALID_PARAMETER_W); 684 return (HDC)NULLHANDLE; 685 } 686 } 687 688 if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) 689 { 835 690 memset(&rectl, 0, sizeof(rectl)); 836 691 dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!")); … … 844 699 wnd->SetClipRegion(hrgnOldClip); 845 700 lComplexity = RGN_NULL; 846 }847 else {701 } 702 else { 848 703 rectlClip.yBottom = rectlClip.xLeft = 0; 849 704 rectlClip.yTop = rectlClip.xRight = 1; … … 854 709 WinValidateRegion(hwndClient, hrgnClip, FALSE); 855 710 856 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient); 857 WinIntersectRect(NULL, &rectlClip, &rectl, &rectlClient); 858 WinOffsetRect(NULL, &rectlClip, -rectlClient.xLeft, -rectlClient.yBottom); 859 860 //clip update region with client window rectangle 861 HRGN hrgnClient = GpiCreateRegion(pHps->hps, 1, &rectlClient); 862 GpiCombineRegion(pHps->hps, hrgnClip, hrgnClip, hrgnClient, CRGN_AND); 863 GpiDestroyRegion(pHps->hps, hrgnClient); 864 865 //change origin of clip region (window -> client) 866 POINTL point = {-rectlClient.xLeft, -rectlClient.yBottom}; 867 GpiOffsetRegion(pHps->hps, hrgnClip, &point); 711 dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnClip); 712 868 713 #ifdef DEBUG 869 dprintfRegion1(pHps->hps, hWnd, hrgnClip); 714 lComplexity = GpiQueryClipBox(pHps->hps, &rectlClip); 715 dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop)); 870 716 #endif 717 871 718 //set clip region 872 719 lComplexity = GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip); 873 720 874 //change presentation space for client window 875 //NOTE: MUST do this after GpiSetClipRegion call! 876 // When a window with CS_OWNDC looses focus, for some reason 877 // GpiSetClipRegion resets the window dc origin back to (0,0) 721 if(lComplexity == RGN_NULL) { 722 dprintf (("BeginPaint %x: EMPTY update rectangle (show=%d/%d vis=%d/%d", hWnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()), WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()))); 723 } 878 724 selectClientArea(wnd, pHps); 879 725 880 GpiQueryClipBox(pHps->hps, &rectl); 881 dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop)); 882 726 #ifdef DEBUG 727 GpiQueryClipBox(pHps->hps, &rectlClip); 728 dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop)); 729 #endif 883 730 //save old clip region (restored for CS_OWNDC windows in EndPaint) 884 731 wnd->SetClipRegion(hrgnOldClip); 885 memcpy(&rectl, &rectlClip, sizeof(RECTL)); 886 lComplexity = RGN_RECT; 887 } 888 889 if(hPS_ownDC == 0) 890 setMapMode (wnd, pHps, MM_TEXT_W); 891 else 892 setPageXForm(wnd, pHps); 893 894 pHps->hdcType = TYPE_3; 895 896 HideCaret(hwnd); 897 WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE); 898 899 if(wnd->needsEraseBkgnd() && lComplexity != RGN_NULL) { 732 } 733 734 if(hPS_ownDC == 0) 735 setMapMode (wnd, pHps, MM_TEXT_W); 736 else 737 setPageXForm(wnd, pHps); 738 739 pHps->hdcType = TYPE_3; 740 741 HideCaret(hwnd); 742 WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE); 743 744 if((wnd->needsEraseBkgnd() || wnd->IsVisibleRegionChanged()) && lComplexity != RGN_NULL) { 900 745 wnd->setEraseBkgnd(FALSE); 746 wnd->SetVisibleRegionChanged(FALSE); 901 747 lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0); 902 } 903 else lpps->fErase = TRUE; 904 905 dprintfOrigin(pHps->hps); 906 907 lpps->hdc = (HDC)pHps->hps; 908 909 if(lComplexity != RGN_NULL) { 748 } 749 else lpps->fErase = TRUE; 750 751 lpps->hdc = (HDC)pHps->hps; 752 753 if(lComplexity != RGN_NULL) { 910 754 long height = wnd->getClientHeight(); 911 755 lpps->rcPaint.top = height - rectl.yTop; … … 913 757 lpps->rcPaint.bottom = height - rectl.yBottom; 914 758 lpps->rcPaint.right = rectl.xRight; 915 }916 else {759 } 760 else { 917 761 lpps->rcPaint.bottom = lpps->rcPaint.top = 0; 918 762 lpps->rcPaint.right = lpps->rcPaint.left = 0; 919 }920 921 SetLastError(0);922 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));923 return (HDC)pHps->hps;763 } 764 765 SetLastError(0); 766 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)); 767 return (HDC)pHps->hps; 924 768 } 925 769 //****************************************************************************** … … 931 775 pDCData pHps; 932 776 933 dprintf (("USER32: EndPaint(%x)", hwnd)); 934 935 if (!pPaint || !pPaint->hdc ) 936 return TRUE; 937 938 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 939 940 if (!wnd) goto exit; 941 942 pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc); 943 if (pHps && (pHps->hdcType == TYPE_3)) 944 { 945 dprintfOrigin(pHps->hps); 946 777 dprintf (("USER32: EndPaint(%x)", hwnd)); 778 779 if (!pPaint || !pPaint->hdc ) 780 return TRUE; 781 782 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 783 784 if (!wnd) goto exit; 785 786 pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc); 787 if (pHps && (pHps->hdcType == TYPE_3)) 788 { 947 789 GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld); 948 790 wnd->SetClipRegion(0); 949 791 if(hrgnOld) { 950 792 GpiDestroyRegion(pHps->hps, hrgnOld); 951 793 } 952 794 pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails 953 795 ReleaseDC(hwnd, pPaint->hdc); 954 }955 else {796 } 797 else { 956 798 dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc)); 957 }958 wnd->setEraseBkgnd(TRUE);959 ShowCaret(hwnd);960 WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);799 } 800 wnd->setEraseBkgnd(TRUE); 801 ShowCaret(hwnd); 802 WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE); 961 803 962 804 exit: 963 SetLastError(0);964 return TRUE;805 SetLastError(0); 806 return TRUE; 965 807 } 966 808 //****************************************************************************** … … 971 813 int rc; 972 814 973 if (hwnd)974 {815 if (hwnd) 816 { 975 817 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 976 818 if(wnd == NULL) { 977 978 819 dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc)); 820 return 0; 979 821 } 980 822 isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc); 981 823 if(!isOwnDC) 982 824 { 983 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc); 984 if(pHps && pHps->psType == MICRO_CACHED) { 985 removeClientArea(wnd, pHps); 986 if(pHps->hrgnVis) { 987 GreDestroyRegion(pHps->hps, pHps->hrgnVis); 988 pHps->hrgnVis = 0; 989 } 825 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc); 826 if(pHps && pHps->psType == MICRO_CACHED) { 827 removeClientArea(wnd, pHps); 828 if(pHps->hrgnVis) { 829 GreDestroyRegion(pHps->hps, pHps->hrgnVis); 830 pHps->hrgnVis = 0; 990 831 } 991 else { 992 dprintf(("ERROR: ReleaseDC: pHps == NULL!!")); 993 DebugInt3(); 994 } 832 } 833 else { 834 dprintf(("ERROR: ReleaseDC: pHps == NULL!!")); 835 DebugInt3(); 836 } 995 837 } 996 838 else { 997 998 } 999 }1000 1001 if(isOwnDC) {839 dprintf2(("ReleaseDC: CS_OWNDC, not released")); 840 } 841 } 842 843 if(isOwnDC) { 1002 844 rc = TRUE; 1003 }1004 else {845 } 846 else { 1005 847 UnselectGDIObjects(hdc); 1006 848 rc = O32_ReleaseDC (0, hdc); 1007 }1008 1009 dprintf(("ReleaseDC %x %x", hwnd, hdc));1010 return (rc);849 } 850 851 dprintf(("ReleaseDC %x %x", hwnd, hdc)); 852 return (rc); 1011 853 } 1012 854 //****************************************************************************** … … 1035 877 PS_Type psType; 1036 878 1037 if(hwnd == 0) {879 if(hwnd == 0) { 1038 880 dprintf(("error: GetDCEx window %x not found", hwnd)); 1039 881 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 1040 882 return 0; 1041 }1042 1043 if(hwnd)1044 {883 } 884 885 if(hwnd) 886 { 1045 887 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 1046 888 if(wnd == NULL) { … … 1049 891 return 0; 1050 892 } 1051 hWindow = wnd->getOS2WindowHandle(); 1052 } 1053 1054 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC())) 1055 && !(flags & (DCX_CACHE_W|DCX_WINDOW_W))); 1056 1057 if(isWindowOwnDC) //own dc always for client area 1058 { 1059 hps = wnd->getOwnDC(); 1060 if (hps) 1061 { 1062 pDCData pHps = (pDCData)GpiQueryDCData (hps); 1063 if (!pHps) 1064 goto error; 1065 1066 selectClientArea(wnd, pHps); 1067 1068 //TODO: Is this always necessary?? 1069 setPageXForm (wnd, pHps); 1070 pHps->hdcType = TYPE_1; 1071 1072 //TODO: intersect/exclude clip region? 1073 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps)); 1074 return (HDC)hps; 1075 } 1076 else 1077 creatingOwnDC = TRUE; 1078 } 1079 1080 if(isWindowOwnDC) 1081 { 1082 SIZEL sizel = {0,0}; 1083 hps = GpiCreatePS (WinQueryAnchorBlock (hWindow), 1084 WinOpenWindowDC (hWindow), 1085 &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC ); 1086 psType = MICRO; 1087 // default cp is OS/2 one: set to windows default (ODIN.INI) 1088 GpiSetCp(hps, GetDisplayCodepage()); 1089 } 1090 else 1091 { 1092 if (hWindow == HWND_DESKTOP) { 1093 hps = WinGetScreenPS (hWindow); 1094 } 1095 else { 1096 int clipstyle = 0; 1097 int clipwnd = HWND_TOP; 1098 if(flags & (DCX_USESTYLE_W)) { 893 if(flags & DCX_WINDOW_W) { 894 hWindow = wnd->getOS2FrameWindowHandle(); 895 } 896 else hWindow = wnd->getOS2WindowHandle(); 897 } 898 899 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC())) 900 && !(flags & (DCX_CACHE_W|DCX_WINDOW_W))); 901 902 if(isWindowOwnDC) //own dc always for client area 903 { 904 hps = wnd->getOwnDC(); 905 if (hps) 906 { 907 pDCData pHps = (pDCData)GpiQueryDCData (hps); 908 if (!pHps) 909 goto error; 910 911 selectClientArea(wnd, pHps); 912 913 //TODO: Is this always necessary?? 914 setPageXForm (wnd, pHps); 915 pHps->hdcType = TYPE_1; 916 917 //TODO: intersect/exclude clip region? 918 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps)); 919 return (HDC)hps; 920 } 921 else creatingOwnDC = TRUE; 922 } 923 924 if(isWindowOwnDC) 925 { 926 SIZEL sizel = {0,0}; 927 hps = GpiCreatePS (WinQueryAnchorBlock (hWindow), 928 WinOpenWindowDC (hWindow), 929 &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC ); 930 psType = MICRO; 931 // default cp is OS/2 one: set to windows default (ODIN.INI) 932 GpiSetCp(hps, GetDisplayCodepage()); 933 } 934 else 935 { 936 if (hWindow == HWND_DESKTOP) { 937 hps = WinGetScreenPS (hWindow); 938 } 939 else { 940 int clipstyle = 0; 941 int clipwnd = HWND_TOP; 942 if(flags & (DCX_USESTYLE_W)) { 1099 943 int style = wnd->getStyle(); 1100 944 if(style & WS_CLIPCHILDREN_W) { 1101 945 clipstyle |= PSF_CLIPCHILDREN; 1102 946 } 1103 947 if(style & WS_CLIPSIBLINGS_W) { 1104 948 clipstyle |= PSF_CLIPSIBLINGS; 1105 949 } 1106 950 if(wnd->fHasParentDC()) { 1107 951 clipstyle |= PSF_PARENTCLIP; 1108 952 } 1109 }1110 if(flags & DCX_CLIPSIBLINGS_W) {953 } 954 if(flags & DCX_CLIPSIBLINGS_W) { 1111 955 clipstyle |= PSF_CLIPSIBLINGS; 1112 }1113 if(flags & DCX_CLIPCHILDREN_W) {956 } 957 if(flags & DCX_CLIPCHILDREN_W) { 1114 958 clipstyle |= PSF_CLIPCHILDREN; 1115 }1116 if(flags & DCX_PARENTCLIP_W) {959 } 960 if(flags & DCX_PARENTCLIP_W) { 1117 961 clipstyle |= PSF_PARENTCLIP; 1118 } 1119 if(clipstyle) { 1120 dprintf2(("WinGetClipPS style %x", clipstyle)); 1121 hps = WinGetClipPS(hWindow, clipwnd, clipstyle); 1122 } 1123 else hps = WinGetPS (hWindow); 1124 1125 // default cp is OS/2 one: set to windows default (ODIN.INI) 1126 GpiSetCp(hps, GetDisplayCodepage()); 1127 } 1128 psType = MICRO_CACHED; 1129 } 1130 1131 if (!hps) 1132 goto error; 1133 1134 HPSToHDC (hWindow, hps, NULL, NULL); 1135 pHps = (pDCData)GpiQueryDCData (hps); 1136 1137 if(!(flags & DCX_WINDOW_W)) 1138 { 1139 selectClientArea(wnd, pHps); 1140 } 1141 else removeClientArea(wnd, pHps); 1142 1143 setMapMode(wnd, pHps, MM_TEXT_W); 1144 1145 if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W)) 1146 { 1147 ULONG BytesNeeded; 1148 PRGNDATA RgnData; 1149 PRECT pr; 1150 int i; 1151 RECTL rectl; 1152 1153 if (!hrgn) 1154 goto error; 1155 1156 success = TRUE; 1157 if (flags & DCX_EXCLUDERGN_W) 1158 { 962 } 963 if(clipstyle) { 964 dprintf2(("WinGetClipPS style %x", clipstyle)); 965 hps = WinGetClipPS(hWindow, clipwnd, clipstyle); 966 } 967 else hps = WinGetPS (hWindow); 968 969 // default cp is OS/2 one: set to windows default (ODIN.INI) 970 GpiSetCp(hps, GetDisplayCodepage()); 971 } 972 psType = MICRO_CACHED; 973 } 974 975 if (!hps) 976 goto error; 977 978 HPSToHDC (hWindow, hps, NULL, NULL); 979 pHps = (pDCData)GpiQueryDCData (hps); 980 981 if(flags & DCX_WINDOW_W) { 982 removeClientArea(wnd, pHps); 983 } 984 else selectClientArea(wnd, pHps); 985 986 setMapMode(wnd, pHps, MM_TEXT_W); 987 988 if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W)) 989 { 990 ULONG BytesNeeded; 991 PRGNDATA RgnData; 992 PRECT pr; 993 int i; 994 RECTL rectl; 995 996 if (!hrgn) 997 goto error; 998 999 success = TRUE; 1000 if (flags & DCX_EXCLUDERGN_W) 1001 { 1159 1002 #if 0 //CB: todo 1160 1003 long height; … … 1181 1024 } 1182 1025 #endif 1183 }1184 else //DCX_INTERSECTRGN_W1185 {1186 //SvL: I'm getting paint problems when clipping a dc created in GetDCEx1187 // with a region that covers the entire window (RealPlayer 7 Update 1)1188 // Using SelectClipRgn here doesn't make any difference.1189 if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {1026 } 1027 else //DCX_INTERSECTRGN_W 1028 { 1029 //SvL: I'm getting paint problems when clipping a dc created in GetDCEx 1030 // with a region that covers the entire window (RealPlayer 7 Update 1) 1031 // Using SelectClipRgn here doesn't make any difference. 1032 if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) { 1190 1033 dprintf(("ExtSelectClipRgn failed!!")); 1191 }1192 }1193 if (!success)1194 goto error;1195 }1196 1197 if (creatingOwnDC)1198 wnd->setOwnDC ((HDC)hps);1199 1200 pHps->psType = psType;1201 pHps->hdcType = TYPE_1;1202 //TODO: WM_SETREDRAW affects drawingAllowed flag!!1203 GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);1204 1205 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));1206 return (HDC)pHps->hps;1034 } 1035 } 1036 if (!success) 1037 goto error; 1038 } 1039 1040 if (creatingOwnDC) 1041 wnd->setOwnDC ((HDC)hps); 1042 1043 pHps->psType = psType; 1044 pHps->hdcType = TYPE_1; 1045 //TODO: WM_SETREDRAW affects drawingAllowed flag!! 1046 GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF); 1047 1048 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps)); 1049 return (HDC)pHps->hps; 1207 1050 1208 1051 error: 1209 /* Something went wrong; clean up1210 */1211 dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags));1212 DebugInt3();1213 if (pHps)1214 {1215 if (pHps->hps)1216 {1217 if(pHps->psType == MICRO_CACHED)1218 WinReleasePS(pHps->hps);1219 else1220 GpiDestroyPS(pHps->hps);1221 }1222 1223 if (pHps->hdc) DevCloseDC(pHps->hdc);1224 if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);1225 1226 O32_DeleteObject (pHps->nullBitmapHandle);1227 }1228 SetLastError(ERROR_INVALID_PARAMETER_W);1229 return NULL;1052 /* Something went wrong; clean up 1053 */ 1054 dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags)); 1055 DebugInt3(); 1056 if (pHps) 1057 { 1058 if (pHps->hps) 1059 { 1060 if(pHps->psType == MICRO_CACHED) 1061 WinReleasePS(pHps->hps); 1062 else 1063 GpiDestroyPS(pHps->hps); 1064 } 1065 1066 if (pHps->hdc) DevCloseDC(pHps->hdc); 1067 if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC); 1068 1069 O32_DeleteObject (pHps->nullBitmapHandle); 1070 } 1071 SetLastError(ERROR_INVALID_PARAMETER_W); 1072 return NULL; 1230 1073 } 1231 1074 //****************************************************************************** … … 1233 1076 HDC WIN32API GetDC (HWND hwnd) 1234 1077 { 1235 if(!hwnd) 1236 return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W ); 1237 return GetDCEx (hwnd, NULL, 0); 1078 if(!hwnd) 1079 return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W ); 1080 1081 return GetDCEx (hwnd, NULL, 0); 1238 1082 } 1239 1083 //****************************************************************************** … … 1241 1085 HDC WIN32API GetWindowDC (HWND hwnd) 1242 1086 { 1243 if (!hwnd) hwnd = GetDesktopWindow();1244 return GetDCEx (hwnd, NULL, DCX_WINDOW_W);1087 if (!hwnd) hwnd = GetDesktopWindow(); 1088 return GetDCEx (hwnd, NULL, DCX_WINDOW_W); 1245 1089 } 1246 1090 //****************************************************************************** … … 1249 1093 LRESULT WIN32API RedrawChildEnumProc(HWND hwnd, LPARAM lParam) 1250 1094 { 1251 RedrawWindow(hwnd, NULL, 0, lParam);1252 return TRUE;1095 RedrawWindow(hwnd, NULL, 0, lParam); 1096 return TRUE; 1253 1097 } 1254 1098 //****************************************************************************** … … 1265 1109 // 1266 1110 //TODO: Works ok for RDW_FRAME?? 1111 // SDK docs say RDW_FRAME is only valid for RDW_INVALIDATE... 1267 1112 //****************************************************************************** 1268 1113 BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw) 1269 1114 { 1270 Win32BaseWindow *wnd;1271 1272 if(pRect) {1273 1274 }1275 elsedprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));1276 1277 if (hwnd == NULLHANDLE)1278 {1115 Win32BaseWindow *wnd; 1116 1117 if(pRect) { 1118 dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw)); 1119 } 1120 else dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw)); 1121 1122 if (hwnd == NULLHANDLE) 1123 { 1279 1124 #if 1 1280 1125 // Don't do this for now (causes lots of desktop repaints in WordPad) 1281 1282 1126 SetLastError(ERROR_INVALID_PARAMETER_W); 1127 return FALSE; 1283 1128 #else 1284 1129 hwnd = HWND_DESKTOP; … … 1293 1138 } 1294 1139 #endif 1295 }1296 else1297 {1140 } 1141 else 1142 { 1298 1143 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1299 1144 … … 1305 1150 return FALSE; 1306 1151 } 1307 hwnd = wnd->getOS2WindowHandle(); 1308 } 1309 1310 BOOL IncludeChildren = (redraw & RDW_ALLCHILDREN_W) ? TRUE : FALSE; 1311 BOOL success = TRUE; 1312 HPS hpsTemp = NULLHANDLE; 1313 HRGN hrgnTemp = NULLHANDLE; 1314 RECTL rectl; 1315 1316 if (hrgn) 1317 { 1318 ULONG BytesNeeded; 1319 PRGNDATA RgnData; 1320 PRECTL pr; 1321 int i; 1322 LONG height; 1323 1324 if(wnd) { 1325 height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight(); 1326 } 1327 else height = OSLibQueryScreenHeight(); 1328 1329 if (!hrgn) 1330 goto error; 1331 1332 BytesNeeded = GetRegionData (hrgn, 0, NULL); 1333 RgnData = (PRGNDATA)_alloca (BytesNeeded); 1334 if (RgnData == NULL) 1152 if(redraw & RDW_FRAME_W) { 1153 hwnd = wnd->getOS2FrameWindowHandle(); 1154 } 1155 else hwnd = wnd->getOS2WindowHandle(); 1156 } 1157 1158 BOOL IncludeChildren = (redraw & RDW_ALLCHILDREN_W) ? TRUE : FALSE; 1159 BOOL success = TRUE; 1160 HPS hpsTemp = NULLHANDLE; 1161 HRGN hrgnTemp = NULLHANDLE; 1162 RECTL rectl; 1163 1164 if (hrgn) 1165 { 1166 ULONG BytesNeeded; 1167 PRGNDATA RgnData; 1168 PRECTL pr; 1169 int i; 1170 LONG height; 1171 1172 if(wnd) { 1173 height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight(); 1174 } 1175 else height = OSLibQueryScreenHeight(); 1176 1177 if (!hrgn) 1178 goto error; 1179 1180 BytesNeeded = GetRegionData (hrgn, 0, NULL); 1181 RgnData = (PRGNDATA)_alloca (BytesNeeded); 1182 if (RgnData == NULL) 1335 1183 goto error; 1336 GetRegionData (hrgn, BytesNeeded, RgnData);1337 1338 pr = (PRECTL)(RgnData->Buffer);1339 for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {1340 LONG temp = pr->yTop;1341 pr->yTop = height - pr->yBottom;1342 pr->yBottom = height - temp;1343 dprintf2(("RedrawWindow: region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop));1344 }1345 1346 hpsTemp = WinGetScreenPS (HWND_DESKTOP);1347 hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));1348 if (!hrgnTemp) goto error;1349 }1350 else if (pRect)1351 {1352 if(wnd) {1353 1354 1355 1356 else mapWin32ToOS2RectClientToFrame(wnd, (PRECT)pRect, (PRECTLOS2)&rectl);1357 }1358 elsemapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);1359 }1360 1361 if (redraw & RDW_INVALIDATE_W)1362 {1184 GetRegionData (hrgn, BytesNeeded, RgnData); 1185 1186 pr = (PRECTL)(RgnData->Buffer); 1187 for (i = RgnData->rdh.nCount; i > 0; i--, pr++) { 1188 LONG temp = pr->yTop; 1189 pr->yTop = height - pr->yBottom; 1190 pr->yBottom = height - temp; 1191 dprintf2(("RedrawWindow: region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop)); 1192 } 1193 1194 hpsTemp = WinGetScreenPS (HWND_DESKTOP); 1195 hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer)); 1196 if (!hrgnTemp) goto error; 1197 } 1198 else if (pRect) 1199 { 1200 if(wnd) { 1201 if(redraw & RDW_FRAME_W) { 1202 mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1203 } 1204 else mapWin32ToOS2Rect(wnd->getClientHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1205 } 1206 else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1207 } 1208 1209 if (redraw & RDW_INVALIDATE_W) 1210 { 1363 1211 //TODO: SvL: pingpong.exe doesn't have RDW_NOERASE, but doesn't want WM_ERASEBKGND msgs 1364 1212 if (redraw & RDW_ERASE_W) { 1365 1213 wnd->setEraseBkgnd(TRUE); 1366 1214 } 1367 else 1368 if (redraw & RDW_NOERASE_W) 1369 wnd->setEraseBkgnd(FALSE); 1215 else wnd->setEraseBkgnd(FALSE); 1370 1216 1371 1217 if (!pRect && !hrgn) … … 1403 1249 1404 1250 if (!success) goto error; 1405 }1406 else if (redraw & RDW_VALIDATE_W)1407 {1251 } 1252 else if (redraw & RDW_VALIDATE_W) 1253 { 1408 1254 if (redraw & RDW_NOERASE_W) 1409 1255 wnd->setEraseBkgnd(FALSE); … … 1423 1269 if(!success) goto error; 1424 1270 } 1425 }1426 1427 if(WinQueryUpdateRect(hwnd, NULL))1428 {1271 } 1272 1273 if(WinQueryUpdateRect(hwnd, &rectl)) 1274 { 1429 1275 //TODO: Does this work if RDW_ALLCHILDREN is set?? 1430 1276 if(redraw & RDW_UPDATENOW_W) { 1431 wnd->MsgNCPaint(); 1432 wnd->MsgPaint(0, FALSE); 1277 RECT rectUpdate; 1278 1279 if(redraw & RDW_FRAME_W) { 1280 mapOS2ToWin32Rect(wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate); 1281 wnd->MsgNCPaint(&rectUpdate); 1282 } 1283 1284 wnd->MsgPaint(0, FALSE); 1433 1285 } 1434 1286 else 1435 1287 // if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W)) 1436 1288 if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd()) 1437 1289 wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0); 1438 1290 // if(redraw & RDW_ALLCHILDREN_W) { 1439 1291 // EnumChildWindows(wnd->getWindowHandle(), RedrawChildEnumProc, redraw); 1440 1292 // } 1441 }1442 else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))1443 {1293 } 1294 else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W)) 1295 { 1444 1296 if(redraw & RDW_UPDATENOW_W) { 1445 wnd->MsgNCPaint(); 1446 wnd->MsgPaint (0, FALSE); 1447 } 1448 else PostMessageA(hwnd, WINWM_PAINT, 0, 0); 1449 } 1297 wnd->MsgPaint(0, FALSE); 1298 } 1299 else PostMessageA(hwnd, WINWM_PAINT, 0, 0); 1300 } 1450 1301 1451 1302 error: 1452 /* clean up */1453 if (hrgnTemp)1454 GpiDestroyRegion (hpsTemp, hrgnTemp);1455 1456 if (hpsTemp)1457 WinReleasePS (hpsTemp);1458 1459 if (!success) {1303 /* clean up */ 1304 if (hrgnTemp) 1305 GpiDestroyRegion (hpsTemp, hrgnTemp); 1306 1307 if (hpsTemp) 1308 WinReleasePS (hpsTemp); 1309 1310 if (!success) { 1460 1311 dprintf(("RedrawWindow failure!")); 1461 1312 SetLastError(ERROR_INVALID_PARAMETER_W); 1462 }1463 return (success);1313 } 1314 return (success); 1464 1315 } 1465 1316 //****************************************************************************** … … 1468 1319 { 1469 1320 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1470 1471 if(!wnd) { 1321 RECTL rectl; 1322 BOOL rc; 1323 1324 if(!wnd) { 1325 dprintf (("ERROR: User32: UpdateWindow INVALID hwnd %x", hwnd)); 1472 1326 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 1473 1327 return FALSE; 1474 } 1475 1476 dprintf (("User32: UpdateWindow hwnd %x", hwnd)); 1477 //SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here) 1478 // Breaks vpbuddy 1479 // return RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W); 1480 // -> RDW_UPDATENOW causes WM_PAINT messages to be directy posted to window 1481 // handler; possibly bypassing queued WM_PAINT messages for parent window(s) 1482 // -> out of sync painting (i.e. parent paints over child) 1483 WinUpdateWindow(wnd->getOS2WindowHandle()); 1484 return TRUE; 1328 } 1329 1330 #ifdef DEBUG 1331 if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), &rectl)) 1332 { 1333 RECT rectUpdate; 1334 mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, &rectUpdate); 1335 1336 dprintf (("User32: UpdateWindow hwnd %x: update rectangle (%d,%d)(%d,%d)", hwnd, rectUpdate.left, rectUpdate.top, rectUpdate.right, rectUpdate.bottom)); 1337 } 1338 else dprintf (("User32: UpdateWindow hwnd %x; EMPTY update rectangle (vis=%d/%d)", hwnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()))); 1339 #endif 1340 //SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here) 1341 // Breaks vpbuddy 1342 //rc = RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W); 1343 // -> RDW_UPDATENOW causes WM_PAINT messages to be directy posted to window 1344 // handler; possibly bypassing queued WM_PAINT messages for parent window(s) 1345 // -> out of sync painting (i.e. parent paints over child) 1346 1347 // if(!WinIsWindowShowing(wnd->getOS2FrameWindowHandle()) || !WinIsWindowShowing(wnd->getOS2WindowHandle())) { 1348 // dprintf(("UpdateWindow: window not showing %d/%d", WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()) )); 1349 // return FALSE; 1350 // } 1351 //Must use frame window here. If the frame window has a valid update region and we call 1352 //WinUpdateWindow for the client window, then no WM_PAINT messages will be sent. 1353 rc = WinUpdateWindow(wnd->getOS2FrameWindowHandle()); 1354 #ifdef DEBUG 1355 if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), NULL)) 1356 { 1357 //if parent has valid update region then WinUpdateWindow will still fail.. 1358 //might be harmless and happen even in windows 1359 dprintf (("ERROR: User32: UpdateWindow didn't send WM_PAINT messages!!")); 1360 } 1361 #endif 1362 return rc; 1485 1363 } 1486 1364 //****************************************************************************** … … 1508 1386 BOOL result; 1509 1387 1510 if(pRect) {1388 if(pRect) { 1511 1389 dprintf(("InvalidateRect %x (%d,%d)(%d,%d) erase=%d", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, erase)); 1512 }1513 else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));1390 } 1391 else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase)); 1514 1392 #if 1 1515 result = RedrawWindow (hwnd, pRect, NULLHANDLE, 1516 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W | 1393 result = RedrawWindow (hwnd, pRect, NULLHANDLE, 1394 RDW_INVALIDATE_W | 1395 (erase ? RDW_ERASE_W : 0) | 1396 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1397 #else 1398 result = RedrawWindow (hwnd, pRect, NULLHANDLE, 1399 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W | 1400 (erase ? RDW_ERASE_W : RDW_NOERASE_W) | 1401 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1402 #endif 1403 return (result); 1404 } 1405 //****************************************************************************** 1406 //****************************************************************************** 1407 BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase) 1408 { 1409 BOOL result; 1410 1411 dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase)); 1412 #if 1 1413 result = RedrawWindow (hwnd, NULL, hrgn, 1414 RDW_INVALIDATE_W | 1517 1415 (erase ? RDW_ERASE_W : 0) | 1518 1416 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1519 1417 #else 1520 result = RedrawWindow (hwnd, pRect, NULLHANDLE,1418 result = RedrawWindow (hwnd, NULL, hrgn, 1521 1419 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W | 1522 1420 (erase ? RDW_ERASE_W : RDW_NOERASE_W) | 1523 1421 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1524 1422 #endif 1525 return (result); 1526 } 1527 //****************************************************************************** 1528 //****************************************************************************** 1529 BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase) 1530 { 1531 BOOL result; 1532 1533 dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase)); 1534 #if 1 1535 result = RedrawWindow (hwnd, NULL, hrgn, 1536 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W | 1537 (erase ? RDW_ERASE_W : 0) | 1538 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1539 #else 1540 result = RedrawWindow (hwnd, NULL, hrgn, 1541 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W | 1542 (erase ? RDW_ERASE_W : RDW_NOERASE_W) | 1543 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1544 #endif 1545 return (result); 1423 return (result); 1546 1424 } 1547 1425 //****************************************************************************** … … 1625 1503 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1626 1504 1627 if 1505 if((hwnd == NULLHANDLE) || !wnd) 1628 1506 { 1629 1507 return (FALSE); … … 1702 1580 RECTL rectlUpdate; 1703 1581 HRGN hrgn; 1704 RECTL clientRect;1705 1582 RECTL clipOS2; 1706 1583 RECTL scrollOS2; … … 1708 1585 PRECTL pClipOS2 = NULL; 1709 1586 1710 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&clientRect);1711 1712 1587 if(pScroll) { 1713 mapWin32ToOS2Rect ClientToFrame(wnd, &scrollRect, (PRECTLOS2)&scrollOS2);1588 mapWin32ToOS2Rect(wnd->getClientHeight(), &scrollRect, (PRECTLOS2)&scrollOS2); 1714 1589 pScrollOS2 = &scrollOS2; 1715 1716 //Scroll rectangle relative to client area1717 WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);1718 }1719 else {1720 pScrollOS2 = &clientRect;1721 1590 } 1722 1591 1723 1592 if(pClip) { 1724 mapWin32ToOS2RectClientToFrame(wnd, &clipRect, (PRECTLOS2)&clipOS2); 1725 pClipOS2 = &clipOS2; 1726 1727 //Clip rectangle relative to client area 1728 WinIntersectRect((HAB) 0, pClipOS2, pClipOS2, &clientRect); 1729 } 1730 else { 1731 pClipOS2 = &clientRect; 1593 mapWin32ToOS2Rect(wnd->getClientHeight(), &clipRect, (PRECTLOS2)&clipOS2); 1594 pClipOS2 = &clipOS2; 1732 1595 } 1733 1596 … … 1741 1604 RECT winRectUpdate; 1742 1605 1743 mapOS2ToWin32Rect(wnd->get WindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);1606 mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate); 1744 1607 1745 1608 if (pRectUpdate) … … 1747 1610 1748 1611 if (hrgnUpdate) 1749 rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->get WindowHeight());1612 rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->getClientHeight()); 1750 1613 1751 1614 return (rc); 1752 1615 } 1753 1616 //****************************************************************************** 1754 // SvL:Using WinScrollWindow to scroll child windows is better (smoother).1617 //Using WinScrollWindow to scroll child windows is better (smoother). 1755 1618 //****************************************************************************** 1756 1619 INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip, … … 1759 1622 Win32BaseWindow *window; 1760 1623 APIRET rc; 1761 RECTL clientRect;1762 1624 RECTL scrollRect; 1763 1625 RECTL clipRect; … … 1781 1643 if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlagsOS2 |= SW_SCROLLCHILDREN; 1782 1644 1783 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect);1784 1785 1645 if(pScroll) { 1786 mapWin32ToOS2Rect ClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);1646 mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pScroll, (PRECTLOS2)&scrollRect); 1787 1647 pScrollOS2 = &scrollRect; 1788 1789 //Scroll rectangle relative to client area1790 WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);1791 }1792 else {1793 pScrollOS2 = &clientRect;1794 1648 } 1795 1649 1796 1650 if(pClip) { 1797 mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect); 1798 pClipOS2 = &clipRect; 1799 1800 //Clip rectangle relative to client area 1801 WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect); 1802 } 1803 else { 1804 pClipOS2 = &clientRect; 1651 mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pClip, (PRECTLOS2)&clipRect); 1652 pClipOS2 = &clipRect; 1805 1653 } 1806 1654 … … 1816 1664 } 1817 1665 1818 LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy, 1819 pScrollOS2, 1820 pClipOS2, 1821 hrgn, &rectlUpdate, scrollFlagsOS2); 1666 LONG lComplexity = WinScrollWindow(window->getOS2WindowHandle(), dx, dy, 1667 pScrollOS2, pClipOS2, 1668 hrgn, &rectlUpdate, scrollFlagsOS2); 1822 1669 if (lComplexity == RGN_ERROR) 1823 1670 { … … 1850 1697 } 1851 1698 rectChild = *child->getWindowRect(); 1852 if(!p RectUpdate|| IntersectRect(&rectChild, &rectChild, &rc))1699 if(!pScroll || IntersectRect(&rectChild, &rectChild, &rc)) 1853 1700 { 1854 1701 dprintf(("ScrollWindowEx: Scroll child window %x", hwndChild)); … … 1862 1709 RECT winRectUpdate; 1863 1710 1864 mapOS2ToWin32Rect(window->get WindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);1711 mapOS2ToWin32Rect(window->getClientHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate); 1865 1712 1866 1713 if (pRectUpdate) … … 1868 1715 1869 1716 if (hrgnUpdate) 1870 rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, window->getWindowHeight());1717 rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, window->getClientHeight()); 1871 1718 1872 1719 #if 0 … … 1891 1738 switch (lComplexity) 1892 1739 { 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1740 case RGN_NULL: 1741 regionType = NULLREGION_W; 1742 break; 1743 case RGN_RECT: 1744 regionType = SIMPLEREGION_W; 1745 break; 1746 case RGN_COMPLEX: 1747 regionType = COMPLEXREGION_W; 1748 break; 1749 default: 1750 regionType = ERROR_W; 1751 break; 1905 1752 } 1906 1753 … … 1937 1784 //****************************************************************************** 1938 1785 //****************************************************************************** 1939 #ifdef DEBUG 1940 void dprintfOrigin(HDC hdc) 1941 { 1942 POINTL point; 1943 1944 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc); 1945 if(!pHps) 1946 { 1947 return; 1948 } 1949 1950 GreGetDCOrigin(pHps->hps, &point); 1951 dprintf(("HDC %x origin (%d,%d) org (%d,%d)", hdc, point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y)); 1952 } 1953 #endif 1954 //****************************************************************************** 1955 //****************************************************************************** 1786
Note:
See TracChangeset
for help on using the changeset viewer.