Ignore:
Timestamp:
Feb 7, 2000, 3:30:18 PM (26 years ago)
Author:
sandervl
Message:

Fix for DCX_INTERSECTRGN in GetDCEx

File:
1 edited

Legend:

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

    r2672 r2676  
    1 /* $Id: dc.cpp,v 1.43 2000-02-06 22:00:22 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.44 2000-02-07 14:30:18 sandervl Exp $ */
    22
    33/*
     
    7777int  WIN32API ReleaseDC(HWND hwnd, HDC hdc);
    7878BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
     79int  WIN32API ExtSelectClipRgn(HDC hdc, HRGN hrgn, int fnMode);
    7980
    8081//******************************************************************************
     
    437438//******************************************************************************
    438439//******************************************************************************
     440#if 1
     441HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
     442{
     443   HWND     hwnd = hWnd ? hWnd : HWND_DESKTOP;
     444   pDCData  pHps = NULLHANDLE;
     445   RECTL    rect;
     446   HPS      hPS_ownDC = NULLHANDLE;
     447
     448   if ( !lpps )
     449   {
     450      O32_SetLastError (ERROR_INVALID_PARAMETER);
     451      return (HDC)NULLHANDLE;
     452   }
     453
     454   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     455
     456#if 0
     457   if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC())
     458   {
     459        hPS_ownDC = wnd->getOwnDC();
     460        //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
     461        if(hPS_ownDC) {
     462                pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
     463                if (!pHps)
     464                {
     465                        O32_SetLastError (ERROR_INVALID_PARAMETER);
     466                        return (HDC)NULLHANDLE;
     467                }
     468        }
     469   }
     470#endif
     471
     472   HWND hwndClient = wnd->getOS2WindowHandle();
     473   HPS  hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);
     474
     475   if (!pHps)
     476   {
     477      HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);
     478      pHps = (pDCData)GpiQueryDCData(hps);
     479   }
     480
     481   if (hPS_ownDC == 0)
     482      setMapMode (wnd, pHps, MM_TEXT_W);
     483   else
     484      setPageXForm (wnd, pHps);
     485
     486   pHps->hdcType = TYPE_3;
     487   lpps->hdc = (HDC)hps;
     488
     489   if(!wnd->isSuppressErase()) {
     490        wnd->setSuppressErase(TRUE);
     491        wnd->setEraseBkgnd (FALSE, !wnd->MsgEraseBackGround(lpps->hdc));
     492   }
     493   lpps->fErase = wnd->isPSErase();
     494
     495   if (!hPS_ownDC)
     496   {
     497      long height  = wnd->getClientHeight();
     498      rect.yTop    = height - rect.yTop;
     499      rect.yBottom = height - rect.yBottom;
     500   }
     501   else
     502   {
     503      rect.yTop--;
     504      rect.yBottom--;
     505      GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rect);
     506   }
     507
     508   WINRECT_FROM_PMRECT(lpps->rcPaint, rect);
     509   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));
     510
     511   O32_SetLastError(0);
     512   return (HDC)pHps->hps;
     513}
     514
     515BOOL WIN32API EndPaint (HWND hwnd, const PAINTSTRUCT_W *pPaint)
     516{
     517 pDCData pHps;
     518
     519   dprintf (("USER32: EndPaint(%x)", hwnd));
     520
     521   if (!pPaint || !pPaint->hdc )
     522      return TRUE;
     523
     524   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     525
     526   if (!wnd) goto exit;
     527
     528   //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
     529   pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
     530   if (pHps && (pHps->hdcType == TYPE_3)) {
     531          WinEndPaint (pHps->hps);
     532   }
     533   wnd->setSuppressErase(FALSE);
     534
     535exit:
     536   O32_SetLastError(0);
     537   return TRUE;
     538}
     539#else
    439540HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
    440541{
     
    563664                GpiDestroyRegion(pHps->hps, hrgnOld);
    564665        }
    565         //todo restore old clip region for CS_OWNDC windows
    566666        if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) {
    567667                ReleaseDC(hwnd, pPaint->hdc);
     
    587687   return TRUE;
    588688}
     689#endif
    589690//******************************************************************************
    590691//******************************************************************************
     
    710811// DCX_EXCLUDERGN (complex regions allowed)
    711812// DCX_INTERSECTRGN (complex regions allowed)
     813//
     814//TODO: WM_SETREDRAW affects drawingAllowed flag!!
    712815//******************************************************************************
    713816HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
     
    806909         goto error;
    807910
    808       BytesNeeded = O32_GetRegionData (hrgn, 0, NULL);
    809       RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
    810       if (RgnData == NULL)
    811           goto error;
    812       O32_GetRegionData (hrgn, BytesNeeded, RgnData);
    813 
    814       i = RgnData->rdh.nCount;
    815       pr = (PRECT)(RgnData->Buffer);
    816 
    817911      success = TRUE;
    818912      if (flags & DCX_EXCLUDERGN_W)
     
    820914#if 0 //CB: todo
    821915         long height;
     916
     917         BytesNeeded = GetRegionData (hrgn, 0, NULL);
     918         RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
     919         if (RgnData == NULL)
     920                goto error;
     921         GetRegionData (hrgn, BytesNeeded, RgnData);
     922
     923         i = RgnData->rdh.nCount;
     924         pr = (PRECT)(RgnData->Buffer);
     925
    822926         if (flags & DCX_WINDOW_W)
    823927                height = wnd->getWindowHeight();
     
    835939      else //DCX_INTERSECTRGN_W
    836940      {
    837         O32_SelectClipRgn(pHps->hps,hrgn); //CB: works so far
     941         if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
     942                dprintf(("ExtSelectClipRgn failed!!"));
     943         }
    838944      }
    839945      if (!success)
     
    846952   pHps->psType  = psType;
    847953   pHps->hdcType = TYPE_1;
     954   //TODO: WM_SETREDRAW affects drawingAllowed flag!!
    848955   GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
    849956
     
    9801087   if (redraw & RDW_UPDATENOW_W) redraw &= ~RDW_ERASENOW_W;
    9811088
    982    if (redraw & RDW_NOERASE_W || !(redraw & (RDW_ERASE_W|RDW_ERASENOW_W))) {
     1089   if (redraw & RDW_NOERASE_W) {
    9831090        wnd->setSuppressErase(TRUE);
    9841091   }
    9851092   else wnd->setSuppressErase(FALSE);
    986 
    987 //   if (redraw & RDW_NOERASE_W)
    988 //      wnd->setEraseBkgnd (FALSE);
    989 
    990 //SvL: Test
    991 //   if (redraw & RDW_UPDATENOW_W)
    992 //      wnd->setSuppressErase (FALSE);
    993 //   else if (redraw & RDW_ERASENOW_W)
    994 //      wnd->setSuppressErase (FALSE);
    9951093
    9961094   if (hrgn)
Note: See TracChangeset for help on using the changeset viewer.