Ignore:
Timestamp:
Jun 8, 2000, 8:10:12 PM (25 years ago)
Author:
sandervl
Message:

lots of fixes + changes (see ChangeLog)

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:25 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.60 2000-06-08 18:10:09 sandervl Exp $ */
    22
    33/*
     
    348348        goto setupclipregion;
    349349   }
    350 
     350   if(pHps->isClientArea) {
     351        //TODO: counter
     352        dprintf(("WARNING: selectClientArea; already selected!!"));
     353        goto setupclipregion;
     354   }
    351355   pHps->isClient = TRUE;
    352356
     
    411415setupclipregion:
    412416   if(prclPaint) {
     417#if 0
    413418        hrgnClip = GpiQueryClipRegion(pHps->hps);
    414419        if(hrgnClip) {
     
    419424        }
    420425        else {
     426#endif
    421427                hrgnClip = GreCreateRectRegion(pHps->hps, prclPaint, 1);
    422428                GreSelectClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
    423         }
     429//      }
    424430   }
    425431
     
    610616        dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!"));
    611617
    612         mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
    613         WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom);
    614 
    615         hrgnOldClip = selectClientArea(wnd, pHps, &rectlClient);
     618//      mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
     619//      WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom);
     620
     621        hrgnOldClip = selectClientArea(wnd, pHps, &rectl);
    616622        //save old clip region (restored for CS_OWNDC windows in EndPaint)
    617623        wnd->SetClipRegion(hrgnOldClip);
     
    619625   }
    620626   else {
     627#if 0
    621628        HRGN hrgnTmp = GpiCreateRegion(pHps->hps, 1, &rectl);
    622629
     
    627634        GpiQueryRegionRects(pHps->hps, hrgnTmp, &rcltemp, &rgnrect, &rectls[0]);
    628635        GpiDestroyRegion(pHps->hps, hrgnTmp);
    629 
     636#endif
    630637        WinValidateRect(hwndClient, &rectl, FALSE);
    631638
     
    696703   if (pHps && (pHps->hdcType == TYPE_3))
    697704   {
    698         removeClientArea(pHps);
     705        GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld);
     706        wnd->SetClipRegion(0);
    699707        if(hrgnOld) {
    700                 GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);
    701708                GpiDestroyRegion(pHps->hps, hrgnOld);
    702709        }
    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);
    714712   }
    715713   else {
     
    723721   SetLastError(0);
    724722   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         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;
    772 #endif
    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)
    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 valid
    827         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 0
    834         //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         else
    848         {
    849 #endif
    850                 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    else
    862    {
    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_NCPAINT
    872 //******************************************************************************
    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 valid
    890      if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE;
    891      mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectl,pRect);
    892    }
    893    else
    894        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;
    916723}
    917724//******************************************************************************
     
    929736                return 0;
    930737        }
    931         //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
    932 //      isOwnDC = wnd->isOwnDC() && wnd->getOwnDC();
    933738        isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
    934739        if(!isOwnDC)
     
    1002807
    1003808   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
    1007812   {
    1008813      hps = wnd->getOwnDC();
    1009814      if (hps)
    1010815      {
    1011          pDCData pHps = (pDCData)GpiQueryDCData (hps);
    1012          if (!pHps)
     816        pDCData pHps = (pDCData)GpiQueryDCData (hps);
     817        if (!pHps)
    1013818            goto error;
    1014819
    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;
    1025829      }
    1026830      else
    1027          creatingOwnDC = TRUE;
     831        creatingOwnDC = TRUE;
    1028832   }
    1029833
     
    1086890   else removeClientArea(pHps);
    1087891
    1088 
    1089892   setMapMode(wnd, pHps, MM_TEXT_W);
    1090893
     
    12001003// RDW_ERASENOW
    12011004// RDW_UPDATENOW
     1005// RDW_FRAME
     1006//
     1007//TODO: Work ok for RDW_FRAME??
    12021008//******************************************************************************
    12031009BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
     
    12601066      PRECTL pr;
    12611067      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();
    12631074
    12641075      if (!hrgn)
     
    12841095   else if (pRect)
    12851096   {
    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);
    12911104   }
    12921105
     
    13301143        //TODO: Does this work if RDW_ALLCHILDREN is set??
    13311144        if(redraw & RDW_UPDATENOW_W) {
    1332                 wnd->MsgPaint (0, FALSE);
     1145                wnd->MsgNCPaint();
     1146                wnd->MsgPaint(0, FALSE);
    13331147        }
    13341148        else
     
    13391153   else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
    13401154   {
    1341         if(redraw & RDW_UPDATENOW_W)
     1155        if(redraw & RDW_UPDATENOW_W) {
     1156                wnd->MsgNCPaint();
    13421157                wnd->MsgPaint (0, FALSE);
     1158        }
    13431159        else    PostMessageA(hwnd, WINWM_PAINT, 0, 0);
    13441160   }
     
    14661282//******************************************************************************
    14671283//TODO: Check if this one works correctly...
     1284//Have to check if dc is for frame or client!!
    14681285//******************************************************************************
    14691286BOOL WIN32API ScrollDC(HDC hDC, int dx, int dy, const RECT *pScroll,
     
    17911608//******************************************************************************
    17921609//******************************************************************************
    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 //******************************************************************************
    18021610BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
    18031611{
     
    18161624    return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
    18171625}
    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.