Ignore:
Timestamp:
Sep 28, 1999, 8:14:57 PM (26 years ago)
Author:
dengert
Message:

ScrollWindowEx implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/dc.cpp

    r1078 r1087  
    1 /* $Id: dc.cpp,v 1.10 1999-09-28 12:44:32 dengert Exp $ */
     1/* $Id: dc.cpp,v 1.11 1999-09-28 18:14:57 dengert Exp $ */
    22
    33/*
     
    155155#define RGN_OR_W              2
    156156
     157/* Window scrolling */
     158#define SW_SCROLLCHILDREN_W    0x0001
     159#define SW_INVALIDATE_W        0x0002
     160#define SW_ERASE_W             0x0004
     161
    157162/*********************/
    158163
     
    12141219}
    12151220
     1221BOOL setPMRgnIntoWinRgn (HRGN hrgnPM, HRGN hrgnWin, LONG height)
     1222{
     1223   BOOL    rc;
     1224   HPS     hps = WinGetScreenPS (HWND_DESKTOP);
     1225   RGNRECT rgnRect;
     1226   rgnRect.ircStart    = 1;
     1227   rgnRect.crc         = 0;
     1228   rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;     // doesn't make a difference because we're getting them all
     1229
     1230   rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, NULL);
     1231
     1232   if (rc && (rgnRect.crcReturned > 0))
     1233   {
     1234      PRECTL Rcls = new RECTL[rgnRect.crcReturned];
     1235      PRECTL pRcl = Rcls;
     1236
     1237      if (Rcls != NULL)
     1238      {
     1239         rgnRect.crc = rgnRect.crcReturned;
     1240         rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls);
     1241
     1242         rc = _O32_SetRectRgn (hrgnWin, pRcl->xLeft,
     1243                                        pRcl->xRight,
     1244                                        height - pRcl->yTop,
     1245                                        height - pRcl->yBottom);
     1246
     1247         if (rgnRect.crcReturned > 1)
     1248         {
     1249            int i;
     1250            HRGN temp;
     1251            temp = _O32_CreateRectRgn (0, 0, 1, 1);
     1252
     1253            for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++)
     1254            {
     1255              rc = _O32_SetRectRgn (temp, pRcl->xLeft,
     1256                                          pRcl->xRight,
     1257                                          height - pRcl->yTop,
     1258                                          height - pRcl->yBottom);
     1259              rc &= _O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
     1260            }
     1261            _O32_DeleteObject (temp);
     1262         }
     1263         delete[] Rcls;
     1264      }
     1265      else
     1266      {
     1267         rc = FALSE;
     1268      }
     1269   }
     1270   else
     1271   {
     1272      rc = _O32_SetRectRgn (hrgnWin, 0, 0, 0, 0);
     1273   }
     1274
     1275   WinReleasePS (hps);
     1276   return (rc);
     1277}
     1278
    12161279BOOL WIN32API ScrollDC (HDC hDC, int dx, int dy, const RECT *pScroll,
    12171280                        const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate)
     
    13361399
    13371400   if (hrgnUpdate)
    1338    {
    1339       RGNRECT  rgnRect;
    1340       rgnRect.ircStart    = 1;
    1341       rgnRect.crc         = 0;
    1342       rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;     // doesn't make a difference because we're getting them all
    1343       rc = GpiQueryRegionRects (pHps->hps, hrgn, NULL, &rgnRect, NULL);
    1344 
    1345       if (rc && (rgnRect.crcReturned > 0))
    1346       {
    1347          PRECTL pRectl = new RECTL[rgnRect.crcReturned];
    1348          if (pRectl != NULL)
    1349          {
    1350             rgnRect.crc = rgnRect.crcReturned;
    1351             rc = GpiQueryRegionRects (pHps->hps, hrgn, NULL, &rgnRect, pRectl);
    1352 
    1353             rc = _O32_SetRectRgn (hrgnUpdate, pRectl[0].xLeft,
    1354                                               pRectl[0].xRight,
    1355                                               height - pRectl[0].yTop,
    1356                                               height - pRectl[0].yBottom);
    1357 
    1358             if (rgnRect.crcReturned > 1)
    1359             {
    1360                HRGN temp;
    1361                temp = _O32_CreateRectRgn (0, 0, 1, 1);
    1362 
    1363                for (int x = 1; rc && (x < rgnRect.crcReturned); x++)
    1364                {
    1365                  rc = _O32_SetRectRgn (temp, pRectl[x].xLeft,
    1366                                              pRectl[x].xRight,
    1367                                              height - pRectl[x].yTop,
    1368                                              height - pRectl[x].yBottom);
    1369                  rc = _O32_CombineRgn (hrgnUpdate, hrgnUpdate, temp, RGN_OR_W);
    1370                }
    1371                _O32_DeleteObject (temp);
    1372             }
    1373             delete[] pRectl;
    1374          }
    1375          else
    1376          {
    1377             rc = FALSE;
    1378          }
    1379       }
    1380       else
    1381       {
    1382          rc = _O32_SetRectRgn (hrgnUpdate, 0, 0, 0, 0);
    1383       }
    1384    }
     1401      rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
    13851402
    13861403   SetFS(sel);
     
    13921409BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
    13931410{
     1411 USHORT sel = RestoreOS2FS();
    13941412 Win32BaseWindow *window;
    13951413 APIRET  rc;
     
    14041422    if(!window) {
    14051423        dprintf(("ScrollWindow, window %x not found", hwnd));
     1424        SetFS(sel);
    14061425        return 0;
    14071426    }
     
    14481467                         NULL, scrollFlags);
    14491468
     1469    SetFS(sel);
    14501470    return (rc != RGN_ERROR);
    14511471}
    14521472//******************************************************************************
    1453 //TODO: Implement this one
    14541473//******************************************************************************
    14551474INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip,
    14561475                            HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
    14571476{
    1458     dprintf(("USER32:  ScrollWindowEx NOT CORRECTLY IMPLEMENTED\n"));
    1459     return ScrollWindow(hwnd, dx, dy, pScroll, pClip);
     1477    USHORT sel = RestoreOS2FS();
     1478    Win32BaseWindow *window;
     1479    APIRET  rc;
     1480    RECTL   scrollRect;
     1481    RECTL   clipRect;
     1482    ULONG   scrollFlags = 0;
     1483    int     regionType = ERROR_W;
     1484
     1485    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     1486    if(!window) {
     1487        dprintf(("ScrollWindowEx, window %x not found", hwnd));
     1488        SetFS(sel);
     1489        return 0;
     1490    }
     1491
     1492    dprintf(("ScrollWindowEx %x %d %d\n", hwnd, dx, dy));
     1493
     1494    dy = revertDy (window, dy);
     1495
     1496    if (scrollFlag & SW_INVALIDATE_W)      scrollFlags |= SW_INVALIDATERGN;
     1497    if (scrollFlag & SW_SCROLLCHILDREN_W)  scrollFlags |= SW_SCROLLCHILDREN;
     1498
     1499    if(pScroll) MapWin32ToOS2Rectl((RECT *)pScroll, (PRECTLOS2)&scrollRect);
     1500    if(pClip)   MapWin32ToOS2Rectl((RECT *)pClip, (PRECTLOS2)&clipRect);
     1501
     1502    RECTL rectlUpdate;
     1503    HRGN  hrgn;
     1504
     1505    LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy,
     1506                                        (pScroll) ? &scrollRect : NULL,
     1507                                        (pClip) ? &clipRect : NULL,
     1508                                        hrgn, &rectlUpdate, scrollFlags);
     1509    if (lComplexity == RGN_ERROR)
     1510    {
     1511        SetFS(sel);
     1512        return (0);
     1513    }
     1514
     1515    RECT winRectUpdate;
     1516    LONG height = window->getWindowHeight();
     1517
     1518    winRectUpdate.left   = rectlUpdate.xLeft;
     1519    winRectUpdate.right  = rectlUpdate.xRight;
     1520    winRectUpdate.top    = height - rectlUpdate.yTop;
     1521    winRectUpdate.bottom = height - rectlUpdate.yBottom;
     1522
     1523    if (pRectUpdate)
     1524       *pRectUpdate = winRectUpdate;
     1525
     1526    if (hrgnUpdate)
     1527       rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
     1528
     1529    if ((scrollFlag & SW_INVALIDATE_W) &&
     1530        ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
     1531    {
     1532       rc = InvalidateRect (hwnd, &winRectUpdate, scrollFlag & SW_ERASE_W);
     1533       if (rc == FALSE)
     1534       {
     1535          SetFS(sel);
     1536          return (0);
     1537       }
     1538    }
     1539
     1540    switch (lComplexity)
     1541    {
     1542       case RGN_NULL:
     1543         regionType = NULLREGION_W;
     1544         break;
     1545       case RGN_RECT:
     1546         regionType = SIMPLEREGION_W;
     1547         break;
     1548       case RGN_COMPLEX:
     1549         regionType = COMPLEXREGION_W;
     1550         break;
     1551       default:
     1552         regionType = ERROR_W;
     1553         break;
     1554    }
     1555
     1556    SetFS(sel);
     1557    return (regionType);
    14601558}
    14611559//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.