- Timestamp:
- Feb 17, 2001, 8:25:08 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dc.cpp
r5146 r5152 1 /* $Id: dc.cpp,v 1.8 4 2001-02-17 14:49:25sandervl Exp $ */1 /* $Id: dc.cpp,v 1.85 2001-02-17 19:25:08 sandervl Exp $ */ 2 2 3 3 /* … … 86 86 rc = GpiQueryRegionRects(hps, hrgnClip, NULL, &rgnRect, &rectRegion[0]); 87 87 for(int i=0;i<rgnRect.crcReturned;i++) { 88 88 dprintf(("(%d,%d)(%d,%d)", rectRegion[i].xLeft, rectRegion[i].yBottom, rectRegion[i].xRight, rectRegion[i].yTop)); 89 89 } 90 90 } … … 354 354 if(pHps->isClientArea) 355 355 { 356 357 358 356 dprintf2(("removeClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y)); 357 pHps->isClientArea = FALSE; 358 GreSetupDC(pHps->hps, 359 359 pHps->hrgnVis, 360 360 pHps->ptlOrigin.x, … … 380 380 381 381 if(pClient->left == 0 && pClient->top == 0 && 382 window->getClientHeight() == window->getWindowHeight() && 382 window->getClientHeight() == window->getWindowHeight() && 383 383 window->getClientWidth() == window->getWindowWidth()) 384 384 { 385 386 385 //client rectangle = frame rectangle -> no change necessary 386 return; 387 387 } 388 388 pHps->isClient = TRUE; … … 395 395 GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp); 396 396 397 if(pHps->isClientArea) 398 { 399 400 401 397 if(pHps->isClientArea) 398 { 399 //TODO: counter 400 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)); 401 RECT rectWindow; 402 402 RECTL rectWindowOS2; 403 404 405 406 rectWindowOS2.yBottom + rcl.yBottom != rcltemp.yBottom) 403 GetWindowRect(window->getWindowHandle(), &rectWindow); 404 mapWin32ToOS2Rect(OSLibGetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2); 405 if(rectWindowOS2.xLeft + rcl.xLeft != rcltemp.xLeft || 406 rectWindowOS2.yBottom + rcl.yBottom != rcltemp.yBottom) 407 407 { 408 409 410 411 412 413 } 414 elsereturn;408 dprintf2(("WARNING: origin changed (%d,%d) instead of (%d,%d)!", rcltemp.xLeft, rcltemp.yBottom, rectWindowOS2.xLeft + rcl.xLeft, rectWindowOS2.yBottom + rcl.yBottom)); 409 rcl.xLeft += rectWindowOS2.xLeft; 410 rcl.xRight += rectWindowOS2.xLeft; 411 rcl.yTop += rectWindowOS2.yBottom; 412 rcl.yBottom += rectWindowOS2.yBottom; 413 } 414 else return; 415 415 } 416 416 else { … … 423 423 pHps->ptlOrigin.y = rcltemp.yBottom; 424 424 } 425 425 426 426 dprintf2(("selectClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom)); 427 427 428 428 if(pHps->hrgnVis == 0) 429 429 pHps->hrgnVis = GreCreateRectRegion(pHps->hps, &rcl, 1); 430 430 431 431 hrgnRect = GreCreateRectRegion(pHps->hps, &rcl, 1); … … 440 440 dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnRect); 441 441 #endif 442 442 443 443 // Set the new origin plus visible region in the DC 444 444 GreSetupDC(pHps->hps, … … 463 463 if ((hwnd != 0) || (pHps == 0)) 464 464 { 465 466 467 468 469 elsereturn (wnd->getClientHeight());470 471 elsereturn OSLibQueryScreenHeight();465 if(wnd) { 466 if(pHps && !pHps->isClientArea) { 467 return (wnd->getWindowHeight()); 468 } 469 else return (wnd->getClientHeight()); 470 } 471 else return OSLibQueryScreenHeight(); 472 472 } 473 473 else if (pHps->bitmapHandle) … … 631 631 { 632 632 pDCData pHps = (pDCData)GpiQueryDCData ((HPS)hps); 633 633 634 634 dprintf2(("releaseOwnDC %x", hps)); 635 635 … … 695 695 696 696 if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) { 697 697 memset(&rectl, 0, sizeof(rectl)); 698 698 dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!")); 699 699 700 701 702 703 700 HRGN hrgnClip = GpiCreateRegion(pHps->hps, 1, &rectl); 701 GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip); 702 703 selectClientArea(wnd, pHps); 704 704 705 705 //save old clip region (restored for CS_OWNDC windows in EndPaint) 706 706 wnd->SetClipRegion(hrgnOldClip); 707 707 lComplexity = RGN_NULL; 708 708 } 709 709 else { 710 711 712 713 714 715 710 rectlClip.yBottom = rectlClip.xLeft = 0; 711 rectlClip.yTop = rectlClip.xRight = 1; 712 713 //Query update region 714 HRGN hrgnClip = GpiCreateRegion(pHps->hps, 1, &rectlClip); 715 WinQueryUpdateRegion(hwndClient, hrgnClip); 716 716 WinValidateRegion(hwndClient, hrgnClip, FALSE); 717 717 718 719 720 721 722 723 724 725 726 727 728 729 718 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient); 719 WinIntersectRect(NULL, &rectlClip, &rectl, &rectlClient); 720 WinOffsetRect(NULL, &rectlClip, -rectlClient.xLeft, -rectlClient.yBottom); 721 722 //clip update region with client window rectangle 723 HRGN hrgnClient = GpiCreateRegion(pHps->hps, 1, &rectlClient); 724 GpiCombineRegion(pHps->hps, hrgnClip, hrgnClip, hrgnClient, CRGN_AND); 725 GpiDestroyRegion(pHps->hps, hrgnClient); 726 727 //change origin of clip region (window -> client) 728 POINTL point = {-rectlClient.xLeft, -rectlClient.yBottom}; 729 GpiOffsetRegion(pHps->hps, hrgnClip, &point); 730 730 #ifdef DEBUG 731 731 dprintfRegion1(pHps->hps, hWnd, hrgnClip); 732 732 #endif 733 734 735 736 733 //set clip region 734 lComplexity = GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip); 735 736 //change presentation space for client window 737 737 //NOTE: MUST do this after GpiSetClipRegion call! 738 738 // When a window with CS_OWNDC looses focus, for some reason 739 739 // GpiSetClipRegion resets the window dc origin back to (0,0) 740 740 selectClientArea(wnd, pHps); 741 741 742 742 GpiQueryClipBox(pHps->hps, &rectl); … … 745 745 //save old clip region (restored for CS_OWNDC windows in EndPaint) 746 746 wnd->SetClipRegion(hrgnOldClip); 747 748 747 memcpy(&rectl, &rectlClip, sizeof(RECTL)); 748 lComplexity = RGN_RECT; 749 749 } 750 750 … … 809 809 if (pHps && (pHps->hdcType == TYPE_3)) 810 810 { 811 811 GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld); 812 812 wnd->SetClipRegion(0); 813 813 if(hrgnOld) { 814 814 GpiDestroyRegion(pHps->hps, hrgnOld); 815 815 } 816 816 pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails 817 817 ReleaseDC(hwnd, pPaint->hdc); 818 818 } … … 843 843 } 844 844 isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc); 845 846 847 848 849 850 851 852 853 854 } 855 856 857 858 859 860 861 862 845 if(!isOwnDC) 846 { 847 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc); 848 if(pHps && pHps->psType == MICRO_CACHED) { 849 removeClientArea(wnd, pHps); 850 if(pHps->hrgnVis) { 851 GreDestroyRegion(pHps->hps, pHps->hrgnVis); 852 pHps->hrgnVis = 0; 853 } 854 } 855 else { 856 dprintf(("ERROR: ReleaseDC: pHps == NULL!!")); 857 DebugInt3(); 858 } 859 } 860 else { 861 dprintf2(("ReleaseDC: CS_OWNDC, not released")); 862 } 863 863 } 864 864 865 865 if(isOwnDC) { 866 866 rc = TRUE; 867 867 } 868 868 else { 869 869 rc = O32_ReleaseDC (0, hdc); 870 870 } 871 871 … … 929 929 selectClientArea(wnd, pHps); 930 930 931 931 //TODO: Is this always necessary?? 932 932 setPageXForm (wnd, pHps); 933 933 pHps->hdcType = TYPE_1; 934 934 935 935 //TODO: intersect/exclude clip region? 936 936 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps)); 937 937 return (HDC)hps; … … 957 957 } 958 958 else { 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 959 int clipstyle = 0; 960 int clipwnd = HWND_TOP; 961 if(flags & (DCX_USESTYLE_W)) { 962 int style = wnd->getStyle(); 963 if(style & WS_CLIPCHILDREN_W) { 964 clipstyle |= PSF_CLIPCHILDREN; 965 } 966 if(style & WS_CLIPSIBLINGS_W) { 967 clipstyle |= PSF_CLIPSIBLINGS; 968 } 969 if(wnd->fHasParentDC()) { 970 clipstyle |= PSF_PARENTCLIP; 971 } 972 } 973 if(flags & DCX_CLIPSIBLINGS_W) { 974 clipstyle |= PSF_CLIPSIBLINGS; 975 } 976 if(flags & DCX_CLIPCHILDREN_W) { 977 clipstyle |= PSF_CLIPCHILDREN; 978 } 979 if(flags & DCX_PARENTCLIP_W) { 980 clipstyle |= PSF_PARENTCLIP; 981 } 982 982 if(clipstyle) { 983 984 985 986 elsehps = WinGetPS (hWindow);983 dprintf2(("WinGetClipPS style %x", clipstyle)); 984 hps = WinGetClipPS(hWindow, clipwnd, clipstyle); 985 } 986 else hps = WinGetPS (hWindow); 987 987 988 988 // default cp is OS/2 one: set to windows default (ODIN.INI) … … 1000 1000 if(!(flags & DCX_WINDOW_W)) 1001 1001 { 1002 1002 selectClientArea(wnd, pHps); 1003 1003 } 1004 1004 else removeClientArea(wnd, pHps); … … 1168 1168 return FALSE; 1169 1169 } 1170 1170 hwnd = wnd->getOS2WindowHandle(); 1171 1171 } 1172 1172 … … 1186 1186 1187 1187 if(wnd) { 1188 1189 } 1190 else 1188 height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight(); 1189 } 1190 else height = OSLibQueryScreenHeight(); 1191 1191 1192 1192 if (!hrgn) … … 1213 1213 { 1214 1214 if(wnd) { 1215 1216 1217 1218 elsemapWin32ToOS2RectClientToFrame(wnd, (PRECT)pRect, (PRECTLOS2)&rectl);1219 } 1220 else 1215 if(redraw & RDW_FRAME_W) { 1216 mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1217 } 1218 else mapWin32ToOS2RectClientToFrame(wnd, (PRECT)pRect, (PRECTLOS2)&rectl); 1219 } 1220 else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1221 1221 } 1222 1222 … … 1227 1227 wnd->setEraseBkgnd(TRUE); 1228 1228 } 1229 1229 else 1230 1230 if (redraw & RDW_NOERASE_W) 1231 1231 wnd->setEraseBkgnd(FALSE); … … 1237 1237 success = WinInvalidateRegion (hwnd, hrgnTemp, IncludeChildren); 1238 1238 if(IncludeChildren && WinQueryUpdateRect(hwnd, NULL) == FALSE) { 1239 1239 dprintf(("WARNING: WinQueryUpdateRect %x region %x returned false even though we just invalidated part of a window!!!", hwnd, hrgnTemp)); 1240 1240 success = success = WinInvalidateRegion (hwnd, hrgnTemp, FALSE); 1241 1241 } … … 1246 1246 //SvL: If all children are included, then WinInvalidateRect is called 1247 1247 // with fIncludeChildren=1 -> rect of hwnd isn't invalidated if child(ren) 1248 // overlap(s) the specified rectangle completely (EVEN if window doesn't 1248 // overlap(s) the specified rectangle completely (EVEN if window doesn't 1249 1249 // have WS_CLIPCHILREN!) 1250 1250 // -> example: XWing vs Tie Fighter install window … … 1259 1259 // 1260 1260 if(IncludeChildren && WinQueryUpdateRect(hwnd, NULL) == FALSE) { 1261 1261 dprintf(("WARNING: WinQueryUpdateRect %x (%d,%d)(%d,%d) returned false even though we just invalidated part of a window!!!", hwnd, rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop)); 1262 1262 success = WinInvalidateRect (hwnd, &rectl, FALSE); 1263 1263 } … … 1291 1291 //TODO: Does this work if RDW_ALLCHILDREN is set?? 1292 1292 if(redraw & RDW_UPDATENOW_W) { 1293 1293 wnd->MsgNCPaint(); 1294 1294 wnd->MsgPaint(0, FALSE); 1295 1295 } … … 1298 1298 if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd()) 1299 1299 wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0); 1300 // 1301 // 1302 // 1300 // if(redraw & RDW_ALLCHILDREN_W) { 1301 // EnumChildWindows(wnd->getWindowHandle(), RedrawChildEnumProc, redraw); 1302 // } 1303 1303 } 1304 1304 else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W)) 1305 1305 { 1306 1306 if(redraw & RDW_UPDATENOW_W) { 1307 1307 wnd->MsgNCPaint(); 1308 1308 wnd->MsgPaint (0, FALSE); 1309 1309 } 1310 1310 else PostMessageA(hwnd, WINWM_PAINT, 0, 0); 1311 1311 } … … 1320 1320 1321 1321 if (!success) { 1322 1323 1322 dprintf(("RedrawWindow failure!")); 1323 SetLastError(ERROR_INVALID_PARAMETER_W); 1324 1324 } 1325 1325 return (success); … … 1371 1371 1372 1372 if(pRect) { 1373 1373 dprintf(("InvalidateRect %x (%d,%d)(%d,%d) erase=%d", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, erase)); 1374 1374 } 1375 1375 else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase)); … … 1580 1580 } 1581 1581 else { 1582 1582 pScrollOS2 = &clientRect; 1583 1583 } 1584 1584 … … 1591 1591 } 1592 1592 else { 1593 1594 } 1595 1596 LONG lComplexity = WinScrollWindow(hwnd, dx, dy, pScrollOS2, 1593 pClipOS2 = &clientRect; 1594 } 1595 1596 LONG lComplexity = WinScrollWindow(hwnd, dx, dy, pScrollOS2, 1597 1597 pClipOS2, hrgn, &rectlUpdate, 0); 1598 1598 if (lComplexity == RGN_ERROR) … … 1615 1615 //****************************************************************************** 1616 1616 //****************************************************************************** 1617 BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip) 1617 INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip, 1618 HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag) 1618 1619 { 1619 1620 Win32BaseWindow *window; … … 1624 1625 PRECTL pScrollOS2 = NULL; 1625 1626 PRECTL pClipOS2 = NULL; 1626 ULONG scrollFlags = SW_INVALIDATERGN; 1627 1628 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 1629 if(!window) { 1630 dprintf(("ScrollWindow, window %x not found", hwnd)); 1631 return 0; 1632 } 1633 dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip)); 1634 1635 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect); 1636 1637 if(pScroll) { 1638 mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect); 1639 pScrollOS2 = &scrollRect; 1640 1641 //Scroll rectangle relative to client area 1642 WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect); 1643 } 1644 else { 1645 pScrollOS2 = &clientRect; 1646 scrollFlags |= SW_SCROLLCHILDREN; 1647 } 1648 1649 if(pClip) { 1650 mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect); 1651 pClipOS2 = &clipRect; 1652 1653 //Clip rectangle relative to client area 1654 WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect); 1655 } 1656 else { 1657 pClipOS2 = &clientRect; 1658 } 1659 1660 dy = revertDy (window, dy); 1661 1662 rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy, 1663 pScrollOS2, pClipOS2, NULLHANDLE, 1664 NULL, scrollFlags); 1665 1666 return (rc != RGN_ERROR); 1667 } 1668 //****************************************************************************** 1669 //****************************************************************************** 1670 INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip, 1671 HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag) 1672 { 1673 Win32BaseWindow *window; 1674 APIRET rc; 1675 RECTL clientRect; 1676 RECTL scrollRect; 1677 RECTL clipRect; 1678 PRECTL pScrollOS2 = NULL; 1679 PRECTL pClipOS2 = NULL; 1680 ULONG scrollFlags = 0; 1627 ULONG scrollFlagsOS2 = 0; 1628 int orgdy = dy; 1681 1629 int regionType = ERROR_W; 1682 1630 … … 1691 1639 dy = revertDy (window, dy); 1692 1640 1693 if (scrollFlag & SW_INVALIDATE_W) scrollFlags |= SW_INVALIDATERGN; 1694 if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlags |= SW_SCROLLCHILDREN; 1641 if (scrollFlag & SW_INVALIDATE_W) scrollFlagsOS2 |= SW_INVALIDATERGN; 1695 1642 1696 1643 mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect); … … 1704 1651 } 1705 1652 else { 1706 pScrollOS2 = &clientRect; 1707 scrollFlags |= SW_SCROLLCHILDREN; //TODO: ????? 1653 pScrollOS2 = &clientRect; 1708 1654 } 1709 1655 … … 1716 1662 } 1717 1663 else { 1718 1664 pClipOS2 = &clientRect; 1719 1665 } 1720 1666 … … 1730 1676 } 1731 1677 1678 // Scroll children first 1679 if (scrollFlag & SW_SCROLLCHILDREN_W) 1680 { 1681 HWND hwndChild; 1682 RECT rectChild, rc; 1683 1684 dprintf(("ScrollWindowEx: Scroll child windows")); 1685 GetClientRect(hwnd, &rc); 1686 if (pScroll) IntersectRect(&rc, &rc, pScroll); 1687 1688 hwndChild = GetWindow(hwnd, GW_CHILD_W); 1689 1690 while(hwndChild) 1691 { 1692 Win32BaseWindow *child; 1693 1694 child = Win32BaseWindow::GetWindowFromHandle(hwndChild); 1695 if(!child) { 1696 dprintf(("ScrollWindowEx, child %x not found", hwnd)); 1697 return 0; 1698 } 1699 rectChild = *child->getWindowRect(); 1700 if(pRectUpdate || IntersectRect(&rectChild, &rectChild, &rc)) 1701 { 1702 dprintf(("ScrollWindowEx: Scroll child window %x", hwndChild)); 1703 SetWindowPos(hwndChild, 0, rectChild.left + dx, 1704 rectChild.top + orgdy, 0, 0, SWP_NOZORDER_W | 1705 SWP_NOSIZE_W | SWP_NOACTIVATE_W | SWP_NOREDRAW); 1706 } 1707 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT_W); 1708 } 1709 dprintf(("***ScrollWindowEx: Scroll child windows DONE")); 1710 } 1711 1732 1712 LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy, 1733 1713 pScrollOS2, 1734 1714 pClipOS2, 1735 hrgn, &rectlUpdate, scrollFlags );1715 hrgn, &rectlUpdate, scrollFlagsOS2); 1736 1716 if (lComplexity == RGN_ERROR) 1737 1717 { … … 1783 1763 //****************************************************************************** 1784 1764 //****************************************************************************** 1765 BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip) 1766 { 1767 Win32BaseWindow *window; 1768 1769 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 1770 if(!window) { 1771 dprintf(("ScrollWindow, window %x not found", hwnd)); 1772 return 0; 1773 } 1774 dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip)); 1775 return (ERROR_W != ScrollWindowEx(hwnd, dx, dy, pScroll, pClip, 0, NULL, 1776 (pScroll ? 0 : SW_SCROLLCHILDREN_W) | 1777 SW_INVALIDATE_W )); 1778 } 1779 //****************************************************************************** 1780 //****************************************************************************** 1785 1781 HWND WIN32API WindowFromDC(HDC hdc) 1786 1782 {
Note:
See TracChangeset
for help on using the changeset viewer.