Changeset 3679 for trunk/src/user32/dc.cpp
- Timestamp:
- Jun 8, 2000, 8:10:12 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dc.cpp
r3662 r3679 1 /* $Id: dc.cpp,v 1. 59 2000-06-07 14:51:25sandervl Exp $ */1 /* $Id: dc.cpp,v 1.60 2000-06-08 18:10:09 sandervl Exp $ */ 2 2 3 3 /* … … 348 348 goto setupclipregion; 349 349 } 350 350 if(pHps->isClientArea) { 351 //TODO: counter 352 dprintf(("WARNING: selectClientArea; already selected!!")); 353 goto setupclipregion; 354 } 351 355 pHps->isClient = TRUE; 352 356 … … 411 415 setupclipregion: 412 416 if(prclPaint) { 417 #if 0 413 418 hrgnClip = GpiQueryClipRegion(pHps->hps); 414 419 if(hrgnClip) { … … 419 424 } 420 425 else { 426 #endif 421 427 hrgnClip = GreCreateRectRegion(pHps->hps, prclPaint, 1); 422 428 GreSelectClipRegion(pHps->hps, hrgnClip, &hrgnOldClip); 423 }429 // } 424 430 } 425 431 … … 610 616 dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!")); 611 617 612 mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);613 WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom);614 615 hrgnOldClip = selectClientArea(wnd, pHps, &rectl Client);618 // mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient); 619 // WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom); 620 621 hrgnOldClip = selectClientArea(wnd, pHps, &rectl); 616 622 //save old clip region (restored for CS_OWNDC windows in EndPaint) 617 623 wnd->SetClipRegion(hrgnOldClip); … … 619 625 } 620 626 else { 627 #if 0 621 628 HRGN hrgnTmp = GpiCreateRegion(pHps->hps, 1, &rectl); 622 629 … … 627 634 GpiQueryRegionRects(pHps->hps, hrgnTmp, &rcltemp, &rgnrect, &rectls[0]); 628 635 GpiDestroyRegion(pHps->hps, hrgnTmp); 629 636 #endif 630 637 WinValidateRect(hwndClient, &rectl, FALSE); 631 638 … … 696 703 if (pHps && (pHps->hdcType == TYPE_3)) 697 704 { 698 removeClientArea(pHps); 705 GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld); 706 wnd->SetClipRegion(0); 699 707 if(hrgnOld) { 700 GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);701 708 GpiDestroyRegion(pHps->hps, hrgnOld); 702 709 } 703 if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) { 704 pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails 705 ReleaseDC(hwnd, pPaint->hdc); 706 } 707 else 708 if(wnd->GetClipRegion()) { 709 //TODO: What else do we need to restore here??? 710 GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld); 711 wnd->SetClipRegion(0); 712 pHps->hdcType = TYPE_1; 713 } 710 pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails 711 ReleaseDC(hwnd, pPaint->hdc); 714 712 } 715 713 else { … … 723 721 SetLastError(0); 724 722 return TRUE; 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 else756 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 0765 lpRect->top = pHps->height - rectl.yTop;766 lpRect->bottom = pHps->height - rectl.yBottom;767 #else768 //No conversion required as GpiQueryClipBox is affected by769 //the y-inversion of the window770 lpRect->top = rectl.yBottom;771 lpRect->bottom = rectl.yTop;772 #endif773 //Convert including/including to including/excluding774 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)789 {790 int rc;791 792 rc = O32_GetClipRgn(hdc, hRgn);793 dprintf(("GDI32: GetClipRgn %x %x returned %x", hdc, hRgn, rc));794 return rc;795 }796 //******************************************************************************797 //******************************************************************************798 BOOL WIN32API GetUpdateRect (HWND hwnd, LPRECT pRect, BOOL erase)799 {800 if (!hwnd)801 {802 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));803 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);804 return FALSE;805 }806 807 RECTL rectl;808 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);809 810 if (!wnd)811 {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));818 819 BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);820 if (!pRect) {821 return (updateRegionExists);822 }823 824 if (updateRegionExists)825 {826 //CB: for PM empty rect is valid827 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) {828 if(pRect) {829 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;830 }831 return FALSE;832 }833 #if 0834 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)835 // if (wnd->isOwnDC() && wnd->getOwnDC())836 if (wnd->isOwnDC())837 {838 pDCData pHps = NULL;839 pHps = (pDCData)GpiQueryDCData(wnd->getOwnDC());840 if (!pHps)841 {842 SetLastError(ERROR_INVALID_HANDLE_W);843 return FALSE;844 }845 GpiConvert (pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rectl);846 }847 else848 {849 #endif850 long height = wnd->getClientHeight();851 rectl.yTop = height - rectl.yTop;852 rectl.yBottom = height - rectl.yBottom;853 ////////// }854 855 if (pRect)856 WINRECT_FROM_PMRECT (*pRect, rectl);857 858 if (erase)859 sendEraseBkgnd (wnd);860 }861 else862 {863 if(pRect) {864 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;865 }866 }867 868 return updateRegionExists;869 }870 //******************************************************************************871 //functions for WM_NCPAINT872 //******************************************************************************873 INT SYSTEM GetOS2UpdateRgn(HWND hwnd,HRGN hrgn)874 {875 return O32_GetUpdateRgn(hwnd,hrgn,FALSE);876 }877 //******************************************************************************878 //******************************************************************************879 BOOL GetOS2UpdateRect(Win32BaseWindow *window, LPRECT pRect)880 {881 RECTL rectl;882 BOOL updateRegionExists = WinQueryUpdateRect(window->getOS2WindowHandle(),pRect ? &rectl:NULL);883 884 if (!pRect)885 return (updateRegionExists);886 887 if (updateRegionExists)888 {889 //CB: for PM empty rect is valid890 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE;891 mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectl,pRect);892 }893 else894 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;895 896 return updateRegionExists;897 }898 //******************************************************************************899 //******************************************************************************900 int WIN32API GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase)901 {902 LONG Complexity;903 904 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);905 906 if (!wnd)907 {908 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);909 return ERROR_W;910 }911 912 Complexity = O32_GetUpdateRgn (wnd->getOS2WindowHandle(), hrgn, FALSE);913 if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd(wnd);914 915 return Complexity;916 723 } 917 724 //****************************************************************************** … … 929 736 return 0; 930 737 } 931 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)932 // isOwnDC = wnd->isOwnDC() && wnd->getOwnDC();933 738 isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc); 934 739 if(!isOwnDC) … … 1002 807 1003 808 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC())) 1004 && !(flags & DCX_CACHE_W));1005 1006 if(isWindowOwnDC) 809 && !(flags & (DCX_CACHE_W|DCX_WINDOW_W))); 810 811 if(isWindowOwnDC) //own dc always for client area 1007 812 { 1008 813 hps = wnd->getOwnDC(); 1009 814 if (hps) 1010 815 { 1011 1012 816 pDCData pHps = (pDCData)GpiQueryDCData (hps); 817 if (!pHps) 1013 818 goto error; 1014 819 1015 if(flags & DCX_WINDOW_W) 1016 removeClientArea(pHps); 1017 else 1018 selectClientArea(wnd, pHps, NULL); 1019 1020 setPageXForm (wnd, pHps); 1021 pHps->hdcType = TYPE_1; 1022 1023 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps)); 1024 return (HDC)hps; 820 selectClientArea(wnd, pHps, NULL); 821 822 //TODO: Is this always necessary?? 823 setPageXForm (wnd, pHps); 824 pHps->hdcType = TYPE_1; 825 826 //TODO: intersect/exclude clip region? 827 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps)); 828 return (HDC)hps; 1025 829 } 1026 830 else 1027 831 creatingOwnDC = TRUE; 1028 832 } 1029 833 … … 1086 890 else removeClientArea(pHps); 1087 891 1088 1089 892 setMapMode(wnd, pHps, MM_TEXT_W); 1090 893 … … 1200 1003 // RDW_ERASENOW 1201 1004 // RDW_UPDATENOW 1005 // RDW_FRAME 1006 // 1007 //TODO: Work ok for RDW_FRAME?? 1202 1008 //****************************************************************************** 1203 1009 BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw) … … 1260 1066 PRECTL pr; 1261 1067 int i; 1262 LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight(); 1068 LONG height; 1069 1070 if(wnd) { 1071 height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight(); 1072 } 1073 else height = OSLibQueryScreenHeight(); 1263 1074 1264 1075 if (!hrgn) … … 1284 1095 else if (pRect) 1285 1096 { 1286 LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight(); 1287 1288 PMRECT_FROM_WINRECT (rectl, *pRect); 1289 rectl.yTop = height - rectl.yTop; 1290 rectl.yBottom = height - rectl.yBottom; 1097 if(wnd) { 1098 if(redraw & RDW_FRAME_W) { 1099 mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1100 } 1101 else mapWin32ToOS2RectClientToFrame(wnd, (PRECT)pRect, (PRECTLOS2)&rectl); 1102 } 1103 else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl); 1291 1104 } 1292 1105 … … 1330 1143 //TODO: Does this work if RDW_ALLCHILDREN is set?? 1331 1144 if(redraw & RDW_UPDATENOW_W) { 1332 wnd->MsgPaint (0, FALSE); 1145 wnd->MsgNCPaint(); 1146 wnd->MsgPaint(0, FALSE); 1333 1147 } 1334 1148 else … … 1339 1153 else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W)) 1340 1154 { 1341 if(redraw & RDW_UPDATENOW_W) 1155 if(redraw & RDW_UPDATENOW_W) { 1156 wnd->MsgNCPaint(); 1342 1157 wnd->MsgPaint (0, FALSE); 1158 } 1343 1159 else PostMessageA(hwnd, WINWM_PAINT, 0, 0); 1344 1160 } … … 1466 1282 //****************************************************************************** 1467 1283 //TODO: Check if this one works correctly... 1284 //Have to check if dc is for frame or client!! 1468 1285 //****************************************************************************** 1469 1286 BOOL WIN32API ScrollDC(HDC hDC, int dx, int dy, const RECT *pScroll, … … 1791 1608 //****************************************************************************** 1792 1609 //****************************************************************************** 1793 INT WIN32API ExcludeUpdateRgn( HDC hDC, HWND hWnd)1794 {1795 dprintf(("USER32: ExcludeUpdateRgn\n"));1796 hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);1797 1798 return O32_ExcludeUpdateRgn(hDC,hWnd);1799 }1800 //******************************************************************************1801 //******************************************************************************1802 1610 BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc) 1803 1611 { … … 1816 1624 return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0)); 1817 1625 } 1818 /***************************************************************************** 1819 * Name : int WIN32API GetWindowRgn 1820 * Purpose : The GetWindowRgn function obtains a copy of the window region of a window. 1821 * Parameters: HWND hWnd handle to window whose window region is to be obtained 1822 * HRGN hRgn handle to region that receives a copy of the window region 1823 * Variables : 1824 * Result : NULLREGION, SIMPLEREGION, COMPLEXREGION, ERROR 1825 * Remark : 1826 * Status : UNTESTED STUB 1827 * 1828 * Author : Patrick Haller [Thu, 1998/02/26 11:55] 1829 *****************************************************************************/ 1830 1831 int WIN32API GetWindowRgn(HWND hwnd, HRGN hRgn) 1832 { 1833 Win32BaseWindow *window; 1834 HRGN hWindowRegion; 1835 1836 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 1837 if(!window) { 1838 dprintf(("SetWindowContextHelpId, window %x not found", hwnd)); 1839 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 1840 return 0; 1841 } 1842 dprintf(("USER32:GetWindowRgn (%x,%x)", hwnd, hRgn)); 1843 hWindowRegion = window->GetWindowRegion(); 1844 1845 return O32_CombineRgn(hRgn, hWindowRegion, 0, RGN_COPY_W); 1846 } 1847 /***************************************************************************** 1848 * Name : int WIN32API SetWindowRgn 1849 * Purpose : The SetWindowRgn function sets the window region of a window. The 1850 * window region determines the area within the window where the 1851 * operating system permits drawing. The operating system does not 1852 * display any portion of a window that lies outside of the window region 1853 * When this function is called, the system sends the WM_WINDOWPOSCHANGING and 1854 * WM_WINDOWPOSCHANGED messages to the window. 1855 * 1856 * Parameters: HWND hWnd handle to window whose window region is to be set 1857 * HRGN hRgn handle to region 1858 * BOOL bRedraw window redraw flag 1859 * Variables : 1860 * Result : If the function succeeds, the return value is non-zero. 1861 * If the function fails, the return value is zero. 1862 * Remark : 1863 * Status : UNTESTED STUB 1864 * 1865 * Author : Patrick Haller [Thu, 1998/02/26 11:55] 1866 *****************************************************************************/ 1867 1868 int WIN32API SetWindowRgn(HWND hwnd, 1869 HRGN hRgn, 1870 BOOL bRedraw) 1871 { 1872 Win32BaseWindow *window; 1873 HRGN hWindowRegion; 1874 1875 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 1876 if(!window) { 1877 dprintf(("SetWindowContextHelpId, window %x not found", hwnd)); 1878 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 1879 return 0; 1880 } 1881 dprintf(("USER32:SetWindowRgn (%x,%x,%d)", hwnd, hRgn, bRedraw)); 1882 if(window->GetWindowRegion()) { 1883 O32_DeleteObject(window->GetWindowRegion()); 1884 } 1885 window->SetWindowRegion(hRgn); 1886 if(bRedraw) { 1887 RedrawWindow(hwnd, 0, 0, RDW_UPDATENOW_W); 1888 } 1889 //TODO: 1890 // When this function is called, the system sends the WM_WINDOWPOSCHANGING and 1891 // WM_WINDOWPOSCHANGED messages to the window. 1892 return 1; 1893 } 1894 //****************************************************************************** 1895 //****************************************************************************** 1626 //****************************************************************************** 1627 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.